Hi, 
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 interruptb transfer 
but it's not important because the above program send me information from device 
properly.)
That works properly under windows...
And now reading from device is succeful under linus-2.4.20.

I use the file /dev/usb/hiddev0.
Here is my program:

#include <malloc.h>
#include <unistd.h>
#include <fcntl.h>

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)){
      printf("Error in labtec-hid! Read %d of expected %d bytes!\n",
             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 errno return me the value 22(EINVAL) although I open fd in 
O_WRONLY or O_RDWR...

Please help me because I don't know what I have to do...

                                B.GIRAUD<[EMAIL PROTECTED]>


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to