当前位置:网站首页>[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 ...
边栏推荐
- Significance and requirements of semiconductor particle control
- Programming knowledge -- basis of C language
- C WinForm [realize the previous and next selection pictures] - practice 7
- Relationship between line voltage and phase voltage, line current and phase current
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
- Reasons for rapid wear of conductive slip rings
- Network communication model -- Network OSI tcp/ip layering
- Scm-05 basis of independent keyboard
- LED display equipment records of the opening ceremony of the Beijing Winter Olympics
- Global and Chinese markets of nano biosensors 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Extended application of single chip microcomputer-06 independent key
Altium Designer 19.1.18 - 清除测量距离产生的信息
C language # and #
Altium designer learning (I)
UEFI development learning 5 - simple use of protocol
The firmware of the connected j-link does not support the following memory access
C language uses arrays to realize the intersection, union, difference and complement of sets
UEFI development learning 3 - create UEFI program
C WinForm [view status bar -- statusstrip] - Practice 2
Shell script basic syntax
随机推荐
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Drive LED -- GPIO control
Extended application of single chip microcomputer-06 independent key
Development tools -- gcc compiler usage
VESC Benjamin test motor parameters
Bootloader implementation of PIC MCU
Global and Chinese market of rammers 2022-2028: Research Report on technology, participants, trends, market size and share
Define in and define out
Global and Chinese market of resistivity meter 2022-2028: Research Report on technology, participants, trends, market size and share
UEFI development learning series
Introduction of air gap, etc
万字详解八大排序 必读(代码+动图演示)
Factors affecting the quality of slip rings in production
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
Network communication model -- Network OSI tcp/ip layering
About yolov3, conduct map test directly
Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
Win10 shortcut key