Page 1 of 2

How to output data to e.g. HID device

Posted: Thu Jan 07, 2010 9:19 am
by tommyjunge
Hi,

I would like to create a V-USB application, that allows to send a few bytes from the host to the AVR and back.
I would like to use drivers already available in Windows, e.g. HID. (Are there other Windows interfaces that are better suited for this purpose?)

To my understanding HID is for INput devices. Can it still be used to OUTput data from the PC to the AVR? Can anybody recommend a V-USB example project where I can study how this is done?

Thanks, Tom

Re: How to output data to e.g. HID device

Posted: Thu Jan 07, 2010 12:35 pm
by christian
You can use HID for bidirectional data transfer. However, since you must use feature reports (set and get), you are limited to fixed size data blocks. See the hid-data example, it uses HID feature reports to send and receive data.

Re: How to output data to e.g. HID device

Posted: Thu Jan 07, 2010 2:29 pm
by tommyjunge
Thank you for the hint!

I am afraid I couldn't find the hid-data example. Can you please give me a link?

Thanks, Tom

Re: How to output data to e.g. HID device

Posted: Thu Jan 07, 2010 2:56 pm
by christian
It's in the "examples" directory of the current driver package found at http://www.obdev.at/products/vusb/download.html

Re: How to output data to e.g. HID device

Posted: Fri Jan 08, 2010 10:15 pm
by tommyjunge
Thanks, I have found HID_DATA and the AVR side is working nicely.

Now I need to learn how to deal with the host side.

I have no experience with HID. Where can I read how to handle the HID-DATA device on the host side, e.g. what kinds of transfers are being used and what are the APIs to be used?

I need to do this in Pascal/Delphi. Does anybody have experience how to use the Jedi JvHIDDevieController for this purpose?

Re: How to output data to e.g. HID device

Posted: Sat Jan 09, 2010 10:37 pm
by iphi
Ok, I finally figured it out to feed HID_DATA from Delphi.
The JvHidController component works great.
If anybody would like the Pascal code, contact me.

Tom

Re: How to output data to e.g. HID device

Posted: Tue Jan 19, 2010 5:49 pm
by uchar
christian wrote:You can use HID for bidirectional data transfer. However, since you must use feature reports (set and get), you are limited to fixed size data blocks. See the hid-data example, it uses HID feature reports to send and receive data.


Respected Christian!
You have written about limitation by the fixed block size of the data. What size for the block - 8 byte?

Re: How to output data to e.g. HID device

Posted: Tue Jan 19, 2010 5:53 pm
by christian
It depends on your report descriptors. You can choose any block size you like (as long as you don't exceed the limits of V-USB or the host side drivers), provided that you describe the block in the report descriptor.

Re: How to output data to e.g. HID device

Posted: Tue Jan 19, 2010 6:09 pm
by uchar
Thanks.

I use an example hid-data. I wish to write and read 512 byte in EEPROM.
But for me it is impossible to transfer more than 254 byte. In what there can be a problem?

Re: How to output data to e.g. HID device

Posted: Tue Jan 19, 2010 6:56 pm
by christian
254 bytes is the size limit of V-USB in the default configuration. If you need bigger descriptors, define USB_CFG_LONG_TRANSFERS in usbconfig.h.

Re: How to output data to e.g. HID device

Posted: Wed Jan 20, 2010 6:13 pm
by uchar
Yes, I saw this define and have installed it, but it has not helped :(

Also I have changed a report-descriptor :

Code: Select all

PROGMEM char usbHidReportDescriptor[23] = {    /* USB report descriptor */
    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0xff,              //   LOGICAL_MAXIMUM (512) 
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x96, 0xff, 0xff,                //   REPORT_COUNT (512) 
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION
};



Please, tell in what my error.

Re: How to output data to e.g. HID device

Posted: Wed Jan 20, 2010 6:38 pm
by uchar
Excuse, I have understood :)

Has downloaded HID Descriptor Tool and has checked up parametre Report Count - for 512 byte it should be such: 0x96, 0x00, 0x02.

Now all works :)

Re: How to output data to e.g. HID device

Posted: Thu Jan 21, 2010 3:03 pm
by uchar
Christian, is again necessary to me your help :)

In an example hid-data the exchange goes through default control endpoint. Where it is described descriptor by this endpoint? (In a file usbdrv.c described two endpoint, with numbers 1 and 3)

Re: How to output data to e.g. HID device

Posted: Fri Jan 22, 2010 11:36 am
by christian
Endpoint 0 is described in the USB spec. Since it MUST be a control endpoint, there is no need to add a separate descriptor for it.

Re: How to output data to e.g. HID device

Posted: Wed Feb 10, 2010 11:15 pm
by pcs
hi,

i would be interested how to get the HID smaple to work with the Delphi HIDcontroller.
Tom can you please give me some advce?

kind regards
pcs