X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fnorma-dmm%2Fapi.c;h=8a93f790dcc740d17963e7f854784d9f0a083dd6;hb=1e726f568d6d72a8c6afdcd8fa98b98e910ad523;hp=6dc9ed87da25ffe21b512ff36a16ad8edff78f6f;hpb=d545c81c96b5058e52e5354269972876026dd7e3;p=libsigrok.git diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 6dc9ed87..8a93f790 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -46,10 +46,7 @@ SR_PRIV struct sr_dev_driver siemens_b102x_driver_info; static const char *get_brandstr(struct sr_dev_driver *drv) { - if (drv == &norma_dmm_driver_info) - return "Norma"; - else - return "Siemens"; + return (drv == &norma_dmm_driver_info) ? "Norma" : "Siemens"; } static const char *get_typestr(int type, struct sr_dev_driver *drv) @@ -59,12 +56,13 @@ static const char *get_typestr(int type, struct sr_dev_driver *drv) {"DM920", "B1025"}, {"DM930", "B1026"}, {"DM940", "B1027"}, - {"DM950", "B1028"}}; + {"DM950", "B1028"}, + }; if ((type < 1) || (type > 5)) return "Unknown type!"; - return nameref[type-1][(drv == &siemens_b102x_driver_info)]; + return nameref[type - 1][(drv == &siemens_b102x_driver_info)]; } static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) @@ -80,11 +78,10 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options) struct sr_config *src; struct sr_serial_dev_inst *serial; GSList *l, *devices; - int len, cnt; + int len, cnt, auxtype; const char *conn, *serialcomm; char *buf; char req[10]; - int auxtype; devices = NULL; drvc = drv->context; @@ -131,7 +128,7 @@ static GSList *scan(struct sr_dev_driver *drv, GSList *options) continue; buf[BUF_MAX - 1] = '\0'; - /* Match ID string, e.g. "1834 065 V1.06,IF V1.02" (DM950) */ + /* Match ID string, e.g. "1834 065 V1.06,IF V1.02" (DM950). */ if (g_regex_match_simple("^1834 [^,]*,IF V*", (char *)buf, 0, 0)) { auxtype = xgittoint(buf[7]); sr_spew("%s %s DMM %s detected!", get_brandstr(drv), get_typestr(auxtype, drv), buf + 9); @@ -252,21 +249,17 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (!sdi || !cb_data || !(devc = sdi->priv)) - return SR_ERR_BUG; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - devc->cb_data = cb_data; + devc = sdi->priv; - /* Send header packet to the session bus. */ - std_session_send_df_header(cb_data, LOG_PREFIX); + std_session_send_df_header(sdi, LOG_PREFIX); /* Start timer, if required. */ if (devc->limit_msec) @@ -280,7 +273,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -288,7 +281,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) if (sdi && (devc = sdi->priv) && devc->limit_msec) g_timer_stop(devc->elapsed_msec); - return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close, + return std_serial_dev_acquisition_stop(sdi, dev_close, sdi->conn, LOG_PREFIX); }