Skip to content

mbc_master_start(modbus) fails with error 258 ESP_ERR_INVALID_ARG (IDFGH-15441) #123

Description

@kotyara12

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Actual behavior (suspected bug)

Today I needed to add some new options to the firmware of my automatic greenhouse. After the OTA update, all the sensors suddenly stopped working, because rs485/modbus stopped working. Even visually, requests stopped being sent via the RS485 adapter.

Reason: Modbus initialization error [mbc_master_start]: 258 (ESP_ERR_INVALID_ARG)

Moreover, the SAME code worked perfectly before!

The reason is here!!!!
BUT I DON'T NEED A TABLE OF DESCRIPTORS!!!!!!!!!!!!!!!!!!!!!!! I DON'T USE IT

Image

Error logs or terminal output

Modbus initialization error [mbc_master_start]: 258 (ESP_ERR_INVALID_ARG)

Steps to reproduce the behavior

void sensorsInitModbus()
{
rlog_i(logTAG, "Modbus initialization");
// Config master serial mode
mb_communication_info_t config;
memset(&config, 0, sizeof(config));
config.mode = SENSOR_MODBUS_MODE;
// config.common_opts.mode = SENSOR_MODBUS_MODE;
// config.common_opts.port = SENSOR_MODBUS_PORT;
// config.common_opts.response_tout_ms = SENSOR_MODBUS_TIMEOUT;
config.ser_opts.mode = SENSOR_MODBUS_MODE;
config.ser_opts.port = SENSOR_MODBUS_PORT;
config.ser_opts.response_tout_ms = SENSOR_MODBUS_TIMEOUT;
config.ser_opts.baudrate = SENSOR_MODBUS_SPEED;
config.ser_opts.data_bits = SENSOR_MODBUS_DATA_BITS;
config.ser_opts.stop_bits = SENSOR_MODBUS_STOP_BITS;
config.ser_opts.parity = SENSOR_MODBUS_PARITY;

esp_err_t err = mbc_master_create_serial(&config, &_modbus);
if (err != ESP_OK) {
tgSend(MK_SERVICE, MP_HIGH, true, CONFIG_TELEGRAM_DEVICE, "Ошибка инициализации Modbus [mbc_master_create_serial]: %d (%s)", err, esp_err_to_name(err));
return;
};
// Set UART pins
err = uart_set_pin(SENSOR_MODBUS_PORT, SENSOR_MODBUS_PIN_TXD, SENSOR_MODBUS_PIN_RXD, SENSOR_MODBUS_PIN_RTS, SENSOR_MODBUS_PIN_CTS);
if (err != ESP_OK) {
tgSend(MK_SERVICE, MP_HIGH, true, CONFIG_TELEGRAM_DEVICE, "Ошибка инициализации Modbus [uart_set_pin]: %d (%s)", err, esp_err_to_name(err));
return;
};
// Set UART mode
err = uart_set_mode(SENSOR_MODBUS_PORT, UART_MODE_RS485_HALF_DUPLEX);
if (err != ESP_OK) {
tgSend(MK_SERVICE, MP_HIGH, true, CONFIG_TELEGRAM_DEVICE, "Ошибка инициализации Modbus [uart_set_mode]: %d (%s)", err, esp_err_to_name(err));
return;
};
// Start Modbus
err = mbc_master_start(_modbus);
if (err != ESP_OK) {
tgSend(MK_SERVICE, MP_HIGH, true, CONFIG_TELEGRAM_DEVICE, "Ошибка инициализации Modbus [mbc_master_start]: %d (%s)", err, esp_err_to_name(err));
return;
};
return;
}

Project release version

2.0.2

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Windows

Operating system version

Windows 10

Shell

CMD

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions