Closed yel-best closed 8 months ago
Please do not remove the above macro. You can just add the line below into CMakeFiles.txt file in your main
project folder.
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
The issue happens because the you need correct type conversion in the format messages. The %x
corresponds to int
but the operand is converted to uint32_t
(change to int, solves this). These lines come from some previous version of modbus and need to be fixed of just apply the change above to disable errors related to format checking.
Please do not remove the above macro. You can just add the line below into CMakeFiles.txt file in your
main
project folder.target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
The issue happens because the you need correct type conversion in the format messages. The
%x
corresponds toint
but the operand is converted touint32_t
(change to int, solves this). These lines come from some previous version of modbus and need to be fixed of just apply the change above to disable errors related to format checking.
Thank you for your answer. According to your guidance, I added this code to the path. The effect is as shown in the screenshot. However, there will be such a prompt when I compile. Did I add it correctly?
After adding it, my compilation still failed. I restored all the changes and still couldn't compile. When I commented out the new sentence, I could compile normally. Why?
Using idf version 5.1.2
CMake Error at CMakeLists.txt:5 (target_compile_options): Cannot specify compile options for target "PRIVATE" which is not built by this project.
-- Configuring incomplete, errors occurred!
See also "E:/MyProject/IoT/PlatformIO-ESP/esp-idf-mesh-lite/mesh-lite-test/build/CMakeFiles/CMakeOutput.log".
FAILED: build.ninja
E:\MyProject\IoT\esp\Tools\.espressif\tools\cmake\3.24.0\bin\cmake.exe --regenerate-during-build -SE:\MyProject\IoT\PlatformIO-ESP\esp-idf-mesh-lite\mesh-lite-test -BE:\MyProject\IoT\PlatformIO-ESP\esp-idf-mesh-lite\mesh-lite-test\build
ninja: error: rebuilding 'build.ninja': subcommand failed
As I said above the line needs to be added at the end of the file CMakeFiles.txt located in the main
folder of your project.
As I said above the line needs to be added at the end of the file CMakeFiles.txt located in the
main
folder of your project.
Yes you are right, it was my problem, sorry, I realized my mistake after I sent the query and it is valid now
I defined a custom component named app_modbus
. The content of my CMakeLists.txt
in the component is as follows, and I referenced the modbus_params.h file. This component implements all the modbus functions I need, but when I compile, some problems will appear. The error means that the holding_reg_params, input_reg_params, coil_reg_params and discrete_reg_params
I defined were not found. However, if I add the content defined in modbus_params.h
directly to the app_modbus.c
file, this problem will not occur without specifying where the problem occurred. , is it related to the idf compilation chain? Please give me some help, thank you very much
idf_component_register(SRCS "app_modbus.c"
INCLUDE_DIRS "include"
REQUIRES esp-modbus)
These structures for parameters are defined here. Add the path for this component to your CMakeLists.txt ( other variant put it like here to the manifest) or copy this component to your project components
folder as you did. I don't know what caused the issue in your app_modbus component. Please try to copy original component with shared parameters. Please also try to remove the REQUIRES esp-modbus
and include mbcontroller.h
in the header if there are no dependencies to modbus types in your component. Please take a look here cmake script
@yel-best,
Could you please update the status of the issue? Did you solve the issue? Can this ticket be closed?
@yel-best,
Could you please update the status of the issue? Did you solve the issue? Can this ticket be closed?
yes, what you said is correct. It is a problem with my code. You can close this issue. thanks.
The following problem occurred when I compiled, I specified esp-modbus version 1.0.13
But when I comment out the code about MB_RETURN_ON_FALSE, it compiles normally. Is it because of compatibility issues?