return 0;
}
-int contour_read_entry(int fd, int uc, struct msg *in)
+int contour_read_entry(int fd, int uc, struct msg *in, int extra_delay)
{
struct msg msg;
int j;
msg.direction = OUT;
set_first_msg_byte(&msg, &j, 0x01);
set_msg_byte(&msg, &j, 1, 0x06);
+ usleep(extra_delay * 1000);
send_msg(&msg, fd, uc);
+
read_and_verify(in, fd);
return datalen(in->data);
}
};
int contour_initialize(int fd, int uc);
-int contour_read_entry(int fd, int uc, struct msg *in);
+int contour_read_entry(int fd, int uc, struct msg *in, int extra_delay);
int wait_for_device(int vendor, int product, int *usage_code);
struct msg msg;
int ret;
int entries = 0;
+ int extra_delay = 0;
trace(0, "Reading data ...\n");
if (opts->output_format == CSV)
"Activity,\"Control test\"\n");
while (1) {
- ret = contour_read_entry(fd, usage_code, &msg);
+ ret = contour_read_entry(fd, usage_code, &msg, extra_delay);
if (ret < 45)
break;
entries++;
+ /*
+ * Add 20ms magic sleep. This is needed especially for
+ * meters that have reached the internal limit of 2000
+ * glucose readings. We don't want to delay any other
+ * reads as it appears to be needed only for every
+ * 16th read.
+ */
+ if (!(entries % 16))
+ extra_delay = 20;
+ else
+ extra_delay = 0;
+
if ((opts->outf != stdout) || !isatty(fileno(stdout))) {
trace(0, "\r%d entries", entries);
fflush(stdout);