]> sigrok.org Git - libsigrok.git/commitdiff
teleinfo: Minor cleanups.
authorUwe Hermann <redacted>
Thu, 26 Dec 2013 23:35:42 +0000 (00:35 +0100)
committerUwe Hermann <redacted>
Fri, 27 Dec 2013 11:27:52 +0000 (12:27 +0100)
hardware/teleinfo/api.c
hardware/teleinfo/protocol.c

index 7728a314e94f016f6da16923392e503c464b8d3c..ffbabf0694b918d6ecabe4d97214113477708a77 100644 (file)
@@ -53,10 +53,13 @@ static GSList *scan(GSList *options)
        GSList *devices = NULL, *l;
        const char *conn = NULL, *serialcomm = NULL;
        uint8_t buf[292];
-       size_t len = sizeof(buf);
+       size_t len;
+       struct sr_config *src;
+
+       len = sizeof(buf);
 
        for (l = options; l; l = l->next) {
-               struct sr_config *src = l->data;
+               src = l->data;
                switch (src->key) {
                case SR_CONF_CONN:
                        conn = g_variant_get_string(src->data, NULL);
@@ -266,8 +269,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
-       return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
-                       sdi->conn, LOG_PREFIX);
+       return std_serial_dev_acquisition_stop(sdi, cb_data,
+                       std_serial_dev_close, sdi->conn, LOG_PREFIX);
 }
 
 SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
@@ -279,10 +282,12 @@ SR_PRIV struct sr_dev_driver teleinfo_driver_info = {
        .scan = scan,
        .dev_list = dev_list,
        .dev_clear = dev_clear,
+       .config_get = NULL,
        .config_set = config_set,
        .config_list = config_list,
        .dev_open = std_serial_dev_open,
        .dev_close = std_serial_dev_close,
        .dev_acquisition_start = dev_acquisition_start,
        .dev_acquisition_stop = dev_acquisition_stop,
+       .priv = NULL,
 };
index 28dfcfa1fbd3b950ebb22a6ce9945dbfce3ea9b8..0d7e6ce53da7bdfbf2f1c0ad78f646bf14c06d52 100644 (file)
@@ -125,7 +125,7 @@ static gboolean teleinfo_parse_group(struct sr_dev_inst *sdi,
                                      const uint8_t *group, char *optarif)
 {
        char label[9], data[13], control, cr;
-       const char *str = (const char *) group;
+       const char *str = (const char *)group;
        if (sscanf(str, "\x0A%8s %13s %c%c", label, data, &control, &cr) != 4
            || cr != CR)
                return FALSE;
@@ -139,12 +139,13 @@ static const uint8_t *teleinfo_parse_data(struct sr_dev_inst *sdi,
                                           const uint8_t *buf, int len,
                                           char *optarif)
 {
-       const uint8_t *group_start = memchr(buf, LF, len);
+       const uint8_t *group_start, *group_end;
+
+       group_start = memchr(buf, LF, len);
        if (!group_start)
                return NULL;
 
-       const uint8_t *group_end = memchr(group_start, CR,
-                                         len - (group_start - buf));
+       group_end = memchr(group_start, CR, len - (group_start - buf));
        if (!group_end)
                return NULL;
 
@@ -181,6 +182,7 @@ SR_PRIV int teleinfo_receive_data(int fd, int revents, void *cb_data)
        struct sr_serial_dev_inst *serial;
        const uint8_t *ptr, *next_ptr, *end_ptr;
        int len;
+       int64_t time;
 
        (void)fd;
 
@@ -220,7 +222,7 @@ SR_PRIV int teleinfo_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (devc->limit_msec) {
-               int64_t time = (g_get_monotonic_time() - devc->start_time) / 1000;
+               time = (g_get_monotonic_time() - devc->start_time) / 1000;
                if (time > (int64_t)devc->limit_msec) {
                        sr_info("Requested time limit reached.");
                        sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);