...
In this example the application shall handle I&M data on the application side. For that, it is necessary to change the configuration packet, to implement the "wirte Write I&M indication" “, the "read Read I&M indication" and the "reset Reset to factory indication". For that, the application needs a possibility to save information remanent in a flash.
Example Sourcecode The extendedConfig example can be found in the Extended Config Example: netX 90 - PROFINET IO Device - extendedConfig V2.2.0.0
2. Configuration Packet
In the configuration packet 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
In the configuration packet, it is necessary to change the ptSetConfig→ulSystemFlags ptSetConfig → ulSystemFlags.
First step is to disable the flag PNS_IF_SYSTEM_STACK_HANDLE_I_M_ENABLED.
The next step is the use of the same data in the configuration packet like in the I&M0 informationsFor Example you can create first information.
You can for example first create a structure of I&M0 and than then use it:ptSetConfig→ulVendorId
ptSetConfig → ulVendorId = IM0.usManufacturerId;
ptSetConfig
...
→ usSwRevision1 = IM0.tSoftwareRevision.bX;
ptSetConfig
...
→ usSwRevision2 = IM0.tSoftwareRevision.bY;
ptSetConfig
...
→ usSwRevision3 = IM0.tSoftwareRevision.bZ;
ptSetConfig
...
→ bSwRevisionPrefix = IM0.tSoftwareRevision.bPrefix;
...
4. Values from GSDML file
In the GSDML the device, the developer need needs to give the information , about which modul module has I&M data. Default in Below you see the default configuration in our PNS V5.1.0.4 is at the moment on device.
I&M is currently just configured for the DAP:
<VirtualSubmoduleItem ID="DIM 31" IM5_Supported="false" MayIssueProcessAlarm="false" SubmoduleIdentNumber="0x00003010" Writeable_IM_Records="1 2 3">
That means, I&M0 till 3 is supported to 3. I&M4 till and 5 are is not supported. Only the DAP Modul module has I&M Data.
It is possbile possible to use the Writeable_IM_Records="1 2 3 4" on a moduldifferent module. For example:
<VirtualSubmoduleItem ID="10byteinput" MayIssueProcessAlarm="false" SubmoduleIdentNumber="0x00000001" Writeable_IM_Records="1 2">
Thas That means the DAP has now I&M0 till to 3 and the 10 Byte Input modul module has it own its dataset for I&M0 till to 2.
In this case the application need to implement the I&M handling
...
, the I&M data handling needs to be implemented in your application because the stack can only handle the default I&M data on the DAP.
5. Indications
Implement the packet handler Indications for
- PNS_IF_READ_IM_IND
- PNS_IF_WRITE_IM_IND
The stack does not know anything about the GSDML file. The stack needs first the information about supported I&M data. For that the stack sens in startup theapplication needs to implement in PNS_IF_READ_IM_IND with the parameter PNS_IF_IM_TYPE_IM0FILTER. That means the stack wants to get from the application the information which Modul does support I&M dataWith IM0FILTER
the application can return which module and submodule has own I&M data.
To get this IM0FILTER request, it is necessary to send this from IO Controller. An easy way is to use the Testcase IP_UDP_RPC_I&M_EPM testcase from ART Test Tool.
The application can response respond with some flags to this request.
For Example example, the stack as requests for Slot 0 and Subslot 1 (DAP):
Send Back:
ptReadImRes->tDataThe application sends back the response with these flags:
ptReadImRes → tData.tData.atIM0FilterData[0].ulFlags = PNS_IF_IM0_FILTER_DATA_HAS_IM_DATA | PNS_IF_IM0_FILTER_DATA_MODULE_REF | PNS_IF_IM0_FILTER_DATA_DEVICE_REF;
PNS_IF_IM0_FILTER_DATA_HAS_IM_DATA means, that the Modul module has his own I&M Data:
(The DAP has in data)
PNS_IF_IM0_FILTER_DATA_MODULE_REF means, that the I&M data of this Modul module are the reference for all Submoduls submodules which belong to this modulmodule:
(All other submodules respond with the I&M data from the DAP)
PNS_IF_IM0_FILTER_DATA_DEVICE_REF this is only used only one time once (on the DAP) and means , that all other Moduls modules and Submoduls submodules without own I&M data willrefer will refer to this modulmodule:
(All other modules and submodules respond with the I&M data from the DAP)
That means GSDML with
DAP: <VirtualSubmoduleItem ID="DIM 31" IM5_Supported="false" MayIssueProcessAlarm="false" SubmoduleIdentNumber="0x00003010" Writeable_IM_Records="1 2 3">
For Slot 0 Subslot 1
ptReadImRes->tData.tData.atIM0FilterData[0].ulFlags = PNS_IF_IM0_FILTER_DATA_HAS_IM_DATA | PNS_IF_IM0_FILTER_DATA_MODULE_REF | PNS_IF_IM0_FILTER_DATA_DEVICE_REF;
...
module: <VirtualSubmoduleItem ID="10byteinput" MayIssueProcessAlarm="false" SubmoduleIdentNumber="0x00000001" Writeable_IM_Records="1 2">
For Slot 2 Subslot 1
ptReadImRes->tData.tData.atIM0FilterData[0].ulFlags = PNS_IF_IM0_FILTER_DATA_HAS_IM_DATA | PNS_IF_IM0_FILTER_DATA_MODULE_REF;
(Slot 2 has its own I&M data and will not respond with the I&M data from the DAP)
(For the Modul module which is not marked yellow, only
ptReadImRes->tData.tData.atIM0FilterData[0].ulFlags = PNS_IF_IM0_FILTER_DATA_HAS_IM_DATA;
is necessary , because there are no submodulssubmodules).
More informations information to I&M can be found on here: How to deal with I&M data? (Updated 2016-12-20)
...
6. Indication implementation
I&M0 is allways always read only read. In If a PNS_IF_WRITE_IM_IND comes for I&M0, than this can not cannot be correct. I&M0 has the value usIMRevisionCounter. This must be updatet updated as soon as I&M1 till 4 go - I&M4 are written.
I&M1 till 4 is - I&M4 are read/write and need to be saved remanent on the application flash.
I&M5 is allwasy only readalways read only.
That means each write and read can come for a slot with a subslot Subslot and the application need needs to ckeck check if the combination of reaquested requested slot and sbuslot, Subslot and write or read is really possbilepossible.