Page 1 of 1

[CLOSED] How to get HID-data working with interrupt-in?

Posted: Sun Jul 03, 2011 9:50 pm
by CaCO3
After quite some trial and errors I was able to modify HID-data so it works for my purpose.
What I does:
It reads in serial data and stores them in a buffer.
For now, the PC has to do polling to fetch the data.
During the fetching time, all incoming serial data is lost.
Because of that I would like to switch to interrupt-in instead polling.
This way, the serial data could let the device know when there is the right time to send the data to the PC.

AFAIK there is no real "sending to PC", the PC still has to fetch it itself. But the device could send an interrupt, so the PC knows when it is a good time for fetching.

There are other project which seem to do it that way, like RemoteSensor, but I am not able to adapt it for my purpose.
If somebody could guide me how to implement HID-data to use interrupt-in, that would help me a lot.

Re: How to get HID-data working with interrupt-in?

Posted: Mon Jul 11, 2011 7:12 am
by Micha
Try something like this:

while (!usbInterruptIsReady()) usbPoll(); // check if USB int is ready
usbSetInterrupt(&buffer[0], sizeof(data) + sizeof(uint8_t)); // send ReportID & data

where buffer is an array that holds the data including the report ID, sizeof(data) gives the length of the data and sizeof(uint8_t) the length of the report ID.

Re: How to get HID-data working with interrupt-in?

Posted: Sat Jul 23, 2011 1:31 pm
by CaCO3
Hi Micha

Thank you for your tip.
I added this already to the firmware side, how ever my struggles are with the PC side.
I don't understand how to make the PC application to wait and respond to an interrupt.
There is a code fragment at http://vusb.wikidot.com/host-software , also the remotesensor sensor applications uses interrupt-in.
But I just am not able to adapt it into my HID-data example.
How would I have to do that?
Is it even possible to have interrupt-in with HID?

I really would appreciate any tips or even working examples.

Re: How to get HID-data working with interrupt-in?

Posted: Mon Jul 25, 2011 6:15 pm
by CaCO3
I spent another few hours to get it working, but finally gave up.
How ever I now gave the Remote Sensor project another try and successed.
I could merge it with the latest v-usb source and got it working on an attiny85.
If anybody is interested in a stripped down version let me know.
Currently the host (PC) waits for an interrupt from the USB client and then fetches all available data.

Re: [CLOSED] How to get HID-data working with interrupt-in?

Posted: Tue Jul 26, 2011 12:41 am
by Micha
Depending on the programming language you want to use there are several possible pieces of software you could use: http://www.mikrocontroller.net/articles ... ternativen
I tried all of them more or less detailed, at last I'm using the HidLib from jj-jabb as it is his improvement of the HidLibrary (originally from Mike O'Brien) and fits my needs very well.

The "perfect" solution concerning USB standards is probably GenericHID from Jan Axelson, but it supports no interrupts out of the box. The HidLibrary (from Mike O'Brien as well as from jj-jabb) works with interrupts and so does the HID USB Library from Florian Leitner.