alejoseb / Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS
GNU Lesser General Public License v2.1
576 stars 191 forks source link

modH->conn is NULL within TCPinitserver() #112

Closed FebsterVF closed 2 months ago

FebsterVF commented 2 months ago

Hi,

my implementation on an STM32H745-Disco dev board is stuck in the while loop in TCPinitServer, which is only entered if modH->conn is not initialized:

Screenshot 2024-09-18 133510

i tried replacing netconn_new() with the function it is referencing to: netconn_new_with_proto_and_callback(), but same problem.

here is the debug content of modH->conn:

Screenshot 2024-09-18 133647

i went through the code step by step, and it seems conn is not being initialized properly...

am i doing something wrong here?

alejoseb commented 2 months ago

The only reason that I can imagine is if you are calling that function before the FreeRTOS kernel is initialized, as already mentioned in the code comment. I recommend you first have your STM32H745-Disco dev board running the TCP stack, after you confirm it is working then add the Modbus library. Besides, this is not an issue related to the library.

FebsterVF commented 2 months ago

Thanks for the help, once i moved the MX_LWIP_Init(); to the section where all configured peripherals are initialized, i am no longer stuck.

It was in StartDefaultTask() by default...

Since the library is still not working for me, ill take a step back and look at just the TCP-Stack implementation as you recommended...

Thanks!