mterveen
Posts: 4
Joined: Sun Dec 29, 2019 1:18 am

ftdi driver under mono

Mon Jan 06, 2020 6:06 pm

i have several large windows vb.net applications i would like to port to my rpi4. after installing mono they work quite well. however, any app that uses the ftdi d2xx driver fails. i have successfully installed on the rpi4 the ftdi drivers (libftd2xx.so). however, i am still unable to get my win vb.net app to run. i've tried many things that work under windows (e.g. dynamically loading the dll at runtime) but it continues to bomb out on the rpi4. does anyone have a windows vb.net example using the ftdi2xx driver that works under mono for the rpi4? i would hate to have to port it to C and then compile it on the rpi4. there's thousands of lines of code!!!

Heater
Posts: 14296
Joined: Tue Jul 17, 2012 3:02 pm

Re: ftdi driver under mono

Wed Jan 08, 2020 4:45 am

As far as I can tell the driver in question is for a com port chip.

Why does your application need to know anything about a specific serial port hardware device?

On Linux systems the kernel has all the drivers for various serial port devices. On the Pi SoC itself, USB/serial adapters etc.

Applications only need to talk to the kernel to use any serial ports that show up in /dev/ Typically languages provide libraries and modules to do that. For example C uses libc.

I have created code that uses serial ports in many different languages running on different operating systems and platforms. I have never needed to know about any particular serial hardware device the machine may have. Well, at least not when there is actually an operating system on the platform.

Of the thousands of lines in your application only some small part of it should need changing to make use of the proper Linux facilities.

https://elinux.org/CSharp_on_RPi#Serial ... ractive.29
Memory in C++ is a leaky abstraction .

mterveen
Posts: 4
Joined: Sun Dec 29, 2019 1:18 am

Re: ftdi driver under mono

Wed Jan 08, 2020 10:52 pm

the ftdi driver under windows can load BOTH the vcp driver and d2xx driver, the first being your "normal" com port driver and the second being the hardware level driver. the default latency on the ftdi chip is 16ms. the d2xx driver allows you to programmatically change the latency to whatever you want, in my case i set it to 2ms since the device i am interfacing to only can receive and send 1 byte at a time, vs a "burst". the raspbian OS only allows you to use 1 or the other drivers at a time unlike windows. so before you run the program you need to remove the ftdi_sio and usbserial devices and then load the d2xx driver.

problem is i can't figure out how to interface to the d2xx driver. the windows driver is ftd2xx.dll and the raspbian driver is libftd2xx.so. in my windows program the driver is added as a reference in the assembly so it auto loads it at run time. so it obviously doesn't find the libftd2xx.so library driver when running under mono. i've tried to set up code to dynamically load the correct driver at run time but just can't get it to take.

so, hence my question. i'm looking for a simple windows visual studio example in vb.net or C that uses the ftd2xx.dll and will also run the same executable on the rpi under mono. i'ld be willing to pay someone $50 for working example!!!

Heater
Posts: 14296
Joined: Tue Jul 17, 2012 3:02 pm

Re: ftdi driver under mono

Thu Jan 09, 2020 4:15 am

Interesting. If it's possible at all the way to do it is described here:
https://www.ftdichip.com/Support/Docume ... _Linux.pdf
Memory in C++ is a leaky abstraction .

Return to “Other programming languages”