kai-morich / simpleusbterminal Goto Github PK
View Code? Open in Web Editor NEWAndroid terminal app for devices with a serial / UART interface connected with a USB-to-serial-converter
License: MIT License
Android terminal app for devices with a serial / UART interface connected with a USB-to-serial-converter
License: MIT License
Playstore App SerialUsbTerminal with BaudRate 9600, HEX Mode and CR+LF connects to PL2303 USB device and sends data to our BMS device and receives output too. Attaching pics for reference.
However, the same SimpleUSB - We jus cloned the repo and built the app - set BaudRate to 9600 is connecting and sending but not able to receive the output. What could be the reason ? How can we test easily using emulator ?
I'm surprised that this app says that there is no driver for my USB device.
It works well with the Serial Usb Terminal App:
Connected to CDC device
Data is received perfectly.
If the phone is rebooted, but the cable remains plugged in, and then the app is opened, the pop up will come back.
If the USB cable is unplugged, upon replugging the pop up does not come back.
However, if the app is closed, but the cable remains plugged in, and then the app is reopened, the pop up does not come back.
Hi,
I am trying to start the service from an Activity, but OnServiceConnected
never gets called. Any idea?
Hello
want to use serial adapter in chroot environment (Linux Deploy).
Is there a way to attach it as /dev/ttyUSBx that others can use the adapter to?
Means any chances to apply this to generic driver?
The driver does not work for a FTDI RS232 cable. I've tries in Android 10 and 11 in some differents terminals and does not work.
I've also tried with Simple USB Terminal with no luck.
Is there any new driver or something to use it with the new Android Version?
hello
please add function to start, when connected, server on localhost or abstract unix socket which will give access to this port for there clients.
with this server it will be possible to access such port from apps like termux, in which it is difficult to use your backend library directly.
Hi,
Ive been using your Android app SerialUSBTerminal for a while and had a few thoughts on how I would like to use it so I came here. So far this repo is good enough for what I need, theres just one problem that maybe you can help me with. When I send a message longer than one line of an Android screen, it then cuts the message into pieces. For example, if two lines are sent then two separate messages are sent. The index of the messages are changed when this happens too.
example=
msg ="hello world,hello world,hello world,hello world,hello world,hello man"
name = msg[0]= h //for first line
name = msg[0] = m // for second line
Ive looked through all the code to fınd where this problem might be, but to no avail.
On the Android app, there is no problem like this, so Im wondering where the difference is here.
I would really appreciate any help. Thanks.
I am no longer to connect Serial USB Terminal to my ESP32 DevKitC-V4 using my Samsung Galaxy S9 running Android 10.0. My ESP32 uses a CP2102N UART module. I am positive it worked before but now I can't get it connected. I get the following error:
Connection failed: Setting baudrate failed: result=‑1
I don't remember when it last worked, but my ESP8266 which uses a CP2102 UART module works fine. I also tried a couple other USB Terminal Apps from the Google Play store such as "Pytool USB Serial" which work fine but aren't as nice as your app. I've tried different cables and adapters, but nothing works. I have the baud rate and other serial settings set correctly as 115200, 8-N-1.
It would be great to implement a data stream transfer mode from the device over the network. I have a compatible device - an emg sensor, I want to make a script on the server for signal processing, and when certain events occur, play an audio file. Although, probably, I will have to master java programming for android)))
I followed this guide to set up serial access over USB https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget
The app does not detect a device. I know the USB otg adaptor and cable work and I am plugged in to the USB data port on the PI Zero.
I have tried your applications and it works great with my weighbridge machine its shows weight in mobile device using rs232 to usb cable
I have implemented the Library mik3y/usb-serial-for-android in my flutter app and trying to receive data I am getting the data but when I try to convert the data to string it shows me random string not the weight
I tried using TextUtil file and used TextUtil.toHexString(data) function but still shows random strings not the weight of weighbridge
private final SerialInputOutputManager.Listener mListener = new SerialInputOutputManager.Listener() {
@Override
public void onRunError(Exception e) {
Log.d(TAG, "Runner stopped.");
}
@Override
public void onNewData(byte[] data) {
runOnUiThread(() -> {
if (m_EventSink != null) {
// String msg = new String(data);
m_EventSink.success(TextUtil.toHexString(data) + '\n');
}
});
}
};
when I am using
var msg = String(data)
it stops the app how can I solve this issue please let me know.
Line based mode precludes interacting in important ways with many terminals. This is especially evident when using a USB keyboard. Actions such as tab completion, history search, up arrow to scroll through command history, interaction with programs that need one character at a time such as less, etc.
Hello friend how I can fix this, the UI become very slow when receive a lot of data and append it to TextView
I/Choreographer: Skipped 31 frames! The application may be doing too much work on its main thread.
Add support for xmodem protocol
Hello Kai Morich,
Can you please tell me in which file exactly in the USB-Serial library is the asynchronous data reception code? I tried to figure out but was unable to do so. Thanks in Advance.
is it possible to enable it to work with a baud rate of 110?
I cannot increase the baud rate on the device.
Upon calling len = port.read(response, READ_WAIT_MILLIS);
shown in the README I was getting len=0 for a simple arduino printing the char "A" every 1000ms. I could not for the life of me figure out why my other serial terminals like CoolTerm and Arduino's IDE terminal were having no issue reading this, but my Android code was. The connection, device, port, etc. all looked to have reasonable values when inspected with an inline debugger, and no errors were raised.
It wasn't until I dug REAL deep into SimpleUsbTerminal code to find this little hint. I dunno, maybe this is obvious to more experienced embedded engineers, but I wasted almost an entire day on this.
I saw reference to this setDTR
method in the FAQ after finding it in the sample code mentioned above, but would never have thought it to be relevant based on what I was seeing. Not sure how large a percentage your user base is for Arduino, but I'd suggest adding at least a reference to this setDTR
method in the README code as a requirement for any communication with an Arduino to work. So all I had to do was after the "Open Device" section of the README, add:
port.setDTR(true);
prior to writing/reading. Hopefully this issue helps others at the very least. Or maybe I've misunderstood something and this is not the approach I should even be taking?
I am using rs232 to usb and receiving data from it.
sometimes when receiving the data and I remove the cable the mobile shutdown. I am facing it both with your app and the app that I am trying to develop how can I solve it.
Thanks
Would it possible for this application to be packaged and released on F-Droid? To the best of my knowledge, it fits with their inclusion policy, it's possible I missed something though. If you intended this as more of a proof of concept for those asking how you made it work, that's completely understandable and you can close this issue. Thank you!
Hi, I was using your driver for an android app to receive CANBUS data. The can speed is 500k baud. But after a while the USB data reception is slowing down.. could you please think of any issues ? It's been two weeks I am trying but without much progress. The device I am trying to use is : https://www.alibaba.com/product-detail/Android-Car-Player-Touch-screen-USB_1600120601898.html?spm=a2700.pc_countrysearch.main07.66.db2fecbadYNr4Z
The Serial USB Terminal app seems to work on my Lenovo TB8504F (Android 7.1.1). But both Samsung S20 (Android 11) and Samsung S8 (Android 9) are not able to see the device. The device is Arduino UNO R3 in CDC ACM mode. How can I make the app to work on S8 and S20? Is there some kind of permission I need to know? Thank you
Hi @kai-morich.
This will probably look silly but I'm unable to open the project in Android Studio.
Nothing Happens when I select the folder where I downloaded the code.
Any Help appreciated.
Hey, thanks for building a pretty good software, it really works with the USB otg device and a serial converter on my phone.
I would like to leave the phone connected to an appliance that's continuously sending information, in a csv file like output, with a new "row" being output each five seconds, unattended. For this, a minimal implementation I can think is once a buffer is filled it would write a file to the phone storage and start a new buffer. I would use it to leave the phone connected to it for two or more days, and pick it up later.
The code is not upto date with the app the newline names and newline values have 6 fields in app but here I can only see 3
can you update it or let me know what would be value for the rest of the fields
CR+LF LF <none> \u000d\u000a \u000athe newline values in app are
CR+LF
CR
LF
STX/ETX
NUL
None
I'm trying to use your code in a project of mine.
I'm able to connect to my device but unable to receive data. I have no clue of what is going wrong:
Here is my Listener:
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
private SerialInputOutputManager mSerialIoManager;
private final SerialInputOutputManager.Listener mListener = new SerialInputOutputManager.Listener() {
@Override
public void onRunError(Exception e) {
Log.d(TAG, "Runner stopped.");
}
@Override
public void onNewData(final byte[] data) {
Log.d(TAG, "received " + data.length +" bytes of data from usb device");
if (data.length > 0) {
ReactUsbSerialModule.this.emitNewData(data);
}
}
};
This is how I trigger the read after being connected:
public void readDeviceAsync(String deviceId) {
try {
UsbSerialDevice usd = usbSerialDriverDict.get(deviceId);
if (usd == null) {
throw new Exception(String.format("No device opened for the id '%s'", deviceId));
}
mSerialIoManager = new SerialInputOutputManager(usd.port, mListener);
mExecutor.submit(mSerialIoManager);
} catch (Exception e) {
}
}
I don't know why but I'm receiving big arrays of garbage data.
The device is supposed to send me 20 bytes every second.
What could be the root cause of the problem?
Any help appreciated.
Trying to connect app to Arduino Leonardo through USB but getting the following error: "Could not clam control interface". What does this mean?
Hi there,
Thanks a lot for this app source code, much appreciated.
I was wondering if this app can read and show serial data from a serial device like the Serial USB Terminal app.
I tried to open the app source code package on Mac OS X based Android Studio 4.1.2 and have got this classpath set in the build.gradle for the project: com.android.tools.build:gradle:4.1.2
But The Constants.java file returns this build failed error
/SimpleUsbTerminal-master/app/src/main/java/de/kai_morich/simple_usb_terminal/Constants.java:8: error: cannot find symbol
static final String INTENT_ACTION_GRANT_USB = BuildConfig.APPLICATION_ID + ".GRANT_USB";
^
symbol: variable APPLICATION_ID
location: class BuildConfig
This occurs for the Constants.java file lines 9-11 also.
What should be the gradle plugin version to use? It seems some solutions stated online by others for other projects states to downgrade the gradle version. But does not help, same issue occurs.
Would be grateful if there is a solution for this as I would like to run and edit the app using Android Studio or any other IDE.
Thanks, Pratik
Sorry - my mistake in the prior question.
hello.
if this app is already opensource, may be it will be usefull to try to publish it in f-droid.org?
I am using Android 10. I am trying to attach the USB device using an OTG adapter to the app. No USB device message appears and no device shows in the list of USB devices.
The USB device shows When I run this app Below Android 10.
I just tried to compile this app with Android Studio 2021.2.1. The app runs however when connecting to a device it crashes with a few permissions errors:
Not sure exactly what causing this. Your app should request permissions properly from reading android documentation.
java.lang.SecurityException: User has not given 10452/de.kai_morich.simple_usb_terminal permission to access device /dev/bus/usb/001/002
at android.os.Parcel.createExceptionOrNull(Parcel.java:2426)
at android.os.Parcel.createException(Parcel.java:2410)
at android.os.Parcel.readException(Parcel.java:2393)
at android.os.Parcel.readException(Parcel.java:2335)
at android.hardware.usb.IUsbManager$Stub$Proxy.openDevice(IUsbManager.java:1022)
at android.hardware.usb.UsbManager.openDevice(UsbManager.java:719)
...
java.lang.IllegalArgumentException: de.kai_morich.simple_usb_terminal: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at de.kai_morich.simple_usb_terminal.TerminalFragment.connect(TerminalFragment.java:275)
I need to send a command to the device that is just one byte.
For instance, I need to send 0xf2, which is supposed to tell the device to send me data at 200Hz. By default the device sends me 20 bytes at 1Hz.
I've tried \xf2
in the app, but this does nothing, meaning I'm still receiving 20 bytes à 1Hz.
Hello, here when I send a command, I expect to receive related info from the USB, however, the result returns always "invalid command" which means the usb read invalid command.
but interesting thing is: I also tried the Serial Usb Terminal APP:
the first time I tried, it returned the same string "invalid command":
the I changed the receive newline value from CR+LF to CR
and the result was still invalid command
then I changed back the receive newline value from CR to CR+LF, tried it again, I got the correct response!
Can anyone help me to solve this issue ?
Thanks
I had downloaded your code and made clean build succesfully but when i tried to deploy to my device the apk , it was installed but there is error about it. When beginning the application crashes.
2019-05-27 12:40:08.141 8725-8725/de.kai_morich.simple_usb_terminal E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.kai_morich.simple_usb_terminal, PID: 8725
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.kai_morich.simple_usb_terminal/de.kai_morich.simple_usb_terminal.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f080059
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3086)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f080059
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:228)
at android.content.res.Resources.getValue(Resources.java:1346)
at android.support.v7.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:235)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:753)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:196)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at android.support.v7.app.AppCompatDelegateImpl.(AppCompatDelegateImpl.java:260)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at de.kai_morich.simple_usb_terminal.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Activity.performCreate(Activity.java:7317)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3066)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
The console line with FTDI FT232RL+211 double chips, is it support? thanks very much!
Hello.
I am trying to use this app to send a command to a device connected to an USB port.
Thanks to the app i can see the device but i do not understand how i need to insert the byte to execute the command.
I need to send 186 2 1 185.
Could you please explain me how to do that?
Is there support for this device ?
I am using mik3y/usb-serial-for-android library
but the data I am receiving is in single characters I tried to set setReadTimeout like this but its not working.
mSerialIoManager = new SerialInputOutputManager(port, mListener);
mSerialIoManager.setReadTimeout(200);
I succeeded in connecting and reading data with your wonderful code.
I want to switch pages while staying connected after being connected. Can you advise me how to do it?
thank taecher..
Thank you for this project! I've tried this app with the device it is running on acting as a USB Host and it works great! However, when I run the app with the device it is running on acting as a USB device, it shows no device connected.
I was wondering if the app supports this use case?
I'm connected to a device by uart using your app the communiction works but the app doesn't poll meaning the device is meant to send me a character every 10 seconds and I can't see them I can only see direct output
I am using this app to send data to a pc2102 device
I commented the line
byte[] data = (str + newline).getBytes();
with the line
byte[] data = str.getBytes();
since i did not want to send line endings to the device
this still sends an extra random byte to the device at the end
When I use Serial USB Terminal
app I am receiving correct hex value, but when I use Simple USB Terminal
app the values are differnt from what I expect.
baud rate: 115200
data bits: 8
stop bits: 1
parity: none
What can be the the issue and what can be the difference?
usbSerialPort?.open(usbConnection)
usbSerialPort?.setParameters(
baudRate,
UsbSerialPort.DATABITS_8,
UsbSerialPort.STOPBITS_1,
UsbSerialPort.PARITY_NONE
)
De pronto suena muy básico pero no soy experto en el uso de este aplicativo android studio, alguien me puede colaborar con los pasos para poder correrlo y emularlo en android studio. lo he intentando y me sale un error "Error: Module not specified".
Apenas llevo 4 días usando android studio.
de antemano agradezco su atención.
Hi I am Trying to connect Cp210x to my Android device when I install this app and tried to connect device it does detect USB but it says No Driver.
Hi @kai-morich
I am getting references from your library code and I must say it is a pretty awesome lightweight app. I am stuck on one change and seeking help from your side. I want to avoid the restart of the app every time whenever a device is connected. At the start of the application, a dialog appears which contains that allows the USB terminal app to always open for this device with a checkbox. I want to avoid restarting of the app every time when the app is in the foreground already. Any help will be appreciable.
Hello. I am using the app and can connect to the PL2303 device. I have set the baud rate to 115200.
When I send my hex commands F6 30 01 0A 31 6F
the terminal prints strange characters. Ex: ?^A^A^@?o
Any ideas what I am doing wrong? Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.