libftdi Archives

Subject: Re: libftdi on Mac: calling library runs in C++ console app, breaks in Cocoa app

From: Adam Preble <preble@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 1 Jun 2009 10:13:32 -0400
Thanks for your reply, Jim.  The issue ended up being related to using
the older libusb 0.1.12.  I updated to libusb-1.0 and used
libusb-compat to get libftdi to work with it; it's running fine under
Cocoa now.

Adam

On Sat, May 30, 2009 at 2:20 PM, Jim Paris <jim@xxxxxxxx> wrote:
> Adam Preble wrote:
>> Hello,
>> I am working on a library that uses libftdi 0.16 (and libusb 0.1.12) to
>> communicate with a FT245RL.  All of my work is taking place on a Mac (Intel,
>> 10.5.6) but we're keeping the library code portable.  I've written a C++
>> console app that uses the library and everything works great there.
>>
>> The problems arose when I started trying to call the library from a Cocoa
>> app.  My library can still enumerate all of the devices and open one, but
>> when it calls to write to the device via ftdi_write_data() it returns 0
>> bytes written.
>>
>> I've used Xcode to step down through the code, all the way into the libusb
>> bulk write code but haven't been able to observe the actual problem.
>>  Sometimes Xcode/gdb will print out the following while stepping over the
>> write call:
>>
>> Program received signal:  “EXC_BAD_ACCESS”.
>>
>> Cannot access memory at address 0x6f697377
>>
>> Cannot access memory at address 0x6f697377
>
> That's "oisw", which makes this look like you've corrupted the address
> of your buffer.  Do you use the substring "wsio" anywhere in your code?
>
> You could try running the non-cocoa version under valgrind to ensure
> there are no memory related bugs.
>
> libftdi will only return 0 from ftdi_write_data if the underlying
> usb_bulk_write returns 0.  For darwin, that seems to be a mess of code
> involving a "CFRunLoop" that I don't understand, but maybe using Cocoa
> is affecting that somehow?
>
> -jim
>

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

Current Thread