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
539 stars 183 forks source link

Ethernet Communication with Lwip TCP /IP #53

Closed anilizgu1 closed 2 years ago

anilizgu1 commented 2 years ago

Hello,

I've added the Modbus TCP library with the ModbusH743TCP example for my own project. My board is stm32h747-disc0. I am trying to see the firstly ethernet communication between board to pc over Ethernet peripheral. Software gets stuck into prvCheckTasksWaitingTermination() but I think it is not related to your Modbus library. When I ping the IP over the cmd window I couldn't be able to communicate with the board yet. To do that, which parts of code do I need to check especially?

Thanks in advance.

alejoseb commented 2 years ago

Sorry, I cannot provide support for a particular implementation. It is expected that the freertos.c is different since that is not part of the library, it is part of an example, or your implementation. You should first have a TCP connection working and tested with ping in your board and then try to port the library on top of that.

anilizgu1 commented 2 years ago

Okay, thank you. I will do the TCP connection working first as you suggest.

anilizgu1 commented 2 years ago

Hi, I am getting this error, what can be the reason? Thanks.

Ekran görüntüsü 2022-05-23 161137

alejoseb commented 2 years ago

I think you did not initialize the modbus handler in main.c. You can see the initialization in this example:

https://github.com/alejoseb/Modbus-STM32-HAL-FreeRTOS/blob/32eb8bd122530acb003e28bcbf0fd2324154208f/Examples/ModbusF429/Core/Src/main.c#L97

Also, if you are only using the TCP version of the library the "UART_HandleTypeDef *port" must not be used, since it is not initialized or used at all. It is expected that you observe that error in the IDE in this case.

anilizgu1 commented 2 years ago

Hi, thanks for your reply. I want to use only the TCP version of the library for Modbus TCP/IP communication.( What is the role of Uart in TCP example ?) I have an ethernet lwip stack working on the board ( Stm32h747-disc0 ) .İt reacts to PING (ICMP) requests with a fixed IP address. (192.168.1.10) successfully. I am trying to port the Modbus library right now. The same issue there are for the pTxBuffPtr and pRxBuffPtr. Which sections I have to disable in the library for UART. After disabling that should I do anything additionally like that? Thanks in advance.

alejoseb commented 2 years ago

In the case of TCP the uart has no functionality at all, you don't need to disable anything to work only with TCP, those fields will be there in any case. pTxBuffPtr and pRxBuffPtr are part of the HAL library for USART, since you are only using TCP just ignore them, don't access any field related to the uart.

anilizgu1 commented 2 years ago

Hi, thanks for your time and effort to support.

I am a little bit stuck, according to the ModbusH743TCP example configuration, I've added to my project. When I tried to Master mode with the Slave simulation tool on the pc (PymodSlave), the debug program comes here as below. What could be the reason ? Thanks.

Ekran görüntüsü 2022-06-03 125839

alejoseb commented 2 years ago

As you can read there, that might happen if you are running out of heap. Check the configuration of your project, including the heap for each FreeRTOS task that you are creating.

DmitryWorks commented 2 years ago

Hello, I'm testing your library on NUCLEO-H743ZI2 for Modbus TCP, I checked everything, for example, writing register reading works. I want to go further, for example if 400000 holding register = 1 turn on the built-in LED on the board by analogy with this video https://www.youtube.com/watch?v=-JRI9GmA0dg only for Modbus TCP, but there are problems when I change the configuration of your project in order to use the built-in LED and generate a new code in the MX Cube, everything stops working at the ping level, tell me what could be the matter? I'm using Cube MX 6.3.0 as you created the project. Thank you.