but I see the characters in the board console, only after pressing "enter" in teraterm
The behavior you describe is characteristic of canonical read (aka reading lines).
The behavior you seem to want is called non-canonical read (aka raw read or binary read).
- why are the characters received in Linux driver only when pressing enter key ?
No, the Linux serial port driver is receiving every character as it is appears on the wire.
Each character is buffered (typically in DMA-able memory), and then forwarded to a line discipline handler, which is also buffering the received data.
A canonical read() syscall by the userland program is blocked until the line discipline handler detects a line termination character.
- Is there some way to receive the characters without pressing the enter key ?
Yes, before issuing the cat
command, configure the serial port to non-canonical mode:
stty -F /dev/tty05 raw
or more likely the correct device node is
stty -F /dev/ttyO5 raw
Or use the termios interface to configure the serial port to non-canonical mode in a userspace program on the board. Sample code is here.
Documentation on how to properly program a serial port are
Serial Programming Guide for POSIX Operating Systems and Setting Terminal Modes Properly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…