2021-09-09 08:22 AM
I am working on getting a Nucleo-H743ZI2 board to communicate with a python GUI over Ethernet. I am using CubeMX to initialize all of my peripherals and CubeIDE for development. For testing I have used the Lwip_HTTP_Server_Netconn_RTOS for STM32H743ZI_Nucleo example that can be selected in example selector. I have these codes readily available to post but I am very new to all of this so I am not sure what parts of it I should be posting. My goal is to be able to be able to click my button on the GUI and send an Ethernet packet to the board that I can read and then act upon as well as be able to send a packet from the board to the GUI with sensor reading information. I was able to run the Lwip example on the board that shows connectivity by having an orange LED for connected to ethernet and a red LED on for disconnected. I am not sure if this example is compatible with the HAL_ETH_transmit() and other functions in the ETH HAL driver to make this functionality work?
If there is any general guidance on this topic or anyone who has worked on a similar project I would greatly appreciate any and all help I could get. If there is anything I need to add to this post or expand upon please let me know and I will do so as soon as possible. Thank you!
Update:
Per the suggestion of ChahinezC I have gone through the article "How to create Project for STM32H7 with Ethernet and LwIP stack working" and now have clearer questions and goals.
Like the example I am trying to send a word over ethernet but instead of UDP I am using TCP. Here is what the code looks like:
Figure 1: I have not changed these functions that were generated by CubeMX but wanted to post them in case anything looks off. Also curious about where I may put my main functionality of my application if the scheduler prevents the code from going any further? For example if my goal is to blink an LED, turn a servo, or read a sensor, do I now put that code inside of the default task where it loops? Some clarification on that would be wonderful as I was still unsure after reading the article.
Figure 2: Here you can see that I commented the udp example code so that I could use it as reference. I have changed the message as I am trying to get my Pythong GUI to send a tcp message of "Hello There!" and my board to respond with "General Kenobi!". I have kept the IP address the same and used the tcp functions instead of udp. I am aware that these are not a 1:1 translation and that the tcp functions behave differently but I am not sure in what ways and how I may achieve the functionality seen in the code.
Figure 3: Similar to figure 2, I have commented udp example code and written tcp replacement. I also replaced udp_send() with tcp_write() as I believe that was the closest to similar functionality but I am not completely sure that is correct.
Now there are two separate errors that I am running into. The first (which I believe to be causing the second) is the MX_lwip_init() function is running into a software reset timeout error which is throwing up a HAL_ERROR explained in the figure below:
Figure 4: this is in the stm32h7xx_hal_eth.c file that is generated. This triggers the ErrorHandler. I am not exactly sure why the timeout is happening. Whether it be how I am writing my software or how I have initialized things in CubeMX. The other issue that I believe is being caused by this is explained in the figure below:
Figure 5: This is part of the code in Python for a pyside6 gui that is supposed to send the tcp message when the button is clicked. Unfortunately there was a version control issue and I had to cut this picture out in a separate file and I will not be able to display pictures of the GUI. However when the button is clicked it seems to go through this protocol and then gives me the error "ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it". Not sure if resolving the timeout issue will also fix this or if it I am also doing this wrong.
Thank you for all the assistance and please bear with me as I am still quite a novice.
2021-09-10 06:28 AM
Hello @MAgui.1,
I recommend you referring to the "How to create project for STM32H7 with Ethernet and LwIP stack working" article, it will help you.
Chahinez.
2021-09-17 09:32 AM
Thank you very much! This article helped a ton, I'll be updating my question soon with much more specific details very soon.