Android Question Serial in Linux

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello All,
I am trying to use the JSerial lib in ubuntu with no success.
Anyone knows if I can use this Lib in Linux ?
I get an exception error when i try to open the com1 (its working and reported in system) /dev/ttyS0
And even a simple application to list all ports serial.listports returns a empty list. (works in Windows)
I have a RSR232 CardReader that I need to use, so any suggestions would be welcome.
 

OliverA

Expert
Licensed User
Longtime User
It's most likely a permission issue. Try running your application using sudo. In my case the jar is called serialtest.jar, so I use the command
sudo java -jar serialtest.jar
If you want to run the application without using sudo constantly, you have to add your user to the correct group. In my case it is the dialout group (Ubuntu Server 16.04 LTS). To see what group your port belongs to you can issue
ls -l /dev/ttyS0
Example (in my case)
olivera@styx:~$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Sep 26 11:54 /dev/ttyS0
Now I just add myself to the group dialout with
sudo usermod -a -G dialout olivera
Then I log out and back in and voila, I can run the application without sudo.

Reference:
https://unix.stackexchange.com/questions/14354/read-write-to-a-serial-port-without-root
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
It's most likely a permission issue. Try running your application using sudo. In my case the jar is called serialtest.jar, so I use the command If you want to run the application without using sudo constantly, you have to add your user to the correct group. In my case it is the dialout group (Ubuntu Server 16.04 LTS). To see what group your port belongs to you can issue Example (in my case)
Now I just add myself to the group dialout with Then I log out and back in and voila, I can run the application without sudo.

Reference:
https://unix.stackexchange.com/questions/14354/read-write-to-a-serial-port-without-root
Hello Oliver,

i have some problem with my FriendlyAm NanoPc-T2 Andorid.
I can't access to /dev/ttyAMA3 from my App
To access i must sign Apk with Rom signature:
java -jar ./signapk.jar platform.x509.pem platform.pk8 ./SerialPortDemo.apk SerialPortDemo-Signed.apk

and add this in APK manifest :
SetManifestAttribute(android:sharedUserId,"android.uid.system")

then install Apk using :
ADB install -r myapk-signed.apk

but cannot auto-update apk see:
https://www.b4x.com/android/forum/threads/auto-update-apk-signed-with-rom-key.116613/#post-729464

I think it's same problem, how can add use a user ?
 
Upvote 0
Top