Charles Lepple wrote:
On Jan 8, 2010, at 7:29 AM, Tim Nicholson wrote:

Charles Lepple wrote:
On Jan 8, 2010, at 6:16 AM, Tim Nicholson wrote:

I am trying to write an interface in C so I can communicate with a PIC chip via USB using libhid, but I do not understand how to use the path information I am seeing to send and receive massages.

Your device's HID report descriptor does not specify any report IDs, so the paths don't matter.

However, there is a chance that the device is only expecting you to read and write to the interrupt endpoints (not the control endpoint). Is the source code for this device available online?

Charles,

Thanks so much for replying so quickly.

The code is part of the Microchip USB framework which can be downloaded from the microchip website. It is the generic HID example code for the low pin count development board which uses the PIC18F14K50.
Is there anything I can post that will help? I could email you the source I used to compile the .hex if you wouldn't mind taking a look?

I could take a look after work. For the benefit of others searching the list in the future, can you post a direct link to the page on Microchip's site?

If you have made any significant changes to the source code, that would be useful to know - but if you are just reading and writing the 64-byte buffers being sent in and out, then the exact data probably doesn't matter. That also means that libhid is probably overkill for what you are doing. There are a few key libusb functions which you might be interested in, and you can save yourself some trouble by just incorporating that into your code.

libhid is really for devices like uninterruptible power supplies, which provide a "tree" of values (hence the "path" for specifying a value of interest). In the case of an UPS, you would want to poll a few key values to determine whether to shut down the system, and the rest are just statistics which are harvested less frequently.

Also, if your target application is more like a specialized mouse or keyboard, you can adjust the HID descriptor to mimic a standard input device. Microchip used to provide virtual mouse firmware which basically moved the mouse cursor around when you plugged the device in. This use case also doesn't require libhid, since the OS input subsystem would handle the events the same way it would read from your primary mouse and keyboard.

Thanks,

The Microchip URL where the download can be found is http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2651&param=en534494. (The framework comes in the form of a zip file which, unfortunately, is pretty large even by modern standards).

I have not made any changes to the demo source code as yet, as I was just trying to interface with the standard demo software as a first step. My final application will not be much more complex   as all I need to do is detect some key presses and read the ADC on the PIC. The ability to read and write single 64-byte buffers is all I am looking for.  I will have a look at libusb, to see if I can make any sense of that. My biggest problem is I am very new to USB and I am finding all the terminology difficult to get my head around. All of the Microchip texts and examples are designed for Windows developers which is fine except my final application will be running on embedded Linux and I have not really had anything to do with Windows software development since the mid 90's. I have tried looking at the USB specifications but trying to tie it altogether is not proving very easy - I am suffering from information overload!

Any pointers would be much appreciated. I just need to understand what functions I need to call to establish a connection and transfer data to and fro.

Tim
_______________________________________________
libhid-discuss mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Reply via email to