当前位置:网站首页>Freemodbus parsing 1
Freemodbus parsing 1
2022-06-23 04:47:00 【Boundless also initial heart】
Online for FreeModBus There are many ways to parse , I also read it by referring to these analyses FreeModBus.FreeModBus In a thousand ways , here , I picked up one of the clues , Just call one of the functions , Sort it out , Learn a lot .
Compare the following two functions :
peMBFrameReceiveCur And eMBRTUReceive See how they are defined , How to call .
Here is the declaration of the first function :
typedef eMBErrorCode( *peMBFrameReceive )( UCHAR * pucRcvAddress,
UCHAR ** pucFrame,
USHORT * pusLength );
static peMBFrameReceive peMBFrameReceiveCur;Declaration of the second function :
eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength);choice RTU Mode time , The former hooks the latter :
peMBFrameReceiveCur = eMBRTUReceive;In the state machine eMBPoll in , When the time is EV_FRAME_RECEIVED when , Execute function
eStatus = peMBFrameReceiveCur( & ucRcvAddress, & ucMBFrame, & usLength );
Three parameters in the state machine eMBPoll Is defined as :
static UCHAR ucRcvAddress;
static UCHAR *ucMBFrame;
static USHORT usLength; This example can learn :
1, This is not known as a callback function , Hook function , Anyway, my understanding now is ,peMBFrameReceiveCur May have been in a different ModBus Hook different functions in mode , Execute these different functions under appropriate conditions . One of the benefits of this is , The caller and the callee are separated , The caller can call other callees under appropriate conditions .
2, Finally, let's look at the function call , Here is a typical pointer passing , When the function is called, the ucRcvAddress,*ucMBFrame,usLength, The addresses of these three parameters are passed to the callback function , After the callback function is executed , The values of these three parameters change , That is, the address of this frame data is obtained , Length and data content .
problem :
1, The difference between hook function and callback function
2, The callee is a callback function , I understand right
3, In a function declaration passed with a pointer eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength);
Parameters UCHAR ** pucFrame In fact, the array name is passed , It's a pointer to a pointer , Notice here .
边栏推荐
猜你喜欢

X24cxx series EEPROM chip C language universal reading and writing program

国家药品不良反应监测中心 ADR 电子传输EDI解决方案

Abnova ACTN4纯化兔多克隆抗体说明书

Common concepts and terms in offline warehouse modeling

② cocoapods原理及 PodSpec 文件上传操作

电流继电器JDL-1002A

win10下安装、运行MongoDB
![[multimode] unimo](/img/a5/a857e20e1432ef3623527c8655a49a.png)
[multimode] unimo
![Fundamentals of 3D mathematics [16] formulas for uniformly accelerated linear motion](/img/51/5b05694bbd0f4fd01dd26cf55b22c7.png)
Fundamentals of 3D mathematics [16] formulas for uniformly accelerated linear motion
Laravel中使用 Editor.md 上传图片如何处理?
随机推荐
ADR electronic transmission EDI solution of national adverse drug reaction monitoring center
【多模态】UNIMO
X24cxx series EEPROM chip C language universal reading and writing program
力扣今日题513. 找树左下角的值
使用Live Chat促进业务销售的惊人技巧
AD9使用技巧拾遗
TS进阶之infer
Cocos学习日记1——节点
The paddepaddle model is deployed in a service-oriented manner. After restarting the pipeline, an error is reported, and the TRT error is reported
2022 simulated examination question bank and answers for safety management personnel of metal and nonmetal mines (open pit mines)
Leetcode 1208. Try to make the strings equal as much as possible (finally solved, good night)
Second assignment notes
notepad++ 查找替换之分组替换保留
静态双位置继电器 XJLS-84/440/DC220V
free( )的一个理解(《C Primer Plus》的一个错误)
麦肯锡:2021年量子计算市场投资增长强劲,人才缺口扩大
thinkphp6 无关联ID的连表查询(2张表)主要是select的应用
Pta:7-67 friend is very simple 2016final
Kail 渗透基本素养 基础命令
语料库数据处理个案实例(分词和分句、词频统计、排序)