From: Gerhard Sittig Date: Sun, 9 Jun 2019 08:18:52 +0000 (+0200) Subject: serial-dmm: fixup 'conn' vs 'serialcomm' confusion X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=09c650d5e910d841c49e7b1e86e4126cecd7e060;p=libsigrok.git serial-dmm: fixup 'conn' vs 'serialcomm' confusion The 'conn' field in the device context and the CONN values in the declarations of supported DMM models seemed inappropriate. They specify the communication parameters (UART frame format and bitrate), not the connection (port name). Adjust the respective identifiers. Also rephrase the evaluation logic. Instead of checking for the absence of user specs and optionally assigning a fallback value, just preset from defaults and override from user specs when present. This simplifies the logic (eliminates a check). --- diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 98bf7fb2..7a7be0c2 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -61,7 +61,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) dmm = (struct dmm_info *)di; - conn = serialcomm = NULL; + conn = NULL; + serialcomm = dmm->serialcomm; for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -76,9 +77,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) if (!conn) return NULL; - if (!serialcomm) - serialcomm = dmm->conn; - serial = sr_serial_dev_inst_new(conn, serialcomm); if (serial_open(serial, SERIAL_RDWR) != SR_OK) @@ -196,7 +194,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_OK; } -#define DMM(ID, CHIPSET, VENDOR, MODEL, CONN, PACKETSIZE, TIMEOUT, \ +#define DMM(ID, CHIPSET, VENDOR, MODEL, SERIALCOMM, PACKETSIZE, TIMEOUT, \ DELAY, REQUEST, VALID, PARSE, DETAILS) \ &((struct dmm_info) { \ { \ @@ -217,7 +215,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) .dev_acquisition_stop = std_serial_dev_acquisition_stop, \ .context = NULL, \ }, \ - VENDOR, MODEL, CONN, PACKETSIZE, TIMEOUT, DELAY, \ + VENDOR, MODEL, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \ REQUEST, 1, NULL, VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \ }).di diff --git a/src/hardware/serial-dmm/protocol.h b/src/hardware/serial-dmm/protocol.h index f96d1357..27533b6e 100644 --- a/src/hardware/serial-dmm/protocol.h +++ b/src/hardware/serial-dmm/protocol.h @@ -29,8 +29,8 @@ struct dmm_info { const char *vendor; /** Model. */ const char *device; - /** serialconn string. */ - const char *conn; + /** serialcomm string. */ + const char *serialcomm; /** Packet size in bytes. */ int packet_size; /**