Hello, this probably is a linux issue.
i'm using boost asio 1.66 serial port on a Ubuntu Mate 64 machine, and I facing the fact that open("port name", error_code) command on an already openned port do not return an error.
My test sequence :
On the same machine I pre-open /dev/ttsS0 on minicom : minicom -D /dev/ttyS0 and check that is indeed open by sending some chars.
You could use /dev/cua*-devices for this instead of /dev/ttyS*. /dev/cua*-Devicess take exclusive use of the serial port, while /dev/ttyS* are intended for being used in interactive sessions (with a serial terminal attached). Until recently, the linux kernel included a file Documentation/devices.txt (It was there in Linux-4.9.72) saying /dev/cua* are major 5, minor 64 and up. Newer kernels describe the cua*-devices in Documentation/admin-guide/devices.rst.
Now while minicom still openned, I try openning a second minicom on same /dev/ttyS0 and this return an error : "device /dev/ttyS0 locked" as expected.
This works, because minicom uses additional locking with a lock-file. If you strace minicom, you will see, that minicom not even tried to open /dev/ttyS0. The locking procedure for serial ports also is described in Documentation/admin-guide/devices.rst. 73, Mario -- Mario Klebsch Actia I+ME GmbH Mario.klebsch@ime-actia.de Dresdenstrasse 17/18 Fon: +49 531 38 701 716 38124 Braunschweig Fax: +49 531 38 701 88 Germany