Dear all,
I try to port da esktop USB driver to WinCE.Net 4.2 for a custom USB
hardware. On desktop PC, it use UsbBuildVendorRequest to send a data out
through control endpoint and receive data using
UsbBuildInterruptOrBulkTransferRequest from bulk endpoint.

-------------------------------------------------------- PC USB
er: --------------------------------------------------------------
Write:
// write to default pipe
UsbBuildVendorRequest(urb,
URB_FUNCTION_VENDOR_ENDPOINT,
sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
0,
4, //ReservedBits
0x01, // bRequest
0, // wValue (not use)
0, // wIndex (not use)
&(inputBuffer[3]), // data
NULL,
0, // data length
NULL
);

Read:
// read from bulk pipe
UsbBuildInterruptOrBulkTransferRequest(urb, sizeof(struct
_URB_BULK_OR_INTERRUPT_TRANSFER), pipeInfo->PipeHandle, NULL,
Irp->MdlAddress, 8,
USBD_TRANSFER_DIRECTION_IN|USBD_SHORT_TRANSFER_OK, NULL);
----------------------------------------------------------------------------
--------------------------------------------------------------

For WinCE.Net, I have replace these two function to IssueVendorTransfer and
IssueBulkTransfer.
-------------------------------------------------------- WinCE.Net
-----------------------------------------------------------
Write:
ControlHeader.bmRequestType =
0x04|USB_REQUEST_VENDOR|USB_REQUEST_FOR_ENDPOINT;
ControlHeader.bRequest = 0x01;
ControlHeader.wValue = 0;
ControlHeader.wIndex = 0;
ControlHeader.wLength = 0;

m_hControlTransfer = (*m_lpUsbFuncs->lpIssueVendorTransfer)(m_hDevice,
NULL, NULL, 0 ,

&ControlHeader, (LPVOID) 0, 0);

Read:
m_hBulkTransfer = (*m_lpUsbFuncs->lpIssueBulkTransfer)( m_hBulkPipeIn,
BulkTransferComplete, 0,
USB_IN_TRANSFER |
USB_SHORT_TRANSFER_OK, 8, (LPVOID)m_pbDataBuffer, 0);
----------------------------------------------------------------------------
--------------------------------------------------------------
My problem is I can send out data to USB device successfully because I
receive USB_NO_ERROR when calling GetTransferStatus().
When i try to read data from bulk pipe, IssueBulkTransfer return a handle
but when call GetTransferStatus(), it returns
USB_DEVICE_NOT_RESPONDING_ERROR.
FYI, I have a valid m_hBulkPipeIn that point to pipe address 0x81.

Do you guys have any idea which step i did wrong? Is the my setting for
above function correct (IssueVendorTransfer & IssueBulkTransfer)?
Or, did i miss out something?
Is ReservedBits in UsbBuildVendorRequest equivalent to bmRequestType for
IssueVendorTransfer?

Thank for your help.

Best Regards,
Francis

RE: UsbBuildVendorRequest vs IssueVendorTransfer by RobertMagyar

RobertMagyar
Fri Oct 01 12:23:06 CDT 2004

Hi Francis,

While it's good to see USB_NO_ERROR and sending data, hopefully you also
checked this with a USB protocol monitor, and you saw your data go out to
your usb device, and the data coming from your usb device back to the CE
platform.

And if the above worked ok, try using a debug build of the host controller
driver, and if you turn on debug output at different levels, it should help
see what's going on.

Also check out the sample drives in:
\WINCE420\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS

"Francis" wrote:

