Difference between revisions of "How to use TTY with User Terminal"

[quality revision] [checked revision]
m (Parity errors detection)
m
 


1 Purpose[edit]

This article describes how to use TTY with a user terminal. The TTY overview is described in Serial TTY overview article.

The use case of the following examples is a data transfer between a STM32 MPU board and PC, over a USB to a RS232 adapter cable.
The setup of this use case is described in details in the How to get Terminal article.


For the following examples:

  • uart4 is activated by default (for the Linux console)
  • usart3 is enabled by device tree
  • The usart3 pins are connected to a RS232 card
  • The RS232 card is connected to the PC over the USB to RS232 adapter cable.

Note: Some TTY tools are used in this article. A list of TTY tools is defined a dedicated article [TTY Tools ].

2 Print the file name of the terminal connected to standard input (with tty tool)[edit]

Board $> tty
# The console is connected to uart4 (aka ttySTM0) #
/dev/ttySTM0

3 Change serial port configuration (with stty tool)[edit]

Many serial port properties can be displayed and changed with the stty tool. The full feature list is available in stty user manual pages [1] .

Board $> stty --help
  • Display the current configuration:
The termios default configuration is specific to each Linux distribution. Before starting a serial communication between two devices, it's recommended to check that termios configurations are compatible on both devices. The termios configurations need to be aligned first.
Board $> stty -a -F /dev/ttySTM1
# Display the configuration of uart3 (aka ttySTM1) #
speed 115200 baud; rows 45; columns 169; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc ocrnl -onlcr -onocr onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

  • Display only the current baud rate:
Board $> stty -F /dev/ttySTM1 speed
# uart3 (aka ttySTM1) baud rate is set to 115200 bps #
115200
  • Change the baud rate:
stty -F /dev/ttySTMx EXPECTED_BAUDRATE


Example: change the baud rate to 19200
# Change uart3 (aka ttySTM1) baud rate to 19200 bps #
Board $> stty -F /dev/ttySTM1 19200

The stty tool proposes many arguments allowing many operations on a tty terminal, such as:

  • special settings (various arguments such as speed, line discipline, minimum number of characters for a completed read, size, timeout, etc...)
  • control settings
  • input settings
  • output settings
  • local settings
  • combination settings


Note: If you want to go further, an interesting tutorial describes termios and stty [2].

4 Send / Receive data (with stty, minicom, echo and cat tools)[edit]

Serial counters can be very useful to debug the following use cases.

4.1 Default configuration (8 data bits frame, no parity errors detection, no framing errors detection)[edit]

Canonical mode, input modes and output modes termios settings have a major influence on data processing. The following settings can be deactivated for testing.
In case of unexpected behavior, all canonical mode, input modes and output modes settings has to be checked. mkssoftware proposes an enriched version of termios manual [3], where following definitions are provided.

  • echo: Enable echo. If ECHO is set input characters are echoed back to the terminal.
  • icanon: Canonical input (erase and kill processing). If ICANON is set canonical processing is enabled. In canonical mode input processing is processed in units of lines. A line is delimited by a '\n' character or and end-of-file (EOF) character. A read request does not return until an entire line is read from the port or a signal is received.
  • onlcr: Map NL to CR-NL on output. If ONLCR is set the NL character is transmitted as the CR-NL character pair.

Sending data can be simply done by opening the device as a file and writing data to it.

  • Configure a port on ttySTM1 (aka usart3). echo, icanon and onlcr properties are deactivated to handle raw data.
Board $> stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr

  • Display the current configuration on ttySTM1 (usart3):
# display the configuration of uart3 (aka ttySTM1) #
Board $> stty -a -F /dev/ttySTM1
speed 115200 baud; rows 45; columns 169; line = 0;
  • Open a port on ttySTM1 (usart3) to receive data
Board $> cat /dev/ttySTM1 &
  • On the remote PC, identify the tty terminal associated to RS232 card connected on STM32MPU USART3 pins
# Command to execute from host terminal #
PC $> ls /dev/ttyUSB*
/dev/ttyUSB0

  • Open a minicom in a second terminal on the remote device connected on USART3 pins
PC $> minicom -D /dev/ttyUSB0
  • Display the current configuration on ttyUSB0 (remote device):
# Display the configuration of host uart (aka ttyUSB0) #
PC $> stty -a -F /dev/ttyUSB0
speed 115200 baud; rows 45; columns 169; line = 0;
  • Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
# Execute this command from host terminal #
PC $> echo "HELLO" > /dev/ttyUSB0
  • send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity)
# Execute this command from STM32 terminal #
Board $> echo "HELLO" > /dev/ttySTM1

4.2 Parity errors detection[edit]

Some additional termios funtions allow to enable parity errors detection:

  • parenb: Parity enable
  • parodd: Odd parity else even
  • inpck: Enable input parity or framing check
  • ignpar: Ignore characters with parity or framing errors


Exemples:

  • Configure a port on ttySTM1 (usart3) with even parity enabling
# STM32 parity enabling #
Board $> stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr parenb -parodd inpck ignpar
  • Open a port on ttySTM1 (usart3) to receive data
Board $> cat /dev/ttySTM1 &
Open a minicom in a second terminal on the remote device connected on USART3 pins
PC $> minicom -D /dev/ttyUSB0
  • Configure a port on ttyUSB0 (remote device) with even parity enabling:
# Remote device parity enabling #
PC $> stty -a -F /dev/ttyUSB0 115200 -echo -icanon -onlcr parenb -parodd inpck ignpar
speed
115200 baud; rows 45; columns 169; line = 0;

  • Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
# Execute this command from host terminal #
PC $> echo "HELLO" > /dev/ttyUSB0
  • send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity)
#  Execute this command from STM32 terminal #
Board $> echo "HELLO" > /dev/ttySTM1


4.3 Framing errors detection[edit]

Some additional termios funtions allow to enable framing errors detection:


Exemples:

  • Configure a port on ttySTM1 (usart3) with framing check enabling and 7 data bits length frames
# STM32 framing enabling #
Board $> stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr cs7 inpck ignpar
  • Open a port on ttySTM1 (usart3) to receive data
Board $> cat /dev/ttySTM1 &
Open a minicom in a second terminal on the remote device connected on USART3 pins
PC $> minicom -D /dev/ttyUSB0
  • Configure a port on ttyUSB0 (remote device) with framing check enabling and 7 data bits length frames
# Remote device parity enabling #
PC $> stty -a -F /dev/ttyUSB0 115200 -echo -icanon -onlcr cs7 inpck ignpar
speed 115200 baud; rows 45; columns 169; line = 0;
  • Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
# Execute this command from host terminal #
PC $> echo "HELLO" > /dev/ttyUSB0
  • send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity)
# Execute this command from STM32 terminal #
Board $> echo "HELLO" > /dev/ttySTM1

5 Identify processes using a tty serial device (with fuser tool)[edit]

Board $> fuser /dev/ttySTM0
# The process numbered 395, 691 and 3872 are using a tty serial device #
395 691 3872

6 Link a tty serial device with a line discipline (with ldattach tool)[edit]

Attach ttySTM1 with line discipline number n :

Board $> ldattach n /dev/ttySTM1

7 File transfer over serial console[edit]

Please see the dedicated article How to transfer a file over serial console.

8 References[edit]



<noinclude>

{{ArticleMainWriter | ErwanLR}}
{{ArticleApprovedVersion | ErwanLR | FabriceG (Passed), AlexandreT (Passed) , NathalieS | No previous approved version | AlainF - 14Aug'18 - 8369 | 28Aug'18}}
{{UpdateNeededForNewRelease}}

[[Category:Serial TTY|3]]</noinclude>
__TOC__<br />


