From 61a567b3b7f159079e0d58f1c8ae0aa4fdbb6aa7 Mon Sep 17 00:00:00 2001 From: jarvis Date: Sat, 8 Mar 2025 16:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9E=E5=85=AC=E5=AE=A4=E7=94=B5=E8=84=9103?= =?UTF-8?q?08=E6=9C=80=E5=90=8E=E7=9A=84=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 8 ++++++-- components/FluxMod/FluxMod.c | 7 +++++++ main/i80_controller_example_main.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e4fd63..126d8c8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,12 +12,16 @@ "idf.openOcdConfigs": [ "board/esp32s3-builtin.cfg" ], - "idf.portWin": "COM6", + "idf.portWin": "COM5", "idf.flashType": "UART", "files.associations": { "ledc.h": "c", "gpio.h": "c", "sdmmc_host.h": "c", - "modbus_params.h": "c" + "modbus_params.h": "c", + "array": "c", + "string": "c", + "string_view": "c", + "span": "c" } } diff --git a/components/FluxMod/FluxMod.c b/components/FluxMod/FluxMod.c index 9946769..6df5bd5 100644 --- a/components/FluxMod/FluxMod.c +++ b/components/FluxMod/FluxMod.c @@ -16,6 +16,7 @@ const uint16_t num_device_parameters = (sizeof(device_parameters)/sizeof(device_ esp_err_t modbus_master_init(void) { + // Initialize and start Modbus controller mb_communication_info_t comm = { .port = MB_PORT_NUM, @@ -26,6 +27,7 @@ esp_err_t modbus_master_init(void) void* master_handler = NULL; esp_err_t err = mbc_master_init(MB_PORT_SERIAL_MASTER, &master_handler); + /**/ MB_RETURN_ON_FALSE((master_handler != NULL), ESP_ERR_INVALID_STATE, TAG, "mb controller initialization fail."); MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG, @@ -54,7 +56,12 @@ esp_err_t modbus_master_init(void) MB_RETURN_ON_FALSE((err == ESP_OK), ESP_ERR_INVALID_STATE, TAG, "mb controller set descriptor fail, returns(0x%x).", (int)err); ESP_LOGI(TAG, "Modbus master stack initialized..."); + ESP_LOGI(TAG, "Modbus master initialized..."); return err; + + uint8_t data=0; + mbc_master_get_parameter(device_parameters->cid,device_parameters->param_key,&data,0); + } diff --git a/main/i80_controller_example_main.c b/main/i80_controller_example_main.c index a77b14d..d5a1faf 100644 --- a/main/i80_controller_example_main.c +++ b/main/i80_controller_example_main.c @@ -464,7 +464,7 @@ void app_main(void) button_init(); /*初始化Modbus*/ - //modbus_master_init(); + ESP_ERROR_CHECK(modbus_master_init()); // Lock the mutex due to the LVGL APIs are not thread-safe if (example_lvgl_lock(-1)) {