return 0;
}
-int communicate(int fd, int uc)
+int contour_initialize(int fd, int uc)
{
int i, j;
- struct msg msg, in;
+ struct msg msg;
msg.direction = OUT;
- trace(0, "Initializing..\n");
read_msgs(fd);
SET_FIRST_BYTE(0x01);
send_msg_with_proggress_note(&msg, fd, uc);
read_msgs(fd);
- trace(0, "\nGlucose readings:\n");
usleep(100 * 1000);
- do {
- send_msg(&msg, fd, uc);
- read_and_verify(&in, fd);
- print_ascii(in.data, datalen(in.data));
- } while (datalen(in.data) > 45);
+ trace(0, "\n");
return 0;
}
+int contour_read_entry(int fd, int uc, struct msg *in)
+{
+ struct msg msg;
+ int j;
+
+ msg.direction = OUT;
+ SET_FIRST_BYTE(0x01);
+ SET_BYTE(1, 0x06);
+
+ send_msg(&msg, fd, uc);
+ read_and_verify(in, fd);
+
+ return datalen(in->data);
+}
+
int wait_for_device(int vendor, int product, int *usage_code)
{
int fd;
OUT,
};
-int communicate(int fd, int uc);
+int contour_initialize(int fd, int uc);
+int contour_read_entry(int fd, int uc, struct msg *in);
int wait_for_device(int vendor, int product, int *usage_code);
int main(int argc, char *argv[])
{
- int fd, usage_code;
+ int fd, usage_code, ret;
struct user_options opts;
+ struct msg msg;
read_args(argc, argv, &opts);
trace_level = opts.trace_level;
if (fd < 0)
return 1;
- communicate(fd, usage_code);
+ trace(0, "Initializing\n");
+ contour_initialize(fd, usage_code);
+
+ trace(0, "Done! Reading data\n");
+ while (1) {
+ ret = contour_read_entry(fd, usage_code, &msg);
+ print_ascii(msg.data, ret);
+
+ if (ret < 45)
+ break;
+ }
return 0;
}