> Dear all,
> I try to port da esktop USB driver to WinCE.Net 4.2 for a custom USB
> hardware. On desktop PC, it use UsbBuildVendorRequest to send a data out
> through control endpoint and receive data using
> UsbBuildInterruptOrBulkTransferRequest from bulk endpoint.
>
> -------------------------------------------------------- PC USB
> er: --------------------------------------------------------------
> Write:
> // write to default pipe
> UsbBuildVendorRequest(urb,
> URB_FUNCTION_VENDOR_ENDPOINT,
> sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
> 0,
> 4, //ReservedBits
> 0x01, // bRequest
> 0, // wValue (not use)
> 0, // wIndex (not use)
> &(inputBuffer[3]), // data
> NULL,
> 0, // data length
> NULL
> );
>
> Read:
> // read from bulk pipe
> UsbBuildInterruptOrBulkTransferRequest(urb, sizeof(struct
> _URB_BULK_OR_INTERRUPT_TRANSFER), pipeInfo->PipeHandle, NULL,
> Irp->MdlAddress, 8,
> USBD_TRANSFER_DIRECTION_IN|USBD_SHORT_TRANSFER_OK, NULL);
> ----------------------------------------------------------------------------
> --------------------------------------------------------------
>
> For WinCE.Net, I have replace these two function to IssueVendorTransfer and
> IssueBulkTransfer.
> -------------------------------------------------------- WinCE.Net
> -----------------------------------------------------------
> Write:
> ControlHeader.bmRequestType =
> 0x04|USB_REQUEST_VENDOR|USB_REQUEST_FOR_ENDPOINT;
> ControlHeader.bRequest = 0x01;
> ControlHeader.wValue = 0;
> ControlHeader.wIndex = 0;
> ControlHeader.wLength = 0;
>
> m_hControlTransfer = (*m_lpUsbFuncs->lpIssueVendorTransfer)(m_hDevice,
> NULL, NULL, 0 ,
>
> &ControlHeader, (LPVOID) 0, 0);
>
> Read:
> m_hBulkTransfer = (*m_lpUsbFuncs->lpIssueBulkTransfer)( m_hBulkPipeIn,
> BulkTransferComplete, 0,
> USB_IN_TRANSFER |
> USB_SHORT_TRANSFER_OK, 8, (LPVOID)m_pbDataBuffer, 0);
> ----------------------------------------------------------------------------
> --------------------------------------------------------------
> My problem is I can send out data to USB device successfully because I
> receive USB_NO_ERROR when calling GetTransferStatus().
> When i try to read data from bulk pipe, IssueBulkTransfer return a handle
> but when call GetTransferStatus(), it returns
> USB_DEVICE_NOT_RESPONDING_ERROR.
> FYI, I have a valid m_hBulkPipeIn that point to pipe address 0x81.
>
> Do you guys have any idea which step i did wrong? Is the my setting for
> above function correct (IssueVendorTransfer & IssueBulkTransfer)?
> Or, did i miss out something?
> Is ReservedBits in UsbBuildVendorRequest equivalent to bmRequestType for
> IssueVendorTransfer?
>
> Thank for your help.
>
> Best Regards,
> Francis
>
>
>
>
>

Re: UsbBuildVendorRequest vs IssueVendorTransfer by Francis

Francis
Sun Oct 03 20:06:20 CDT 2004

Hi, Robert,
Thanks for your reply.
I am sure that the correct data has been sent out to the USB device
because USB device will light up a LED when it received the correct command.
But, I am not sure on the data coming back from USB device, but i believe it
should be correct because the USB device will automatically return 2 byte
status to host through bulk endpoint once receive a correct command (this
work fine with PC). Unfortunately, I don't have any USB protocol analyzer to
monitor the data transmission between WinCE machine and USB device, thats
put me in a hard time...
Anyway, I will try to enable the debug zone on host controller driver
and hopefully can have more idea what's when wrong.
For your information, I develop this driver base on sample in WinCE's DDK
and mouse class sample in platform builder source code. The code is pretty
simple, and contains the following function.
USBDeviceAttach - GetDeviceInfo, Open pipe and create a ThreadTemp to
send/receive data from USB device
USBInstallDriver - doing nothing at the moment
USBUnInstallDriver - doing nothing at the moment
DllEntry -
USBDeviceNotifications - detect USB device unplug event
ThreadTemp - send command data out through Control EndPoint and try to
receive something on Bulk EndPoint

