Merge branch 'bugfix/fix_master_tcp_stop_method_initialization' into 'main'

fix slave tcp stop method initialization

See merge request idf/esp-modbus!106
This commit is contained in:
Alex Lisitsyn
2025-03-01 00:59:55 +08:00
4 changed files with 12 additions and 6 deletions

View File

@ -1,4 +1,4 @@
version: "2.0.1~1"
version: "2.0.2"
description: ESP-MODBUS is the official Modbus library for Espressif SoCs.
url: https://github.com/espressif/esp-modbus
dependencies:

View File

@ -182,10 +182,11 @@ esp_err_t mbc_tcp_slave_controller_create(void ** ctx)
// Initialization of interface pointers
mbs_controller_iface->create = mbc_tcp_slave_create;
mbs_controller_iface->delete = mbc_tcp_slave_delete;
mbs_controller_iface->start = mbc_tcp_slave_start;
mbs_controller_iface->check_event = mbc_tcp_slave_check_event;
mbs_controller_iface->get_param_info = mbc_tcp_slave_get_param_info;
mbs_controller_iface->set_descriptor = NULL; // Use common descriptor setter
mbs_controller_iface->start = mbc_tcp_slave_start;
mbs_controller_iface->stop = mbc_tcp_slave_stop;
*ctx = mbs_controller_iface;
return ESP_OK;

View File

@ -116,10 +116,13 @@ extern "C" void app_main(void)
// Initialization of device peripheral and objects
ESP_LOGI(TAG, "Setup master cpp....");
ESP_ERROR_CHECK(master_serial_init(&pmaster_handle));
ESP_ERROR_CHECK(mbc_master_stop(pmaster_handle));
ESP_ERROR_CHECK(mbc_master_delete(pmaster_handle));
ESP_LOGI(TAG, "Master test passed successfully.");
ESP_LOGI(TAG, "Setup slave cpp....");
ESP_ERROR_CHECK(slave_serial_init(&pslave_handle));
// explicitly check stop method before delete
ESP_ERROR_CHECK(mbc_slave_stop(pslave_handle));
ESP_ERROR_CHECK(mbc_slave_delete(pslave_handle));
ESP_LOGI(TAG, "Slave test passed successfully.");
}

View File

@ -3,13 +3,15 @@
import pytest
from pytest_embedded import Dut
MB_APP_WAIT_TOUT_SEC = 10
@pytest.mark.esp32
@pytest.mark.generic
def test_cpp_mb_serial_master_slave(dut: Dut) -> None:
dut.expect('Setup master cpp....')
dut.expect('Modbus master stack initialized...', timeout=5)
dut.expect('Master test passed successfully.', timeout=5)
dut.expect('Modbus master stack initialized...', timeout=MB_APP_WAIT_TOUT_SEC)
dut.expect('Master test passed successfully.', timeout=MB_APP_WAIT_TOUT_SEC)
dut.expect('Setup slave cpp....')
dut.expect('Modbus slave stack initialized...', timeout=5)
dut.expect('Slave test passed successfully.', timeout=5)
dut.expect('Modbus slave stack initialized...', timeout=MB_APP_WAIT_TOUT_SEC)
dut.expect('Slave test passed successfully.', timeout=MB_APP_WAIT_TOUT_SEC)
dut.expect('Returned from app_main()')