Let's say I wish to restart NetX stuff because an error has occurred, like the cable got unplugged. What is the proper procedure?
Here's what I've tried. When an error is detected, sit in a loop trying to init everything. If anything fails, stop and delete everything that was started, and try again. So basically,
Stop HttpServer, Stop DHCP, delete DNS, Delete DHCP, Delete HTTP, delete IP instance, delete Packet Pool in that order. Then, recreate everything just like before.
When I do this with the cable unplugged, the first time through the loop it works fine i.e. detects no IP returned from DHCP and it unwinds itself. The second time, when it gets around to the DHCP server, it goes away and never comes back on the ip_status_check:
status = nx_dhcp_create(&dhcp_0, &ip_0, "SynergyBaseDHCP"); status = nx_dhcp_start(&dhcp_0);
status = nx_ip_status_check(&ip_0, NX_IP_ADDRESS_RESOLVED, &dhcp_status, 500);
All the Stops and deletes return status 0. All subsequent creates and starts return 0.
In reply to @remo:
In reply to wflynn:
In reply to garyj:
OK - we're back to this again. The original post was under SSP 1.1.3 where stuff like DNS and DHCP had to be created with code by hand. Under 1.1.3, since I called nx_XXX_create, and nx_XXX_start, the zeroing things out trick worked - not zeroing them out didn't. Under 1.2+ it's been added to the configurator, and so now I don't have that code anymore, it's under SynergyGen and is automatically created, which is good, except that there is not a "restart" should the desired parameters change, or should things hang up for whatever reason. And so if I stop these function, zero them out with a memset, and/or delete them, the structures are invalid and nothing works ever again.
Short of rebooting, there doesn't seem to be a clean way around this since my App doesn't "own" the code, Synergy does. I could duplicate the code in XXXThread.c that is generated by Synergy (bad), or I could call straight into it (even worse since I don't "know" what it's doing from one rev SSP to the next).
What is the proper method for restarting the NETX apps when they have been configured and started via the Configurator? These capabilities exist in Express Logic, but they have been "wrappered" away in Synergy. While we're at it, what about FileX, USBX, GuiX, etc?
Starting from SSP 1.2.1, most module has an option to disable/enable auto initialization and the corresponding function name. You can reuse these functions and call them later in your code. Please look at an example application which uses DHCP client and periodically restarts NetX: