X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-6xxx%2Fprotocol.c;h=75d8ab91c0f14fb4c2cfed4ce2222173e53f4660;hb=1e7468a8858768806a066f52d47d167a3721a8e4;hp=a08e126c5e32a9fc7f672b23d379ac6eeabfe57c;hpb=6402c379161ec138e451901c411817a55846a75b;p=libsigrok.git diff --git a/src/hardware/hantek-6xxx/protocol.c b/src/hardware/hantek-6xxx/protocol.c index a08e126c..75d8ab91 100644 --- a/src/hardware/hantek-6xxx/protocol.c +++ b/src/hardware/hantek-6xxx/protocol.c @@ -27,7 +27,7 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) struct sr_usb_dev_inst *usb; struct libusb_device_descriptor des; libusb_device **devlist; - int err, i; + int err = SR_ERR, i; char connection_id[64]; devc = sdi->priv; @@ -46,7 +46,9 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) /* * Check device by its physical USB bus/port address. */ - usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); + if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0) + continue; + if (strcmp(sdi->connection_id, connection_id)) /* This is not the one. */ continue; @@ -61,14 +63,16 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) usb->address = libusb_get_device_address(devlist[i]); } - sdi->status = SR_ST_ACTIVE; sr_info("Opened device on %d.%d (logical) / " "%s (physical) interface %d.", usb->bus, usb->address, sdi->connection_id, USB_INTERFACE); + + err = SR_OK; } else { sr_err("Failed to open device: %s.", libusb_error_name(err)); + err = SR_ERR; } /* If we made it here, we handled the device (somehow). */ @@ -77,10 +81,7 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) libusb_free_device_list(devlist, 1); - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR; - - return SR_OK; + return err; } SR_PRIV void hantek_6xxx_close(struct sr_dev_inst *sdi)