IOT: Is there any way to check serial port are having signal before connecting?

42 Views Asked by At

I have a range of product types. Some of them only use 2 in 4 serial ports (tty0, tty1, tty2 & tty3). In case my product type only uses tty0 and tty1, I want my app to self-identify these 2 ports and only open FileInputStream to listen to data. If you have worked with this before. I hope you can help. Thanks!

I tried to use some of command in linux but it only list the available ports, not connected ports.

Solution: my problem actually is connecting all above ports may affect another process like Bluetooth. I changed my approach to detect which port is being used by com.android.bluetooth process. Command is lsof | grep dev/ttyS* and find is there any bluetooth process.

Sorry for my first time working with IoT system, so the concept may be incorrect at some point.

0

There are 0 best solutions below