libusb icon indicating copy to clipboard operation
libusb copied to clipboard

Cannot pass variables to `ControlTransfer` because type is not exported

Open s5mat opened this issue 3 years ago • 0 comments

The libusb.DeviceHandle::ControlTransfer methods arg[0] has a non-exported type bmRequestType. As a result it seems like this method can only be called with hard-coded values and not passed in with a variable of type byte.

Example of what I have to write:

bytes_sent, err := handle.ControlTransfer(
	(0x01<<5)+0x01,
	0x09,
	reportId+(0x03<<8),
	0,
	msg,
	len(msg),
	5000)

Example of what I would like to write:

requestClass := byte(0)
interfaceIndex := byte(32)
endpointOutIndex := byte(1)
bytes_sent, err := handle.ControlTransfer(
	requestClass | interfaceIndex | endpointOutIndex,
	0x09,
	reportId+(0x03<<8),
	0,
	msg,
	len(msg),
	5000)

s5mat avatar Oct 11 '22 17:10 s5mat