[Lazarus] USB Commincation with Lazarus and libusb library

Henry Vermaak henry.vermaak at gmail.com
Wed Apr 8 14:12:52 CEST 2009


> Hi,
>
> in response to your message :
>
> I have install the libusb library on my MAC OS X and I have link libusb with my Lazrus project and I can call function.
>
> The problem is when I try do dev := dev^.next; or dev^.descriptor.idVendor = $04d8 or another operation on dev I get an error
> "EXC_ACCESS_ERROR"
> Is it an memory problem ?

make sure you have sufficient rights to access the usb device (run
your program as root to test).  i have no idea how to give this access
on the mac, but you use udev for this on linux.

i see in your sources that you don't try and open the device or claim
an interface.  try and do this before you check vid/pid:  like so:

while bus <> nil do begin
    dev := bus^.devices;
    while dev <> nil do begin
          usb_device := usb_open(dev);
          if (usb_device <> nil) and ((dev^.descriptor.idVendor =
$1234) and (dev^.descriptor.idProduct = $4568)) then ...

i'm not sure if it will solve your problem, though.

if this doesn't help, try the testlibusb.c program in the usb sources
and see if that works.

henry



More information about the Lazarus mailing list