John Chen wrote:
>
> I need to convert a legacy app from win api calls to libusbx, most of
> the legacy app is using DeviceIoControl , from libusbx docs, the I
> believe I need to use libusb_control_transfer, but I am not sure how
> to change the calls from DeviceIoControl calls to
> libusb_control_transfer as the parameters for those api are total
> different.
>
> Would anyone give me some advice how to do that? maybe some examples?
Honestly, you should be able to figure this out on your own. Did you
even notice that the parameter names in the
VENDOR_OR_CLASS_CONTROL_REQUEST structure are exactly the same as the
parameter names to libusb? RequestType, Request, Index, Value? A few
minutes reading would tell you how to combine direction, recipient and
request type into the bmRequestType field for control requests, but I
will tell you that a device-to-host vendor request to an endpoint has a
bmRequestType of 0xC2.
When you use libusbx, you are writing a driver. It may not feel like
it, but it is a driver. You need to understand something about USB in
order to drive a USB device, and right now you don't seem to have that.
> Below is some of our legacy calls in window api.
No, this is exactly one legacy call.
> {
> enError = SendVendorRequest(
> VENDOR_REQUEST_DIRECTION_DEVICE2HOST,// direction
> VENDOR_REQUEST_REQUESTTYPE_VENDOR,// request type
> VENDOR_REQUEST_RECEPIENT_ENDPOINT,// recipient
> VR_I2C_COMMAND,// request
> c_usDeviceId,// device id
> c_usOffset,// offset
> c_uiLength,// size
> reinterpret_cast<UCHAR*>(pszAssNum));// buffer
bmRequestType = 0xC2
bRequest = VR_I2C_COMMAND
wValue = c_usDeviceId
wIndex = c_usOffset
length = c_uiLength
You should be able to figure the parameters out from that.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel