Fix parsing systolic pressure
[visomat-utils.git] / src / visomat-data-downloader.c
index 08a752a..d925388 100644 (file)
@@ -63,6 +63,7 @@ struct datetime  {
 };
 
 struct pressure  {
+       unsigned int flag; /* XXX Maybe this means arrhythmia? */
        unsigned int systolic;
        unsigned int diastolic;
        unsigned int pulses;
@@ -102,10 +103,16 @@ static void print_record_csv_compat(struct datetime *d, struct pressure *p)
        pulse_pressure = p->systolic - p->diastolic;
        printf("%u;", pulse_pressure);
 
+       if (p->flag)
+               printf("x");
+
+#if 0
+       /* The original software does not seem to be doing that */
        if (p->pulses > 100)
                printf("tachycardia");
        else if (p->pulses < 60)
                printf("bradycardia");
+#endif
 
        printf("\n");
 }
@@ -157,11 +164,12 @@ static int decode_eeprom(unsigned char *buffer, unsigned int len)
                                i += 10;
 
                                ret = sscanf((char *)(buffer + i),
-                                            "%04u%03u%03u",
+                                            "%1u%03u%03u%03u",
+                                            &p.flag,
                                             &p.systolic,
                                             &p.diastolic,
                                             &p.pulses);
-                               if (ret != 3)
+                               if (ret != 4)
                                        return -EINVAL;
 
                                /* pressure data is 10 bytes */