USBSerial&Arduino

koep

Member
Licensed User
Longtime User
Hi All!

I'm trying to connect to Arduino Uno with B4A and my chinese tablet running Android4.0.3, but keep getting "Error opening USB port"

Arduino works with VB.net and PC so problem is not on arduino.

Tablet recognizes mouse when plugged in so USB host is ok, I think:sign0104:

I have this same problem with the example app.

Has anyone any ideas where to look for cure?

Rgds,
Tapio

Add/Edit:

I read that android should show dialog asking if app is permitted to access usb port but my app not rhe provided sample trigger this dialog
 
Last edited:

koep

Member
Licensed User
Longtime User
Hi Andrew!

I think it is time for:icon_clap::icon_clap::icon_clap::sign0060:

I can now connect to RoboClaw and it behaves as it is supposed to:
sits there quietly and answers only when spoken to, no more streaming 0's.

Test reading the temperature value returns same as with .net app.

Minor oddity is that under some yet unconfirmed circumstances the driver makes connection to wifi(Realtek) on my tablet and disconnects wireless B4A-bridge. I I suppose I'll have to put checking for this in my code.

Rgds,
Tapio
 
Upvote 0

sunish

Member
Licensed User
Longtime User
How do I access USBSerial3 mentioned in this post ?
I need to toggle CTS on CP2102 based board. I understand its not possible with the current lib.
If not, is there a way to enable and disable power of the OTG powered device with code.

Sunish

The modem controls signals don't seem to be exposed by either UsbSerial or UsbSerial3. You can try using reflection which should work but I haven't tested it as I don't have an FTDI device.
B4X:
Dim UART AS USbSerial3

UART.Open(9600)

Dim R as Reflector
R.Target = UART
R.Target = R.getField("driver")

R.RunMethod2("setDTR", true, "java.lang.boolean")
If this works you may already know that the driver supports

getCD(), getCTS(), getDSR(), getDTR() and getRI() which all return a Boolean

as well as setRTS(Boolean).
 
Upvote 0
Top