==Purpose==
This article describes how to use TTY with a user terminal. The TTY overview is described in [[Serial TTY overview]] article. <br/>


The use case of the following examples is a data transfer between a STM32 MPU board and PC, over a USB to a RS232 adapter cable. <br/>

The setup of this use case is described in details in the [[How_to_get_Terminal#Remote Terminal via serial link (UART/USB)|How to get Terminal]] article.

For the following examples:

* uart4 is activated by default (for the Linux console)
* usart3 is enabled by [[Serial TTY_device_tree_configuration#Activation_of_a_USART_or_UART_instance|device tree]]
* The usart3 pins are connected to a RS232 card
* The RS232 card is connected to the PC over the USB to RS232 adapter cable.

Note: Some TTY tools are used in this article. A list of TTY tools is defined a dedicated article [TTY Tools ].

== Print the file name of the terminal connected to standard input (with tty tool)==
 {{Board$}} tty
 {{highlight|# The console is connected to uart4 (aka ttySTM0) #}}
 {{Green|'''/dev/ttySTM0'''}}

==Change serial port configuration (with stty tool)==
Many serial port properties can be displayed and changed with the stty tool. The full feature list is available in stty user manual pages <ref>[https://linux.die.net/man/1/stty stty manual page]</ref> .
 {{Board$}} stty --help

* Display the current configuration: : The termios default configuration is specific to each Linux distribution. Before starting a serial communication between two devices, it's recommended to check that termios configurations are compatible on both devices. The termios configurations need to be aligned first.
{{Board$}} stty -a -F /dev/ttySTM1
 {{highlight|# Display the configuration of uart3 (aka ttySTM1) #}}
 speed 115200 baud; rows 45; columns 169; line = 0;intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
 stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
 discard = ^O; min = 1; time = 0;
 -parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
 -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
 opost -olcuc ocrnl -onlcr -onocr onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
 isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
* Display only the current baud rate:
 {{Board$}} stty -F /dev/ttySTM1 speed
 {{highlight|# uart3 (aka ttySTM1) baud rate is set to 115200 bps #}}
 115200

* Change the baud rate: : stty -F /dev/ttySTMx ''EXPECTED_BAUDRATE''<br/>
<br/>
: Example: change the baud rate to 19200
 {{highlight|# Change uart3 (aka ttySTM1) baud rate to 19200 bps #}}
 {{Board$}} stty -F /dev/ttySTM1 19200

The stty tool proposes many arguments allowing many operations on a tty terminal, such as: 
* special settings (various arguments such as speed, line discipline, minimum number of characters for a completed read, size, timeout, etc...)
* control settings
* input settings
* output settings
* local settings
* combination settings
<br/>

'''Note''': If you want to go further, an interesting tutorial describes termios and stty <ref>[https://blog.nelhage.com/2009/12/a-brief-introduction-to-termios-termios3-and-stty/ A Brief Introduction to termios: termios(3) and stty] stty tutorial</ref>.

==Send / Receive data (with stty, minicom, echo and cat tools)==
[[Serial_TTY_overview#procfs_serialcounters|Serial counters]] can be very useful to debug the following use cases.
===Default configuration (8 data bits frame, no parity errors detection, no framing errors detection)===Canonical mode, input modes and output modes termios settings have a major influence on data processing. The following settings can be deactivated for testing. <br/>

In case of unexpected behavior, all canonical mode, input modes and output modes settings has to be checked.
mkssoftware proposes an enriched version of termios manual <ref>[https://www.mkssoftware.com/docs/man5/struct_termios.5.asp struct_termios man page]</ref>, where following definitions are provided.
* echo: Enable echo. If ECHO is set input characters are echoed back to the terminal.<br/>

* icanon: Canonical input (erase and kill processing). If ICANON is set canonical processing is enabled. In canonical mode input processing is processed in units of lines. A line is delimited by a '\n' character or and end-of-file (EOF) character. A read request does not return until an entire line is read from the port or a signal is received.<br/>

* onlcr: Map NL to CR-NL on output. If ONLCR is set the NL character is transmitted as the CR-NL character pair.
Sending data can be simply done by opening the device as a file and writing data to it.<br/>

* Configure a port on ttySTM1 (aka usart3)
. echo, icanon and onlcr properties are deactivated to handle raw data.{{Board$}} stty -F /dev/ttySTM1 115200 -echo 
-icanon -onlcr
* Display the current configuration on ttySTM1 (usart3):
 {{highlight|# display the configuration of uart3 (aka ttySTM1) #}}
 {{Board$}} stty -a -F /dev/ttySTM1
 speed 115200 baud; rows 45; columns 169; line = 0;

* Open a port on ttySTM1 (usart3) to receive data
 {{Board$}} cat /dev/ttySTM1 &

* On the remote PC, identify the tty terminal associated to RS232 card connected on STM32MPU USART3 pins
 {{highlight|# Command to execute from host terminal #}}
 {{PC$}} ls /dev/ttyUSB* /dev/ttyUSB0

* Open a minicom in a second terminal on the remote device connected on USART3 pins
 {{PC$}} minicom -D /dev/ttyUSB0

* Display the current configuration on ttyUSB0 (remote device):
 {{highlight|# Display the configuration of host uart (aka ttyUSB0) #}}
 {{PC$}} stty -a -F /dev/ttyUSB0
 speed 115200 baud; rows 45; columns 169; line = 0;

* Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
 {{highlight|# Execute this command from host terminal #}}
 {{PC$}} echo "HELLO" > /dev/ttyUSB0

* send data from STM32MPU to remote PC over USART3  with default termios configuration (8 frames length, no parity)
 {{highlight|# Execute this command from STM32 terminal #}}
 {{Board$}} echo "HELLO" > /dev/ttySTM1

===Parity errors detection===
Some additional termios funtions allow to enable parity errors detection:
* parenb: Parity enable
* parodd: Odd parity else even
* inpck: Enable input parity or framing check
* ignpar: Ignore characters with parity or framing errors<br/>

Exemples:
* Configure a port on ttySTM1 (usart3) with even parity enabling
 {{highlight|# STM32 parity enabling #}}
 {{Board$}} stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr parenb -parodd inpck ignpar

* Open a port on ttySTM1 (usart3) to receive data
 {{Board$}} cat /dev/ttySTM1 &

 Open a minicom in a second terminal on the remote device connected on USART3 pins
 {{PC$}} minicom -D /dev/ttyUSB0

* Configure a port on ttyUSB0 (remote device) with even parity enabling:
 {{highlight|# Remote device parity enabling #}}
 {{PC$}} stty -a -F /dev/ttyUSB0 115200 -echo -icanon -onlcr parenb -parodd inpck ignparspeed 115200 baud; rows 45; columns 169; line = 0;

* Send data from remote PC to STM32MPU over USART3with default termios configuration (8 frames length, no parity) {{highlight|# Execute this command from host terminal #}}
 {{PC$}} echo "HELLO" > /dev/ttyUSB0

* send data from STM32MPU to remote PC over USART3with default termios configuration (8 frames length, no parity){{highlight|#  Execute this command from STM32 terminal #}}
 {{Board$}} echo "HELLO" > /dev/ttySTM1<br/>


===Framing errors detection===
Some additional termios funtions allow to enable framing errors detection:
* csize: Number of bits per byte (CS5, CS6, CS7, or CS8[[Serial_TTY_overview#CSIZE_configurations|character size and parity bit configurations]])
* inpck: Enable input framing check
* ignpar: Ignore characters with parity or framing errors<br/>

Exemples:
* Configure a port on ttySTM1 (usart3) with framing check enabling and 7 data bits length frames
 {{highlight|# STM32 framing enabling #}}
 {{Board$}} stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr cs7 inpck ignpar

* Open a port on ttySTM1 (usart3) to receive data
 {{Board$}} cat /dev/ttySTM1 &

 Open a minicom in a second terminal on the remote device connected on USART3 pins
 {{PC$}} minicom -D /dev/ttyUSB0

* Configure a port on ttyUSB0 (remote device) with framing check enabling and 7 data bits length frames
 {{highlight|# Remote device parity enabling #}}
 {{PC$}} stty -a -F /dev/ttyUSB0 115200 -echo -icanon -onlcr cs7 inpck ignpar
 speed 115200 baud; rows 45; columns 169; line = 0;

* Send data from remote PC to STM32MPU over USART3with default termios configuration (8 frames length, no parity) {{highlight|# Execute this command from host terminal #}}
 {{PC$}} echo "HELLO" > /dev/ttyUSB0

* send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity) {{highlight|# Execute this command from STM32 terminal #}}
 {{Board$}} echo "HELLO" > /dev/ttySTM1

==Identify processes using a tty serial device (with fuser tool)==
 {{Board$}} fuser /dev/ttySTM0
 {{highlight|# The process numbered 395, 691 and 3872 are using a tty serial device #}}
 395 691 3872

==Link a tty serial device with a line discipline (with ldattach tool)==

Attach ttySTM1 with [[Serial TTY line discipline|line discipline]] number ''n'' :
 {{Board$}} ldattach ''n'' /dev/ttySTM1

==File transfer over serial console==
Please see the dedicated article [[How to transfer a file over serial console]].

==References==<references />

<noinclude>

{{ArticleMainWriter | ErwanLR}}
{{ArticleApprovedVersion | ErwanLR | FabriceG (Passed), AlexandreT (Passed) , NathalieS | No previous approved version | AlainF - 14Aug'18 - 8369 | 28Aug'18}}

[[Category:Serial TTY|3]]</noinclude>
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>
 
{{ArticleMainWriter | ErwanLR}}
 
{{ArticleApprovedVersion | ErwanLR | FabriceG (Passed), AlexandreT (Passed) , NathalieS | No previous approved version | AlainF - 14Aug'18 - 8369 | 28Aug'18}}
 
{{UpdateNeededForNewRelease}}
 
 
[[Category:Serial TTY|3]]
 
</noinclude>
 
 
__TOC__
 
__TOC__
 
<br />
 
<br />
Line 35: Line 28:
   
 
* Display the current configuration:
 
* Display the current configuration:
  +
: The termios default configuration is specific to each Linux distribution. Before starting a serial communication between two devices, it's recommended to check that termios configurations are compatible on both devices. The termios configurations need to be aligned first.
  +
 
  {{Board$}} stty -a -F /dev/ttySTM1
 
  {{Board$}} stty -a -F /dev/ttySTM1
 
  {{highlight|# Display the configuration of uart3 (aka ttySTM1) #}}
 
  {{highlight|# Display the configuration of uart3 (aka ttySTM1) #}}
 
  speed 115200 baud; rows 45; columns 169; line = 0;
 
  speed 115200 baud; rows 45; columns 169; line = 0;
  +
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
  +
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
  +
discard = ^O; min = 1; time = 0;
  +
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
  +
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
  +
opost -olcuc ocrnl -onlcr -onocr onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
  +
isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
   
 
* Display only the current baud rate:
 
* Display only the current baud rate:
Line 45: Line 47:
   
 
* Change the baud rate:  
 
* Change the baud rate:  
stty -F /dev/ttySTMx ''EXPECTED_BAUDRATE''<br/>
+
: stty -F /dev/ttySTMx ''EXPECTED_BAUDRATE''<br/>
 
<br/>
 
<br/>
Example: change the baud rate to 19200
+
: Example: change the baud rate to 19200
 
  {{highlight|# Change uart3 (aka ttySTM1) baud rate to 19200 bps #}}
 
  {{highlight|# Change uart3 (aka ttySTM1) baud rate to 19200 bps #}}
 
  {{Board$}} stty -F /dev/ttySTM1 19200
 
  {{Board$}} stty -F /dev/ttySTM1 19200
Line 63: Line 65:
   
 
==Send / Receive data (with stty, minicom, echo and cat tools)==
 
==Send / Receive data (with stty, minicom, echo and cat tools)==
  +
  +
[[Serial_TTY_overview#procfs_serialcounters|Serial counters]] can be very useful to debug the following use cases.
   
 
===Default configuration (8 data bits frame, no parity errors detection, no framing errors detection)===
 
===Default configuration (8 data bits frame, no parity errors detection, no framing errors detection)===
  +
Canonical mode, input modes and output modes termios settings have a major influence on data processing. The following settings can be deactivated for testing. <br/>
  +
In case of unexpected behavior, all canonical mode, input modes and output modes settings has to be checked.
  +
mkssoftware proposes an enriched version of termios manual <ref>[https://www.mkssoftware.com/docs/man5/struct_termios.5.asp struct_termios man page]</ref>, where following definitions are provided.
  +
* echo: Enable echo. If ECHO is set input characters are echoed back to the terminal.<br/ >
  +
* icanon: Canonical input (erase and kill processing). If ICANON is set canonical processing is enabled. In canonical mode input processing is processed in units of lines. A line is delimited by a '\n' character or and end-of-file (EOF) character. A read request does not return until an entire line is read from the port or a signal is received.<br/ >
  +
* onlcr: Map NL to CR-NL on output. If ONLCR is set the NL character is transmitted as the CR-NL character pair.
  +
 
Sending data can be simply done by opening the device as a file and writing data to it.
 
Sending data can be simply done by opening the device as a file and writing data to it.
 
<br/>
 
<br/>
* Configure a port on ttySTM1 (aka usart3)
+
* Configure a port on ttySTM1 (aka usart3). echo, icanon and onlcr properties are deactivated to handle raw data.
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo
+
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr
   
 
* Display the current configuration on ttySTM1 (usart3):
 
* Display the current configuration on ttySTM1 (usart3):
Line 81: Line 92:
 
  {{highlight|# Command to execute from host terminal #}}
 
  {{highlight|# Command to execute from host terminal #}}
 
  {{PC$}} ls /dev/ttyUSB*
 
  {{PC$}} ls /dev/ttyUSB*
/dev/ttyUSB0
+
/dev/ttyUSB0
   
 
* Open a minicom in a second terminal on the remote device connected on USART3 pins
 
* Open a minicom in a second terminal on the remote device connected on USART3 pins
Line 109: Line 120:
 
* Configure a port on ttySTM1 (usart3) with even parity enabling
 
* Configure a port on ttySTM1 (usart3) with even parity enabling
 
  {{highlight|# STM32 parity enabling #}}
 
  {{highlight|# STM32 parity enabling #}}
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo parenb -parodd inpck ignpar
+
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr parenb -parodd inpck ignpar
   
 
* Open a port on ttySTM1 (usart3) to receive data
 
* Open a port on ttySTM1 (usart3) to receive data
Line 119: Line 130:
 
* Configure a port on ttyUSB0 (remote device) with even parity enabling:
 
* Configure a port on ttyUSB0 (remote device) with even parity enabling:
 
  {{highlight|# Remote device parity enabling #}}
 
  {{highlight|# Remote device parity enabling #}}
  {{PC$}} stty -a -F /dev/ttyUSB0 115200 -echo parenb -parodd inpck ignpar
+
  {{PC$}} stty -F /dev/ttyUSB0 115200 -echo -icanon -onlcr parenb -parodd inpck ignpar
  speed 115200 baud; rows 45; columns 169; line = 0;
+
   
 
+
* Send data from remote PC to STM32MPU over USART3
* Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
 
 
  {{highlight|# Execute this command from host terminal #}}
 
  {{highlight|# Execute this command from host terminal #}}
 
  {{PC$}} echo "HELLO" > /dev/ttyUSB0
 
  {{PC$}} echo "HELLO" > /dev/ttyUSB0
   
* send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity)
+
* send data from STM32MPU to remote PC over USART3
 
  {{highlight|#  Execute this command from STM32 terminal #}}
 
  {{highlight|#  Execute this command from STM32 terminal #}}
 
  {{Board$}} echo "HELLO" > /dev/ttySTM1
 
  {{Board$}} echo "HELLO" > /dev/ttySTM1
Line 133: Line 143:
 
===Framing errors detection===
 
===Framing errors detection===
 
Some additional termios funtions allow to enable framing errors detection:
 
Some additional termios funtions allow to enable framing errors detection:
* csize: Number of bits per byte (CS5, CS6, CS7, or CS8)
+
* csize: Number of bits per byte ([[Serial_TTY_overview#CSIZE_configurations|character size and parity bit configurations]])
 
* inpck: Enable input framing check
 
* inpck: Enable input framing check
 
* ignpar: Ignore characters with parity or framing errors
 
* ignpar: Ignore characters with parity or framing errors
Line 140: Line 150:
 
* Configure a port on ttySTM1 (usart3) with framing check enabling and 7 data bits length frames
 
* Configure a port on ttySTM1 (usart3) with framing check enabling and 7 data bits length frames
 
  {{highlight|# STM32 framing enabling #}}
 
  {{highlight|# STM32 framing enabling #}}
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo cs7 inpck ignpar
+
  {{Board$}} stty -F /dev/ttySTM1 115200 -echo -icanon -onlcr cs7 inpck ignpar
   
 
* Open a port on ttySTM1 (usart3) to receive data
 
* Open a port on ttySTM1 (usart3) to receive data
Line 150: Line 160:
 
* Configure a port on ttyUSB0 (remote device) with framing check enabling and 7 data bits length frames
 
* Configure a port on ttyUSB0 (remote device) with framing check enabling and 7 data bits length frames
 
  {{highlight|# Remote device parity enabling #}}
 
  {{highlight|# Remote device parity enabling #}}
  {{PC$}} stty -a -F /dev/ttyUSB0 115200 -echo cs7 inpck ignpar
+
  {{PC$}} stty -a -F /dev/ttyUSB0 115200 -echo -icanon -onlcr cs7 inpck ignpar
 
  speed 115200 baud; rows 45; columns 169; line = 0;
 
  speed 115200 baud; rows 45; columns 169; line = 0;
   
* Send data from remote PC to STM32MPU over USART3 with default termios configuration (8 frames length, no parity)
+
* Send data from remote PC to STM32MPU over USART3
 
  {{highlight|# Execute this command from host terminal #}}
 
  {{highlight|# Execute this command from host terminal #}}
 
  {{PC$}} echo "HELLO" > /dev/ttyUSB0
 
  {{PC$}} echo "HELLO" > /dev/ttyUSB0
   
* send data from STM32MPU to remote PC over USART3 with default termios configuration (8 frames length, no parity)
+
* send data from STM32MPU to remote PC over USART3  
 
  {{highlight|# Execute this command from STM32 terminal #}}
 
  {{highlight|# Execute this command from STM32 terminal #}}
 
  {{Board$}} echo "HELLO" > /dev/ttySTM1
 
  {{Board$}} echo "HELLO" > /dev/ttySTM1
Line 176: Line 186:
 
==References==
 
==References==
 
<references />
 
<references />
  +
  +
<noinclude>
  +
{{ArticleMainWriter | ErwanLR}}
  +
{{ArticleApprovedVersion | ErwanLR | FabriceG (Passed), AlexandreT (Passed) , NathalieS | No previous approved version | AlainF - 14Aug'18 - 8369 | 28Aug'18}}
  +
  +
[[Category:Serial TTY|3]]
  +
</noinclude>

Attachments

Discussions