Hi,

I need again help !!

I have create a simple library in C compiled with GCC in mylibusb.o

The code is :
#include <usb.h>


myusb_open(usb_dev_handle *udev)
{
   struct usb_bus *bus;
   struct usb_device *dev;
   char buff[64];
   int i;

   //Initialisation du bus USB
   usb_init();
   usb_find_busses();
   usb_find_devices();

   for (bus = usb_busses; bus; bus = bus->next)
   {
      for (dev = bus->devices; dev; dev = dev->next)
      {
         if ((dev->descriptor.idVendor == 0x04D8) &&
(dev->descriptor.idProduct == 0x1985))
         {
            udev = usb_open(dev);
         }

           }

       }
}


myusb_close(usb_dev_handle *udev)
{
   usb_close(udev);
}


myusb_write(usb_dev_handle *udev)
{
   usb_bulk_write(udev, 0x01, 0x01, 64, 1000);
}


I link this myusblib.o with my lazarus program :


unit usb_api;



interface


     function myusb_open(udev : thandle);cdecl;
     procedure myusb_close(udev : thandle) ; cdecl;
     procedure myusb_write(udev : thandle); cdecl;


implementation

{$link myusblib.o}
{$linklib usb}
{$linklib c}
{$linklib gcc}


uses CTypes;

function myusb_open; cdecl; external;
procedure myusb_close; cdecl; external;
procedure myusb_write; cdecl; external;
end.



and when I do

var
myhost : thandle;

begin
myusb_open(myhost);
myusb_write(myhost);
myusb_close(myhost);
end;

I have no communication with my usb board. My libusb.o work with the same
program in C.

Have you got an idea on my problem or can you tell me if you have another
solutions.

Is it possible to create a library Dll for windows and MAC OS and How can I
do it with the libusb library?
Thanks you

-- 
Bonne journée

Sébastien
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to