]> sigrok.org Git - libsigrok.git/blobdiff - hardware/colead-slm/protocol.c
Various cosmetics, whitespace, consistency fixes.
[libsigrok.git] / hardware / colead-slm / protocol.c
index d14a382bae8cbcec3f9db76691ae3be8a9a915b0..e10fc37e438b8dbf7f914faafa579fbd9160f031 100644 (file)
@@ -25,7 +25,6 @@
 #include <errno.h>
 #include <string.h>
 
-
 static void process_packet(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -181,6 +180,7 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
 {
        const struct sr_dev_inst *sdi;
        struct dev_context *devc;
+       struct sr_serial_dev_inst *serial;
        int len;
        char buf[128];
 
@@ -196,21 +196,22 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
                /* Timeout event. */
                return TRUE;
 
+       serial = sdi->conn;
        if (devc->state == IDLE) {
-               if (serial_read(devc->serial, buf, 128) != 1 || buf[0] != 0x10)
+               if (serial_read(serial, buf, 128) != 1 || buf[0] != 0x10)
                        /* Nothing there, or caught the tail end of a previous packet,
                         * or some garbage. Unless it's a single "data ready" byte,
                         * we don't want it. */
                        return TRUE;
                /* Got 0x10, "measurement ready". */
-               if (serial_write(devc->serial, "\x20", 1) == -1)
+               if (serial_write(serial, "\x20", 1) == -1)
                        sr_err("unable to send command: %s", strerror(errno));
                else {
                        devc->state = COMMAND_SENT;
                        devc->buflen = 0;
                }
        } else {
-               len = serial_read(devc->serial, devc->buf + devc->buflen,
+               len = serial_read(serial, devc->buf + devc->buflen,
                                10 - devc->buflen);
                if (len < 1)
                        return TRUE;
@@ -230,4 +231,3 @@ SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
 
        return TRUE;
 }
-