Hi. I seem to be having problems communicating to my USB device with WinUSB. I have successfully opened a WinUSB handle and can at least retrieve pipe information (and even read status packets). However, I think I need a sanity check about a couple of items. I’ll just post one to start with:
- How do you make a Control Transfer with WinUSB? Here is an example call I am making:
ULONG nOutput = 0;
setup.RequestType = 0x40;
setup.Request = 0x01;
setup.Value = 0x48fd;
setup.Index = 0x01f0;
setup.Length = 0x00;
WinUsb_ControlTransfer(winusbHandle,
setup,
NULL,
0,
&nOutput,
NULL);
Are the NULL’s okay here? Is zero acceptable as well?
Thanks,
–Brian Hindman
Yes, both NULLs and the 0 are acceptable
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@dalsemi.com
Sent: Thursday, April 19, 2007 2:36 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WinUsb_ControlTransfer question
Hi. I seem to be having problems communicating to my USB device with
WinUSB. I have successfully opened a WinUSB handle and can at least
retrieve pipe information (and even read status packets). However, I
think I need a sanity check about a couple of items. I’ll just post one
to start with:
- How do you make a Control Transfer with WinUSB? Here is an
example call I am making:
ULONG nOutput = 0;
setup.RequestType = 0x40;
setup.Request = 0x01;
setup.Value = 0x48fd;
setup.Index = 0x01f0;
setup.Length = 0x00;
WinUsb_ControlTransfer(winusbHandle,
setup,
NULL,
0,
&nOutput,
NULL);
Are the NULL’s okay here? Is zero acceptable as well?
Thanks,
–Brian Hindman
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Doron,
Thanks. How do you perform a write on a bulkwrite pipe? I have a need to write 8-bytes. I’m trying to do the following (basically, query for a pipe and then write to it):
// buffer is retrieved from parameter in subroutine: UCHAR *buffer
ULONG nBytes = 0;
WINUSB_PIPE_INFORMATION pipe;
if (!WinUsb_QueryPipe (winusbHandle, 0, 1, &pipe))
{
// Error
return FALSE;
}
if (!WinUsb_WritePipe(winusbHandle, pipe.PipeId, &buffer[0], sizeof(buffer), &nBytes, NULL))
{
// Error
return FALSE;
}
Do I have to worry about the NULL? What about setting the pipe policies? If so, is there anything specific I should worry about? Is there a write single byte timeout?
–Brian Hindman
xxxxx@dalsemi.com wrote:
Thanks. How do you perform a write on a bulkwrite pipe? I have a need to write 8-bytes. I’m trying to do the following (basically, query for a pipe and then write to it):
// buffer is retrieved from parameter in subroutine: UCHAR *buffer
ULONG nBytes = 0;
WINUSB_PIPE_INFORMATION pipe;
if (!WinUsb_QueryPipe (winusbHandle, 0, 1, &pipe))
{
// Error
return FALSE;
}
if (!WinUsb_WritePipe(winusbHandle, pipe.PipeId, &buffer[0], sizeof(buffer), &nBytes, NULL))
{
// Error
return FALSE;
}
Do I have to worry about the NULL? What about setting the pipe policies? If so, is there anything specific I should worry about? Is there a write single byte timeout?
That’s almost correct, assuming that your bulk out pipe is the second
pipe in the interface descriptor.
However, given that code, sizeof(buffer) is 4 – the size of a pointer.
If you want to send 8 bytes, you need to tell it 8.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Have you allocated buffer? Also, sizeof(buffer) is always going to be
sizeof(a pointer), not the length of the array (which I think you want
to be 8)
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@dalsemi.com
Sent: Thursday, April 19, 2007 3:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WinUsb_ControlTransfer question
Doron,
Thanks. How do you perform a write on a bulkwrite pipe? I have a need
to write 8-bytes. I’m trying to do the following (basically, query for
a pipe and then write to it):
// buffer is retrieved from parameter in subroutine: UCHAR *buffer
ULONG nBytes = 0;
WINUSB_PIPE_INFORMATION pipe;
if (!WinUsb_QueryPipe (winusbHandle, 0, 1, &pipe))
{
// Error
return FALSE;
}
if (!WinUsb_WritePipe(winusbHandle, pipe.PipeId, &buffer[0],
sizeof(buffer), &nBytes, NULL))
{
// Error
return FALSE;
}
Do I have to worry about the NULL? What about setting the pipe
policies? If so, is there anything specific I should worry about? Is
there a write single byte timeout?
–Brian Hindman
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Tim/Doran,
Thanks! Yes, that was my problem. Now, everything works like a charm…
–Brian Hindman