In the previous message, i posted code for
i. UsbBuildVendorRequest & IssueVendorTransfer
ii.UsbBuildInterruptOrBulkTransferRequest & IssueBulkTransfer
Did I fill in the correct parameter during the replacement of these two
functions?

Best Regards,
KCLye





"Robert Magyar" <RobertMagyar@discussions.microsoft.com> wrote in message
news:B51622C5-C663-48C5-9027-C08762CF13AD@microsoft.com...
> Hi Francis,
>
> While it's good to see USB_NO_ERROR and sending data, hopefully you also
> checked this with a USB protocol monitor, and you saw your data go out to
> your usb device, and the data coming from your usb device back to the CE
> platform.
>
> And if the above worked ok, try using a debug build of the host controller
> driver, and if you turn on debug output at different levels, it should
help
> see what's going on.
>
> Also check out the sample drives in:
> \WINCE420\PUBLIC\COMMON\OAK\DRIVERS\USB\CLASS
>
> "Francis" wrote:
>
> > Dear all,
> > I try to port da esktop USB driver to WinCE.Net 4.2 for a custom USB
> > hardware. On desktop PC, it use UsbBuildVendorRequest to send a data out
> > through control endpoint and receive data using
> > UsbBuildInterruptOrBulkTransferRequest from bulk endpoint.
> >
> > -------------------------------------------------------- PC USB
> > er: --------------------------------------------------------------
> > Write:
> > // write to default pipe
> > UsbBuildVendorRequest(urb,
> > URB_FUNCTION_VENDOR_ENDPOINT,
> > sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
> > 0,
> > 4, //ReservedBits
> > 0x01, // bRequest
> > 0, // wValue (not use)
> > 0, // wIndex (not use)
> > &(inputBuffer[3]), // data
> > NULL,
> > 0, // data length
> > NULL
> > );
> >
> > Read:
> > // read from bulk pipe
> > UsbBuildInterruptOrBulkTransferRequest(urb, sizeof(struct
> > _URB_BULK_OR_INTERRUPT_TRANSFER), pipeInfo->PipeHandle, NULL,
> > Irp->MdlAddress, 8,
> > USBD_TRANSFER_DIRECTION_IN|USBD_SHORT_TRANSFER_OK, NULL);
>
> --------------------------------------------------------------------------
--
> > --------------------------------------------------------------
> >
> > For WinCE.Net, I have replace these two function to IssueVendorTransfer
and
> > IssueBulkTransfer.
> > -------------------------------------------------------- WinCE.Net
> > -----------------------------------------------------------
> > Write:
> > ControlHeader.bmRequestType =
> > 0x04|USB_REQUEST_VENDOR|USB_REQUEST_FOR_ENDPOINT;
> > ControlHeader.bRequest = 0x01;
> > ControlHeader.wValue = 0;
> > ControlHeader.wIndex = 0;
> > ControlHeader.wLength = 0;
> >
> > m_hControlTransfer =
(*m_lpUsbFuncs->lpIssueVendorTransfer)(m_hDevice,
> > NULL, NULL, 0 ,
> >
> > &ControlHeader, (LPVOID) 0, 0);
> >
> > Read:
> > m_hBulkTransfer = (*m_lpUsbFuncs->lpIssueBulkTransfer)(
m_hBulkPipeIn,
> > BulkTransferComplete, 0,
> > USB_IN_TRANSFER |
> > USB_SHORT_TRANSFER_OK, 8, (LPVOID)m_pbDataBuffer, 0);
>
> --------------------------------------------------------------------------
--
> > --------------------------------------------------------------
> > My problem is I can send out data to USB device successfully because I
> > receive USB_NO_ERROR when calling GetTransferStatus().
> > When i try to read data from bulk pipe, IssueBulkTransfer return a
handle
> > but when call GetTransferStatus(), it returns
> > USB_DEVICE_NOT_RESPONDING_ERROR.
> > FYI, I have a valid m_hBulkPipeIn that point to pipe address 0x81.
> >
> > Do you guys have any idea which step i did wrong? Is the my setting for
> > above function correct (IssueVendorTransfer & IssueBulkTransfer)?
> > Or, did i miss out something?
> > Is ReservedBits in UsbBuildVendorRequest equivalent to bmRequestType for
> > IssueVendorTransfer?
> >
> > Thank for your help.
> >
> > Best Regards,
> > Francis
> >
> >
> >
> >
> >



