PROFINET - Sample Applications

Several sample applications are provided for port’s PROFINET protocol stack. They show how to set up and use the stack. The following examples can be found in the folder goal/appl/goal_pnio/

Application

Description

00_rp_cc

communication core application (for multicore targets only)

01_simple_io

Simple I/O data mirror example

02_io_demo

Maps the I/O data on the LEDs and buttons

03_record_write

Shows how to process a record write

05_ioxs_states

IOPS and IOCS handling

06_apdu_status

Like IOxS status but for APDU

07_alarm_button

Trigger an alarm with a button

08_dynamic_modules

Example for dynamic module handling

09_busy_records

Demo for postponing record handling

10_led_demo

DCP signal on LED demo

11_multiple_write

Process a multiple write request

12_diag_entry

Creates and removes a diagnosis entry

13_pnio_snmp

Simple I/O data mirror example incl. SNMP

14_info_set

Set the device information data

15_config_set

Set the PROFINET config data

16_device_name

Set device name in application

17_process_alert

Cyclically process alarm sending example

18_dyn_mod_postpone

ExpectedSubmoduleBlock post-poning example

19_subst_val

 

20_subst_mod

Substitute value module acceptance example

21_pnio_snmp_dm

Simple I/O data mirror example incl. SNMP and MCTC

22_process_alarm_buf

 

24_pnio_snmp_mrp

Simple I/O data mirror example incl. SNMP and MRP

25_dynamic_modules_dm

Equals 08_dynamic_modules but process data will be exchanged via DM instead of RPC

A more detailed description for each application can be get from https://portgmbh.atlassian.net/wiki/spaces/PNIO/pages/131661863/Application+description#Application-description.

Configuring the sample application

Changing MAC Address

The default value of the board MAC address is 02:00:00:00:00:01.

Single-Core

MAC address can be changed by the application using the function goal_miEthCfgMacAddr(). This function keeps the user MAC address and applies it automatically, when Ethernet handler is open by GOAL in stage GOAL_STAGE_ETH_PRE.

Setting the MAC is done in appl_init() in general, as shown in the following example.

 

Code: example for configuring the user MAC

#define APPL_ETH_MAC_ADDR { 0x45, 0x33, 0xab, 0x00, 0x00, 0xFF } GOAL_STATUS_T appl_init void ) { GOAL_ETH_MAC_ADDR_T macAddress = GOAL_ETH_MAC_ADDR; /* mac address */ /* Configure the user MAC */ res = goal_miEthCfgMacAddr(0, GOAL_MI_ID, &macAddress); if (GOAL_RES_ERR(res)) { goal_logErr("failed to set MAC"); } return res; }

Board hardware, like DIP switches or NVS, will not be available when calling appl_init(). If the user MAC requires one of these features, calling goal_miEthCfgMacAddr() in another startup stage of GOAL is also possible. But the user has to register the stage callback by goal_mainStageReg() first.

Please note https://portgmbh.atlassian.net/wiki/spaces/GOALR/pages/191562110 for further details.

Multi-Core

MAC address can be changed either by Communication Core as described in section Single-Core or by Application Core as followed.

Modifications in Communication Core project

Set GOAL_CONFIG_MEDIA_MI_ETH=1 in project configuration to delay opening the ETH interface until protocol instance is going to be created from AC.

Modifications in Application Core project

Call goal_miEthCfgMacAddr in appl_setup prior creating the network protocol instance.

Code: example for configuring the interface MAC from AC

#define APPL_ETH_MAC_ADDR { 0x45, 0x33, 0xab, 0x00, 0x00, 0xFF } GOAL_STATUS_T appl_setup( void ) { GOAL_STATUS_T res; /* result */ GOAL_ETH_MAC_ADDR_T mac = APPL_ETH_MAC_ADDR; /* mac address */ /* set Interface MAC at CC */ goal_miEthCfgMacAddr(0, GOAL_MA_ID_ETH, &mac); /* create new PROFINET instance */ res = goal_pnioNew(&pPnio, APPL_PNIO_ID, appl_pnioCb); if (GOAL_RES_ERR(res)) { goal_logErr("failed to create a new PROFINET instance"); return res; }

Changing IP Address

The IP address is managed by the PLC. With a DCP configuration tool like https://portgmbh.atlassian.net/wiki/spaces/ICE , “Tia Portal” or “Primary Setup Tool” the IP address can be changed.