fix the linking issues when slave id option is disabled v1

This commit is contained in:
Alex Lisitsyn
2025-04-26 00:41:47 +08:00
parent e8317c2822
commit acd7c14457
3 changed files with 6 additions and 1 deletions

View File

@ -192,9 +192,11 @@ static esp_err_t mbc_serial_master_send_request(mb_param_request_t* request, voi
// Calls appropriate request function to send request and waits response
switch(mb_command)
{
#if CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
case MB_FUNC_OTHER_REPORT_SLAVEID:
mb_error = eMBMasterReqReportSlaveID((UCHAR)mb_slave_addr, (LONG)MB_SERIAL_API_RESP_TICS );
break;
#endif
case MB_FUNC_READ_COILS:
mb_error = eMBMasterReqReadCoils((UCHAR)mb_slave_addr, (USHORT)mb_offset,
(USHORT)mb_size , (LONG)MB_SERIAL_API_RESP_TICS );

View File

@ -304,7 +304,7 @@ static void master_operation_func(void *arg)
const mb_parameter_descriptor_t* param_descriptor = NULL;
ESP_LOGI(TAG, "Start modbus test...");
#if CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
// Command - 17 (0x11) Report Slave ID (Serial Line only)
// The command contains vendor specific data and should be interpreted accordingly.
// This version of command handler needs to define the maximum number
@ -324,6 +324,7 @@ static void master_operation_func(void *arg)
} else {
ESP_LOG_BUFFER_HEX_LEVEL("SLAVE_INFO", (void*)info_buf, sizeof(info_buf), ESP_LOG_WARN);
}
#endif
for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) {
// Read all found characteristics from slave(s)

View File

@ -230,6 +230,7 @@ void app_main(void)
ESP_LOGI(TAG, "Modbus slave stack initialized.");
ESP_LOGI(TAG, "Start modbus test...");
#if CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
uint8_t ext_data[] = {0x11, 0x22, 0x33, 0x44, 0x55};
// This is the way to set Slave ID fields to retrieve it by master using report slave ID command.
int err = eMBSetSlaveID(comm_info.slave_addr, true, (uint8_t *)&ext_data, sizeof(ext_data));
@ -238,6 +239,7 @@ void app_main(void)
} else {
ESP_LOGE("SET_SLAVE_ID", "Set slave ID fail, err=%d.", err);
}
#endif
// The cycle below will be terminated when parameter holdingRegParams.dataChan0
// incremented each access cycle reaches the CHAN_DATA_MAX_VAL value.