From: Mike L. <mik...@gm...> - 2016-07-20 15:09:14
|
Nevermind, solved it! The proper write message is: dev.write(writeEP,"\x01\x03\x06",0) -- Mike Lawrence Graduate Student Department of Psychology & Neuroscience Dalhousie University ~ Certainty is (possibly) folly ~ On Tue, Jul 19, 2016 at 10:28 PM, Mike Lawrence <mik...@gm...> wrote: > Hi all, > > I wonder if anyone might be able to help with this one. I'm looking to use > pyusb to interact with a wired xbox 360 gamepad. So far I can read just > fine but I'd also like to write so I can make the LED stop blinking. > > Looking here ( > http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/UsbInfo), > I should be able to do it, but no matter what messages I try sending, I'm > not having any luck controlling the LED. Below is the code I have thus far, > any suggestions? > > import usb > dev = usb.core.find(idVendor=1118, idProduct=654) > dev.set_configuration() > readEP = dev[0][(0,0)][0] #endpoint to read from > writeEP = dev[0][(0,0)][1] #endpoint to write to > > print readEP #should be: <ENDPOINT 0x81: Interrupt IN> > print writeEP #should be: <ENDPOINT 0x1: Interrupt OUT> > > ##read the startup messages > for i in range(4): #usually only 4 messages > data = dev.read(readEP.bEndpointAddress,readEP.wMaxPacketSize,100) > print len(data) #should be 3 > > ##get initial button/axes state > data = dev.read(readEP.bEndpointAddress,readEP.wMaxPacketSize,100) > print len(data) #should be 20 > > ##Try to set the LED to illuminate just one element (message 0x06). > ##Each of the following commented-out attempts fails to leave only the > first > ##element illuminated and subsequent attempts at reading or writing yields > ##"usb.core.USBError: [Errno 5] Input/Output Error" > dev.write(writeEP,'010306',100) > # dev.write(writeEP,'0\x010306',100) > # dev.write(writeEP,'66310',100) #decimal value of 0x010306 > > ##attempt to read again > while True: > data = dev.read(readEP.bEndpointAddress,readEP.wMaxPacketSize,100) > > |