Scubapro G2: add zero report type to USBHID packet write
Jef reports that this is required for HIDAPI, and while I would really
like to just make the report type part of the custom packet_io interface
instead of making it visible here, this is the minimal fix for now.
See commit d251b373becc ("Add a zero report ID to the commands"), which
does the same thing, except for the fact that we now need to treat BLE
and USB HID differently.
I may still end up teaching the USB HID custom-IO layer to add the
report ID byte, and just specify it at dc_usbhid_custom_io() time
instead. That would make the G2 code not have to care about the
transfer protocol again.
(But the other user of USB HID - the Suunto EON Steel - has much bigger
protocol differences between USB HID and BLE, so the whole "try to be
protocol-agnostic" hope may be just a pipe dream anyway, and it's just
the Scubapro G2 that _could_ work that way).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
aed80fe7fd
commit
d7503b05e2
@ -112,16 +112,25 @@ scubapro_g2_transfer(scubapro_g2_device_t *g2, const unsigned char command[], un
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
size_t transferred = 0;
|
||||
|
||||
if (csize >= PACKET_SIZE) {
|
||||
if (csize > PACKET_SIZE-2) {
|
||||
ERROR(g2->base.context, "command too big (%d)", csize);
|
||||
return DC_STATUS_INVALIDARGS;
|
||||
}
|
||||
|
||||
HEXDUMP (g2->base.context, DC_LOGLEVEL_DEBUG, "cmd", command, csize);
|
||||
|
||||
buf[0] = csize;
|
||||
memcpy(buf+1, command, csize);
|
||||
status = io->packet_write(io, buf, csize+1, &transferred);
|
||||
buf[0] = 0; // USBHID report type
|
||||
buf[1] = csize; // command size
|
||||
memcpy(buf+2, command, csize); // command bytes
|
||||
|
||||
// BLE GATT protocol?
|
||||
if (io->packet_size < 64) {
|
||||
// No report type byte
|
||||
status = io->packet_write(io, buf+1, csize+1, &transferred);
|
||||
} else {
|
||||
status = io->packet_write(io, buf, csize+2, &transferred);
|
||||
}
|
||||
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
ERROR(g2->base.context, "Failed to send the command.");
|
||||
return status;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user