aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2018-09-12 06:39:41 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-12 05:31:29 -0700
commit37e417c28a172b8c489feb789432aecdb42f2d56 (patch)
tree4a9b4da9e0cc5fb373ce791babd2189ceea82ca0
parent32eeb5130583c5f861d5ab8c9c77ecab2b34ae0e (diff)
downloadsubsurface-37e417c28a172b8c489feb789432aecdb42f2d56.tar.gz
DLF import: use battery_end in preparation
Prepare for recording both start and end pressures. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
-rw-r--r--core/parse-xml.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 865e9675e..227ce7f54 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1673,12 +1673,13 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *tabl
unsigned int time = 0;
int i;
char serial[6];
- struct {
+ struct battery_status {
uint16_t volt1;
uint8_t percent1;
uint16_t volt2;
uint8_t percent2;
- } battery = {0, 0, 0, 0};
+ };
+ struct battery_status battery_end = {0, 0, 0, 0};
target_table = table;
@@ -1978,10 +1979,10 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *tabl
switch (ptr[2] >> 5) {
case 1:
/* Measure Battery, recording the last reading only */
- battery.volt1 = (ptr[5] << 8) + ptr[4];
- battery.percent1 = ptr[6];
- battery.volt2 = (ptr[9] << 8) + ptr[8];
- battery.percent2 = ptr[10];
+ battery_end.volt1 = (ptr[5] << 8) + ptr[4];
+ battery_end.percent1 = ptr[6];
+ battery_end.volt2 = (ptr[9] << 8) + ptr[8];
+ battery_end.percent2 = ptr[10];
break;
case 2:
/* Measure He */
@@ -2014,21 +2015,21 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *tabl
}
/* Recording the ending battery status to extra data */
- if (battery.volt1) {
- size_t size = snprintf(NULL, 0, "%dmV (%d%%)", battery.volt1, battery.percent1) + 1;
+ if (battery_end.volt1) {
+ size_t size = snprintf(NULL, 0, "%dmV (%d%%)", battery_end.volt1, battery_end.percent1) + 1;
char *ptr = malloc(size);
if (ptr) {
- snprintf(ptr, size, "%dmV (%d%%)", battery.volt1, battery.percent1);
- add_extra_data(cur_dc, "Battery 1", ptr);
+ snprintf(ptr, size, "%dmV (%d%%)", battery_end.volt1, battery_end.percent1);
+ add_extra_data(cur_dc, "Battery 1 (end)", ptr);
free(ptr);
}
- size = snprintf(NULL, 0, "%dmV (%d%%)", battery.volt2, battery.percent2) + 1;
+ size = snprintf(NULL, 0, "%dmV (%d%%)", battery_end.volt2, battery_end.percent2) + 1;
ptr = malloc(size);
if (ptr) {
- snprintf(ptr, size, "%dmV (%d%%)", battery.volt2, battery.percent2);
- add_extra_data(cur_dc, "Battery 2", ptr);
+ snprintf(ptr, size, "%dmV (%d%%)", battery_end.volt2, battery_end.percent2);
+ add_extra_data(cur_dc, "Battery 2 (end)", ptr);
free(ptr);
}
}