I am accessing a USB HID Device using python hidapi from a Mac OSX 10.10.5 doing:
import hid
import time
hidraw = hid.device(0x1a67, 0x0004)
hidraw.open(0x1a67, 0x0004)
# Rpt, GnS, Tgt, Size, Index LSB, Index MSB, Data
# Blink 4 pulses
hidraw.send_feature_report([0x00, 0x00, 0x00,0x01, 0x01, 0x00, 0x03])
hidraw.get_feature_report(33,33)
time.sleep(3)
The HID Feature Report works nicely without problems. However, I am trying to port this code to PyUSB and trying to do the same thing (on a RaspberryPi)
import usb.core
import usb.util
# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0004)
# was it found?
if dev is None:
raise ValueError('Device not found')
# get an endpoint instance
for interface in dev.get_active_configuration():
if dev.is_kernel_driver_active(interface.bInterfaceNumber):
# Detach kernel drivers and claim through libusb
dev.detach_kernel_driver(interface.bInterfaceNumber)
usb.util.claim_interface(dev, interface.bInterfaceNumber)
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
ret = dev.ctrl_transfer(0x00, 0x00, 0x01, 0x01, [0x00, 0x03])
But I get a Broken Pipe when executed with root permissions. It is not very clear how to map the parameters that I used in the send_feature_report of Hidapi to how it is actually used from ctrl_transfer in PyUSB.
Any help on how this mapping should be made?
Thanks !!!