Using serial with FTDI

One problem with the built in serial component is that it does not include d2xx.jar needed for communication with FTDI usb to serial converter. If you connect this device you get an error “Java Lang.NoClassDefFoundError: Failed resolution of Lcom/ftdi/j2xx/D2xxManager”. I guess this is from the PhysicaloidLibrary. It is the same problem with the com.pavitra.5.aix that make use of the PhysicaloidLibrary.

If this is solved, then some of the Arduino clones can be used with App Inventor.

A better solution can bee to use https://github.com/mik3y/usb-serial-for-android. This library seems to allow communication with most of usb-to-serial chips used for Aurduino clones and usb to serial converters.

Some more information on serial extension.
I have built a new serial extension with d2xx.jar included. There is two ways to do this, add the library in directory lib/ or make a new physicaloid library from the original and combine this with d2xx. Both ways are possile to use.
This will result in an extension that can be used with CDC-ACM (org UNO), FTDI and according to the documentation CP210x. One problem is that it does not work with ai companion (same problem as above). It seems to be a conflict with the physicaloid library in appinventor. But if you compile and install the app on your device, then it works ok.
But there is one more problem. D2xx is not open source, so you might need permission to use it.
So I will continue with another solution if someone is interested.

I'm not a lawyer, but my interpretation of the license bundled with the D2xx.jar is that we wouldn't be able to include the FTDI driver for distribution as part of App Inventor. If you can find a compaitble library with a license compatible with Apache Software License 2.0 then we might be able to add it to App Inventor to support this in the core system.

Agree! I have found a compatible Physicaloid library with recent updates and Apache Software License 2.0, that handles all common USB-serial chips. During testing I found a problem with some CH34X serial adapters. I have a solution for that, but I just need to verify that it is the correct solution.

...sounds very interesting, especially given the number of people that use App Inventor with microprocessors (and gadgets).

First version of an extension is available on github, rkl099/Appinventor-SerialOTG

EDIT: Here is the link: https://github.com/rkl099/AppInventor-SerialOTG

It is compatible with the built-in component Serial, extended with settings for parity, rts, dtr and refactored so it can be used with AI Companion. It has been tested with CdcAcm, PL2303, PL2303HX, FTDI, CP210x, CH341, CH341 (“fake”) and several android devices. I hope this will solve some problems discussed in the forum and make new applications possible.

Please return if you have any problems.

2 Likes

Hi again

Would it enable an App Inventor App to move files from a phone to a Windows PC via USB cable?

that sounds great... could you please provide a link to your page there?
thank you

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Here is the link: https://github.com/rkl099/AppInventor-SerialOTG

No, the library Physicaloid supports transfer of files, but not to a PC:

  • supports uploading firmware protocols : STK500, STK500V2, Binary blob ESP8266 OTA

The upload function has not been included in extension.

This extension works with my Arduino UNO with CH340 + cable OTG.

Enable OTG in Android Settings.