HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • GM-3568JHF

    • 1. Introduction

      • GM-3568JHF Introduction
    • 2. Quick Start

      • 01 Environment Construction
      • 02 Compilation Instructions
      • 03 Burning Guide
      • 04 Debugging Tools
      • 05 Software Update
      • 06 View information
      • 07 Test Command
      • 08 Application Compilation
      • 09 Source code acquisition
    • 3. Peripherals and Interfaces

      • USB
      • Display and touch
      • Ethernet
      • WIFI
      • Bluetooth
      • TF-Card
      • Audio
      • Serial Port
      • CAN
      • RTC
    • 4. Application Development

      • 01 UART read and write case
      • 02 Key detection case
      • 03 LED light flashing case
      • 04 MIPI screen detection case
      • 05 Read USB device information example
      • 06 FAN Detection Case
      • 07 FPGA FSPI Communication Case
      • 08 FPGA DMA read and write case
      • 09 GPS debugging case
      • 10 Ethernet Test Cases
      • 11 RS485 reading and writing examples
      • 12 FPGA IIC read and write examples
      • 13 PN532 NFC card reader case
      • 14 TF card reading and writing case
    • 5. QT Development

      • 01 ARM64 cross compiler environment construction
      • 02 QT program added automatic startup service
    • 6. Others

      • 01 Modification of the root directory file system
      • 02 System auto-start service

11 RS485 reading and writing examples

1 Case Introduction

This case aims to introduce how to test the read and write functions of RS485 on the development board.

2 RS485 interface introduction

There are two RS485 interfaces on the development board, corresponding to UART7 and UART8 respectively. The interface wiring diagram corresponding to UART7 is as follows:

RS485_1

3 Operation process

Open the terminal and copy the executable program smdt_rs485_rw in the bin directory of this case (05-Development Materials\Software Development Materials\linux_demo\smdt_rs485_rw\bin) to the development board file system (the source code can be viewed in the src path).

Execute the following command in the terminal and switch to the directory where the smdt_rs485_rw executable program is located.

#切换到 smdt_rs485_rw  可执行程序所在目录
cd ‘the file's directory’

#查看 smdt_rs485_rw  是否在该目录下
ls

If the executable file smdt_rs485_rw is in the current directory, modify the permissions of the executable file.

#添加可执行权限
chmod +x smdt_rs485_rw

#查询是否修改成功
ls -ld smdt_rs485_rw

After confirming that the file modification permission is successful, execute ./smdt_rs485_rw -h to view the help information of the program. The default parameters of some settings in this test script are as follows: device: /dev/ttyS7, i.e. UART4 size: 1024, i.e. the default length of the received data in read mode is 1024

#查看帮助信息
./smdt_rs485_rw -h

The execution result is as follows:

RS485_2

Enter the following commands, which are read mode and receive mode respectively

#RS485读取数据模式
./smdt_rs485_rw -d /dev/ttyS7 -r

#RS485发送数据模式
./smdt_rs485_rw -d /dev/ttyS7 -w

Execute ./smdt_rs485_rw -d /dev/ttyS7 -w , it will enter the send input state, and send data when the Enter key is pressed. The execution results are as follows:

Enter Ctrl+Z to force exit this mode.

RS485_3RS485_4

Execute ./smdt_rs485_rw -d /dev/ttyS7 -r to enter the data receiving mode, receive data and stop receiving when the Enter key is pressed or the data size exceeds the limit, and display the data in the terminal window. The execution results are as follows:

Enter Ctrl+Z to force exit this mode.

RS485_5RS485_6

4 Supplementary Notes

The switching of RS485's sending and receiving modes has been integrated into the kernel driver, and the user does not need to manually control the GPIO switching . Some kernel driver codes for automatic switching of RS485 modes are as follows:

RS485_7RS485_8RS485_9RS485_10RS485_11
Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
10 Ethernet Test Cases
Next
12 FPGA IIC read and write examples