Restarting Netx

SSP 1.1.3

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. 


  • Hi Bill,

    just a hint from another "user":
    in the NetX user docu there is another way described on how to check the status of an ethernet link. Independent from the curiosity of your problem you could use this approach as a kind of workaround.

    /* Make a direct call to the application-specific network driver for the previously created IP instance.
    For this example, the network driver is interrogated for the link status. */
    status = nx_ip_driver_direct_command(&ip_0, NX_LINK_GET_STATUS, &link_status);
    /* If status is NX_SUCCESS, the link_status variable contains a
    NX_TRUE or NX_FALSE value representing the status of the physical link. */

    Good luck and have fun :-)
  • In reply to @remo:


    Any response to this? What is the proper way to restart networking?
  • In reply to wflynn:

    Hi Bill,

    Did you memset the packet pool, nx_ip and other data structures to 0 before restarting. the stack?
    Please try that and see if it makes a difference.

  • In reply to garyj:


    Also, are you calling the nx_system_initialize() to do a clean start of NetX ?

  • In reply to garyj:

    No I didn't. I will try that. What other data structures specifically? For packet pool I deleted and recreated, same with nx_ip. I would have thought that would initialize them properly, especially since I did an nx_system_initialize.
  • In reply to garyj:

    Did that. I would think that would take care of setting everything up so no need to memset. If I need to memset to restart, don't I need to do it to start initially?
  • In reply to wflynn:

    The c-runtime initialization zeroes uninitialized memory so the first time you run bring up the network, all of the structures are initialized to 0.

  • 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?  





  • In reply to wflynn:

    Hi Bill,

    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: