Skip to content

Commit 523e432

Browse files
committed
Merge branch 'fix/change_init_order_master_serial' into 'main'
Fix in the init order of serial master in example See merge request idf/esp-modbus!145
2 parents f444c24 + 480a769 commit 523e432

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/serial/mb_serial_master/main/serial_master.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,21 @@ static esp_err_t master_init(void)
603603
MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG,
604604
"mb serial set pin failure, uart_set_pin() returned (0x%x).", (int)err);
605605

606-
err = mbc_master_start(master_handle);
606+
err = mbc_master_set_descriptor(master_handle, &device_parameters[0], num_device_parameters);
607607
MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG,
608-
"mb controller start fail, returned (0x%x).", (int)err);
608+
"mb controller set descriptor fail, returns(0x%x).", (int)err);
609609

610610
// Set driver mode to Half Duplex
611611
err = uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX);
612612
MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG,
613613
"mb serial set mode failure, uart_set_mode() returned (0x%x).", (int)err);
614614

615615
vTaskDelay(5);
616-
err = mbc_master_set_descriptor(master_handle, &device_parameters[0], num_device_parameters);
616+
617+
err = mbc_master_start(master_handle);
617618
MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG,
618-
"mb controller set descriptor fail, returns(0x%x).", (int)err);
619+
"mb controller start fail, returned (0x%x).", (int)err);
620+
619621
ESP_LOGI(TAG, "Modbus master stack initialized...");
620622
return err;
621623
}

0 commit comments

Comments
 (0)