2022-02-15 06:31 PM
2022-02-17 06:31 PM
Finally found the reason for the hardfault. It was a call left over after removing the other associated calls for udp at line 365.
/* get the client IP address and port */
nx_udp_source_extract(data_packet, &source_ip_address, &source_port);
Without the other udp calls before it to enable udp this line would cause code to be executed, who knows where. The Fault analyzer was not helpful. I found it by putting printf statements after every line which forced me to read the line. After commenting it out, no more hardfault.
2022-02-15 06:39 PM
Sorry A little detail is needed. I got this project to work from the repo and was also able to create a copy of the project not in the repo that works. But I would like the IP of the server to be hard coded and not use DHCP. When I comment out the section that starts the DHCP (ret = nx_dhcp_start(&DHCPClient);) and use:
ret = nx_ip_address_set(&IpInstance, IP_ADDRESS(192, 168, 0, 9), 0xFFFFFF00UL);
instead, the server goes into listening state but nothing ever goes to the callback that was registered so no connections are made. I do get a response from the ip_address_change_notify_callback when the IP is set by the line above. I am creating the socket followed by the listen.
I have attached the code for app_netxduo.c
2022-02-16 07:02 AM
One clearification, I did find a missing statement at the beginning of the attached file. It was missing:
nx_system_initialization().
However adding this call to the beginning of the UINT MX_NetXDuo_Init(VOID *memory_ptr) process did not change anything.
Also noticed that a printf statement was not showing the IP really being set. Obviously this has no bearing on the problem.
2022-02-16 01:48 PM
Not sure what the real difference was but I was able to start from the example project in the pack for the TCP server as indicated in the title and setup as a standalone project from the repo. Of course it works without any faults.
Then I commented out the dhcp calls and replaced with a single nx_ip_address_change_notify call.
this works without anymore hardfaults.
I have attached the working file.
Just as a side note: I was able to use the copy - paste method for the project in the project explorer which automatically renamed the new project project_name2. Well really it gave me the choice. I then renamed the .ioc file before any other actions and that worked like a charm.
In that project I, removed the dhcp addon within the .ioc (opened CubeMxIDE) and regenerated the project. It is interesting to note that the regenerated project was now missing all of the Middleware include paths.
It first looked like this in the project it was copied from:
then it turned into this after the regeneration:
To fix it I had to go back through and manually add the paths back.
I used the method of right click on the folder of interest in the project tree and select "Add/Remove include path".
I double checked that making a copy of the project would copy the include paths correctly so it was definitely a fault of the regeneration after the Addons DHCP Client feature was unchecked in the Software Packs Component Selector.
2022-02-17 06:31 PM
Finally found the reason for the hardfault. It was a call left over after removing the other associated calls for udp at line 365.
/* get the client IP address and port */
nx_udp_source_extract(data_packet, &source_ip_address, &source_port);
Without the other udp calls before it to enable udp this line would cause code to be executed, who knows where. The Fault analyzer was not helpful. I found it by putting printf statements after every line which forced me to read the line. After commenting it out, no more hardfault.