How to communicate with multiple serial ports at the same time in Android / linux environment?

problem description

Open two serial ports at the same time in Android environment, one of them receives the instruction and sends the instruction to the other, but the command of the second serial port will block and often return garbled or the two instructions will be combined into one to send

.

the environmental background of the problems and what methods you have tried

the environment for rk3288 development board Android5.0 operating system serial port for ttl level interface uses Google android-serialport-api compiled jni library which is the most popular on the Internet. After adding the flags parameter O_NONBLOCK (non-blocking mode) of the open serial port command, there is no help to test under Windows system without any problem

related codes

mFd = open(path, baudRate, O_NOCTTY | O_NONBLOCK);

what result do you expect? What is the error message actually seen?

it is hoped that two serial ports can work at the same time without interference caused by IO blocking


when there are multiple serial ports, the path parameter of your open function is different

compare the serial port path on my machine:

$ls /dev/tty*
/dev/tty.Bluetooth-Incoming-Port 
/dev/tty.maciPhone-WirelessiAP 
...

I finally called the Android motherboard manufacturer's technical support phone to know that two TTL can't be used at the same time. So there is no proposition that "what should be paid attention to when using two serial ports at the same time"

Menu