How on earth should I restart this? Or is it unnecessary?
Code: Select all
E (2968) MB_PORT_COMMON: xMBMasterPortTimersInit(121): timer set value failure, timer_isr_register() returned (0x105).
E (2968) MB_CONTROLLER_MASTER: mbc_serial_master_start(109): mb stack initialization failure, eMBInit() returns (0x3).
E (2978) MB_CONTROLLER_MASTER: mbc_master_start(211): SERIAL master start failure error=(0x103).
E (2988) MODBUS_CONTROLLER: modbus_init(114): mb controller start fail, returns(0x103).
E (2998) MODBUS_CONTROLLER: modbus_controller_loop(30): mb controller failed to restart
E (3008) FreeRTOS: FreeRTOS Task "modbus_gateway" should not return, Aborting now!
Code: Select all
esp_err_t modbus_restart(void){
SENSE_MB_CHECK((mbc_master_destroy() == ESP_OK), ESP_ERR_INVALID_STATE, "Failed to destroy mb handler structure.");
return modbus_init();
}
esp_err_t modbus_init(void){
mb_communication_info_t comm = {
.port = MB_PORTNUM,
.mode = MB_MODE_RTU,
.baudrate = MB_BAUDRATE,
.parity = MB_PARITY
};
void* master_handler = NULL;
esp_err_t err = mbc_master_init(MB_PORT_SERIAL_MASTER, &master_handler);
SENSE_MB_CHECK((master_handler != NULL), ESP_ERR_INVALID_STATE,
"mb controller initialization fail.");
SENSE_MB_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
"mb controller initialization fail, returns(0x%x).",
(uint32_t)err);
err = mbc_master_setup((void*)&comm);
SENSE_MB_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
"mb controller setup fail, returns(0x%x).",
(uint32_t)err);
err = mbc_master_start();
SENSE_MB_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
"mb controller start fail, returns(0x%x).",
(uint32_t)err);
// Set UART pin numbers
err = uart_set_pin(MB_PORTNUM, CONFIG_MB_UART_TXD, CONFIG_MB_UART_RXD,
CONFIG_MB_UART_RTS, UART_PIN_NO_CHANGE);
SENSE_MB_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
"mb serial set pin failure, uart_set_pin() returned (0x%x).", (uint32_t)err);
// Set driver mode to Half Duplex
err = uart_set_mode(MB_PORTNUM, UART_MODE_RS485_HALF_DUPLEX);
SENSE_MB_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
"mb serial set mode failure, uart_set_mode() returned (0x%x).", (uint32_t)err);
return err;
}
Code: Select all
esp-idf: v4.1-dev-437-gd2ad0f077
xtensa-esp32-elf-gcc (crosstool-NG esp32-2019r1) 8.2.0
Linux
esp-wroom-32 devkitv1