[fpc-pascal] Re: Accessing USB HID from Lazarus programs?
Sven Barth
pascaldragon at googlemail.com
Mon Mar 21 10:19:59 CET 2011
Am 20.03.2011 23:53, schrieb Bo Berglund:
> On Sun, 20 Mar 2011 19:47:28 +0000, Henry Vermaak
> <henry.vermaak at gmail.com> wrote:
>
>> On 20 March 2011 16:35, Bo Berglund<bo.berglund at gmail.com> wrote:
>>> I need to create a program using Lazarus/FPC to access a data
>>> collection device built using a PIC24F series microprocessor with
>>> built-in USB support. The firmware makes the PIC processor register as
>>> a Human Interface Device (HID) class USB device.
>>>
>>> I understand that for the HID class one does not have to provide a USB
>>> driver, there is already a generic one on Windows and possibly also on
>>> Linux.
>>> And the HID interface is not limited to mice and such, for example the
>>> PicKit3 PIC programmer and ICE uses the HID driver and it can both
>>> program code into PIC:s and execute PIC code with breakpoints from
>>> within MPLAB (the PIC develeopment IDE).
>>>
>>> My objective is to read the data from the data collection device using
>>> the USB interface and display the data on screen and also save to the
>>> PC disk.
>>> My FPC program should be able to run on Windows and preferably also on
>>> Linux.
>>>
>>> But I can't find any good examples on how to access the USB HID
>>> device....
>>
>> What you seen hidapi?
>>
>> http://www.signal11.us/oss/hidapi/
>>
>> You will probably have to translate the headers.
>
> Thanks, interesting read. I looked over what I thought would be the
> valid items and also tested the included enumeration test project,
> which found my keyboard, mouse and Microchip PicKit3 programmer.
> So far so good....
>
> But it looks like this is C or C++ stuff.... :-(
> Is there any FPC translation anywhere?
> I don't believe I can translate the C stuff properly myself to FPC.
>
>
You can try to use h2pas, a tool which is distributed together with FPC.
It reads a C header file and outputs a Pascal file that contains the
bindings for the C library.
For the manual see here:
http://www.freepascal.org/tools/h2pas.var
For a little how to see here:
http://wiki.lazarus.freepascal.org/Creating_bindings_for_C_libraries
If it reports errors you should report back here as not every C
construct is understood by the tool.
Regards,
Sven
More information about the fpc-pascal
mailing list