From: Uwe Hermann Date: Thu, 26 Dec 2013 23:35:42 +0000 (+0100) Subject: teleinfo: Minor cleanups. X-Git-Tag: libsigrok-0.3.0~403 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=dafafb0e9429fcc9185df1c861184ce79defb7ee;p=libsigrok.git teleinfo: Minor cleanups. --- diff --git a/hardware/teleinfo/api.c b/hardware/teleinfo/api.c index 7728a314..ffbabf06 100644 --- a/hardware/teleinfo/api.c +++ b/hardware/teleinfo/api.c @@ -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, }; diff --git a/hardware/teleinfo/protocol.c b/hardware/teleinfo/protocol.c index 28dfcfa1..0d7e6ce5 100644 --- a/hardware/teleinfo/protocol.c +++ b/hardware/teleinfo/protocol.c @@ -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);