&ft232r_desc,
};
-static void scan_device(struct sr_dev_driver *di, struct ftdi_context *ftdic,
+static void scan_device(struct ftdi_context *ftdic,
struct libusb_device *dev, GSList **devices)
{
struct libusb_device_descriptor usb_desc;
struct dev_context *devc;
char *vendor, *model, *serial_num;
struct sr_dev_inst *sdi;
- struct drv_context *drvc;
int rv;
- drvc = di->context;
libusb_get_device_descriptor(dev, &usb_desc);
desc = NULL;
/* Allocate memory for the incoming data. */
devc->data_buf = g_malloc0(DATA_BUF_SIZE);
- snprintf(devc->address, sizeof(devc->address), "d:%u/%u",
- libusb_get_bus_number(dev), libusb_get_device_address(dev));
-
devc->desc = desc;
vendor = g_malloc(32);
sdi->vendor = vendor;
sdi->model = model;
sdi->serial_num = serial_num;
- sdi->driver = di;
sdi->priv = devc;
+ sdi->connection_id = g_strdup_printf("d:%u/%u",
+ libusb_get_bus_number(dev), libusb_get_device_address(dev));
for (char *const *chan = &(desc->channel_names[0]); *chan; chan++)
sr_channel_new(sdi, chan - &(desc->channel_names[0]),
SR_CHANNEL_LOGIC, TRUE, *chan);
*devices = g_slist_append(*devices, sdi);
- drvc->instances = g_slist_append(drvc->instances, sdi);
return;
err_free_strings:
g_free(devc);
}
-static GSList *scan_all(struct ftdi_context *ftdic, struct sr_dev_driver *di,
- GSList *options)
+static GSList *scan_all(struct ftdi_context *ftdic, GSList *options)
{
GSList *devices;
struct ftdi_device_list *devlist = 0;
curdev = devlist;
while (curdev) {
- scan_device(di, ftdic, curdev->dev, &devices);
+ scan_device(ftdic, curdev->dev, &devices);
curdev = curdev->next;
}
int i;
drvc = di->context;
- drvc->instances = NULL;
conn = NULL;
for (l = options; l; l = l->next) {
src = l->data;
usb = l->data;
if (usb->bus == libusb_get_bus_number(devlist[i])
&& usb->address == libusb_get_device_address(devlist[i])) {
- scan_device(di, ftdic, devlist[i], &devices);
+ scan_device(ftdic, devlist[i], &devices);
}
}
}
libusb_free_device_list(devlist, 1);
} else
- devices = scan_all(ftdic, di, options);
+ devices = scan_all(ftdic, options);
ftdi_free(ftdic);
- return devices;
+ return std_scan_complete(di, devices);
}
static void clear_helper(void *priv)
if (!devc->ftdic)
return SR_ERR;
- ret = ftdi_usb_open_string(devc->ftdic, devc->address);
+ ret = ftdi_usb_open_string(devc->ftdic, sdi->connection_id);
if (ret < 0) {
/* Log errors, except for -3 ("device not found"). */
if (ret != -3)
devc->samples_sent = 0;
devc->bytes_received = 0;
- std_session_send_df_header(sdi, LOG_PREFIX);
+ std_session_send_df_header(sdi);
/* Hook up a dummy handler to receive data from the device. */
sr_session_source_add(sdi->session, -1, G_IO_IN, 0,
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
- std_session_send_df_end(sdi, LOG_PREFIX);
+ std_session_send_df_end(sdi);
return SR_OK;
}