X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_serial.c;h=90c01424cbb80054efc671295a619938f2d3ca52;hb=2489de3a24e41d14d05aed0c611e16261cbc0450;hp=c73d1b4841a70ae434f50a6222d3555d881828ee;hpb=48b7c3462927616916a1296c862e96e3a36c2a80;p=libsigrok.git diff --git a/src/scpi/scpi_serial.c b/src/scpi/scpi_serial.c index c73d1b48..90c01424 100644 --- a/src/scpi/scpi_serial.c +++ b/src/scpi/scpi_serial.c @@ -35,6 +35,7 @@ struct scpi_serial { gboolean got_newline; }; +/* Default serial port options for some known USB devices */ static const struct { uint16_t vendor_id; uint16_t product_id; @@ -42,7 +43,9 @@ static const struct { } scpi_serial_usb_ids[] = { { 0x0403, 0xed72, "115200/8n1/flow=1" }, /* Hameg HO720 */ { 0x0403, 0xed73, "115200/8n1/flow=1" }, /* Hameg HO730 */ - { 0x0aad, 0x0118, "115200/8n1" }, /* R&S HMO1002 */ + { 0x0aad, 0x0117, "115200/8n1" }, /* R&S HMO series, previously branded as Hameg HMO */ + { 0x0aad, 0x0118, "115200/8n1" }, /* R&S HMO series, previously branded as Hameg HMO */ + { 0x0aad, 0x0119, "115200/8n1" }, /* R&S HMO series, previously branded as Hameg HMO */ }; static GSList *scpi_serial_scan(struct drv_context *drvc) @@ -74,11 +77,30 @@ static GSList *scpi_serial_scan(struct drv_context *drvc) static int scpi_serial_dev_inst_new(void *priv, struct drv_context *drvc, const char *resource, char **params, const char *serialcomm) { + GSList *l, *r; + unsigned i; struct scpi_serial *sscpi = priv; (void)drvc; (void)params; + /* If no serial port option is specified on the command-line using the + * "serialcomm" driver option, but the device is connected through USB + * and it requires a known default serial port option, then used it in + * order to avoid data corruption or even worse problems. + */ + if (!serialcomm) { + for (i = 0; i < ARRAY_SIZE(scpi_serial_usb_ids); i++) { + if (!(l = sr_serial_find_usb(scpi_serial_usb_ids[i].vendor_id, + scpi_serial_usb_ids[i].product_id))) + continue; + for (r = l; r; r = r->next) + if (!strcmp(resource, r->data) && scpi_serial_usb_ids[i].serialcomm) + serialcomm = scpi_serial_usb_ids[i].serialcomm; + g_slist_free_full(l, g_free); + } + } + sscpi->serial = sr_serial_dev_inst_new(resource, serialcomm); return SR_OK;