Re: [concordance-devel] Concordance on the MAC
- Nachricht von s...@techie.net - Never got your previous message... ..just when I thought that I had mastered that jet-lag after two weeks.. OK, next try, now hopefully with the correct From: and To: --- snip -- Hi there, yes it's me, still occasionally browsing the mails from the mailing list. As the one who first put Pronto Hex codes into concordance and congruity I think it's about time for some clarification: The Pronto code input is available in congruity (implemented in the Python code), which should also run on a MAC provided the corresponding Python runtime and libconcord plus its Python bindings are available. I also made a private version of concordance with Pronto code input back in 2008/9 with the Pronto stuff originally in a separate library (libir_remote, somthing like that, have to look that up when I'm back home next week). This library would eventually also include some more conversion stuff between Pronto Hex, Logitech and different Standard codes (RC5, NEC, etc.). I also posted a statically linked module to this mailing list for review by Phil - somewhere around here: http://sourceforge.net/mailarchive/message.php?msg_id=22207296 Since Phil, IIRC, was busy with other stuff that time, and we somehow didn't come to a conclusion how to do it right, my Pronto implementation slowly died and never made it into the mainline of concordance. Somewhere in 2010, HellG from the German and the official Logitech Harmony forums seems to have compiled the latter version and distributed a Windows build, initially also with sources (at least of concordance - libconcord didn't require any change for this). I apparently never bothered (up to now) to check whether he was actually using my code. A discussion about it (in German, with HellG and myself participating) can be found in the German Harmony forum: http://www.harmony-remote-forum.de/viewtopic.php?f=7t=4915start=15 which also includes a link to an archive with sources: http://hellgi.funpic.de/concordance.zip (still working) Eventually a stripped version (without any sources, just the Windows exe and dll) was put by HellG into the Logitech forum and from there spread over the world: http://forums.logitech.com/t5/Harmony-Remotes-Programming/Adding-Pronto-codes-yourself-Windows-and-Linux/td-p/416808 which is the unofficial, GPL-violating version we are now talking about. Andreas -- Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Concordance on the MAC
Just a minor update to my previous message: The Pronto part of congruity was of course done by Stephen (with some minor corrections by myself). And, browsing once again through the old messages from 4 years ago, it seems that the lack of ambition to push the pronto function into the mainline seems to have been mainly on my side (for different reasons), but now that there seems to be some demand, I see a chance to bring it back to life again... Andreas -- Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
[concordance-devel] [PATCH] congruity : error in Pronto code conversion
Stephen, After some time, I now had reason to check the Pronto code conversion of congruity, just to discover an error in the code: You just copy the burst/space times entered as Pronto hex code to the IR signal that is passed to libconcord. However, in Pronto codes burst/space times are given in units of the IR carrier cycle (which is provided by the second hex word, in units of Pronto clock cycles), whereas libconcord expects burst/space times in microseconds. So, what is missing is to multiply the Pronto duration values by the IR carrier cycle (in microseconds). See attached patch for the correction, where I also introduced the value PRONTO_CLOCK=4145146 (Hz) to replace the 'magic' value of (100 / .241246). Andreas diff -rpc -C1 congruity-10/congruity congruity-10+/congruity *** congruity-10/congruity 2009-03-10 02:16:46.0 +0100 --- congruity-10+/congruity 2009-05-08 00:07:36.0 +0200 *** class LearnIrEnterProntoHexPanel(WizardP *** 1341,1346 --- 1341,1347 def _OnValidate(self, event): try: + PRONTO_CLOCK = 4145146 bin = [] str = str_idx = 0 *** class LearnIrEnterProntoHexPanel(WizardP *** 1364,1370 if bin[0] != 0: raise Exception('Not RAW') ! frequency = int(100 / (bin[1] * 0.241246)) count_1 = 2 * bin[2] count_2 = 2 * bin[3] --- 1365,1375 if bin[0] != 0: raise Exception('Not RAW') ! # IR Carrier frequency is given as number of Pronto clock cycles: ! frequency = int(PRONTO_CLOCK / bin[1]) ! # pulse/space durations are given in IR carrier cycles, ! # but we need them in microseconds: ! ir_cycle = int(100 / frequency) count_1 = 2 * bin[2] count_2 = 2 * bin[3] *** class LearnIrEnterProntoHexPanel(WizardP *** 1387,1398 idx = 0 for i in range(count_1): ! self.resources.cur_ir_signal[idx] = bin[start_1 + i] idx += 1 for j in range(repeats): for i in range(count_2): ! self.resources.cur_ir_signal[idx] = bin[start_2 + i] idx += 1 self._OnStatusOk() --- 1392,1403 idx = 0 for i in range(count_1): ! self.resources.cur_ir_signal[idx] = bin[start_1 + i] * ir_cycle idx += 1 for j in range(repeats): for i in range(count_2): ! self.resources.cur_ir_signal[idx] = bin[start_2 + i] * ir_cycle idx += 1 self._OnStatusOk() Nur in congruity-10+: congruity~. -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] [Harmony 555] learning IR codes doesn't work
On Sunday 26 April 2009, Michael Frase wrote: I have sent you a private mail with attached wireshark log. Did you receive it? Please have a look at it, if you have time. Michael Yes, sorry for the delay, but I have been busy with other stuff (plus, as I might have told already, I have always to convince the rest of our family first to leave me the Harmony for some testing). I don't see any obvious problem in the log you sent to me, except that it fails to return to the keys status page for some reason. I have been able to do some more testing, but always failed to fail so far: I tried with my LINUX (Mandriva cooker system , KDE 4.2.2): - works with Konqueror web browser, difference to your log is that konqueror does not always load all these .css and .js files again for the AutoLaunch_Refresh.asp - works with firefox (3.0.8), which always reloads the .css and .js files, like your browser - with Javascript disabled in firefox, I get a notification page from Logitech that Javascript is disabled, but after I clicked on 'Continue' button, the page confirms that the key has been learned. - works also with epiphany (gnome browser, started from KDE). So, I'm running out of ideas about what might be your problem. Did you already succeed to update your remote with concordance, or at least manage to pass the connectivity check before? BTW: It is definitely NO good idea to tell your browser to always open .EZTut with just concordance - this will run concordance in the background and you have no access to the interactive part. For firefox, this almost in an instance blew my .xession-errors file with a gazillion of input prompt lines, until it filled up my home partition... With Javascript initially disabled, I don't even get further than the initial page of myremotesetup.com, telling me that my software has to be updated.. Just of curiosity - there is also no way to get past the first page with lynx (ASCII-browser) - not actually a surprise... Regards, Andreas -- Crystal Reports #45; New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty#45;free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Need firmware tests on 6xx and 7x8 remotes
On Sunday 12 April 2009, Phil Dibowitz wrote: All, I'm fairly certain the work that made firmware updates work on the 5xx remotes should allow the 6xx (arch 7) and 748/768 (arch 3) to firmware update as well. But I never confirmed this. Can someone with these remotes test and report back so we can update the Supported Models page? Thanks. I have tried again and can confirm that firmware 'upgrade' (same version as before) works with my 785: [andr...@andreas Dokumente]$ concordance -v LatestFirmware.EZUp Concordance 0.21 Copyright 2007 Kevin Timmerman and Phil Dibowitz This software is distributed under the GPLv3. Requesting Identity: 100% done Invalidating Flash: done Erasing Flash: 100% done Writing firmware:100% done Resetting Remote:100% done Setting Time: done Contacting website: done Success! Andreas -- Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Failed with error 1
On Thursday 16 October 2008, Phil Dibowitz wrote: On Wed, Oct 15, 2008 at 09:49:38PM -0400, Stuart Doherty wrote: The command I use is: sudo concordance -v -C Connectivity.EZHex That's a *connectivity* file, not a config file. Don't specify a mode (it'll figure it out) or use -t for connectivity test. Then you'll get a config. Can you file a bug and I'll add some better error handling code for this? Phil, Unless you haven't found something better already, I would suggest the attached patch. Note: in the original code, after: if (mode == MODE_UNSET file_name) { the check: if (file_name) { will obviously always succeed, so the 'else' branch printing 'No mode' will never be reached. I also deleted: - err = 0; as redundant, since it is immediately followed by: err = init_concord(); Result of a test run: [EMAIL PROTECTED] concordance]$ ./concordance -C ../../Files/Connectivity.EZHex Concordance 0.20+CVS Copyright 2007 Kevin Timmerman and Phil Dibowitz This software is distributed under the GPLv3. Error: Input file type recognized as: connectivity check does not match requested mode: write configuration Andreas Index: concordance.c RCS file: /cvsroot/concordance/concordance/concordance/concordance.c,v retrieving revision 1.33 diff -u -3 -p -r1.33 concordance.c --- concordance.c 12 Oct 2008 22:35:26 - 1.33 +++ concordance.c 18 Oct 2008 20:43:41 - @@ -871,6 +871,7 @@ int detect_mode(uint8_t *data, uint32_t { int err, type; + *mode = MODE_UNSET; err = identify_file(data, size, type); if (err) { return err; @@ -897,6 +898,35 @@ int detect_mode(uint8_t *data, uint32_t return 0; } +char *mode_string(int mode) +{ + switch (mode) { + case MODE_CONNECTIVITY: + return connectivity check; + break; + case MODE_WRITE_CONFIG: + return write configuration; + break; + case MODE_WRITE_FIRMWARE: + return write firmware; + break; + case MODE_LEARN_IR: + return learn IR; + break; + default: + return unknown; + break; + } +} + +void report_mode_mismatch(int mode, int file_mode) +{ + printf(Error: Input file type recognized as: %s\n, + mode_string(file_mode)); + printf( does not match requested mode: %s\n, + mode_string(mode)); +} + void help() { printf(There are two ways to invoke this software. You can specify); @@ -1076,7 +1106,7 @@ int main(int argc, char *argv[]) { struct options_t options; char *file_name; - int mode, err; + int mode, file_mode, err; uint8_t *data; uint32_t size; @@ -1128,23 +1158,34 @@ int main(int argc, char *argv[]) printf(Cannot read input file.\n); exit(1); } + /* + * Now that the file is read, see if we can recognize it: + */ + if (detect_mode(data, size, file_mode)) { + printf(Cannot determine mode of operation from + file.\n); + } + /* + * If we don't have a mode, lets detect that mode based on + * the file. + */ + if (mode == MODE_UNSET) { + mode = file_mode; + } else { + if (mode != file_mode){ +report_mode_mismatch(mode, file_mode); +exit(1); + } + } } /* - * And if we don't have a mode, lets detect that mode based on - * the file. + * We have checked the parameters and the input file: + * If we still don't know what to do, failure is the only option: */ - if (mode == MODE_UNSET file_name) { - if (file_name) { - if (detect_mode(data, size, mode)) { -printf(Cannot determine mode of operation from - file.\n); -exit(1); - } - } else { - printf(No mode requested. No work to do.\n); - exit(1); - } + if (mode == MODE_UNSET) { + printf(No mode requested. No work to do.\n); + exit(1); } /* @@ -1159,8 +1200,6 @@ int main(int argc, char *argv[]) populate_default_filename(mode, options.binary, file_name); } - err = 0; - err = init_concord(); if (err != 0) { printf(Error initializing libconcord: %s\n, - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Minor proposed IR learning API change
On Tuesday 14 October 2008, Phil Dibowitz wrote: Stephen Warren wrote: .. callback added .. Absolutely the right call. Applied, thanks. Stephen and Phil, thanks also from me for that patch. I have a few days off work next week, so I may find some time to fill in code to make use of the callback. Andreas - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
[concordance-devel] [patch 2/2] Change of libconcord API for IR codes learning - concordance
Changes relative to first patch version (20080628): === concordance.1 - changed entry for IR learn option concordance.c Note: In contrast to Phil's belief, _getch will actually return only '\r' when you hit return, as getchar wil return '\n', so the code is right by design, not by accident. - added comments about the _getch/getchar/set_canon stuff - renamed USE_DEFAULT to ENTER_KEY - no more function names with leading underscores - fixed obscure increment/decrement of key index in learn_ir_commands - some formatting fixes Index: concordance/concordance.1 === RCS file: /cvsroot/concordance/concordance/concordance/concordance.1,v retrieving revision 1.9 diff -u -3 -p -r1.9 concordance.1 --- concordance/concordance.1 15 Apr 2008 02:32:32 - 1.9 +++ concordance/concordance.1 10 Oct 2008 18:14:24 - @@ -60,7 +60,7 @@ Get time from the remote Set the time on the remote .TP .B \-l, \-\-learn-ir filename -Learn IR from other remotes. Use filename. +Learn IR commands from other remotes. Use filename. When you selected multiple commands to learn on the Logitech website, you can move through this command list and let the Harmony learn the IR code for each command. .TP .B \-r, \-\-reset Reset (power-cycle) the remote control @@ -90,6 +90,7 @@ Enable verbose output. .TP .B \-w, \-\-no\-web Do not attempt to talk to the website. This is useful for re-programming the remote from a saved file, or for debugging. +.TP .SH BUGS None known at time of release, but check the website. .SH BUG REPORTS Index: concordance/concordance.c === RCS file: /cvsroot/concordance/concordance/concordance/concordance.c,v retrieving revision 1.32 diff -u -3 -p -r1.32 concordance.c --- concordance/concordance.c 15 Apr 2008 06:17:02 - 1.32 +++ concordance/concordance.c 10 Oct 2008 18:14:24 - @@ -37,6 +37,7 @@ #define strcasecmp stricmp #define strncasecmp strnicmp #define sleep(x) Sleep((x) * 1000) +#define strdup _strdup /* * Windows, in it's infinite awesomeness doesn't include POSIX things @@ -46,12 +47,25 @@ char* basename(char* file_name) { char* _basename = strrchr(file_name, '\\'); - + return _basename ? _basename+1 : file_name; } HANDLE con; +/* + * (see below) Windows does not need this, since _getch already + * does what we need - just make set_canon do nothing + * Note that _getch returns '\r' when user hits the Enter key + */ +int set_canon(int flag) +{ + return(1); +} + +#define read_key _getch +#define ENTER_KEY '\r' + #else /* NON-Windows */ @@ -59,6 +73,29 @@ HANDLE con; #include strings.h #include libgen.h #include unistd.h +#include termios.h + +/* + * set_canon in LINUX modifies stdin such that getchar behaves like + * _getch in Windows, i.e. the next key is returned immediately. + * Note that getchar returns '\n' when user hits the Enter key + */ +int set_canon(int flag) +{ + struct termios t; + + tcgetattr(0, t); + if (flag) { + t.c_lflag |= ICANON; + } else { + t.c_lflag = ~ICANON; + } + tcsetattr(0, TCSANOW, t); + return(1); +} +/* Thus, we can define: */ +#define read_key getchar +#define ENTER_KEY '\n' #endif @@ -140,6 +177,205 @@ void cb_print_percent_status(uint32_t co fflush(stdout); } +void print_ir_burst(uint32_t length) +{ + if (length 250) { + printf(|); + } else if (length 1000) { + printf(#); + } else { + printf(##); + } +} + +void print_ir_space(uint32_t length) +{ + if (length 250) { + printf(.); + } else if (length 1000) { + printf(_); + } else if (length 1) { + printf(__); + } else { + printf(\n); + } +} + +void print_received_ir_signal(uint32_t carrier_clock, uint32_t *ir_signal, + uint32_t ir_signal_length, struct options_t *options) +{ + uint32_t index; + printf(\nASCII-graph of received IR signal:\n); + for (index=0; index ir_signal_length; index += 2){ + print_ir_burst(ir_signal[index]); + print_ir_space(ir_signal[index+1]); + } + printf(\n); + printf(Carrier clock : %u Hz\n, carrier_clock); + printf(Total mark/space pairs : %u\n\n, ir_signal_length/2); +#ifdef _DEBUG + /* + * full dump of new IR signal: + */ + for (index=0; index ir_signal_length; index += 2){ + printf(\tP:%6u\tS:%6u\n, ir_signal[index], + ir_signal[index+1]); + } +#endif +} + +char get_cmd(char *prompt, char *allowed, char def) { + char result = 0; + char got_key; + uint32_t index; + set_canon(0); + while ( result == 0 ) { + printf(%s (%c)?, prompt, def); + got_key = read_key(); + printf(\n); + if (got_key == ENTER_KEY) { + result = def; + } else { + for (index = 0; index strlen(allowed); index++) { +if (allowed[index] == got_key) { + result = got_key; + break; +} + } + } + } + set_canon(1); + return result; +} + +int learn_ir_commands(uint8_t *data, uint32_t size, struct options_t *options) +{ + int err = 0; + uint32_t
Re: [concordance-devel] libconcord new full patch (Re: Next try for the big IR learning patch..)
On Tuesday 24 June 2008, Phil Dibowitz wrote: Andreas Schulz wrote: As I just recognized, better make that delete_*, to be consistent with delete_blob.. Delete blob always deletes the same thing - in your case you have lots of different things.. Sure, by 'delete_*' I meant of course to rename each of them, not all to one, giving: ... void delete_key_names(char **garbage); void delete_ir_signal(uint32_t *garbage); void delete_post_string(char *garbage); - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] libconcord Learn IR Updates
OK, I plead guilty of lazyness and sloppy design in a few cases.. On Saturday 21 June 2008, Phil Dibowitz wrote: I have a request for future submissions of patches that have multiple parts (i.e. patchsets). I'd like to follow the general LKML standard here for this... A valid point - I will follow that for my upcoming attempts. Libirremotes integration should be done in an entirely separate patch. Another case of lazyness - even more as I did so for the first version of my patch set, but didn't repeat for the current. LIBCONCORD LEARNIR API CHANGE * At the bottom of _get_next_key() you said you need to set the index and the name. You actually set to the index in the parent function Yes, the comment is wrong, probably it was that way at some point, until I decided that _get_next_key should only deal with the pointers, and only get_key_name should care about the key counting. * It doesn't seem to me like previous_index and previous_name are properly named. Agreed, 'current' would probably be better naming. Following your and Stephen's other comments, all that will probably end up quite different anyway... - if (search - data = data_size) { + if (search = data + data_size) { why change it? Especially given I think the former is clearer... Justification was to get rid of a VC++ compiler warning that complained about comparing data of different singnedness - apparently the compiler saw that a difference might in theory become negative, so it's signed, while data_size is unsgined. I prefer to fix compiler warnings in the code, even if they may look redundant. LIBIRREMOTE * Why do your error codes in the opposite (numerical) direction? Are you trying to avoid conflict, or ...? Looking at it now, it is a historical relict from the initial phase where I wanted the scanf-functions to return some useful positve value in case of success. Now that they ended up returning just 'OK' or some error, I will change the error codes to positive. * I really, really, really really dislike variables with capitols - ...Anyway, consider num_pulses, pulses, repeat_seq, etc. Well, with Ada actually being my 'native' language, I'd rather prefer Variables_With_Capial_Initals, but since I'm also maintaining lots of legacy code from different authors, I may have become a little deaf to consistent good coding style... Anyway, the most weird looking names related to Pronto codes were initially copied verbatim from the excellent document about the different Pronto IR formats by Evgueni Oulianov ([EMAIL PROTECTED]), which can be found e.g at: http://www.hifi-remote.com/infrared/prontoirformats.pdf N.B.: I thought I had credited his work somewhere in the README, or at least in the code, but apparently I missed that. I see I have been quite inconsistent in style also in the implementation of libIRremotes, and fixed that for the next version. CONCORDANCE ...I *would* like to (as I mentioned earlier), merge just the libconcord API change, let it bake in CVS for a bit, have people test it, and *then* merge the libirremote integration. as you like it.. * Your update to the man page Eh, I don't want that list of authors in the man page growing everytime someone adds a feature. Never mind, just drop it. * Hmm - should be be showing pulses and details in non-verbose mode? I would think that _dump_new_code() should be wrapped in if ((*options).verbose). It mostly is, but parts should possibly wrapped even deeper into #ifdef _DEBUG, since they are mostly aimed at the developer (i.e. me). I'd like to keep the ASCII plot, since it gives you an idea about what is going on, though not as good as the actual plot in congruity, and may help to detect problems in learning codes. I can't comment on it until I actually TRY it, which I can't do until I get my stuff, which is another month or so away. (hmm - feel like copy-n-pasting a session of use?) Sounds like sending executables (Win32 or LINUX) will probably not be helpful - but I'll have to get the Harmony out of my kids' hands first for a sample session... Andreas - more to come soon following the other comments -- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] libconcord new full patch ( Re: Next try for the big IR learning patch ..)
(I re-added some cuts by Phil to answer both posts in one) On Sunday 22 June 2008, Phil Dibowitz wrote: On Sunday 22 June 2008, Stephen Warren wrote: A pulse is usually a low-high-low transition, whereas these docs talk about pulses and spaces. There should be differentiation between pulses (mark followed by space), marks (high time), and spaces (low time) I actually wasn't really happy about the naming either initially, but missed to change it to something more appropriate, and then got used to it... I have changed it now in libIRremotes to ir_signal and ir_signal_length and will adapt libconcord accordingly, also making the documentation clearer, as you suggested below. In the documentation for get_key_name, it may be worth mentioning that valid index values start at 1 anything wrong with index starting at 1 for '1'st entry? and increment by 1 until NULL is returned. Well, probably some things just become too obvious when you have been working on them for several days... I really don't like the static buffer used by get_key_name. It's nasty that a client can only use this API on a single data blob at a time. So the question is - do we want to support more than one file AT THE SAME TIME? Given the current API you can in fact go through more than one file at a time. So being pragmatic, it's not so bad. Thus I've gone back and forth a few times, and can't quite decide. I currently don't see any use for being able to handle multiple files in parallel - maybe sequential, in case someone comes up with a concordance daemon lurking 24/7 in the background - but parallel? Multiple parallel connections to Logitech, or collecting a bunch of downloaded files and procesing them in parallel? It's all still driven by the software on the Logitech servers, anyway... that the API internally maintains non-obvious implicit state. I'd prefer something more like the API below, where the XMLBuffer is dynamically allocated per iterator, but the type/content is still opaque to the client: void *keyiter_create(uint8_t *data, uint32_t size); char *keyiter_next(void* keyiter); void keyiter_destroy(void *keyiter); void keyiter_key_destroy(char *); No reversing or random access allowed either; should be much simpler. So I guess the idea with this feature is being able to go oh, damn, I hit the wrong button on the other remote and don't want to have to go back and redo the whole sequence. I like that. To which Stephen replied: At least in congruity, I will make the client application use get_key_name to retrieve a list of all known key names into a Python list, and then iterate back/forth within that. Well, concordance could do that as well, so what about: char **get_keynames(uint8_t *data, uint32_t size); void destroy_keynames(char **names); and be done with the XML data in one call? Please document that the memory pointed at by get_key_name's return value needs to be free'd by the client. libconcord needs an API for the client to call to do this. encode_for_posting needs to define who owns the memory returned, and how to destroy it. I started adding deallocators in libIRremotes, and will do so for libconcord. I'm not sure about the internals of python - will deallocators be of any use there, and when should they be called? post_new_code and encode_for_posting check all the output/pointer parameters against being NULL, but learn_from_remote doesn't. Guess I thought anybody so stupid to call learn_from_remote(NULL,NULL,NULL) should deserve a SIGSEGV... well, adding a check won't hurt, and may be useful when interfacing to some other language.. I'm not convinced that the Python bindings changes for verbose are the correct way to go; they don't handle exceptions very well. I didn't read through those changes, but I would say that seems reasonable to be able to enable debug in a production version so you can tell your users to do this when they report some problem you can't reproduce. At least it was helpful to me in some stage of the develpment to see what was going on and coming out - I also don't see any big difference in the exception handling - except maybe for the case that 'print' in the wrapper itself throws an exception (is that likely?). It'd be best if you removed the verbose part from the Python bindings as you like it..There's probably also still to much 'verbose' stuff in my proposal for congruity (e.g. it prints geometry data when you zoom the IR signal plot), and probably nobody is actually interested in the way the signal is encoded for posting to Logitech either...some information needed while coding is surely useless once you've got the code right, so what should a verbose mode show? An enthusiast may enjoy to see the exact mark/space durations and even feed them into some other decoding tool, while a plain user will just think 'what the ?' And-probably
Re: [concordance-devel] Remote Support? And Other Questions
On Sunday 22 June 2008, Mike Fletcher wrote: Then, I clicked Build menu on the menu bar, then selected Built Solution or you could press F7. After Visual Studio completed its process I found the exe in (extracted archive folder)\concordance\win\Debug. Ah, yes, it looks like I forgot to mention that in the description that I posted recently - depending on the selected build type ('Debug' or 'Release', Visual Studio will put the executables and the DLLs into ...\concordance\win\Debug resp. ...\concordance\win\Release. is connected when you click next you should get a prompt to download or open a file called Connectivity.EZHex I saved it to the same directory as concordance.exe (this makes it easier in the end so that you do not have to path to the file). I then loaded up the Command You might as well have chosen to just open it with concordance.exe. Prompt by clicking Start then selected Run and enter cmd (without the quotes). From there I changed the directory to the one containing the built output noted above. Next I entered concordance --connectivity-test Connectivity.EZHex (again without the quotes). The next easiest method would be to just drag-and-drop the downloaded file onto the concordance.exe icon in Windows Explorer. Remember that concordance can now judge from the file what to do - it will barely need the command line options to specify the action. little longer but after it finished it restarted the remote and poof it worked! Nice that you made it... P.S.: Phil and Stephen - I got your comments about my IR learning stuff, and probably will take a few days to go through them in all details.. Andreas - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] libIRremotes (Re: Patches for major update of IR code learning)
On Sunday 22 June 2008, Stephen Warren wrote: Phil Dibowitz wrote: Stephen Warren wrote: It'd be nice if all symbols (types, values, functions, etc.) were all prefixed with e.g. IRR_/irr_ to ensure they never conflict with any other library. ACK for the public functions, definitely. I highly prefer lower case. Yeah, I meant irr_ for functions, IRR_ for defines/enums. Accepted - admittedly, I tend to ignore the lack of distinct namespaces in 'C'. Doesn't the LIRC project have a library that does this kind of thing already, that could be re-used instead of re-inventing the wheel? In fact, don't they have a big database of key codes that might be useful? I was going to go do some research on if another library already did this, actually, but never got around to it. If another library already supports the actions we're looking for with a decent API, we shouldn't merge our own without good reason. I took a look at LIRC. It doesn't seem like they have a separate NEC/RC5/... protocol encode/decode library (although perhaps they have that code just hidden inside lircd or something). I guess looking at the Pronto format, it's also essentially just a list of mark/space timings, so perhaps needing IR protocol encode/decode functionality isn't that common right now, so a new library makes sense. Still, I didn't search outside of the LIRC project yet, so that'd be worth doing too. I have been using LIRC for a while to program undocumented codes into my Harmony (through a second learing remote, since I didn't know about libconcord by then). I didn't discover any remotely usable interface inside either, except maybe if someone would write a device driver that spits out IR codes in Harmony posting format, instead of sending the signals to some hardware. The LIRC devices database, except for the fact that it can be easily edited and new codes can be added by the user, is otherwise IMHO not even remotely a competitor to the Logitech database. Recently, a converter for Pronto hex files to LIRC config files has been added to LIRC, but that is no much use here either (even though it's written in Python). There seem to be a few tools for generating Pronto codes from NEC, RC5, etc. - but AFIAK, all of them are for Windows (as all Pronto programming), and most likely closed source. Coming back to Stephen's other remarks from the first post: On Sunday 22 June 2008, Stephen Warren wrote: scanf_pronto_hex, printf_pronto_hex: It seems like accepting a FILE *file or int fd instead of char *filename would be more flexible, and avoid all the special-cases for stdout. I guess I should probably even drop the file/stdin/stdout for good and just leave the string-pronto_hex version, handing the responsiblity for file/console-I/O to the caller. I just used them to start, since scanf was easier to handle than sscanf. For APIs that return pointers to memory, please define whether the client or library is reponsible for de-allocating the memory, and when this will occur. Please provide an API for clients to call to do this if required. Accepted (and almost completed). Just not quite sure if this will also work with the python bindings. In addition, a single-shot application like concordance will IMHO not actually suffer too much from a small memory leak. I've seen other applictaions at work, running 24/7 for weeks, where even few bytes leaking here and there eventually crashed the system, but that's a completely different story.. When calling pronto_to_pulses, how does one initialize the pronto_hex structure? Is there some kind of standard representation for the data in that structure that a user would use? If so, it seems that libIRRemotes should provide a function to parse that user input and convert it to pronto_hex, rather than making each client application write that code themselves. I though it was obvious (apparently not?) that that is exactly the purpose of (s)scanf_pronto_hex - string or text file with hex code gets in, pronto_hex structure out. Is this library intended to support anything other than Pronto codes (e.g. CIR, RC5, ... encode/decode)? If not, naming the library something with pronto in the name seems like a good idea (ignoring trademark issues anyway.) At least, something much less generic would be good. You probably missed the paragraph in the IGN^H^H^HREADME file: Future extensions should also include en-/decoding of standard IR protocols like the NEC and RC5 protocols. Andreas - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
[concordance-devel] Next try for the big IR learning patch..
First, my apology to Stephen - I didn't surely intend to interfere with your release policy for congruity, but I just needed a new version, and mindlessly decided that I would do well enough to it to deserve a new major number. Since I already told everyone around here to please ignore my congruity8+ stuff, I shifted down to fractional 7.x versions, so my final word (for the time) is now called congruity 7.4 (see follow-up message). I have been busy this week (as long as I wasn't stuck at the TV watching the Europe soccer championships..) switching back and forth between WindowsXP and LINUX to get both concordance and congruity sources finally working in both environments, adding a few features and fixing some remaining bugs, removing warnings by Visual C++ and trying to document the build process (and its traps) for Windows. Concordance IR learning is now full interactive with navigation back and forth trough the received command list and selection to learn codes from other remote or read Pronto hex codes. For congruity, I mostly had to fix the IR signal plot, which didn't work as well in Windows as in LINUX in the first version, and, in the course of the action, added the option to zoom in/out by left/right mouseclick. I am closing this first message attaching my experiences of building concordance on WindowsXP with Visual C++ 2005 Express, accompanied by a tgz archive of the win/concordance.sln and concordance/win/concordance.vcproj files to include libIRremotes into the concordance VC++ project. (tried .ZIP first, but apparently sourceforge doesn't like ZIP attachments...) Andreas Concordance build with MS Visual C++ 2005 Express Edition: -- Note: If want the latest and shiny, or just happen to have the DVD at hand (it has been published in some PC magazines recently), you may also get the 2008 Express edition, but AFAIR the download is larger, and the 2008 will convert the project files to its new format. With a CD/DVD, just go ahead installing - it should come ready with the SDK included. Otherwise, you will need: - MS Visual C++ 2005 Express Edition from Microsoft: http://www.microsoft.com/express/2005 You will first get an installer of ~2MB, which, when launched, will get the actual software of ~68MB. Adding Visual Studio plus service pack 1 when you start Microsoft update, which adds another 45MB. Note: You _MUST_ run the installer logged in as admin user, running it logged in as normal user with 'runas' will not work. - (parts of) the latest Windows SDK from: http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDCdisplaylang=en This will give you another installer of merely ~400k. Run it (logged in as administrator) to install. It will initially offer you an impressive 1.2GB download - just may deselect everything, and then select just the 'Windows Headers and Libraries' section. This will strip the figure down to acceptable 27.3MB. It may complain about .NET development tools not selected - adding them would result in a total of 45.2MB (did that-who knows?). If you select the target directory for the install to $(VCInstallDir)\PlatformSDK, Visual C++ may be happy already (didn't try that). Otherwise, you have to: - include the SDK folders into Visual C++ 2005 Express Edition: - From the Visual C++ main menu, select Extra-Options - In the Options dialogue, select 'Projects and Project Folders -VC++Folders' - Switch to 'Inlcude folders' and add the ...\include folder in the SDK installation folder. - Same for 'library folders' and the SDK ...\lib folder Now you should be set to compile concordance. CVS for Windows: If you want direct access to the concordance CVS from windows, you will need a Windows CVS client. There may be some around - I myself have installed Tortoise CVS (http://www.tortoisecvs.org/). In its extended settings panel (bottom line), you can select whether files from CVS shall be converted during checkout to DOS (CR/LF line terminator) or UNIX (LF line terminator) mode - you should select UNIX mode if you plan to apply patches that were created in a LINUX environment. Build concordance from CVS: --- - get concordance source from CVS (checkout or tarball, with concordance, libconcord, consnoop and win subdirectories plus some files) - double-click on win\concordance.dsw (VC++ 6 workspace file) to launch Visual Studio - You will get several messages that a current .vcproj file already exists - confirm with 'Yes' for each to load. - In the toolbar, select whether to build a 'Debug' or 'Release' version. - Select build-build project folder from the main menu - After probably a few warnings, build should be complete and end up with concordance.exe and libconcord.dll in the win/Debug resp. win/Release folder. - when you save the
[concordance-devel] libIRremotes (Re: Patches for major update of IR code learning)
Here comes libIrremotes, that allows to put Pronto hex codes into the Logitech database. Extract, the build and install simliar to libconcord. Patches for concordance and congruity following, due to size limit. I'm not sure if it's worth to become its own sourceforge project, perhaps Phil could just adopt it for concordance. Considering all that Licensing mumbo-jumbo, well, the code is all by myself (though with knowledge from some docs from the web behind it), hacked together in my spare time, so feel free to do with it whatever you like, just don't hold me responsible in case it should kill your cat... Regards, Andreas Schulz libirremotes-0.20.tar.gz Description: application/tgz - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
[concordance-devel] libIRremotes, plus patches (Re: Patches for major update of IR code learning)
Last, but not least, here comes the patches for congruity and concordance to utilize libIRremotes for reading Pronto codes. Patches are against congruity8 resp. CVS concordance plus patch for new IR learning (from previous messages). Regards, Andreas Schulz diff -prc congruity8/Changelog congruity8.1/Changelog *** congruity8/Changelog 2008-06-05 09:00:15.0 +0200 --- congruity8.1/Changelog 2008-06-05 08:58:55.0 +0200 *** *** 1,3 --- 1,7 + * 2008-06-05 Andreas Schulz [EMAIL PROTECTED] - congruity-8.1 + - Added support for learning IR codes from Philips Pronto hex codes, + using libIRremotes. + * 2008-06-05 Andreas Schulz [EMAIL PROTECTED] - congruity-8 - Added retrieval of remote information, shown as tooltip for the remote image. diff -prc congruity8/congruity congruity8.1/congruity *** congruity8/congruity 2008-06-05 23:46:27.0 +0200 --- congruity8.1/congruity 2008-06-05 23:46:27.0 +0200 *** import wx *** 33,44 import wx.lib.dialogs import libconcord ! version = 8 # global: need_deinit = False #- # added for development debug output a.schulz: import pdb # debugger a.schulz --- 33,51 import wx.lib.dialogs import libconcord + import libIRremotes ! version = 8.1 # global: need_deinit = False + # Times to add a potential Repeat part of a Pronto HEX code + # to the transmitted IR pulse stream. Trying: + nRepeat = 2 + # so the Logitech database might recognize the repetition. + # might be worth to be changeable by the user at runtime? + #- # added for development debug output a.schulz: import pdb # debugger a.schulz *** iwh = (iw, ih) *** 59,64 --- 66,72 #-- pass verbose flag to imported libraries: libconcord.set_verbose(verbose) + libIRremotes.set_verbose(verbose) #-- shortcut to produce verbose output: def vprint(message): *** class LearnIRPanel_Start(LearnIRPanel): *** 1160,1166 self.resources.default_action = Learn else: disconnect_Harmony() ! self.resources.default_action = Skip self.parent.ReenableNext() # --- --- 1168,1174 self.resources.default_action = Learn else: disconnect_Harmony() ! self.resources.default_action = Pronto self.parent.ReenableNext() # --- *** class LearnIRPanel_Key(LearnIRPanel): *** 1173,1193 self.bmp_code_source_select = wx.StaticBitmap(self, -1, self.resources.icon_unstarted, None, iwh) self.text_code_source_select = wx.StaticText(self, ! -1, Select action for this key :) self.code_source_select = wx.RadioBox( self, -1, , wx.DefaultPosition, wx.DefaultSize, ! ['Learn', 'Skip'], 2, wx.RA_SPECIFY_COLS | wx.NO_BORDER) sizer.Add(self.bmp_code_source_select, (vpos, 0), (1, 1), ALIGN_LC, 5) sizer.Add(self.text_code_source_select, (vpos, 1), (1, 1), ALIGN_LC, 5) sizer.Add(self.code_source_select, (vpos, 2), (1, 1), ALIGN_CC, 5) self.Bind(wx.EVT_RADIOBOX, self.on_ir_radio_box, self.code_source_select) return vpos + 1 # -- construct panel items, called by __init__ def fill_panel(self, vpos, sizer): vpos = self.add_keyname_row(vpos, sizer) vpos = self.add_source_select_row(vpos, sizer) vpos = self.add_text_action_row(vpos, sizer) return vpos # --- --- 1181,1217 self.bmp_code_source_select = wx.StaticBitmap(self, -1, self.resources.icon_unstarted, None, iwh) self.text_code_source_select = wx.StaticText(self, ! -1, IR code source for this key :) self.code_source_select = wx.RadioBox( self, -1, , wx.DefaultPosition, wx.DefaultSize, ! ['Learn', 'Pronto', 'Skip'], 3, wx.RA_SPECIFY_COLS | wx.NO_BORDER) sizer.Add(self.bmp_code_source_select, (vpos, 0), (1, 1), ALIGN_LC, 5) sizer.Add(self.text_code_source_select, (vpos, 1), (1, 1), ALIGN_LC, 5) sizer.Add(self.code_source_select, (vpos, 2), (1, 1), ALIGN_CC, 5) self.Bind(wx.EVT_RADIOBOX, self.on_ir_radio_box, self.code_source_select) return vpos + 1 + def add_pronto_hex_row(self, vpos, sizer): + self.bmp_prontohex = wx.StaticBitmap(self, -1, + self.resources.icon_unstarted, None, iwh) + self.text_prontohex = wx.StaticText(self, -1, Pronto Hex Code:) + self.value_prontohex
Re: [concordance-devel] Using Visual Basic 2008 Express
Joe, On Thursday 08 May 2008, N Farms wrote: I can't get Visual Basic C++ 6.0 to install on my XP system. Would it be possible to send me the executable in a zip file so I can try it to see if it is even worth all the effort to compile on my own ? Note that 'Visual Basic C++ 6.0' is a contradiction in itself - it's either Basic or C++. I don't have VC++ 6.0, but you can get MS Visual Studio 2008 Express (V9.0) edition for free as download from Microsoft (but be aware that it's several 100MB!). This includes a few different programming languages, like Visual Basic, Visual C++ and Visual C#. For concordance, you only need the C++ part. You can even still get MS Visual C++ 2005 Express (probably V8.0?) from the same site, which may be a slightly smaller download. - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Learn-IR not yet working?
On Wednesday 09 April 2008, Phil Dibowitz wrote: Marcel de Jong wrote: Hello all, I'm afraid I have some bad news, not sure if others have had this as well. When I tried to set up my 555, I needed to have the remote learn some new trick via IR (basically because it refused to turn on or off me TV and all other devices I have), but when I ran the command it gave me this error message: It got broken sometime recently - when the file_read() stuff was done. I fixed it in CVS, thanks for pointing that out. Did you? Cannot see any change yet.. In case you didn't have time, I found meanwhile that it's actually two bugs - one probably from the file_read changes in libharmony.cpp, which fails because checking an unset err variable, and the next one in remote.cpp from the USB buffer changes, to the effect that the length byte now sits in rsp[63], not in rsp[64]. Attached patch should fix both. Andreas Index: libconcord.cpp === RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.cpp,v retrieving revision 1.26 diff -u -3 -p -u -p -r1.26 libconcord.cpp --- libconcord.cpp 4 Apr 2008 09:16:08 - 1.26 +++ libconcord.cpp 10 Apr 2008 19:39:52 - @@ -1215,12 +1215,9 @@ int extract_firmware_binary(uint8_t *xml int learn_ir_commands(uint8_t *data, uint32_t size, int post) { - int err; + int err = 0; if (data) { - if (err != 0) { - return err; - } uint8_t *t = data; string keyname; Index: remote.cpp === RCS file: /cvsroot/concordance/concordance/libconcord/remote.cpp,v retrieving revision 1.30 diff -u -3 -p -u -p -r1.30 remote.cpp --- remote.cpp 4 Apr 2008 09:16:09 - 1.30 +++ remote.cpp 10 Apr 2008 19:39:52 - @@ -638,7 +638,7 @@ int handle_ir_response(uint8_t rsp[64], unsigned int t_on, unsigned int t_off, unsigned int pulse_count, unsigned int *pulses, unsigned int freq) { - const unsigned int len = rsp[64]; + const unsigned int len = rsp[63]; if ((len 1) == 0) { for (unsigned int u = 2; u len; u += 2) { const unsigned int t = rsp[u] 8 | rsp[1+u]; - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel
Re: [concordance-devel] Suggestion for some cleanup i n libconcord.cpp
On Monday 31 March 2008, Phil Dibowitz wrote: Now that Stephen's patch has been merged, did you want to re-submit your patch against the latest CVS? In theory it should make your patch a bit smaller... Yup - piece of cake now, with all that \0 termination or not stuff gone. Makes some functions almost redundant. I compiled the patch and did a few tests with up- and downloading files from/to the remote that looked ok. Added also debug output of the Harmony code string in learn_ir_code. Maybe read_from_file should eventually even be moved to binaryfile? Andreas Index: libconcord/libconcord.cpp === RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.cpp,v retrieving revision 1.18 diff -u -3 -p -u -p -r1.18 libconcord.cpp --- libconcord/libconcord.cpp 30 Mar 2008 23:59:48 - 1.18 +++ libconcord/libconcord.cpp 1 Apr 2008 07:43:06 - @@ -320,6 +320,37 @@ void delete_blob(uint8_t *ptr) delete[] ptr; } +/* + * Common routine to read contents of file named *file_name into + * byte buffer **out. Get size from file and return out[size] + * as read from file. + */ + +int read_from_file(char *file_name, uint8_t **out, uint32_t *size) +{ + binaryinfile file; + + if (file_name == NULL) { + debug(Empty file_name); + return LC_ERROR_OS_FILE; + } + + if (file.open(file_name) != 0) { + debug(Failed to open %s, file_name); + return LC_ERROR_OS_FILE; + } + + *size = file.getlength(); + *out = new uint8_t[*size]; + file.read(*out, *size); + + if (file.close() != 0) { + debug(Failed to close %s\n, file_name); + return LC_ERROR_OS_FILE; + } + return 0; +} + /* * GENERAL REMOTE STUFF @@ -444,26 +475,17 @@ int post_postconfig(uint8_t *data, uint3 int post_connect_test_success(char *file_name) { + uint32_t size; + uint8_t *buf; + int err = 0; /* * If we arrived, we can talk to the remote - so if it's * just a connectivity test, tell the site we succeeded */ - binaryinfile file; - if (file.open(file_name) != 0) { - return LC_ERROR_OS_FILE; - } - - const uint32_t size = file.getlength(); - uint8_t * const buf = new uint8_t[size]; - file.read(buf, size); - - Post(buf, size, POSTOPTIONS, ri, true); - - if (file.close() != 0) { - return LC_ERROR_OS_FILE; + if ( (err = read_from_file(file_name, buf, size)) == 0 ) { + Post(buf, size, POSTOPTIONS, ri, true); } - - return 0; + return err; } int get_time() @@ -544,23 +566,7 @@ int write_config_to_remote(uint8_t *in, int read_config_from_file(char *file_name, uint8_t **out, uint32_t *size) { - binaryinfile file; - - if (file.open(file_name) != 0) { - debug(Failed to open %s, file_name); - return LC_ERROR_OS_FILE; - } - - *size = file.getlength(); - *out = new uint8_t[*size]; - file.read(*out, *size); - - if (file.close() != 0) { - debug(Failed to close %s, file_name); - return LC_ERROR_OS_FILE; - } - - return 0; + return read_from_file(file_name, out, size); } int write_config_to_file(uint8_t *in, uint32_t size, char *file_name, @@ -787,23 +793,7 @@ int write_safemode_to_file(uint8_t *in, int read_safemode_from_file(char *file_name, uint8_t **out, uint32_t *size) { - binaryinfile file; - - if (file.open(file_name) != 0) { - debug(Failed to open %s, file_name); - return LC_ERROR_OS_FILE; - } - - *size = file.getlength(); - *out = new uint8_t[*size]; - file.read(*out, *size); - - if (file.close() != 0) { - debug(Failed to close %s, file_name); - return LC_ERROR_OS_FILE; - } - - return 0; + return read_from_file(file_name, out, size); } /* @@ -1106,23 +1096,7 @@ int extract_firmware_binary(uint8_t *xml int read_firmware_from_file(char *file_name, uint8_t **out, uint32_t *size, int binary) { - binaryinfile file; - - if (file.open(file_name) != 0) { - debug(Failed to open %s, file_name); - return LC_ERROR_OS_FILE; - } - - *size = file.getlength(); - *out = new uint8_t[*size]; - file.read(*out, *size); - - if (file.close() != 0) { - debug(Failed to close %s, file_name); - return LC_ERROR_OS_FILE; - } - - return 0; + return read_from_file(file_name, out, size); } /* @@ -1133,15 +1107,11 @@ int learn_ir_commands(char *file_name, i int err; if (file_name) { - binaryinfile file; - if (file.open(file_name)) { - return LC_ERROR_OS_FILE; - } - uint32_t size = file.getlength(); - uint8_t * const x = new uint8_t[size]; - file.read(x, size); - if (file.close() != 0) { - return LC_ERROR_OS_FILE; + uint32_t size = 0; + uint8_t *x = NULL; + err = read_from_file(file_name, x, size); + if (err != 0) { + return err; } uint8_t *t = x; @@ -1161,10 +1131,11 @@ int learn_ir_commands(char *file_name, i string ls; rmt-LearnIR(ls); - //printf(%s\n,ls.c_str()); + debug(Learned code: %s,ls.c_str()); - if (post) + if (post) { Post(x, size, POSTOPTIONS, ri, true, ls, keyname); + } } else { rmt-LearnIR(); } - Check out the new
Re: [concordance-devel] Suggestion for some cleanup in libconcord.cpp
On Tuesday 01 April 2008, Phil Dibowitz wrote: Applied. I made a tweak and renamed read_from_file to be _read_from_file, but other than that, I applied it as-is. Though I think I may re-org that file a bit. Feel free as you like - it's just my 2p to keep things going and tidy (same for the bugfix). Sorry for the missing underscore - since it's even illegal in the code I've been paid for the last 15 years, it never came to my mind to start an identifier like that (though I just had to learn the hard way yesterday with _DEBUG)... - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel