usb hid for linux
Hi,
We are working on the same project... so give me your email
I would like to read and write informations (just some bytes) with USB.
(For information my device is a pic which works in low speed in interrupt transfer .)
That works properly under windows...
And now reading from device is succeful under linus-2.4.20.
First, I 'd like to know if hid is the only driver for my device?
Secondly how do I use the libusb? where can I find it?
I use the file /dev/usb/hiddev0.
Here is your program:
typedef struct {
unsigned hid;
signed int value;
} hiddev_event;
main(){
ssize_t bytesread;
int FILEDES;
hiddev_event *buffer;
buffer=(hiddev_event *)malloc(sizeof(hiddev_event));
FILEDES=open("/dev/usb/hiddev0",O_RDONLY);
bytesread=1;
while(bytesread>0){
bytesread=read(FILEDES,buffer,sizeof(hiddev_event));
if(bytesread!=sizeof(hiddev_event)){
exit(1);
}
printf("Unknown event bytes=%d hid=%d value=%d\n",
bytesread,buffer->hid,buffer->value);
}
}
When I try to write in fd (in order to write to the device) errno return me the value 22(EINVAL) although I open fd in O_WRONLY or O_RDWR...
Please help me.
B.GIRAUD<bastgiraud@wanadoo.fr>
Last edited by bast; 08-17-2004 at 03:17 AM.
|