当前位置:网站首页>[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
2022-07-05 08:02:00 【Changjiang houlang blog】
Dear friends , Hello everyone ! Today brings you the most basic functions , A serial port communication . I believe this is no stranger .modbusRTU,Membus And other protocols are based on the software communication protocol built on the serial port . I hope this blog will bring you a little harvest , Old bird can skip this chapter ...
Don't talk too much , Today, let's talk about the most basic communication function , Ten thousand tall buildings rise from the ground
.
Before talking about serial communication , Let's list the relevant instructions :
1.
GET Get a character from the data buffer stream
Examples are as follows :
// Get a character and store it in a temporary variable
DIM get_str ASINTEGER
GET #2,get_str
2.
PRINT Send data by character stream
Examples are as follows :
// Send a string
PRINT #2,"This is Test:"
// Send a character
PRINT #2,CHR(48);
PRINT #2,CHR($30);
3.
ADDRESS Serial port site address
4.
SETCOM Set serial communication parameters
Let's focus on setcom

Examples are as follows :(1) Set up local site 2, Baud rate 9600,8 Data bits ,1 Stop bits , Even check ,232 Hardware , Free port communication
ADDRESS=2
SETCOM(9600,8,1,2,1,0)
(2) Set up local site 1, Baud rate 9600,8 Data bits ,1 Stop bits , Even check ,485 Hardware , Free port communication
ADDRESS=1
SETCOM(9600,8,1,2,2,0,0,3,0)
The preparatory knowledge is finished , Then let's look at the code , See the implementation effect .
DIM get_str,data_num AS INTEGER
ADDRESS=1
'RS232
SETCOM(9600,8,1,2,1,0)
'RS485
SETCOM(9600,8,1,2,2,0,0,3,0)
WA(100)
WHILE TRUE
PRINT #2,"This is Test:"
PRINT #2,data_num;CHR(13);CHR(10);
WA(100)
IF KEY #2 THEN
WHILE KEY #2
GET #2,get_str
PRINT #2,CHR(get_str);
WEND
ENDIF
data_num=data_num+1
WEND matters needing attention : Baud rate of communication between sender and receiver 、 Stop bit 、 The check bits need to be consistent . 
Execution effect

Sending and receiving are normal
Dear brothers , Brothers and sisters , That's all for today , Thank you for reading ...
边栏推荐
- [professional literacy] specific direction of analog integrated circuits
- How to define guid in AMI code
- Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Embedded AI intelligent technology liquid particle counter
- Drive LED -- GPIO control
- UEFI development learning 4 - getting to know variable services
- 找不到实时聊天软件?给你推荐电商企业都在用的!
- 1089 Insert or Merge 含测试点5
- C WinForm [exit application] - practice 3
- Class of color image processing based on Halcon learning_ ndim_ norm. hdev
猜你喜欢
![Halcon's practice based on shape template matching [1]](/img/68/206eed7502fbf108a929aa9365b1ae.jpg)
Halcon's practice based on shape template matching [1]

软件设计师:03-数据库系统

研究发现,跨境电商客服系统都有这五点功能!

How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?

Altium designer 19.1.18 - Import frame

Train your dataset with yolov4

UEFI development learning 5 - simple use of protocol
![[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen](/img/43/7f8becc09c5ce7fe401bed140608f3.jpg)
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen

Altium Designer 19.1.18 - 清除测量距离产生的信息

Realization of binary relation of discrete mathematics with C language and its properties
随机推荐
The browser cannot access Baidu
MySQL blind note common functions
A complete set of indicators for the 10000 class clean room of electronic semiconductors
Extern keyword function
WiFi wpa_ Detailed description of supplicant hostpad interface
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
PMSM dead time compensation
Query the table name used by kettle in Oracle
UEFI development learning 3 - create UEFI program
C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
Application of ultra pure water particle counter in electronic semiconductors
Altium Designer 19.1.18 - 更改铺铜的透明度
Network port usage
Altium designer learning (I)
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
Gradle composite construction
C WinForm [view status bar -- statusstrip] - Practice 2
Summary -st2.0 Hall angle estimation
About the problem that MySQL connector net cannot be cleared in MySQL