PNS ExtendedConfig Example

1. Example project

In this example, the application activates the PROFINET indications. For that, the application needs to call the request "Register Application".

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



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

Nothing needs to be done in the configuration packet.


4. Register Application request

The "Register Application request" activates all PROFINET indications. Indications are messages coming from the stack. The application therefore needs to create a response to the stack.

The application often only has a span of three seconds to create the response. If the application does not respond, the stack will send an error indication.



5. Start Sequence

The "Register Application request" shall be called before the "Set Configuration request". The application will get the first indication after a channel init.

This is the "Link Changed indication" (HIL_LINK_STATUS_CHANGE_IND):

6. Indication / PacketHandler

The PacketHandler needs to read the mailbox and check it for new packets (for example indications). If a new packet is available, the application shall check the command in the header of the packet and implement a switch case.

All PROFINET indication (like in this example the PNS_IF_PARAM_END_IND) shall be implemented in the switch case:


Example for PNS_IF_PARAM_END_IND:

Significant is here, that the application uses the indication packet to create the response packet. The only change is done in the values "Command", "Length", "State" and "Data".

The rest of the values are coming from the indication packet.

Take care, since the length value for the response is not always sizeof(data). Carefully check the PROFINET documentation, sometimes the length value is

X + sizeof(data).


7. Indication / PacketHandler PROFINET default

Often an application does not need to handle all PROFINET indications or the user does not want it to. Only a set of a few indications can be used by the application. However, the application needs to implement all

PROFINET indications. In this case the application can return ERR_HIL_NO_APPLICATION_REGISTERED = 0xC0000202 for not wanted indications.

That means that the stack will handle the indication like if the application is not registered for this indication. Implement all indications like this:


8. Indication / PacketHandler switch case default

The default of the switch case is essential. If not all indications are implemented in the application, the default will create a default response to the stack.

For PROFINET indications this default answer can be wrong, but it is better than no response.


9. When does the application need to implement an indication?

There is no general answer because this needs to be checked for every application. Many indications can be seen as information for the application and only a response is necessary.

Nevertheless, some indications need an implementation in the application. For example, if the application changes the stack behaviour with ptSetConfig → ulSystemFlags, than this makes it necessary to implement indications.

One example for that is the PNS DeviceName/IP Example.

Another example is the PNS Signal LED Example. If the device developer forgets to control the signal LED of the device, or you want to use another LED as Signal LED, it is possible to use the signal indication.