Hello,
I am trying to use
an USB device from
linux.
I already have a
windows driver for
it and I
successfully tried
sniffing the
communication flow
between the PC
(WinXP) and the
device.
I can see the device
characteristics with
linux usbview and
cat
/proc/bus/usb/devices
(see below)
Now I wonder how can
I guess what do I
have to ask to the
device, using usblib
usb_control_msg()
function call.
Does exist a rule
for replacing
sniffed packets with
usb_control_msg
calls ?
TIA
---
T: Bus=01 Lev=01
Prnt=01 Port=00
Cnt=01 Dev#= 5
Spd=12 MxCh= 0
D: Ver= 2.00
Cls=ff(vend.) Sub=ff
Prot=ff MxPS=64
#Cfgs= 1
P: Vendor=04b4
ProdID=8613 Rev=
0.04
C:* #Ifs= 1 Cfg#= 1
Atr=80 MxPwr=100mA
I: If#= 0 Alt= 0
#EPs= 0
Cls=ff(vend.) Sub=ff
Prot=ff
Driver=usbtest
I: If#= 0 Alt= 1
#EPs= 6
Cls=ff(vend.) Sub=ff
Prot=ff
Driver=usbtest
E: Ad=01(O)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=81(I)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=02(O)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=04(O)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=86(I)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=88(I)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
I: If#= 0 Alt= 2
#EPs= 6
Cls=ff(vend.) Sub=ff
Prot=ff
Driver=usbtest
E: Ad=01(O)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=81(I)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=02(O)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=04(O)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=86(I)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=88(I)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
I: If#= 0 Alt= 3
#EPs= 6
Cls=ff(vend.) Sub=ff
Prot=ff
Driver=usbtest
E: Ad=01(O)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=81(I)
Atr=03(Int.) MxPS=
64 Ivl=10ms
E: Ad=02(O)
Atr=01(Isoc) MxPS=
64 Ivl=1ms
E: Ad=04(O)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
E: Ad=86(I)
Atr=01(Isoc) MxPS=
64 Ivl=1ms
E: Ad=88(I)
Atr=02(Bulk) MxPS=
64 Ivl=0ms
---
#define
LED_VENDOR_ID
0x04b4 // Cypress
#define
LED_PRODUCT_ID
0x8613 // FX2
static struct
usb_device
*device_init(void)
{
struct usb_bus
*usb_bus;
struct
usb_device *dev;
usb_init();
usb_find_busses();
usb_find_devices();
for (usb_bus =
usb_busses; usb_bus;
usb_bus =
usb_bus->next)
{
for (dev =
usb_bus->devices;
dev; dev =
dev->next)
{
if
((dev->descriptor.idVendor
== LED_VENDOR_ID) &&
(dev->descriptor.idProduct
== LED_PRODUCT_ID))
return dev;
}
}
return NULL;
}
int main(int argc,
char **argv)
{
struct
usb_device *usb_dev;
struct
usb_dev_handle
*usb_handle;
int retval = 1;
int i;
unsigned char
color = NONE;
usb_dev =
device_init();
if (usb_dev ==
NULL) {
fprintf(stderr,
"Device not
found\n");
goto exit;
}
usb_handle =
usb_open(usb_dev);
if (usb_handle
== NULL) {
fprintf(stderr,
"Failed to opern\n")
;
goto exit;
}
usb_handle =
usb_open(usb_dev);
if (usb_handle
== NULL) {
fprintf(stderr, "Not
able to claim the
USB device\n");
goto exit;
}
fprintf(stderr,
"Device found\n") ;
...
usb_control_msg(usb_handle,
0x000000c8, // ???
0x00000012, // ???
val, // ???
index, // ???
dummy, // ???
0x00000008, // ???
5000); // ???
}
____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users