4.4 rs485

This example demonstrates the MYD-AM335X series of the same type of two development board how to use the Linux API configuration development board on the RS485 and send and receive data,please refer to the source code for detail.

Hardware Preparation:

  • Hardware debugging environment to see chapter2.
Board Type MYD-AM335X MYD-AM335X-Y MYD-AM335X-J
RS485 interface U16 4,5 Pin were connected to the same type of development board 4,5 Pin CON2 5,4 Pin were connected to the same type of development board 5,4 Pin JP2 and JP3 shorted,JP5 and JP7 shorted,J18 1,2,4,5 Pin were connected to the same type of development board 1,2,4,5 Pin

Software Preparation:

  • Linux Kernel 4.1.18
  • tty_test application
Board Type MYD-AM335X MYD-AM335X-Y MYD-AM335X-J
Device node ttyO1 ttyO2 ttyO2 ttyO3

Test Steps:

  • Copy cross compiled <WORKDIR>/Examples/tty/tty_test to /usr/bin directory of the MYD-AM335X series development board, run tty_test application as below:
1
2
3
4
5
6
7
8
9
10
11
# tty_test -h
Usage: tty_test [options]
Version 1.0
Options:
-d | --device name tty device name, default: /dev/tty0
-m | --mode mode operate mode. 0: RS232, 1: RS485 default mode: 0
-f | --flow flow control
-b | --baudrate baudrate set baudrate, default baudrate: 115200
-l | --loop operate circularly
-w | --write frame frame string. such as: 0123456789
-h | --help Print this message
  • One board is used as sender, the other is used as receiver, they communicate with tty_test application as below:
1
2
3
4
# tty_test -d /dev/ttyO1 -b 9600 -w "123456789" -m 1 -l
SEND:123456789
SEND:123456789
SEND:123456789
  • Execute the following command at other board to receive data as below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# tty_test -d /dev/ttyO2 -b 9600 -m 1  -l
RECV:1, total:1
RECV:2, total:1
RECV:3, total:1
RECV:4, total:1
RECV:5, total:1
RECV:6, total:1
RECV:7, total:1
RECV:8, total:1
RECV:9, total:1
RECV:1, total:1
RECV:2, total:1
RECV:3, total:1
RECV:4, total:1
RECV:5, total:1
RECV:6, total:1
RECV:7, total:1
RECV:8, total:1
RECV:9, total:1
  • Exchange roles of the two boards, the result is the same.