PNS DeviceName/IP Example

1. Example project

In this example, the application shall handle Device name and IP on the application side. For that, it is necessary to change the configuration packet, to implement "Save Station Name indication", "Save IP Address indication" and "Reset to Factory indication". For this, the application needs a possibility to save information remanent in a flash.


The extendedConfig example can be found in the Knowledge Base on the following website:

netX 90: https://hilscher.atlassian.net/wiki/display/NXLFWHST/netX+90+-+PROFINET+IO+Device+-+Examples (from V3.0.0.0)



This can alternatively be found under:

kb.hilscher.com → Software → LFW Host Examples → Profinet IO-Device → netX 90 APP / netX 51 → PROFINET IO Device - extendedConfig Vx.x.x.x

The extendedConfig project can be opened by double-clicking the ".solproject" file. This requires the latest version of netXStudio (https://hilscher.atlassian.net/wiki/display/NDT/).


2. PROFINET Sources

A GSDML file is required for this example. The GSDML file can be found in the netXStudio project in Project Explorer at:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemoPNS → DeviceDescription → GSDML-V2.3x-HILSCHER-NETX xx-RE PNS-20xxxxxx.xml


The PacketHandler describes the acyclic packages and can be found in the Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemoPNS → Sources → AppPNS_DemoApplicationFunctions.c


The IO Data Handler describes the IO data that is exchanged between the application and the stack and can be found in the Project Explorer under:

    long SetModulConfig( void* pvPck)


The terminal handler uses the interface used by UART to display debug messages and is located in Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemo → Sources → App_TerminalHandler.c


The event handler shows the diagnoses and alarms, which can be found in the Project Explorer under:

netXxx_PNSVx_extendedConfig → Components → cifXApplicationDemo → Sources → App_EventHandler.c


3. Configuration Packet

In the configuration packet, it is necessary to change the ptSetConfig → ulSystemFlags.

First step is to disable the flag PNS_IF_SYSTEM_NAME_IP_HANDLING_BY_STACK_ENABLED.



The next step is the use of device name and IP address parameter in the configuration packet.

The application reads the last remanent saved data from the (application) flash.

ptSetConfig → abNameOfStation = value from flash (240 signs)

ptSetConfig → ulIpAddr                = value from flash  

ptSetConfig → ulGateway            = value from flash 

ptSetConfig → ulNetMask            = value from flash  


4. Indications

Implement the packet handler Indications for

  • PNS_IF_SAVE_STATION_NAME_IND
  • PNS_IF_SAVE_IP_ADDR_IND
  • PNS_IF_RESET_FACTORY_SETTINGS_IND


Use for example the Ethernet Device Configuration Tool to change the device name or IP address over the network with the DCP protocol.

This requires the latest version of the Ethernet Device Configuration Tool (https://hilscher.atlassian.net/wiki/display/ETHDEVCFG/).


The stack forwards this change to the application as an indication. The application now needs to handle the indication.

Check in the indication, if the value shall be saved remanent in the application flash.

      if(ptSaveStationNameInd -> tData.bRemanent == 1)
      if(ptSaveIpInd          -> tData.bRemanent == 1)

If the bRemanent value is 1, the application shall check if the value in the application flash is still the same as in the indication. If it is not the same value, write the new value into the application flash.

If the bRemanent value is 0, your application needs to save the value temporary. That means the saved value in the application flash needs to be deleted.