Closed Frenelius closed 3 years ago
Hi, I provide the complete source code of 2 examples (including the CubeMX configuration file) for the Nucleo boards F429 and H743. These examples include the usage of the library in a FreeRTOS task.
You can check this file of the F429 for your particular question: Examples/ModbusF429TCP/Core/Src/freertos.c
To assign the IP address, you can either launch the CubeMX tool of CubeIDE and change the TCP Address there, or manually change the IP in the CubeMX generated files.
Thank you so much!
I was blind enough to not look into freertos.c haha.
Now I got it working in my F407VET.
The only thing that happens now is that the software gets stuck into prvCheckTasksWaitingTermination() but I think it is not related to your Modbus library.
No problem, close the issue when you solve it and do not forget to star :star: the library project :smiley:
I forgot to ask, I have a compiler error in modbus.c, lines 479, 892 and 1479 for netconn_set_sendtimeout.
The error is: undefined reference to 'netconn_set_sendtimeout'
If I comment the 3 lines, it builds OK, but the system gets stuck after a while (Maybe not related to this, but just in case).
Do you know if I have to copy some other files? Your example for the F429 builds fine including the three lines.
I have started a completely new project with just your library just in case it was another part of the code, but it happens the same.
Thank you,
You have to enable the timeout APIs of LWIP for RX and TX in the option file, otherwise the system gets stuck when a TX or RX fails.
Hi Alejoseb,
It has worked and now compiles OK.
But it keeps getting stuck randomly when it goes into "xQueueSemaphoreTake" (queue.c line 1418), and assigning configASSERT( pxQueue->uxItemSize == 0 );
Could it be related to the line in 154 in FreeRTOSConfig.h: ??
Thank you,
PS1: I am using PHY DP83848 in case it could be the difference with your boards.
PS2: If I leave MX_LWIP_Init(); inside StartDefaultTask (which is where CubeMX puts it), the whole thing will not work. I have to initialize it in the peripherals initialize section inside main(void).
Hi, I have seen this assert "configASSERT( pxQueue->uxItemSize == 0 );" failing on errors related to running out of heap memory and buffer overflows that corrupt the semaphores, you should double check that you have enough memory assigned to each task, try incrementing the heap of your tasks.
PS1: Probably, I cannot verify it. PS2: Try keeping MX_LWIP_Init() where CubeMX put it, instead move ModbusInit(&ModbusH); and ModbusStart(&ModbusH); after the call to MX_LWIP_Init();
Now the MX_LWIP_Init(); location works well, assigning a higher priority to de StartDefaultTask.
The only thing that keeps giving error is the "configASSERT( pxQueue->uxItemSize == 0 );", but I think it is not related to your code, so I am closing this issue now.
Thank you!
Hello, I am trying to use your library in a project but I do not really know hoy to use it in a task.
Everything compiles fine, but it will not connect to the MTCP server on my LAN (which works with other devices).
Could you explain how to assign the server IP with xIpAddress?
Do you have an example for the library usage? I cannot see how to use it in a RTOS task.
Thank you!