RE: UsbBuildVendorRequest vs IssueVendorTransfer by Vicky

Vicky
Fri Jan 07 07:41:03 CST 2005

Hi Francis
Did you get the solution for the USB_DEVICE_NOT_RESPONDING_ERROR error?

Regards

Vicky

"Francis" wrote:

> Dear all,
> I try to port da esktop USB driver to WinCE.Net 4.2 for a custom USB
> hardware. On desktop PC, it use UsbBuildVendorRequest to send a data out
> through control endpoint and receive data using
> UsbBuildInterruptOrBulkTransferRequest from bulk endpoint.
>
> -------------------------------------------------------- PC USB
> er: --------------------------------------------------------------
> Write:
> // write to default pipe
> UsbBuildVendorRequest(urb,
> URB_FUNCTION_VENDOR_ENDPOINT,
> sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
> 0,
> 4, //ReservedBits
> 0x01, // bRequest
> 0, // wValue (not use)
> 0, // wIndex (not use)
> &(inputBuffer[3]), // data
> NULL,
> 0, // data length
> NULL
> );
>
> Read:
> // read from bulk pipe
> UsbBuildInterruptOrBulkTransferRequest(urb, sizeof(struct
> _URB_BULK_OR_INTERRUPT_TRANSFER), pipeInfo->PipeHandle, NULL,
> Irp->MdlAddress, 8,
> USBD_TRANSFER_DIRECTION_IN|USBD_SHORT_TRANSFER_OK, NULL);
> ----------------------------------------------------------------------------
> --------------------------------------------------------------
>
> For WinCE.Net, I have replace these two function to IssueVendorTransfer and
> IssueBulkTransfer.
> -------------------------------------------------------- WinCE.Net
> -----------------------------------------------------------
> Write:
> ControlHeader.bmRequestType =
> 0x04|USB_REQUEST_VENDOR|USB_REQUEST_FOR_ENDPOINT;
> ControlHeader.bRequest = 0x01;
> ControlHeader.wValue = 0;
> ControlHeader.wIndex = 0;
> ControlHeader.wLength = 0;
>
> m_hControlTransfer = (*m_lpUsbFuncs->lpIssueVendorTransfer)(m_hDevice,
> NULL, NULL, 0 ,
>
> &ControlHeader, (LPVOID) 0, 0);
>
> Read:
> m_hBulkTransfer = (*m_lpUsbFuncs->lpIssueBulkTransfer)( m_hBulkPipeIn,
> BulkTransferComplete, 0,
> USB_IN_TRANSFER |
> USB_SHORT_TRANSFER_OK, 8, (LPVOID)m_pbDataBuffer, 0);
> ----------------------------------------------------------------------------
> --------------------------------------------------------------
> My problem is I can send out data to USB device successfully because I
> receive USB_NO_ERROR when calling GetTransferStatus().
> When i try to read data from bulk pipe, IssueBulkTransfer return a handle
> but when call GetTransferStatus(), it returns
> USB_DEVICE_NOT_RESPONDING_ERROR.
> FYI, I have a valid m_hBulkPipeIn that point to pipe address 0x81.
>
> Do you guys have any idea which step i did wrong? Is the my setting for
> above function correct (IssueVendorTransfer & IssueBulkTransfer)?
> Or, did i miss out something?
> Is ReservedBits in UsbBuildVendorRequest equivalent to bmRequestType for
> IssueVendorTransfer?
>
> Thank for your help.
>
> Best Regards,
> Francis
>
>
>
>
>