Agile Modbus  1.1.4
Lightweight modbus protocol stack.
Common Private Functions
Collaboration diagram for Common Private Functions:

Functions

static uint8_t agile_modbus_compute_meta_length_after_function (agile_modbus_t *ctx, int function, agile_modbus_msg_type_t msg_type)
 The length of the data element to be received after calculating the function code. More...
 
static int agile_modbus_compute_data_length_after_meta (agile_modbus_t *ctx, uint8_t *msg, int msg_length, agile_modbus_msg_type_t msg_type)
 The length of data to be received after calculating the data element. More...
 
static int agile_modbus_receive_msg_judge (agile_modbus_t *ctx, uint8_t *msg, int msg_length, agile_modbus_msg_type_t msg_type)
 Check the correctness of received data. More...
 

Detailed Description

Function Documentation

◆ agile_modbus_compute_meta_length_after_function()

static uint8_t agile_modbus_compute_meta_length_after_function ( agile_modbus_t ctx,
int  function,
agile_modbus_msg_type_t  msg_type 
)
static

The length of the data element to be received after calculating the function code.

   ---------- Request     Indication ----------
   | Client | ---------------------->| Server |
   ---------- Confirmation  Response ----------

   Take the 03 function code request message as an example

   ---------- ------ --------------- ---------
   | header | | 03 | | 00 00 00 01 | | CRC16 |
   ---------- ------ --------------- ---------

   ----------
   | header |
   ----------
       RTU: device address
       TCP: | transaction identifier  protocol identifier  length  unit identifier |

   ---------------
   | 00 00 00 01 |
   ---------------
       Data element: Data related to the function code, such as 03. The function code data element contains the register starting address and register length.
Parameters
ctxmodbus handle
functionfunction code
msg_typemessage type
Returns
data element length

Definition at line 88 of file agile_modbus.c.

Here is the caller graph for this function:

◆ agile_modbus_compute_data_length_after_meta()

static int agile_modbus_compute_data_length_after_meta ( agile_modbus_t ctx,
uint8_t *  msg,
int  msg_length,
agile_modbus_msg_type_t  msg_type 
)
static

The length of data to be received after calculating the data element.

   ---------- Request     Indication ----------
   | Client | ---------------------->| Server |
   ---------- Confirmation  Response ----------

   Example of responding to a message with function code 03

   ---------- ------ ------ --------- ---------
   | header | | 03 | | 02 | | 00 00 | | CRC16 |
   ---------- ------ ------ --------- ---------

   ----------
   | header |
   ----------
       RTU: device address
       TCP: | transaction identifier  protocol identifier  length  unit identifier |

   ------
   | 02 |
   ------
       Data element: two bytes of data

   ---------
   | 00 00 |
   ---------
       data
Parameters
ctxmodbus handle
msgmessage pointer
msg_lengthmessage length
msg_typemessage type
Returns
data length

Definition at line 177 of file agile_modbus.c.

Here is the caller graph for this function:

◆ agile_modbus_receive_msg_judge()

static int agile_modbus_receive_msg_judge ( agile_modbus_t ctx,
uint8_t *  msg,
int  msg_length,
agile_modbus_msg_type_t  msg_type 
)
static

Check the correctness of received data.

Parameters
ctxmodbus handle
msgmessage pointer
msg_lengthmessage length
msg_typemessage type
Returns
>0: correct, modbus data frame length; others: exception

Definition at line 224 of file agile_modbus.c.

Here is the call graph for this function:
Here is the caller graph for this function: