Difference between revisions of "ASR-A501 UART(COM1/2/3/4)"

From ESS-WIKI
Jump to: navigation, search
(SW Function:)
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
  
 
[[File:ASR-A501 COM3 4.png|RTENOTITLE]]
 
[[File:ASR-A501 COM3 4.png|RTENOTITLE]]
 
  
 
=== '''SW Function:''' ===
 
=== '''SW Function:''' ===
  
[[File:ASR-A501 UART.png]]
+
[[File:ASR-A501 UART.png|RTENOTITLE]]
  
 
=== '''Configure RS232 or RS485''' ===
 
=== '''Configure RS232 or RS485''' ===
Line 59: Line 58:
 
=== '''Send and Receive Data''' ===
 
=== '''Send and Receive Data''' ===
  
 
+
'''Taking COM4 as receiver and COM2 as sender:'''
 +
<pre># #---- COM4 as receiver ----# #
 +
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
 +
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
 +
 
 +
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
 +
# stty -F /dev/ttyS5 115200 cs8 -cstopb -parenb -crtscts
 +
# echo pass > /dev/ttyS5
 +
 
 +
# #----If no error, the receiver will receive “pass”----# #
 +
pass</pre>
 +
 
 +
[[File:ASR-A501 RS232.png|RTENOTITLE]]

Latest revision as of 02:45, 5 June 2025

User Debian/Linux UART/serial port access is through the tty-devices. The ttydevices have different names depending on UART drivers for different boards.

HW Pin define:

RTENOTITLE

RTENOTITLE

SW Function:

RTENOTITLE

Configure RS232 or RS485

ttyS3 and ttyS5 support only RS485 mode, whereas ttyS6 and ttyS9 support configuration for both RS232 and RS485 modes. The default mode is RS232.

Set RS232 or RS485 separately(0 means RS232;1 means RS485):

Set ttyS6 to RS232 mode and ttyS9 to RS232 mode.

# fw_setenv uart_mode_cpu 6:0,9:0
# reboot

Set ttyS6 to RS232 mode and ttyS9 to RS485 mode.

# fw_setenv uart_mode_cpu 6:0,9:1
# reboot

Set ttyS6 to RS485 mode and ttyS9 to RS232 mode.

# fw_setenv uart_mode_cpu 6:1,9:0
# reboot

Set ttyS6 to RS485 mode and ttyS9 to RS485 mode.

# fw_setenv uart_mode_cpu 6:1,9:1
# reboot

Configure Parameters

Use “stty” command to configure serial port parameters. The commonly used parameters include “Baud rate”, “Data bits”, “Stop bits”, “Parity”, “Flow control”.
See details of the usage of “stty”:

# stty --help
… …
csN set character size to N bits, N in [5..8]
[-]cstopb use two stop bits per character (one with '-')
[-]parenb generate parity bit in output and expect parity bit in input
[-]crtscts enable RTS/CTS handshaking

… …

For example,

set COM4 "Baud rate" to 115200 “Data bits” to 8 “Stop bits” to 1 “Parity” to None “Flow control” to None.

# stty -F /dev/ttyS3 115200 cs8 -parenb -cstopb -crtscts

Send and Receive Data

Taking COM4 as receiver and COM2 as sender:

# #---- COM4 as receiver ----# #
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts

# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
# stty -F /dev/ttyS5 115200 cs8 -cstopb -parenb -crtscts
# echo pass > /dev/ttyS5

# #----If no error, the receiver will receive “pass”----# #
pass

RTENOTITLE