X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fscpi_serial.c;h=7000962aad06bab1e6c9c648d506733be183d94b;hb=144f6660d004d60264a57db7150ed90e5f68ea77;hp=6e73c8944df39b0a84144b03d98f3c761dc87ff6;hpb=17bdda58686a208424520b64f9324eba259ff535;p=libsigrok.git diff --git a/hardware/common/scpi_serial.c b/hardware/common/scpi_serial.c index 6e73c894..7000962a 100644 --- a/hardware/common/scpi_serial.c +++ b/hardware/common/scpi_serial.c @@ -22,6 +22,7 @@ #include "libsigrok-internal.h" #include +#include #include #define LOG_PREFIX "scpi_serial" @@ -35,6 +36,41 @@ struct scpi_serial { size_t read; }; +static struct { + uint16_t vendor_id; + uint16_t product_id; + const char *serialcomm; +} scpi_serial_usb_ids[] = { + { 0x0403, 0xed72, "115200/8n1/flow=1" }, /* Hameg HO720 */ + { 0x0403, 0xed73, "115200/8n1/flow=1" }, /* Hameg HO730 */ +}; + +static GSList *scpi_serial_scan(struct drv_context *drvc) +{ + GSList *l, *r, *resources = NULL; + gchar *res; + unsigned i; + + (void)drvc; + + 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)) == NULL) + continue; + for (r = l; r; r = r->next) { + if (scpi_serial_usb_ids[i].serialcomm) + res = g_strdup_printf("%s:%s", (char *) r->data, + scpi_serial_usb_ids[i].serialcomm); + else + res = g_strdup(r->data); + resources = g_slist_append(resources, res); + } + g_slist_free_full(l, g_free); + } + + return resources; +} + static int scpi_serial_dev_inst_new(void *priv, struct drv_context *drvc, const char *resource, char **params, const char *serialcomm) { @@ -67,7 +103,7 @@ static int scpi_serial_open(void *priv) } static int scpi_serial_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { struct scpi_serial *sscpi = priv; struct sr_serial_dev_inst *serial = sscpi->serial; @@ -190,6 +226,7 @@ SR_PRIV const struct sr_scpi_dev_inst scpi_serial_dev = { .name = "serial", .prefix = "", .priv_size = sizeof(struct scpi_serial), + .scan = scpi_serial_scan, .dev_inst_new = scpi_serial_dev_inst_new, .open = scpi_serial_open, .source_add = scpi_serial_source_add,