Why characters received in serial connection only after pressing enter key?
I have a simple PC to connect to the board using serial (9600, no parity, 8 bits, no hw stream) I opened a simple terminal * with teraterm) on the PC and enter the keys into teraterm and on the board, I just do
cat /dev/ttyO5
I can see the characters pressed in scope, but I can see the characters in the console, only after hitting "enter" in teraterm (as if they were stored in some FIFOs in the Linux driver that only type triggers)
- why are characters received in Linux driver only when enter key is pressed?
- Is there a way to get characters without pressing the enter key? (we are using some kind of ascii protocol so there is no point in sending this as a dummy)
Thanks for the consultation, Ran
source to share
but I see symbols on the console, only after pressing "enter" in teraterm
The behavior you are describing is specific to canonical reads (so called read lines).
The behavior you seem to want is called non-canonical reading (just like raw reading or binary reading).
- why are characters received in Linux driver only when enter key is pressed?
No, the Linux serial driver gets every character as it appears on the wire.
Each character is buffered (usually in DMA memory) and then redirected to a line handler, which also buffers the received data.
The canonical read () syscall by userland blocks until the line handler detects a line termination character.
- Is there a way to get characters without pressing the enter key?
Yes, before issuing the command, cat
configure the serial port in non-canonical mode:
stty -F /dev/tty05 raw
or most likely correct node device
stty -F /dev/ttyO5 raw
Or, use the termios interface to configure the serial port in non-canonical mode in an on-board user-space program. Sample code here .
Documentation on How to Program the Serial Port Correctly, Serial Programming Guide for POSIX Operating Systems, and Correctly Configuring Terminal Modes .
source to share