Attached are a couple of patches to fix firmware updates for the 688 remote, one for trunk and one for zwave_work_branch. I have been trying to test Congruity with the new API and I needed to have a remote with working firmware updates. :-)

Basically, the 688's firmware update file has multiple phases in it and libconcord needed to be able to parse that. The second "phase" is basically a blank config file that the windows software writes to the remote. I didn't bother trying to implement that because we still have to re-write a real config file over it anyway.

I'll upload the patches to sourceforge later, it is being a pain right now.

Scott
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   1 Nov 2012 00:03:12 -0000
@@ -702,7 +702,8 @@ int reset_remote(lc_callback cb, void *c
                err = init_concord();
                if (err == 0) {
                        err = _get_identity(NULL, NULL, 0);
-                       if (err == 0) {
+                       if ((err == 0) || (err == LC_ERROR_INVALID_CONFIG)) {
+                               err = 0;
                                break;
                        }
                        deinit_concord();
@@ -1325,7 +1326,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        1 Nov 2012 00:03:12 -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   1 Nov 2012 00:04:05 -0000
@@ -678,7 +678,8 @@ int upload_firmware(uint8_t *firmware, u
                err = init_concord();
                if (err == 0) {
                        err = get_identity(cb_print_percent_status, NULL);
-                       if (err == 0) {
+                       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   1 Nov 2012 00:04:05 -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;
        }
 
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to