Limit on the # of reports (hid-data) [SOLVED]

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
qdot
Posts: 4
Joined: Wed Dec 30, 2009 2:37 am

Limit on the # of reports (hid-data) [SOLVED]

Post by qdot » Wed Dec 30, 2009 2:48 am

Hi!

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!
Last edited by qdot on Wed Dec 30, 2009 3:08 am, edited 1 time in total.

qdot
Posts: 4
Joined: Wed Dec 30, 2009 2:37 am

Re: Limit on the # of reports (hid-data)

Post by qdot » Wed Dec 30, 2009 3:08 am

I'm such a fool. I was creating a file descriptor with each openDevice(), and, surely enough, 1020 descriptors (+4 default ones) away, we're out of them.

Post Reply