当前位置:网站首页>[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 ...
边栏推荐
- Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
- Some thoughts on extracting perspectives from ealfa and Ebeta
- The browser cannot access Baidu
- Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Software designer: 03 database system
- matlab timeserise
- Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
- Nb-iot technical summary
- 万字详解八大排序 必读(代码+动图演示)
- The firmware of the connected j-link does not support the following memory access
猜你喜欢
Communication standard -- communication protocol
Application of ultra pure water particle counter in electronic semiconductors
生产中影响滑环质量的因素
Basic embedded concepts
Halcon's practice based on shape template matching [2]
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
Wifi-802.11 negotiation rate table
Summary -st2.0 Hall angle estimation
软件设计师:03-数据库系统
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
随机推荐
Reasons for rapid wear of conductive slip rings
Define in and define out
研究发现,跨境电商客服系统都有这五点功能!
Altium designer 19.1.18 - clear information generated by measuring distance
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
UEFI development learning 6 - creation of protocol
1089 insert or merge, including test point 5
solver. Learning notes of prototxt file parameters
PMSM dead time compensation
Realization of binary relation of discrete mathematics with C language and its properties
Network port usage
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
Altium Designer 19.1.18 - 清除测量距离产生的信息
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Basic embedded concepts
[professional literacy] core conferences and periodicals in the field of integrated circuits
C # joint configuration with Halcon
Embedded composition and route
Ads usage skills