|
|
@@ -75,7 +75,7 @@ static esp_err_t mbc_serial_slave_setup(void* comm_info)
|
|
|
(uint32_t)comm_settings->slave_addr);
|
|
|
MB_SLAVE_CHECK((comm_settings->port < UART_NUM_MAX), ESP_ERR_INVALID_ARG,
|
|
|
"mb wrong port to set = (0x%x).", (uint32_t)comm_settings->port);
|
|
|
- MB_SLAVE_CHECK((comm_settings->parity <= UART_PARITY_EVEN), ESP_ERR_INVALID_ARG,
|
|
|
+ MB_SLAVE_CHECK((comm_settings->parity <= UART_PARITY_ODD), ESP_ERR_INVALID_ARG,
|
|
|
"mb wrong parity option = (0x%x).", (uint32_t)comm_settings->parity);
|
|
|
|
|
|
// Set communication options of the controller
|
|
|
@@ -91,12 +91,15 @@ static esp_err_t mbc_serial_slave_start(void)
|
|
|
"Slave interface is not correctly initialized.");
|
|
|
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts;
|
|
|
eMBErrorCode status = MB_EIO;
|
|
|
+ const mb_communication_info_t* comm_info = (mb_communication_info_t*)&mbs_opts->mbs_comm;
|
|
|
+
|
|
|
// Initialize Modbus stack using mbcontroller parameters
|
|
|
- status = eMBInit((eMBMode)mbs_opts->mbs_comm.mode,
|
|
|
- (UCHAR)mbs_opts->mbs_comm.slave_addr,
|
|
|
- (UCHAR)mbs_opts->mbs_comm.port,
|
|
|
- (ULONG)mbs_opts->mbs_comm.baudrate,
|
|
|
- (eMBParity)mbs_opts->mbs_comm.parity);
|
|
|
+ status = eMBInit((eMBMode)comm_info->mode,
|
|
|
+ (UCHAR)comm_info->slave_addr,
|
|
|
+ (UCHAR)comm_info->port,
|
|
|
+ (ULONG)comm_info->baudrate,
|
|
|
+ MB_PORT_PARITY_GET(comm_info->parity));
|
|
|
+
|
|
|
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE,
|
|
|
"mb stack initialization failure, eMBInit() returns (0x%x).", status);
|
|
|
status = eMBEnable();
|