Difference between revisions of "AFE-E630 COM0、COM1"

From ESS-WIKI
Jump to: navigation, search
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
[[File:AFE-E630 COM0 1.png]]
+
=== '''UART(RS232 or RS485)''' ===
  
[[File:AFE-E630 COM0 10.png]]
+
[[File:AFE-E630 COM0 1.png|RTENOTITLE]]
 +
 
 +
[[File:AFE-E630 COM0 10.png|RTENOTITLE]]
 +
 
 +
=== '''Configure RS232 or RS485''' ===
 +
 
 +
Only ttyS3 and ttyS4 support RS485 mode and the default mode is RS485. Set RS232 or RS485 separately (0 means to RS232; 1 means to RS485):<br/> '''Set ttyS3 to RS232 mode and ttyS4 to RS232 mode'''
 +
<pre># fw_setenv uart_mode_cpu 3:0,4:0
 +
# reboot
 +
</pre>
 +
 
 +
'''Set ttyS3 to RS232 mode and ttyS4 to RS485 mode'''
 +
<pre># fw_setenv uart_mode_cpu 3:0,4:1
 +
# reboot
 +
</pre>
 +
 
 +
'''Set ttyS3 to RS485 mode and ttyS4 to RS232 mode.'''
 +
<pre># fw_setenv uart_mode_cpu 3:1,4:0
 +
# reboot
 +
</pre>
 +
 
 +
'''Set ttyS3 to RS485 mode and ttyS4 to RS485 mode.'''
 +
<pre># fw_setenv uart_mode_cpu 3:1,4:1
 +
# reboot
 +
</pre>
 +
 
 +
For example, set COM0 ,“Baud rate” to 115200 ,“Data bits” to 8,“Stop bits” to 1,“Parity” to None,“Flow control” to None.
 +
<pre># stty -F /dev/ttyS3 115200 cs8 -parenb -cstopb -crtscts
 +
</pre>
 +
 
 +
=== '''Send and Receive Data''' ===
 +
 
 +
The following figure shows the connection mode.
 +
 
 +
COM0_GND=>COM1_GND
 +
 
 +
COM0_RS232-TX=>COM1_RS232-TX
 +
 
 +
COM0_RS485+/RS232-RX=>COM1_RS485+/RS232-RX
 +
 
 +
COM0_RS485-=>COM1_RS485-
 +
 
 +
[[File:AFE-E630 COM0 COM1-RS485 1.png|600x220px|AFE-E630 COM0 COM1-RS485 1.png]]
 +
 
 +
Taking COM0 as receiver and COM1 as sender(RS485)&nbsp;:
 +
<pre># #---- COM0 as receiver ----# #
 +
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
 +
# cat /dev/ttyS3 &
 +
 
 +
# #---- COM1 as sender ----# #
 +
# stty -F /dev/ttyS4 115200 cs8 -cstopb -parenb -crtscts
 +
# echo pass > /dev/ttyS4
 +
 
 +
# #----If no error, the receiver will receive “pass”----# #
 +
pass</pre>
 +
 
 +
[[File:AFE-E630 COM0 COM1-RS485.png|RTENOTITLE]]
 +
 
 +
Note:
 +
 
 +
1、Receiver should run before sender.
 +
 
 +
2、The “serial port parameters” should be the same for sender and receiver.

Latest revision as of 02:03, 18 December 2024

UART(RS232 or RS485)

RTENOTITLE

RTENOTITLE

Configure RS232 or RS485

Only ttyS3 and ttyS4 support RS485 mode and the default mode is RS485. Set RS232 or RS485 separately (0 means to RS232; 1 means to RS485):
Set ttyS3 to RS232 mode and ttyS4 to RS232 mode

# fw_setenv uart_mode_cpu 3:0,4:0
# reboot

Set ttyS3 to RS232 mode and ttyS4 to RS485 mode

# fw_setenv uart_mode_cpu 3:0,4:1
# reboot

Set ttyS3 to RS485 mode and ttyS4 to RS232 mode.

# fw_setenv uart_mode_cpu 3:1,4:0
# reboot

Set ttyS3 to RS485 mode and ttyS4 to RS485 mode.

# fw_setenv uart_mode_cpu 3:1,4:1
# reboot

For example, set COM0 ,“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

The following figure shows the connection mode.

COM0_GND=>COM1_GND

COM0_RS232-TX=>COM1_RS232-TX

COM0_RS485+/RS232-RX=>COM1_RS485+/RS232-RX

COM0_RS485-=>COM1_RS485-

AFE-E630 COM0 COM1-RS485 1.png

Taking COM0 as receiver and COM1 as sender(RS485) :

# #---- COM0 as receiver ----# #
# stty -F /dev/ttyS3 115200 cs8 -cstopb -parenb -crtscts
# cat /dev/ttyS3 &

# #---- COM1 as sender ----# #
# stty -F /dev/ttyS4 115200 cs8 -cstopb -parenb -crtscts
# echo pass > /dev/ttyS4

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

RTENOTITLE

Note:

1、Receiver should run before sender.

2、The “serial port parameters” should be the same for sender and receiver.