UsbSerial library - Supports FTDI, Arduinos and other USB serial devices

Status
Not open for further replies.

Rigsby

Member
Licensed User
Since the library is made to
I agree the Arduino is fixed at 8N1 but the FTDI devices are not necessarily fixed & are usually settable, e.g. Being able to set data bits to 7 atleast will cover older devices. Also don't forget parity, hardware handshaking etc!
There is some stuff here about changing parity, databits and even software & hardware handshaking. Now if that come be implemented in this library it would be awesome. Unfortunately it is way above my capability.

UsbSerialDriver.java - usb-serial-for-android - Android USB host serial driver library for CDC, FTDI, Arduino and other devices. - Google Project Hosting

But if it could be implemented, it would be a game changer for Android & RS232 as the FDTI is far superior than the prolific at not dropping characters at high baudrates and this driver from Erel is superb at 8,None & 1.

R.
 

eelias

Active Member
Licensed User
Erel,

I followed the information from this tutorial do add the rights to the application, however I am using PL2303 library.

The problem is that it keeps asking for right to access the USB-Serial cable (prolific 2303)

This is my manifest file:

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="12"/>
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
AddActivityText(main, <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
        android:resource="@xml/device_filter" />)
'End of default text.
I have changed the device_filter.xml to add my device:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
    <usb-device vendor-id="1027" product-id="24577" />

    <!-- 0x2341 / Arduino -->
    <usb-device vendor-id="9025" />

    <!-- 0x16C0 / 0x0483: Teensyduino  -->
    <usb-device vendor-id="5824" product-id="1155" />

    <!-- 0x2303 / 0x067b: Prolific SerialUSB  -->
    <usb-device vendor-id="8963" product-id="1659" />

</resources>
After it gets the rights it access the usb with no problem, send and receive byte fine.

But after some time, like 30 minutes (i believe it is related to screen trying to sleep, besides it is configured to be always on when powered) if you try to use the USB again the program crashes, when it gets back as for rights again. So i believe it crashed because the rights were revoked.

What can I do, I have customer right now waiting for a solution with equipment stopped!!!

Eduardo Elias
 

sergioausrio

New Member
Licensed User
CP2102 support in this Lib where great. I have some Devices with CP2102 Controller. It would be great to connect them with my Android! Cant wait...:D
 

mterveen

Member
Licensed User
erel - how does the google project jar compare/correlate to the d2xx.jar that ftdi has released earlier this month? have you or anyone tried the ftdi jar?
 

bluedude

Well-Known Member
Licensed User
Not working with Arduino Mega ADK

I tried this with my Arduino Mega ADK but it does not work.

When connecting the Phone and Arduino nothing happens at all.

Cheers,
 

bluedude

Well-Known Member
Licensed User
Recognizing

Nope, does not do anything. Also my old code with the USB Manager etc. does not work anymore with the ADK.

With the old code it complains about no installed apps support the accessory while that always worked.

Maybe the last Android update on my Galaxy Nexus is killing my code.

Cheers,
 

yo3ggx

Active Member
Licensed User
CP2102 works with this wrapper

Hi all,

I just want to confirm that using the latest version of the library source file to compile a new jar I have now support for CP2102 on my tablet (Samsung Galaxy Tab 7.7).
It would be great if PL2303 will be included too, to have everything in a single library.

Thank you Erel for your great work.
It is so simple to use...:)

Dan
 

sergioausrio

New Member
Licensed User
Hello Dan,
how did you do it? I tried it on my Samsung Galaxy Tab 10.1 with Erels Example -> Error opening USB port! I can not connect to the CP2102. Can you tell us your source code?
 

yo3ggx

Active Member
Licensed User
CP2102 support

Hi,

You have to recompile usb-serial-for-android using the latest available source code from the repository. No need to modify anything in the wrapper built by Erel. Just replace the jar file in the library folder.

If you want to use one compiled by me, you can find it attached (unzip and copy to Library folder over the previous one).
Do not forget to Refresh the libraries in B4A.

Hope this help.

Dan
P.S. tested with a CP2102 module and a loopback (rx link to tx)
 

Attachments

yo3ggx

Active Member
Licensed User
CP2102 support

I forgot to say that you have to add the following lines in device_filter.xml file:

<!-- 0x10C4 / 0xEA60: CP210x UART Bridge -->
<usb-device vender-id="4292" product-id="60000"/>

and this is all.
I just implemented this in my app using only Bluetooth before and is working like a charm over USB now.
My tablet is a Samsung Galaxy TAB 7.7 with ICS (4.0.4).

Dan
 

Scantech

Well-Known Member
Licensed User
I forgot to say that you have to add the following lines in device_filter.xml file:

<!-- 0x10C4 / 0xEA60: CP210x UART Bridge -->
<usb-device vender-id="4292" product-id="60000"/>

and this is all.
I just implemented this in my app using only Bluetooth before and is working like a charm over USB now.
My tablet is a Samsung Galaxy TAB 7.7 with ICS (4.0.4).

Dan
Hello,

I downloaded the Jar file and added additional filter in xml, but no go. I have this ELM 327 OBD II USB and I believe it is the CP210X type. Now, when I plug it in, it lets me choose an app, but mine is not included. It did power up the unit with this latest Jar file. Need to play around more and figure this out.

Thanks for recompiling the jar.
 

yo3ggx

Active Member
Licensed User
Check if VID and PID are the same for your device.
A simple way is to connect it to a Windows computer and look into the devices.

Play first with the Erel example and put a link between Rx and Tx to get an echo.
 

Scantech

Well-Known Member
Licensed User
Check if VID and PID are the same for your device.
A simple way is to connect it to a Windows computer and look into the devices.

Play first with the Erel example and put a link between Rx and Tx to get an echo.
I have this in device info
USB\VID_067B&PID_2303&REV_0300
USB\VID_067B&PID_2303
 
Status
Not open for further replies.
Top