Removal of sdi->index, step 7: fix testo
This commit is contained in:
parent
c79d4444fe
commit
bde9fbd197
|
@ -58,9 +58,9 @@ static GSList *scan(GSList *options)
|
||||||
libusb_device **devlist;
|
libusb_device **devlist;
|
||||||
struct libusb_device_handle *hdl;
|
struct libusb_device_handle *hdl;
|
||||||
GSList *conn_devices, *devices, *l;
|
GSList *conn_devices, *devices, *l;
|
||||||
int devcnt, ret, i;
|
int ret, i;
|
||||||
const char *str;
|
const char *str;
|
||||||
char manufacturer[64], product[64];
|
char manufacturer[64], product[64], connection_id[64];
|
||||||
|
|
||||||
devices = NULL;
|
devices = NULL;
|
||||||
drvc = di->priv;
|
drvc = di->priv;
|
||||||
|
@ -118,17 +118,19 @@ static GSList *scan(GSList *options)
|
||||||
if (strncmp(manufacturer, "testo", 5))
|
if (strncmp(manufacturer, "testo", 5))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
|
||||||
|
|
||||||
/* Hardcode the 435 for now.*/
|
/* Hardcode the 435 for now.*/
|
||||||
if (strcmp(product, "testo 435/635/735"))
|
if (strcmp(product, "testo 435/635/735"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
devcnt = g_slist_length(drvc->instances);
|
sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Testo",
|
||||||
sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE, "Testo",
|
|
||||||
"435/635/735", NULL);
|
"435/635/735", NULL);
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
sdi->inst_type = SR_INST_USB;
|
sdi->inst_type = SR_INST_USB;
|
||||||
sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
|
sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
|
||||||
libusb_get_device_address(devlist[i]), NULL);
|
libusb_get_device_address(devlist[i]), NULL);
|
||||||
|
sdi->connection_id = g_strdup(connection_id);
|
||||||
devc = g_malloc(sizeof(struct dev_context));
|
devc = g_malloc(sizeof(struct dev_context));
|
||||||
devc->model = &models[0];
|
devc->model = &models[0];
|
||||||
devc->limit_msec = 0;
|
devc->limit_msec = 0;
|
||||||
|
@ -161,6 +163,7 @@ static int dev_open(struct sr_dev_inst *sdi)
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
libusb_device **devlist;
|
libusb_device **devlist;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
char connection_id[64];
|
||||||
|
|
||||||
if (!di->priv) {
|
if (!di->priv) {
|
||||||
sr_err("Driver was not initialized.");
|
sr_err("Driver was not initialized.");
|
||||||
|
@ -170,8 +173,8 @@ static int dev_open(struct sr_dev_inst *sdi)
|
||||||
usb = sdi->conn;
|
usb = sdi->conn;
|
||||||
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
|
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
|
||||||
for (i = 0; devlist[i]; i++) {
|
for (i = 0; devlist[i]; i++) {
|
||||||
if (libusb_get_bus_number(devlist[i]) != usb->bus
|
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
|
||||||
|| libusb_get_device_address(devlist[i]) != usb->address)
|
if (strcmp(sdi->connection_id, connection_id))
|
||||||
continue;
|
continue;
|
||||||
if ((ret = libusb_open(devlist[i], &usb->devhdl))) {
|
if ((ret = libusb_open(devlist[i], &usb->devhdl))) {
|
||||||
sr_err("Failed to open device: %s.", libusb_error_name(ret));
|
sr_err("Failed to open device: %s.", libusb_error_name(ret));
|
||||||
|
|
Loading…
Reference in New Issue