[fpc-pascal] libusb header translation and OOP wrapper
Johann.Glaser at gmx.at
Mon Oct 1 23:04:16 CEST 2012
Am Sonntag, den 30.09.2012, 22:57 +0200 schrieb Christo:
> On Tue, 2012-09-25 at 22:32 +0200, Johann Glaser wrote:
> > I only have access to Linux and don't know anything about Windows
> > development. So, I ask you (and anybody else) on the best and cleanest
> > way to make libusb.pas working in Linux and other OS.
> I have played around with your library to get it working on Windows XP.
> The most significant change I had to make was to change the libusbx
> import from static linking to dynamic loading. I just couldn't get the
> static linking working in windows.
> This created a slight problem with requiring the cthreads unit because
> the libusbx library is multithreaded. I have added this to the libusb
> unit but it needs to be tested more because I don't understand how
> threading between C and fpc works.
> Attached please find a diff file summarizing my changes based on your
> git copy from about a week ago.
Thanks for providing feedback and patches!
The major changes are that you use LoadLibrary instead of dynamic
linking at program start. Note that $LINKLIB is really doing dynamic
linking, not static linking. Therefore I don't see why procedural
variables should be needed here.
Secondly you test whether libusb_get_port_number() and
libusb_get_port_path() are available. I don't know how to handle this
properly. Why not just update to 1.0.12?
Third, at some points you added the unit CThreads. Looking at the
libusbx source code (and API documentation) reveals, that they don't use
threading, they only use the mutexes (pthread_mutex_*) and condition
variables (pthread_cond_*). I also don't know whether it is necessary to
install the Pascal Thread Manager therefore. I'll start a dedicated
thread for that.
Finally, you have added a different implementation of GetUSec which
works on Windows. Thanks for that!
For the clarification of the CThreads and the LoadLibrary stuff I've
created two separate branches libusb-1.0-cthreads and libusb-1.0-dynlib
with your changes (with slight capitalization changes, ...). I'll merge
these branches to libusb-1.0 as soon as these issues are clarified.
More information about the fpc-pascal