libftdi Archives

Subject: Re: libftdi 0.x thread recommendations

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Thomas Heller <theller@xxxxxxxxxx>
Date: Wed, 25 Apr 2012 09:29:51 +0200
On Tuesday, 24. April 2012 16:46:45 Thomas Heller wrote:
> Am 24.04.2012 08:24, schrieb Thomas Jarosch:
> > libftdi is not designed to be thread safe.
> 
> But libusb-win32 is threadsafe? According to
> http://libusb.6.n5.nabble.com/Thread-safety-and-driver-file-name-td327842
> 0.html
> 
> So, if I patch the libftdi-calls that I use to do locking
> then I am safe?

The above link states you are safe if you don't send
USB control messages at the same time.

If you protect all your ftdi_xxx() calls with a lock, you're fine.

> I want to read and write at the same time in different threads
> from/to a FT2232H chip...

That should work. You still have to use proper locking if f.e.
a "background" thread collects data via ftdi_read_data() and you also
call ftdi_read_data() from the "main" thread. (Multi core systems
might see different values for ftdi->readbufer_XXX otherwise)

Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread