X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-6xxx%2Fprotocol.c;h=12a56ab9d09970589aa0fd1e25c46ed29ebc5cc2;hb=16544b38567ce7fa309c1b7da886f3c0c85b1e29;hp=37380490a80d25bcc1c25c7c0f372d61735ec378;hpb=f2a66a8ee669df5afa1b7bdade6e25ac0857fe4b;p=libsigrok.git diff --git a/src/hardware/hantek-6xxx/protocol.c b/src/hardware/hantek-6xxx/protocol.c index 37380490..12a56ab9 100644 --- a/src/hardware/hantek-6xxx/protocol.c +++ b/src/hardware/hantek-6xxx/protocol.c @@ -39,11 +39,7 @@ SR_PRIV int hantek_6xxx_open(struct sr_dev_inst *sdi) libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); for (i = 0; devlist[i]; i++) { - if ((err = libusb_get_device_descriptor(devlist[i], &des))) { - sr_err("Failed to get device descriptor: %s.", - libusb_error_name(err)); - continue; - } + libusb_get_device_descriptor(devlist[i], &des); if (des.idVendor != devc->profile->fw_vid || des.idProduct != devc->profile->fw_pid) @@ -127,7 +123,7 @@ SR_PRIV int hantek_6xxx_get_channeldata(const struct sr_dev_inst *sdi, transfer = libusb_alloc_transfer(0); libusb_fill_bulk_transfer(transfer, usb->devhdl, HANTEK_EP_IN, buf, data_amount, cb, (void *)sdi, 4000); - if ((ret = libusb_submit_transfer(transfer)) != 0) { + if ((ret = libusb_submit_transfer(transfer)) < 0) { sr_err("Failed to submit transfer: %s.", libusb_error_name(ret)); /* TODO: Free them all. */ @@ -219,6 +215,16 @@ SR_PRIV int hantek_6xxx_update_vdiv(const struct sr_dev_inst *sdi) return MIN(ret1, ret2); } +SR_PRIV int hantek_6xxx_update_coupling(const struct sr_dev_inst *sdi) +{ + struct dev_context *devc = sdi->priv; + uint8_t coupling = 0xFF & ((devc->coupling[1] << 4) | devc->coupling[0]); + + sr_dbg("update coupling 0x%x", coupling); + + return write_control(sdi, COUPLING_REG, coupling); +} + SR_PRIV int hantek_6xxx_update_channels(const struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; @@ -234,6 +240,7 @@ SR_PRIV int hantek_6xxx_init(const struct sr_dev_inst *sdi) hantek_6xxx_update_samplerate(sdi); hantek_6xxx_update_vdiv(sdi); + hantek_6xxx_update_coupling(sdi); // hantek_6xxx_update_channels(sdi); /* Only 2 channel mode supported. */ return SR_OK;