X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fserial-dmm%2Fapi.c;h=019bf2096695bda5c8f94021d4dabb5ef434775d;hb=c06785841cd217ad01e32be9201dca69b1f8818d;hp=860062ad510f34297d9299b4458a8c10b3cf3603;hpb=c45c32ce47f429099cb0f1cabc1b45b9bcf44855;p=libsigrok.git diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 860062ad..019bf209 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -41,11 +41,6 @@ static const uint32_t devopts[] = { SR_CONF_LIMIT_MSEC | SR_CONF_SET, }; -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{ - return std_init(di, sr_ctx); -} - static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct dmm_info *dmm; @@ -53,7 +48,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) GSList *l, *devices; const char *conn, *serialcomm; struct sr_dev_inst *sdi; - struct drv_context *drvc; struct dev_context *devc; struct sr_serial_dev_inst *serial; int dropped, ret; @@ -87,7 +81,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sr_info("Probing serial port %s.", conn); - drvc = di->context; devices = NULL; serial_flush(serial); @@ -135,15 +128,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; sdi->priv = devc; - sdi->driver = di; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1"); - drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); scan_cleanup: serial_close(serial); - return devices; + return std_scan_complete(di, devices); } static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, @@ -156,10 +147,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->limits, key, data); } @@ -197,7 +185,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc = sdi->priv; sr_sw_limits_acquisition_start(&devc->limits); - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; @@ -207,20 +195,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi) -{ - return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close, - sdi->conn, LOG_PREFIX); -} - #define DMM(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, \ DELAY, REQUEST, VALID, PARSE, DETAILS) \ - &(struct dmm_info) { \ + &((struct dmm_info) { \ { \ .name = ID, \ .longname = VENDOR " " MODEL, \ .api_version = 1, \ - .init = init, \ + .init = std_init, \ .cleanup = std_cleanup, \ .scan = scan, \ .dev_list = std_dev_list, \ @@ -230,14 +212,36 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) .dev_open = std_serial_dev_open, \ .dev_close = std_serial_dev_close, \ .dev_acquisition_start = dev_acquisition_start, \ - .dev_acquisition_stop = dev_acquisition_stop, \ + .dev_acquisition_stop = std_serial_dev_acquisition_stop, \ .context = NULL, \ }, \ VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, DELAY, \ REQUEST, VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \ - } + }).di -SR_PRIV const struct dmm_info *serial_dmm_drivers[] = { +SR_REGISTER_DEV_DRIVER_LIST(serial_dmm_drivers, + /* + * The items are sorted by chipset first and then model name. + * + * This reflects the developer's perspective and is preferrable + * during maintenance, as a vendor/product based sort order does + * not work well for rebranded models, and from a support point + * of view it's more important to identify similarities between + * models and compatible devices. + * + * Fold marks {{{ }}} with matching braces were added, to further + * speed up navigation in the long list. + */ + /* bm25x based meters {{{ */ + DMM( + "brymen-bm25x", bm25x, + "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1", + 9600, BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL, + sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse, + NULL + ), + /* }}} */ + /* meters based on other chips (to get sorted) */ DMM( "bbcgm-2010", metex14, "BBC Goertz Metrawatt", "M2110", "1200/7n2", 1200, @@ -553,13 +557,6 @@ SR_PRIV const struct dmm_info *serial_dmm_drivers[] = { sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse, NULL ), - DMM( - "brymen-bm25x", bm25x, - "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1", - 9600, BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL, - sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse, - NULL - ), DMM( "velleman-dvm4100", dtm0660, "Velleman", "DVM4100", "2400/8n1/rts=0/dtr=1", @@ -572,5 +569,11 @@ SR_PRIV const struct dmm_info *serial_dmm_drivers[] = { 2400, DTM0660_PACKET_SIZE, 0, 0, NULL, sr_dtm0660_packet_valid, sr_dtm0660_parse, NULL ), - NULL -}; + DMM( + "peaktech-3330", fs9721, + "Peaktech", "3330", "2400/8n1/dtr=1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_01_10_temp_f_c + ), +);