X-Git-Url: https://git.ao2.it/visomat-utils.git/blobdiff_plain/561b6786281209c2bf7b4492f0ac32c275da9b28..8d67f9a624e9097a7c99513dd0e73daf3b59ae8d:/src/visomat-data-downloader.c diff --git a/src/visomat-data-downloader.c b/src/visomat-data-downloader.c index 2bdd5ea..97da8e8 100644 --- a/src/visomat-data-downloader.c +++ b/src/visomat-data-downloader.c @@ -119,7 +119,7 @@ static void print_record_csv_compat(struct datetime *d, struct pressure *p) printf("\n"); } -/* TODO separate better decoding data from printing it */ +/* TODO: it would be better to separate decoding data from printing it */ static int decode_eeprom(unsigned char *buffer, unsigned int len, unsigned int user_mask) @@ -156,6 +156,13 @@ static int decode_eeprom(unsigned char *buffer, /* user_id and num_records take 3 bytes */ i += 3; + /* + * when there are no records, there is a dummy byte + * which has to be consumed + */ + if (num_records == 0) + i += 1; + for (j = 0; j < num_records; j++) { ret = extract_datetime(buffer + i, &d); if (ret < 0)