Benutzer:Rdiez/SerialPortTipsForLinux
Aus /dev/tal
< Benutzer:Rdiez
Version vom 9. Mai 2014, 18:33 Uhr von Rdiez (Diskussion | Beiträge) (No concurrency protection under Linux)
Dies sind die persönlichen Benutzerseiten von rdiez, bitte nicht verändern! Ausnahmen sind nur einfache Sprachkorrekturen wie Tippfehler, falsche Präpositionen oder Ähnliches. Alles andere bitte nur dem Benutzer melden! |
Serial Port Tips for Linux
Set the default configuration with stty to 9600 bps, 8N1, no flow control:
stty -F /dev/serial_port cs8 -parenb -cstopb -clocal raw speed 9600 # What the arguments mean: # cs8: 8 data bits # -parenb: No parity (because of the '-') # -cstopb: 1 stop bit (because of the '-') # -clocal: Disable modem control signals
No exclusive lock when accessing serial ports
I was surprised to learn that several Linux processes can open a given serial port at the same time. This usually makes a mess of the data. If you make a mistake and try to use the same port from several concurrent scripts, it may take a while to figure out why the data is getting chopped and mixed up in random ways.
There is no exclusive lock when opening serial port files, like there is under Windows. As far as I know, there is no way to enforce such a protection against concurrent access at system level. If you do know how to achieve that, please drop me a line!