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

Status
Not open for further replies.

AtoZ

New Member
Licensed User
Longtime User
I just want to say Thanks,

I got it working on the first try with a cheap Visual Land with 4.1.1 (it came with OTG cable etc) and a usb to can converter (USB CAN Interface - CAN USB COM | Grid Connect).

The only thing that got me in the beginning was that I need the window to ask for what app I want to use and select it before it works.

It's seems a bit slow to get data though (missing some data) as the can bus runs at 250k.
 

yo3ggx

Active Member
Licensed User
Longtime User
I have this in device info
USB\VID_067B&PID_2303&REV_0300
USB\VID_067B&PID_2303
This is a Prolific PL2303 and cannot be used with this library (yet).
Try the one specifically designed for PL2303.
 
Last edited:

alexhi

Member
Licensed User
Longtime User
Thank you! I tested it on a clone ARDUINO UNO(CP2102) works OK

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)


Thank you! I tested it on a clone ARDUINO UNO(CP2102) works OK
 

Scantech

Well-Known Member
Licensed User
Longtime User
This is a Prolific PL2303 and cannot be used with this library (yet).
Try the one specifically designed for PL2303.

Ok, Thanks. Somehow, the new Jar file powered up the unit and thought maybe there is hope. I will make a request over there and see if they can support it.
 

yo3ggx

Active Member
Licensed User
Longtime User
I'm very intereted too in PL2303 support. Unfortunately I don't have the skills (yet) to add it myself.

Dan
 

zity

Member
Licensed User
Longtime User
Dear Erel,

I know that the lib is still under development, but updated .jar files from the repository source are already available. However, I would need the setParameter function to set parity and stop bits.
Could you update the wrapper to support that ? I would be happy to test it ASAP!

Cheers!
 

zity

Member
Licensed User
Longtime User
Sorry for the confusion, I meant un-official new builds, like the one posted in this forum topic earlier.
Or would a new wrapper introduce compatibility issues with the old java library ?

(If it's too much of a hassle, I will revert to just recompiling the .jar with the default settings changed)
 

hangloose99

Member
Licensed User
Longtime User
Thank you Erel! Lib works perfect on Galaxy S3
The possibility to the set the parity bit would be great!!!!
 

arge06

Member
Licensed User
Longtime User
Hi,

It sends data perfectly but, is there any way to read data/or how ?
 
Last edited:

csjoe72

Member
Licensed User
Longtime User
Hi,

Does it work with the B4A ver.1.7?

I have an error message:
Compiling code. Error

Thanks, Joe
 

arge06

Member
Licensed User
Longtime User
Look at Erels' example program in the first post. AsyncStreams should call your New_data event when data is received.

B4X:
Sub Astreams_NewData (Buffer() As Byte)
  Log("NewData")
  Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

Thanks a lot Agraham. Working with text values are ok, is there any way to work with hex values ? To send/receive data tablet to mcu vice versa ?
 

csjoe72

Member
Licensed User
Longtime User
Hi,

Error message:

Compiling code. Error
Nem lehet a folyam végét követően olvasni.

Translate: 'the program can't read after end of the stream'

I use the B4A ver.1.7.
I copied the Usbserial.jar, Usbserial.xml and usb-serial-android-v10.jar into the libraries folder.

But the next isn't clear:

1. Add the following code to the manifest editor:
Code:
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" />)

I did it so the new xml:
<?xml version="1.0" encoding="utf-8" ?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="b4a.example1" android:versionCode="1" android:versionName="" android:installLocation="internalOnly">
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
- <application android:icon="@drawable/icon" android:label="B4A Example">
- <activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main" android:label="B4A Example" android:screenOrientation="unspecified">
- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
- <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" />
</activity>
</application>
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" />
)
</manifest>

I know only the B4A v1.8 use a Manifest Editor tool.

Thanks Joe.
 

Stulish

Active Member
Licensed User
Longtime User
I have installed the USB-Serial lib and connected to my Galaxy S3. but keep getting the error Error opening USB port. I looked at the chipset and it is an FT232RL :( is this not supported?? i can only see the FT232R and FT232H might be.

The Hardware ID in windows is:

FTDIBUS\COMPORT&VID_0403&PID_6001

I purchased the adaptor from AMAZON thinking it was the correct one for android, but looks like i may have to look for a different model :(

Unless anyone has any ideas

Thanks
 

arge06

Member
Licensed User
Longtime User
@arge06 - What do you mean by "hex values"? As the data is sent and received as bytes you can send whatever you want.

@csjoe72 - We need to see the complete contents of that error dialog.

By "hex values" i mean this,

Dim TEMP1 As Byte
Dim TEMP2 As Byte
Dim TEMP3 As Byte
Dim TEMP4 As Byte
Dim TEMP5 As Byte
Dim TEMP6 As Byte

TEMP1 = Chr(0XDF)
TEMP2 = Chr(0X00)
TEMP3 = Chr(0X01)
TEMP4 = Chr(0X93)
TEMP5 = Chr(0X94)

astreams.Write(TEMP1&TEMP2&TEMP3&TEMP4&TEMP5)

I just want to do this, send data directly, without assigning to a label or edittext. Is it possible ?

For example, I can use the driver in eclipse and the code works well;

btWrite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String stCommand = "AAAA"+0XFF + 0X00 +0X01 +0X93 + 0X94 +"\n";
mSerial.write(stCommand.getBytes(),stCommand.length());
 
Status
Not open for further replies.
Top