当前位置:网站首页>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 .
边栏推荐
- Qt 及QT VS Tools插件官方下载及安装
- What are the characteristics of SRM supplier management system developed by manufacturing enterprises
- Question bank and answers of 2022 hoisting machinery safety management examination
- Notes on writing questions in C language -- free falling ball
- Static two position relay gls-3004k/dc220v
- Pta:7-63 calculate the number one in the college entrance examination
- ② cocoapods原理及 PodSpec 文件上传操作
- 语料库数据处理个案实例(分词和分句、词频统计、排序)
- QT elidedText 只对中文符合起作用,对英文不起作用的问题解决
- 项目总结1(头文件,switch,&&,位变量)
猜你喜欢

PaddlePaddle模型服务化部署,重新启动pipeline后出现报错,trt报错

电流继电器HDL-A/1-110VDC-1

The spring recruitment in 2022 begins, and a collection of interview questions will help you

距离度量 —— 余弦距离(Cosine Distance)

Distance measure - cosine distance

静态双位置继电器 XJLS-84/440/DC220V

How node+express operates cookies

2020:VL-BERT: Pre-training of generic visual-linguistic representation

#18生成器函数的参数传递

20000 words + 20 pictures | details of nine data types and application scenarios of redis
随机推荐
mysql json
关于php里tcp通讯用swoole框架出现的小问题
开关磁阻电机悬浮驱动IR2128小结
使用Live Chat促进业务销售的惊人技巧
Pta:7-67 friend is very simple 2016final
自动化测试常见的面试题
Pta:6-33 student ranking table (destructor)
OpenJudge NOI 1.13 50:数根
重装Cadence16.3,失败与成功
Abnova 荧光染料 555-C3 马来酰亚胺方案
OpenJudge NOI 1.13 49:计算对数
[pytoch] calculate the derivative of sin (x) by automatic differentiation
thinkPHP6解决跳转问题
Cocos学习日记2——脚本和属性
自举驱动、top开关电源、光耦拾遗
MySQL导入大文件(可以是百万级,也可以是百级)
制造型企业开发的SRM供应商管理系统特点是什么
TS advanced infer
openwrt目录结构
一款MVC5+EasyUI企业快速开发框架源码 BS框架源码