USB : USB Classes    Packing and Unpacking  

Oh, one more thing: we forgot to mention packet boundaries.

If your Report is larger than one packet, here is another type of situation you will need to be able to handle: a data item that crosses the boundary between one packet and the next. In the example below, a 32-bit data item called Data32 (shaded green for clarity) starts in byte 63 of a 64-byte packet, and has to extend into the following packet of the Report.

bit
byte 7 6 5 4 3 2 1 0
58
whatever...
59
whatever...
60
whatever...
61
whatever...
62
whatever...
63
Data32
Data3
64
Data32

 

bit
byte 7 6 5 4 3 2 1 0
1
Data32
2
Data32
3          
Data32
etc.
whatever...
etc.
whatever...
etc.
whatever...
etc.
whatever...

 

This is a common situation that a real HID device must be able to handle. Part of the Data32 item appears in one packet, and the rest of the Data32 item isn't even present until the next USB packet arrives.

 
  

9 of 14
Copyright Notice and Author Information