summaryrefslogtreecommitdiffstats
path: root/uemis.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-21 21:43:36 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-21 21:43:36 -0800
commit48a8c9891300ec50d993f3bdb051720445bd5938 (patch)
tree56ba9570671736281d59db36aa768bba06463fa2 /uemis.c
parent74dd93c6a4cbc3a76af6fc4f467c4f602dd49002 (diff)
downloadsubsurface-48a8c9891300ec50d993f3bdb051720445bd5938.tar.gz
Correct Uemis extra data
When dropping the pointless surface samples at the end of the dive we stopped going through all the samples - for that reason the offset at the end to find the data in the footer was wrong. Now the extra data all seems to match what I can see on my screen after the dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis.c')
-rw-r--r--uemis.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/uemis.c b/uemis.c
index 686dc8f8f..327b350be 100644
--- a/uemis.c
+++ b/uemis.c
@@ -296,8 +296,6 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
char version[5];
datalen = uemis_convert_base64(base64, &data);
- snprintf(version, sizeof(version), "%1u.%02u", data[18], data[17]);
- add_extra_data(dc, "software_version", version);
dive->dc.airtemp.mkelvin = C_to_mkelvin((*(uint16_t *)(data + 45)) / 10.0);
dive->dc.surface_pressure.mbar = *(uint16_t *)(data + 43);
if (*(uint8_t *)(data + 19))
@@ -342,13 +340,15 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
/* first byte of divelog data is at offset 0x123 */
i = 0x123;
u_sample = (uemis_sample_t *)(data + i);
- while ((i < datalen) && (u_sample->dive_time)) {
+ while ((i <= datalen) && (data[i] != 0 || data[i+1] != 0)) {
/* it seems that a dive_time of 0 indicates the end of the valid readings */
/* the SDA usually records more samples after the end of the dive --
* we want to discard those, but not cut the dive short; sadly the dive
* duration in the header is a) in minutes and b) up to 3 minutes short */
- if (u_sample->dive_time > dive->dc.duration.seconds + 180)
- break;
+ if (u_sample->dive_time > dive->dc.duration.seconds + 180) {
+ i += 0x25;
+ continue;
+ }
if (u_sample->active_tank != active) {
active = u_sample->active_tank;
add_gas_switch_event(dive, dc, u_sample->dive_time, active);
@@ -371,6 +371,11 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
/* get data from the footer */
char buffer[24];
+
+ snprintf(version, sizeof(version), "%1u.%02u", data[18], data[17]);
+ add_extra_data(dc, "FW Version", version);
+ snprintf(buffer, sizeof(buffer), "%08x", *(uint32_t *)(data + 9));
+ add_extra_data(dc, "Serial", buffer);
snprintf(buffer, sizeof(buffer), "%d",*(uint16_t *)(data + i + 35));
add_extra_data(dc, "main battery after dive", buffer);
snprintf(buffer, sizeof(buffer), "%0u:%02u", FRACTION(*(uint16_t *)(data + i + 24), 60));