Recent

Author Topic: Lazarus & USB  (Read 20080 times)

makgab

  • Jr. Member
  • **
  • Posts: 55
Lazarus & USB
« 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

« Last Edit: March 08, 2012, 06:41:16 pm by makgab »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus & USB
« Reply #1 on: March 06, 2012, 11:41:50 pm »
Search for "USB" in this forum and also take a look here.

makgab

  • Jr. Member
  • **
  • Posts: 55
Re: Lazarus & USB
« Reply #2 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.



makgab

  • Jr. Member
  • **
  • Posts: 55
Re: Lazarus & USB
« Reply #4 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.

« Last Edit: March 08, 2012, 08:45:02 pm by makgab »

makgab

  • Jr. Member
  • **
  • Posts: 55
Re: Lazarus & USB
« Reply #5 on: March 08, 2012, 08:45:14 pm »
How can I use the HIDAPI libusb in Lazarus?

G.
« Last Edit: March 10, 2012, 04:45:17 pm by makgab »

makgab

  • Jr. Member
  • **
  • Posts: 55
Re: Lazarus & USB
« Reply #6 on: March 22, 2012, 07:31:09 am »

makgab

  • Jr. Member
  • **
  • Posts: 55
Re: Lazarus & USB
« Reply #7 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?

prof7bit

  • Full Member
  • ***
  • Posts: 161
Re: Lazarus & USB
« Reply #8 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

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