Mario,
I suspect the error is in my translation of that code and/or my understanding of USB (which is VERY limited).
I attached a software sniffer under Windows to see what is being sent there to the device when the light blink test is done. This is what I get:
Bus Hound 5.05 capture on Windows XP Service Pack 2. Complements of www.perisoft.net
Device - Device ID (followed by the endpoint for USB devices)
(21) USB Human Interface Device
(22) USB Human Interface Device
(23) USB Human Interface Device
(24) USB Human Interface Device
Length - Total transfer length
Phase - Phase Type
CTL USB control transfer
OUT Data out transfer
URB USB request block
Data - Hex dump of the data transferred
Descr - Description of the phase
Cmd… - Position in the captured data
Device Len Phase Data Description Cmd.Phase.Ofs(rep)
------ -------- ----- ----------------------- ---------------- ------------------
21.0 --- CTL 21 09 40 02 00 00 02 00 SET REPORT 1.1.0
21.0 2 OUT 40 00 @. 1.2.0
21.0 --- URB 50 00 08 00 00 00 00 00 CTRLXFER 1.3.0
From this, I see there are only 2 data bytes sent by the program (0x40 and 0x00) during the OUT phase. This is consistent with what I see under Linux as the command to blink the light is indeed 0x40 (which I then assume is sent as a 16bit number).
Now, obviously, the rest of the data (1st and 3rd lines of which the 1st and 3rd lines only shows the 1st 8 bytes due to screen size) is generated by the USB stack. That’s where my limited knowledge of USB comes into play.
I’m assuming that those 2 lines are similar to how TCP/IP protocol works with regards to sending ethernet packets. Ie, I just write data to a socket and the TCP/IP stack takes care of generating the ethernet packets with all the related overhead. I’m assuming the USB stack in QNX does the same. So I might be wildly offbase with that assumption.
But I also have some questions that aren’t documented (oh to have those DDK examples have a few comment lines…).
-
The device says it’s packet size is 64 bytes. Yet I see no way to know how to specify that other than in the usbd_setup_interrupt() call. I am not sure if the length field there is meant to be 64 or the bytes I am tranferring. I’ve tried both with no success. But I am curious to how the USB stack knows how to deal with that.
-
Under Windows, the when the device is inserted it morphs into 4 interfaces (not sure what you really call it under USB terminology). So when I attached the sniffer, I can attach from 1-4 places on the device. Now, when I do a ‘usb -vvv’ command under QNX, I also see 4 interfaces with start/endpoints. When I start my driver, it does indeed get a ‘device insertion’ call done 4 times (once for each interface). But when I try to attach to those interfaces, the 1st and 4th one fails with EBUSY so I only end up with 2 instances under /dev to open instead of 4. I have no idea why I get the EBUSY, but I do know that the command I want to write is meant to go to the 1st instance (looking at the test code provided) which could be why it’s not working for me.
Here is what my usb -vvv looks like with regards to my device:
USB 2 (UHCI) v1.10, v1.01 DDK, v1.01 HCD
Control, Interrupt, Bulk, Isoch, Low speed, Full speed
Device Address : 1
Upstream Host Controller : 2
Upstream Device Address : 0
Upstream Port : 1
Upstream Port Speed : Full
Vendor : 0x09db (MCC)
Product : 0x0082 (USB-1208FS)
Device Release : r1.00
USB Spec Release : v2.00
Serial Number : N/A
Class : 0x00 (Independant per interface)
Max PacketSize0 : 64
Languages : 0x0409 (English)
Current Frame : 938 (1024 bytes)
Configurations : 1
Configuration : 1 (Default)
Attributes : 0x80 (Bus-powered)
Max Power : 500 mA
Interfaces : 4
Interface : 0 / 0 (Interface 0)
Class : 0x03 (HID)
Subclass : 0x00
Protocol : 0x00
Endpoints : Control + 1
Endpoint : 0
Attributes : Control
Max Packet Size: 64
Endpoint : 1
Attributes : Interrupt/IN
Max Packet Size: 64
Interval : 1 ms
Interface : 1 / 0 (Interface 1)
Class : 0x03 (HID)
Subclass : 0x00
Protocol : 0x00
Endpoints : Control + 2
Endpoint : 0
Attributes : Control
Max Packet Size: 64
Endpoint : 2
Attributes : Interrupt/OUT
Max Packet Size: 64
Interval : 1 ms
Endpoint : 3
Attributes : Interrupt/IN
Max Packet Size: 64
Interval : 1 ms
Interface : 2 / 0 (Interface 2)
Class : 0x03 (HID)
Subclass : 0x00
Protocol : 0x00
Endpoints : Control + 1
Endpoint : 0
Attributes : Control
Max Packet Size: 64
Endpoint : 4
Attributes : Interrupt/IN
Max Packet Size: 64
Interval : 1 ms
Interface : 3 / 0 (Interface 3)
Class : 0x03 (HID)
Subclass : 0x00
Protocol : 0x00
Endpoints : Control + 1
Endpoint : 0
Attributes : Control
Max Packet Size: 64
Endpoint : 5
Attributes : Interrupt/IN
Max Packet Size: 64
Interval : 1 ms
Tim