From d251b373beccfe01eac6ba71a7f22a0ee13b09b3 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 11 Jul 2017 00:17:36 +0200 Subject: [PATCH] Add a zero report ID to the commands The zero report ID byte is required when using the hidapi library. We just never noticed this problem before, because we use libusb by default, and libusb doesn't need the extra zero byte. --- src/uwatec_g2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uwatec_g2.c b/src/uwatec_g2.c index 3328b4c..fc32aff 100644 --- a/src/uwatec_g2.c +++ b/src/uwatec_g2.c @@ -110,16 +110,17 @@ uwatec_g2_transfer (uwatec_g2_device_t *device, const unsigned char command[], u dc_status_t status = DC_STATUS_SUCCESS; size_t transferred = 0; - if (csize >= PACKET_SIZE) { + if (csize + 2 > PACKET_SIZE) { ERROR (device->base.context, "command too big (%d)", csize); return DC_STATUS_INVALIDARGS; } HEXDUMP (device->base.context, DC_LOGLEVEL_DEBUG, "cmd", command, csize); - buf[0] = csize; - memcpy(buf + 1, command, csize); - status = dc_usbhid_write (device->usbhid, buf, csize + 1, &transferred); + buf[0] = 0; + buf[1] = csize; + memcpy(buf + 2, command, csize); + status = dc_usbhid_write (device->usbhid, buf, csize + 2, &transferred); if (status != DC_STATUS_SUCCESS) { ERROR (device->base.context, "Failed to send the command."); return status;