Espressif ESP32-S2 Programming Manual page 642

Table of Contents

Advertisement

Chapter 2. API Reference
Table 10:
mb_param_info_t
Field
Description
time_stamp
the time stamp of the event when defined parameter is accessed
mb_offset start Modbus register accessed by master
type
type of the Modbus register area being accessed (See the
tion)
address memory address that corresponds to accessed register in defined area descriptor
size
number of registers being accessed by master
Example to get event when holding or input registers accessed in the slave:
#define MB_READ_MASK
#define MB_WRITE_MASK
#define MB_READ_WRITE_MASK
#define MB_PAR_INFO_GET_TOUT
....
// The function blocks while waiting for register access
mb_event_group_t event
// Get information about data accessed from master
ESP_ERROR_CHECK(mbc_slave_get_param_info(&reg_info, MB_PAR_INFO_GET_TOUT));
const
char*
rw_str
=
// Filter events and process them accordingly
if
(event
&
(MB_EVENT_HOLDING_REG_WR
ESP_LOGI(TAG,
"HOLDING %s (%u us), ADDR:%u, TYPE:%u, INST_ADDR:0x%.4x, SIZE:%u
",
rw_str,
(uint32_t)reg_info.time_stamp,
(uint32_t)reg_info.mb_offset,
(uint32_t)reg_info.type,
(uint32_t)reg_info.address,
(uint32_t)reg_info.size);
}
else if
(event
&
(MB_EVENT_INPUT_REG_RD)) {
ESP_LOGI(TAG,
"INPUT %s (%u us), ADDR:%u, TYPE:%u, INST_ADDR:0x%.4x,
rw_str,
(uint32_t)reg_info.time_stamp,
(uint32_t)reg_info.mb_offset,
(uint32_t)reg_info.type,
(uint32_t)reg_info.address,
(uint32_t)reg_info.size);
}
Modbus Slave Teardown
and frees all used active objects allocated for the slave.
mbc_slave_destroy()
ESP_ERROR_CHECK(mbc_slave_destroy());
Possible Communication Issues And Solutions
If the examples do not work as expected and slave and master boards are not able to communicate correctly, it is
possible to find the reason for errors. The most important errors are described in master example output and formatted
as below:
Espressif Systems
Table 4 Description of the register info structure:
(MB_EVENT_INPUT_REG_RD | MB_EVENT_HOLDING_REG_RD)
(MB_EVENT_HOLDING_REG_WR)
(MB_READ_MASK | MB_WRITE_MASK)
(10 / portTICK_RATE_MS)
=
mbc_slave_check_event(MB_READ_WRITE_MASK);
(event
&
MB_READ_MASK)
|
MB_EVENT_HOLDING_REG_RD)) {
This function stops the Modbus communication stack, destroys the controller interface,
Submit Document Feedback
mb_event_group_t
?
"READ"
:
"WRITE";
631
for more informa-
SIZE:%u",
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Table of Contents

Save PDF