Lazarus

Programming => General => Topic started by: makgab on March 06, 2012, 10:38:49 am

Title: Lazarus & USB
Post by: makgab on March 06, 2012, 10:38:49 am
Hello!

I am newbie in this forum. I've programmed in many languages and I like Lazarus.

My first question: How can I access the USB port in Lazarus (Linux, Windows)? Is libusb project (and libusb-win32) the best way to access USB ports?


Gabor

Title: Re: Lazarus & USB
Post by: Leledumbo on March 06, 2012, 11:41:50 pm
Search for "USB" in this forum and also take a look here (http://wiki.lazarus.freepascal.org/Hardware_Access).
Title: Re: Lazarus & USB
Post by: makgab on March 07, 2012, 11:12:48 am
Is the libusb-win32 compatible with Linux version?
So it is useable similar the Linux libusb?

G.

Title: Re: Lazarus & USB
Post by: avra on March 07, 2012, 12:17:59 pm
http://wiki.lazarus.freepascal.org/Hardware_Access#libusb
http://libusb.sourceforge.net
http://www.libusb.org
http://mcuprogramming.blogspot.com/2010/12/example-in-lazarus-for-libusb.html
http://www.radiolocman.com/shem/schematics.html?di=67235
Title: Re: Lazarus & USB
Post by: makgab on March 08, 2012, 12:12:27 pm
Ok, thanks!
I try to compile the LIBUSB_Test project. I get:

...LIBUSB_Test//unitmain.pas:44: undefined reference to `libusb_init'
... etc.

I installed the libusb-static package which contains the file "libusb.a". I make a symlink libusb-1.0.a to that in /lib64, /usr/lib/, /usr/lib64.

Which path is missing in Lazarus?

(Fedora 16 Linux x86_64)




G.

Title: Re: Lazarus & USB
Post by: makgab on March 08, 2012, 08:45:14 pm
How can I use the HIDAPI libusb in Lazarus?

G.
Title: Re: Lazarus & USB
Post by: makgab on March 22, 2012, 07:31:09 am
It can help me: ftp://ftp.freepascal.org/fpc/docs-pdf/CinFreePascal.pdf (http://ftp://ftp.freepascal.org/fpc/docs-pdf/CinFreePascal.pdf)
Title: Re: Lazarus & USB
Post by: makgab on March 25, 2012, 01:27:49 pm
How can I use the hid-libusb.o?
The command "h2pas hidapi.h -o hidapi.pas -d" generate hidapi.pas file, but it contains error, when I try it to compile. :(
How can I convert it?
Title: Re: Lazarus & USB
Post by: prof7bit on November 26, 2016, 10:11:30 am
How can I use the HIDAPI libusb in Lazarus?

For Linux I have made a manual header translation with an object oriented wrapper, it works with hidapi-libusb which is the default hidapi backend on *buntu based distros:

https://github.com/prof7bit/HIDAPI.pas (https://github.com/prof7bit/HIDAPI.pas)

To compile it (not to run it) you must also have the libhidapi-dev package installed for the linker to find the the library.

This can serve as a starting point, if you want to port it to windows you should be aware that the wchar_t on Windows is only 2 bytes instead of 4, so you must change the string conversion functions in this wrapper accordingly, i have marked the occurrences of the problems with comments in the source. I cannot maintain a Windows or Mac version of it because I use only Linux but feel free to fork it and change it or expand it to your heart's content, its LGPL + static linking exception.

-Bernd
TinyPortal © 2005-2018