- if ((usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn))) {
- /* We have a list of sr_usb_dev_inst matching the connection
- * string. Wrap them in sr_dev_inst and we're done. */
- for (l = usb_devices; l; l = l->next) {
- sdi = g_malloc0(sizeof(struct sr_dev_inst));
- sdi->status = SR_ST_INACTIVE;
- sdi->vendor = g_strdup(VENDOR);
- sdi->model = g_strdup(MODEL);
- sdi->driver = di;
- sdi->inst_type = SR_INST_USB;
- sdi->conn = l->data;
- for (i = 0; i < ARRAY_SIZE(channel_names); i++)
- sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
- channel_names[i]);
- devc = g_malloc0(sizeof(struct dev_context));
- sdi->priv = devc;
- devc->limit_samples = 0;
- devc->data_source = DEFAULT_DATA_SOURCE;
- drvc->instances = g_slist_append(drvc->instances, sdi);
- devices = g_slist_append(devices, sdi);
- }
- g_slist_free(usb_devices);
- } else
- g_slist_free_full(usb_devices, g_free);
-
- return devices;
-}
-
-static GSList *dev_list(const struct sr_dev_driver *di)
-{
- return ((struct drv_context *)(di->context))->instances;
-}
-
-static int dev_open(struct sr_dev_inst *sdi)
-{
- struct sr_dev_driver *di = sdi->driver;
- struct drv_context *drvc;
- struct sr_usb_dev_inst *usb;
- int ret;
-
- if (!(drvc = di->context)) {
- sr_err("Driver was not initialized.");
- return SR_ERR;
+ serial = sr_serial_dev_inst_new(conn, serialcomm);
+ rc = serial_open(serial, SERIAL_RDWR);
+ serial_flush(serial);
+ /* Cannot query/identify the device. Successful open shall suffice. */
+ serial_close(serial);
+ if (rc != SR_OK) {
+ sr_serial_dev_inst_free(serial);
+ return devices;