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

Functions

void agile_modbus_common_init (agile_modbus_t *ctx, uint8_t *send_buf, int send_bufsz, uint8_t *read_buf, int read_bufsz)
 initialize modbus handle More...
 
int agile_modbus_set_slave (agile_modbus_t *ctx, int slave)
 set address More...
 
void agile_modbus_set_compute_meta_length_after_function_cb (agile_modbus_t *ctx, uint8_t(*cb)(agile_modbus_t *ctx, int function, agile_modbus_msg_type_t msg_type))
 sets the data element length callback function to be received after calculating the function code of the modbus object More...
 
void agile_modbus_set_compute_data_length_after_meta_cb (agile_modbus_t *ctx, int(*cb)(agile_modbus_t *ctx, uint8_t *msg, int msg_length, agile_modbus_msg_type_t msg_type))
 sets the data length callback function to be received after calculating the data element of the modbus object More...
 
int agile_modbus_receive_judge (agile_modbus_t *ctx, int msg_length, agile_modbus_msg_type_t msg_type)
 Verify the correctness of received data. More...
 

Detailed Description

Function Documentation

◆ agile_modbus_common_init()

void agile_modbus_common_init ( agile_modbus_t ctx,
uint8_t *  send_buf,
int  send_bufsz,
uint8_t *  read_buf,
int  read_bufsz 
)

initialize modbus handle

Parameters
ctxmodbus handle
send_bufsend buffer
send_bufszsend buffer size
read_bufreceive buffer
read_bufszreceive buffer size

Definition at line 257 of file agile_modbus.c.

Here is the caller graph for this function:

◆ agile_modbus_set_slave()

int agile_modbus_set_slave ( agile_modbus_t ctx,
int  slave 
)

set address

Parameters
ctxmodbus handle
slaveaddress
Returns
0: success

Definition at line 273 of file agile_modbus.c.

◆ agile_modbus_set_compute_meta_length_after_function_cb()

void agile_modbus_set_compute_meta_length_after_function_cb ( agile_modbus_t ctx,
uint8_t(*)(agile_modbus_t *ctx, int function, agile_modbus_msg_type_t msg_type)  cb 
)

sets the data element length callback function to be received after calculating the function code of the modbus object

Parameters
ctxmodbus handle
cbcallback function of the data element length to be received after calculating the function code
See also
agile_modbus_compute_meta_length_after_function

Definition at line 284 of file agile_modbus.c.

◆ agile_modbus_set_compute_data_length_after_meta_cb()

void agile_modbus_set_compute_data_length_after_meta_cb ( agile_modbus_t ctx,
int(*)(agile_modbus_t *ctx, uint8_t *msg, int msg_length, agile_modbus_msg_type_t msg_type)  cb 
)

sets the data length callback function to be received after calculating the data element of the modbus object

Parameters
ctxmodbus handle
cbThe data length callback function to be received after calculating the data element
See also
agile_modbus_compute_data_length_after_meta

Definition at line 297 of file agile_modbus.c.

◆ agile_modbus_receive_judge()

int agile_modbus_receive_judge ( agile_modbus_t ctx,
int  msg_length,
agile_modbus_msg_type_t  msg_type 
)

Verify the correctness of received data.

Note
This API returns the modbus data frame length, for example, 8 bytes of modbus data frame + 2 bytes of dirty data, returns 8
Parameters
ctxmodbus handle
msg_lengthreceived data length
msg_typemessage type
Returns
>0: correct, modbus data frame length; others: exception

Definition at line 312 of file agile_modbus.c.

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