From: Alan S. <st...@ro...> - 2008-12-15 23:21:52
|
On Mon, 15 Dec 2008, Blaine Booher wrote: > Hey everyone, > This is my first post to the listserv, and I apologize if this is a very easy (and annoying) problem to fix. I want to make sure that I am understanding the USB Packet information correctly. The data packet I am sending has been witnessed in several packets, and I believe it is a simple 'ping' packet to ensure that the device is alive and responding. > > I have snooped a device's data packets on the USB Bus. There is a > packet that I would like to send using the usb_control_msg. (I am > technically doing this in pyUSB, but I dont think this is an issue > with pyUSB more than an issue with my understanding of libUSB). I am > under the impression that I want to send 'RequestType' 0x22, > 'Request' 0x09, 'Value' 0x02, and Index 0x01 (See data attached). > When I issue the following command, I get 'No such file or > directory'. This means that the command timed out and was cancelled. > However, when I change 0x22 to something else like 0x21, > I can successfully send the command, but brick my device. I have to > let the battery drain and reset before I can try again. > The issued command: is my device that has successfully been opened by libusb) > >>> A1=(0x02,0x02,0x95,0x95,0,0,0,0,0,0,0,0,0,0,0,0) > >>> u.handle.controlMsg(0x22,0x09, A1, 0x02, 0x01) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > usb.USBError: error sending control message: No such file or directory > > And finally, the USB Data that leads me to believe this is accurate: > [33] URB_FUNCTION_CLASS_ENDPOINT 20081106085253.603 (+54947) > Transfer flags: 0x00000000 (USBD_SHORT_TRANSFER_OUT) > Transfer buffer length: 8 > Bytes transfered: 02 02 95 95 00 00 00 00 (......) > Request type reserved bits: 22 > Request: 09 > Value: 0200 > Index: 0001 > > Data returned from Device: > [33] URB_FUNCTION_CONTROL_TRANSFER (SUCCESS/0x00000000) 20081106085253.603 (+0) > IRP status: 0x00000000 (STATUS_SUCCESS) > Pipe handle: 0x87E3DC88 > Transfer flags: 0x0000000A (USBD_SHORT_TRANSFER_OUT, USBD_SHORT_TRANSFER_OK) > Setup packet: 22 09 00 02 01 00 08 00 (".......) > > Suggestions? Hints? Thank you in advance You forgot that USB is little-endian. The Value argument should be 0x0200, not 0x02. Also, your buffer should be only 8 bytes long, not 16. Alan Stern |