tags:

views:

305

answers:

2

Dear All,

Do any one knows the procedure of NON-BLOCKING reed() command for HID events in LINUX

Currently I am using

            read(fd, ev, sizeof(struct hiddev_event) * EV_NUM);

But it goes to BLOCKING stage, when my HID pointing device is NOT towards the sensoer bar

Kind regards,

Madni

A: 

I think more information is needed to answer this question. Most of the USB HID APIs that I have looked at put an asynchronous flag in the Open() method. In general, you're not going to want to do an asynchronous read one time, then follow that with a synchronous read. All your read() calls should use the same technique.

Are you using the O_NONBLOCK flag when you open the device?

hurcane
A: 

Thank you

It resolved the issue

Opwn the HID device in a non blocking mode

char *dev1="/dev/usb/hiddev0";

if ((fd = open(dev1, O_NONBLOCK)) < 0) {

  perror("evdev open");

  exit(1);

}

Regards,

Madni