B4A Library PL2303 USB to RS232 adaptor driver

dmtulsa

Member
Licensed User
Longtime User
FTDI Andriod USB-RS232

I don't know if anyone makes a USB-232 using this chip yet but I'd guess some company does. I'll look into it, If not I may design one myself.

FTDI Andriod info :FTDI Android
 

phoenix032

New Member
Licensed User
Longtime User
Hi,

I can't set UART data. I try to set and get data. It return only '0' all (rate,stopbits,parity,databits). This cable is work because I try to use with another demo app from play store already.

Thanks,
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Help with using PL2303 adpter

Hi there,

I am new on everything here, I wonder if i can get a help on the following:

I am in need to write an application for Android to handle serial comunication with a specific class of device. However i am having problems to make Agraham example to work.

I am using Genesis Skyworth tablet. Android 4. 2 usb (1 normal size 1 mini)

Android Usb port worked with: mouse, pendrive, connection to pc.

I have got a Serial to USB cable with PL2303 chip. I have connected on a fresh intallation of windows 7 and it detected as prolific 2303 and installed everything fine and recognized as serial.

I have pluged this cabe to the main usb of the Android. Compiled the USB PL 2303 demo with B4A 2.02 and Android level 15 api. Installed it on the android thru B4a-Bridge succesfully.

When opening it, it says no PL2303 found. I have tried with the mini usb same problem.

I have installed USB Host Controller 0.44 and it give me:
S3C USB Host dirver NOT found!

Root hub present, USB Host mode is active!

on the tab USB I got 2 active usb devices connected:
3-1 2303:067b (the prolific chip)
4-1 8176:0bda Realtek 802.11n WLAN Adapter


I would like to get a direction or ideas on what can be done.

I have not updated the Android on this tablet yet. Not sure if it is possible to install any kernel update etc. or something that I can do on the basic program.

Many thanks,

Eduardo Elias
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Thanks for reply!

The devices.getdevices return 0

Sorry, mean manager.GetDevices on Sub Find: return 0 (devices.length)
 
Last edited:

EduardoElias

Well-Known Member
Licensed User
Longtime User
Googling around I have found this:

"Enable USB-Host Controller on any Android
This app only checks usb host on your device.
To enable USB host API support you should add a file named android.hardware.usb.host.xml
and containing the following lines:
<permissions>
<feature name="android.hardware.usb.host">
</feature></permissions>
into folder /system/etc/permissions
in that folder find file named handheld_core_hardware.xml or tablet_core_hardware.xml
and add <feature name="android.hardware.usb.host"> into <permissions> section
Reboot your device. Usb host api should work."

of course for an Android 3.1 and higher.

I found that in my Tablet, besides it is a 4.0.3 the following:

/system/etc/permissions

file android.hardware.usb.accessory.xml

<permissions>
<feature name="android.hardware.usb.accessory"/>
<library name="com.android.future.usb.accessory" file="/system/framwork/com.android.future.usb.accessory.jar"/>
</permissions>


according the comments i have found i should have on the tablet_core_hardware.xml an entry about USB and host mode.

Does it mean that my tablet is not configured for USB host mode? If I change this will enable this feature, if eventually supported by the hardware?

Sorry, everthing is new for me on this platform, and I got B4A because this unique library PL2303 I could not found in any other language to be used.

Any Idea?

Eduardo Elias
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Found the solution

Here is guys:

The mentioned solution of changing the /system/etc/permissions worked!

The PL2303 demo found the usb->serial cable, at first time asked for permission to take the usb, i have accepted. Next time it found the pl2303 and could comunicate with pc. I have put a cable linking tablet and pc with teraterm and could receive the data sent by PL2303 demo

So, in my case, I was lucky my hardware was prepared and my Android4.0.3 came already rooted from factory. I changed the files and worked.

Eduardo Elias
 
D

Deleted member 103

Guest
Hi eelias,

this is the content of my file, can you tell me what am I to change.

android.hardware.usb.accessory.xml

Ciao,
Filippo
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi eelias,

this is the content of my file, can you tell me what am I to change.

android.hardware.usb.accessory.xml


Ciao,
Filippo

You do not change this file at all, follor these steps:

1 - add a file named android.hardware.usb.host.xml on /system/etc/permissions
2 - containing the following lines:
<permissions>
<feature name="android.hardware.usb.host">
</feature></permissions>
3 - open in /system/etc/permissions file named handheld_core_hardware.xml or tablet_core_hardware.xml and add <feature name="android.hardware.usb.host"/> into <permissions> section
4 - Reboot your device. Usb host api should work

You have to have root access to these files. After the changes and reboot it worked for me.
 
Last edited by a moderator:

realblue

Member
Licensed User
Longtime User
Great info, saved my life. Thanks.

 

pin71

Member
Licensed User
Longtime User
Hi,

I'm new to B4A and I'm coming from VisualBasic. I downloaded your example for the USB2Serial connection and it works.
Now I would like to add some changes and I would need to send out strings for modem commands like "AT" and so on.

I'm trying using USBpl2303.writedata("AT",2 ) but it doesn't work.
Is it possible to have any kind of help?

Thanks
 

pin71

Member
Licensed User
Longtime User
I have a question for Andrew:

Looking into your example I saw that the maximun read packet length is 64.

Is it possible to make it bigger ?

Thanks
 

agraham

Expert
Licensed User
Longtime User
No,the actual packet size is determined by the USB device but 64 bytes is the maximum allowed
 

Vinay Chaddha

New Member
Licensed User
Longtime User
how to bypass requestPermission() for USB HOST

I have been able to use the PL2303 library and every thing is working (sending and receiving data). However my application needs standalone operation. Now every time I switch on the device and run the app, it asks for permission to allow USB Access, In my application this is not possible as application works in standalone mode.

Any way to bypass the permission request or get the permission to use USB HOST without users acceptance?
 

pin71

Member
Licensed User
Longtime User
Timer cause the app to crach

I'm developing my app using this USB driver and it seems to work fine. But now I need to use a timer in my app to hold few secs and everytime I set the time enable the app crash.

this is what i'm getting on the log tab

java.lang.NullPointerException
at android.hardware.usb.UsbRequest.dequeue(UsbRequest.java:155)
at android.hardware.usb.UsbDeviceConnection.requestWait(UsbDeviceConnection.java:156)
at anywheresoftware.b4a.objects.usb.UsbDeviceConnectionWrapper$Reader.run(UsbDeviceConnectionWrapper.java:146)
at java.lang.Thread.run(Thread.java:856)


Any idea?

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…