On Wed, 2 Jan 2013, Phil Dibowitz wrote:
The parsing patch looks fine, but why are you ignoring INVALID_CONFIG as an error?Because, with firmware upgrades that are not "direct" (such as with the 688) the config gets erased as part of the firmware upgrade. So after a firmware upgrade, the config will be invalid (and this is expected).Can you add a comment to that effect?
Done.
Implemented firmware updates for 688 remotes. Added capability to parse the multi-phase firmware file that is used by the 688. Additionally, modified the reset_remote logic to ignore "invalid config" as a fatal error. Signed-off-by: Scott Talbert <s...@techie.net> Index: libconcord/libconcord.cpp =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.cpp,v retrieving revision 1.42.2.22 diff -u -p -r1.42.2.22 libconcord.cpp --- libconcord/libconcord.cpp 15 Jul 2012 07:17:08 -0000 1.42.2.22 +++ libconcord/libconcord.cpp 3 Jan 2013 02:16:08 -0000 @@ -702,7 +702,15 @@ int reset_remote(lc_callback cb, void *c err = init_concord(); if (err == 0) { err = _get_identity(NULL, NULL, 0); - if (err == 0) { + /* + * On remotes where firmware upgrades are not "direct", + * the config gets erased as part of the firmware + * update. Thus, the config could be invalid if we are + * resetting after a firmware upgrade, and we don't + * want to treat this as an error. + */ + if ((err == 0) || (err == LC_ERROR_INVALID_CONFIG)) { + err = 0; break; } deinit_concord(); @@ -1325,7 +1333,8 @@ int update_firmware(lc_callback cb, void if (noreset) return 0; - reset_remote(cb, cb_arg); + if ((err = reset_remote(cb, cb_arg))) + return err; if ((err = set_time(cb, cb_arg))) return err; Index: libconcord/operationfile.cpp =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/Attic/operationfile.cpp,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 operationfile.cpp --- libconcord/operationfile.cpp 29 Sep 2012 23:51:38 -0000 1.1.2.3 +++ libconcord/operationfile.cpp 3 Jan 2013 02:16:08 -0000 @@ -198,10 +198,24 @@ int OperationFile::_ExtractFirmwareBinar uint8_t *o = data; uint8_t *x = xml; + uint8_t *x_new; uint32_t x_size = xml_size; + /* + * Some remotes (e.g., Arch 7) contain multiple phases in their + * firmware update files. In that case, extract only the first phase. + */ + if (GetTag("PHASE", x, x_size, x_new) == 0) { + debug("multi-phase firmware found, extracting 1st phase"); + x_size = x_size - (x_new - x); + x = x_new; + uint8_t *phase_end; + GetTag("/PHASE", x, x_size, phase_end); + x_size = phase_end - x; + } + string hex; - while (GetTag("DATA", x, x_size, x, &hex) == 0) { + while (GetTag("DATA", x, x_size, x_new, &hex) == 0) { uint32_t hex_size = hex.length() / 2; if (hex_size > o_size) { return LC_ERROR; @@ -209,7 +223,8 @@ int OperationFile::_ExtractFirmwareBinar _convert_to_binary(hex, o); - x_size = xml_size - (x - xml); + x_size = x_size - (x_new - x); + x = x_new; o_size -= hex_size; }
Implemented firmware updates for 688 remotes. Added capability to parse the multi-phase firmware file that is used by the 688. Additionally, modified the reset_remote logic to ignore "invalid config" as a fatal error. Signed-off-by: Scott Talbert <s...@techie.net> Index: concordance/concordance.c =================================================================== RCS file: /cvsroot/concordance/concordance/concordance/concordance.c,v retrieving revision 1.44 diff -u -p -r1.44 concordance.c --- concordance/concordance.c 19 Mar 2012 05:41:00 -0000 1.44 +++ concordance/concordance.c 3 Jan 2013 02:20:13 -0000 @@ -678,7 +678,15 @@ int upload_firmware(uint8_t *firmware, u err = init_concord(); if (err == 0) { err = get_identity(cb_print_percent_status, NULL); - if (err == 0) { + /* + * On remotes where firmware upgrades are not "direct", + * the config gets erased as part of the firmware + * update. Thus, the config could be invalid if we are + * resetting after a firmware upgrade, and we don't + * want to treat this as an error. + */ + if ((err == 0) || (err == LC_ERROR_INVALID_CONFIG)) { + err = 0; break; } deinit_concord(); Index: libconcord/libconcord.cpp =================================================================== RCS file: /cvsroot/concordance/concordance/libconcord/libconcord.cpp,v retrieving revision 1.42 diff -u -p -r1.42 libconcord.cpp --- libconcord/libconcord.cpp 27 Jul 2010 19:33:52 -0000 1.42 +++ libconcord/libconcord.cpp 3 Jan 2013 02:20:13 -0000 @@ -1179,10 +1179,24 @@ int extract_firmware_binary(uint8_t *xml uint8_t *o = *out; uint8_t *x = xml; + uint8_t *x_new; uint32_t x_size = xml_size; + /* + * Some remotes (e.g., Arch 7) contain multiple phases in their + * firmware update files. In that case, extract only the first phase. + */ + if (GetTag("PHASE", x, x_size, x_new) == 0) { + debug("multi-phase firmware found, extracting 1st phase"); + x_size = x_size - (x_new - x); + x = x_new; + uint8_t *phase_end; + GetTag("/PHASE", x, x_size, phase_end); + x_size = phase_end - x; + } + string hex; - while (GetTag("DATA", x, x_size, x, &hex) == 0) { + while (GetTag("DATA", x, x_size, x_new, &hex) == 0) { uint32_t hex_size = hex.length() / 2; if (hex_size > o_size) { return LC_ERROR; @@ -1190,7 +1204,8 @@ int extract_firmware_binary(uint8_t *xml _convert_to_binary(hex, o); - x_size = xml_size - (x - xml); + x_size = x_size - (x_new - x); + x = x_new; o_size -= hex_size; }
------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712
_______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel