Pular para o conteúdo principal
Knowledgebase
Home
Renesas Brasil - Knowledgebase

How do I restart a NetX process if I get an error condition?

Last Updated:03/22/2018

Question:

How do I restart a NetX process if I need to, perhaps due to an error condition?

Answer:

When using SSP 1.2.x and above with NetX, it may be a requirement that the application robustly recover from errors such as cables unplugged, noise, etc. In those cases, for example when a cable disconnect is detected, the application may need to unwind the start-up process and totally re-initialize NetX (fresh start). The required steps are explained below:

  • Basically, the steps are to initialize each process you will use
  • Then let your application use the processes in its work
  • When you detect errors, or need to restart:
    • Unwind the processes, in order, by stopping them and then deleting them
    • Clear memory allocated to the pool and the IP instance as needed
  • Once you have completely unwound the processes then you can initialize and start again

 

An example set of starting and unwinding step is described below:

  • nx_common_init0(); // void function initializes the internal threads and structures
  • packet_pool_init0(); // void function that inits the packet pool as configured in SSC
  • ip_init0(); // void function that inits the TCIP as configured in SSC
  • Use nx_ip_interface_status_check to make sure the network has started OK
  • If it has started Ok then
  • Use nx_dhcp_create to create a DHCP service instance
  • Use nx_dhcp_state_change_notify to register a state change callback function
  • Use nx_dhcp_start to start DHCP services
  • Wait for an IP Address from DHCP
  • Check for valid IP Address using the state change callback to check for NX_DHCP_STATE_BOUND
  • Create an HTTP instance using nx_http_server_create
  • Start the HTTP instance using nx_http_server_start

At this point the application is running. If a rewind is needed execute the following steps:

  • Use nx_http_server_stop to stop the server
  • Use nx_http_server_delete to delete the server
  • Use nx_dhcp_stop to stop DHCP
  • Use nx_dhcp_delete to delete DHCP
  • Use memset to release DHCP memory
  • Use nx_ip_delete to delete IP
  • Use memset to release IP memory
  • Use  nx_packet_pool_delete to release the packet pool
  • Use memset to release the packet pool

If needed, re-initialize and start again using the first set of steps given above.

Suitable Products
SSP