OSTC4 stores firmware in another format than OSTC3's.

Signed-off-by: Anton Lundin <[email protected]>
---
 src/hw_ostc_parser.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c
index 5fef74c..67cf677 100644
--- a/src/hw_ostc_parser.c
+++ b/src/hw_ostc_parser.c
@@ -574,7 +574,19 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, 
dc_field_type_t type, unsigned
                                break;
                        case 2: /* firmware */
                                string->desc = "FW Version";
-                               snprintf(buf, BUFLEN, "%0u.%02u", 
data[layout->firmware], data[layout->firmware + 1]);
+                               /* OSTC4 stores firmware as XXXX XYYY YYZZ 
ZZZB, -> X.Y.Z beta? */
+                               if (parser->model == OSTC4) {
+                                       int firmwareOnDevice = array_uint16_le 
(data + layout->firmware);
+                                       unsigned char X = 0, Y = 0, Z = 0, beta 
= 0;
+                                       X = (firmwareOnDevice & 0xF800) >> 11;
+                                       Y = (firmwareOnDevice & 0x07C0) >> 6;
+                                       Z = (firmwareOnDevice & 0x003E) >> 1;
+                                       beta = firmwareOnDevice & 0x0001;
+
+                                       snprintf(buf, BUFLEN, "%u.%u.%u%s\n", 
X, Y, Z, beta? "beta": "");
+                               } else {
+                                       snprintf(buf, BUFLEN, "%0u.%02u", 
data[layout->firmware], data[layout->firmware + 1]);
+                               }
                                break;
                        case 3: /* serial */
                                string->desc = "Serial";
-- 
2.9.3

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to