ESP-32 C3官方例程modbus-master缺少头文件

hoo_wave
Posts: 14
Joined: Mon Dec 11, 2023 2:57 am

ESP-32 C3官方例程modbus-master缺少头文件

Postby hoo_wave » Mon Dec 11, 2023 5:39 am

官方例程modbus-master下载到本地后,提示找不到"modbus_params.h"和"mbcontroller.h"文件,编译不通过,请问这两个文件哪里可以找到?

Code: Select all

"includePath": [
                "${config:idf.espIdfPath}/components/**",
                "${config:idf.espIdfPathWin}/components/**",
                "${config:idf.espAdfPath}/components/**",
                "${config:idf.espAdfPathWin}/components/**",
                "${workspaceFolder}/**"
            ]
CMakeLists.txt

Code: Select all

set(PROJECT_NAME "modbus_master")

idf_component_register(SRCS "master.c"
                        INCLUDE_DIRS ".")
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP-32 C3官方例程modbus-master缺少头文件

Postby ESP_alisitsyn » Fri Dec 15, 2023 10:56 am

The esp-modbus official example uses common structures for saving the modbus parameters for master and slave.
https://github.com/espressif/esp-idf/bl ... ent.yml#L5
Also, the example has the dependency with other esp-modbus components (esp-timer, esp-mdns, etc). One simple way to solve any noncompliance when the some third party IDE and framework is to make your project standalone. The steps are below:
1. add the line below into project CMakeLists.txt file: https://github.com/espressif/esp-modbu ... sts.txt#L6
2. The component with common parameters is here:
https://github.com/espressif/esp-idf/tr ... ple_common
Please copy the context of the above folder into components folder of your project.
3. Then copy also the folder with esp-modbus component from the following location:
https://github.com/espressif/esp-modbus/tree/master
components |--- -esp_modbus
|--- mb_example_common
|--- esp-mdns (if you use modbus TCP with mdns, copy the component here)


In this case your project will be able to be compiled with any supported esp-idf which is part of your third party IDE.
Let me know if you have any issues with this.

Who is online

Users browsing this forum: No registered users and 171 guests