I am playing around with a hid-data code sample. It's running quite happily, with a couple of changes that makes it use a RAM buffer, etc. The goal is to implement some log-console over USB, and to gain more familiarity with USB development.
So, I have the linux-side userland code, that boils down to this (modified hidtool.c):
Code: Select all
while (1) {
while ((dev=openDevice()) == NULL)
usleep(250000);
int len = sizeof(buffer);
if((err = usbhidGetReport(dev, 0, buffer, &len)) != 0){
fprintf(stderr, "error reading data: %s\n", usbErrorMessage(err));
}else{
if (buffer[1] != buffer[2])
hexdump(buffer+1, sizeof(buffer) - 1);
else {
fprintf(stdout, "."); fflush(stdout);
}
}
usleep(10000);
}
Now, I'm getting a very interesting effect - exactly 1020 reports are received, after which libusb presents me with:
Code: Select all
error finding DataStore: The specified device was not found
The device, however, is still there, it just cannot be reopened by the same process. Merely restarting the hidtool solves the problem, for another 1020 reports.
This seems to be independent of the REPORT_SIZE, so I begin to wonder - is there counter that's overflowing? where? userland, or my AVR?
Does any of you have similar experiences with pooling a hid-data device?
cheers!