WinUSB help needed.

Hello,

I’m trying to use the WinUSB driver to talk to our device that simply has bulk in/out endpoints.
The problem comes when I try to send a setup packet to the control endpoint with the following features:

  1. The Length member of the setup packet is used in a customised way - to send a checksum byte to the device.
  2. There is no buffer and the buffer length is 0.

Example:

WINUSB_SETUP_PACKET setup_packet;

setup_packet.RequestType = 0x40; // Vendor write request
setup_packet.Request = 0x14; // a vendor defined request
setup_packet.Value = 0xdf1b;
setup_packet.Index = 0x4000;
setup_packet.Length = 0x0005; // this is a checksum

if (WinUsb_ControlTransfer(hUSBWINDRIVER->hDevice, setup_packet, NULL, 0, &bytesReturned, NULL))
{
// carry on
}
else
{
// error
}

Looking at the actual data sent down the USB bus, instead of getting
0x40, 0x14, 0x1b, 0xdf, 0x00, 0x40, 0x00, 0x05
I get
0x40, 0x14, 0x1b, 0xdf, 0x00, 0x40, 0x00, 0x00

  • the .Length member does not get passed through, presumably because the buffer length parameter is set to 0.

I know this goes against what the USB specification says about the .Length member but unfortunately, we have devices out in the field
that rely on this information for us to talk to them. (We can talk to them like this with an old driver that’s not Vista compatible.)

Does anyone know how I can get around this, and get the .Length member sent, even if the buffer length parameter is 0?

xxxxx@coopersecurity.co.uk wrote:

I’m trying to use the WinUSB driver to talk to our device that simply has bulk in/out endpoints.
The problem comes when I try to send a setup packet to the control endpoint with the following features:

  1. The Length member of the setup packet is used in a customised way - to send a checksum byte to the device.
  2. There is no buffer and the buffer length is 0.

Sorry, your design violates the USB specification, and I’m shocked that
any hardware designer would actually implement such a thing, or that a
reputable company would release such a thing into the wild. That’s what
specs are for.

I know this goes against what the USB specification says about the .Length member but unfortunately, we have devices out in the field
that rely on this information for us to talk to them. (We can talk to them like this with an old driver that’s not Vista compatible.)

Why is it not Vista compatible? Nothing has changed in the USB realm.

Does anyone know how I can get around this, and get the .Length member sent, even if the buffer length parameter is 0?

The short answer is that you can’t use WinUSB. It only works with
well-behaved devices. This shouldn’t be much of a surprise.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.