How-to
Read S7-1200 IP, MAC and MRP ring state with LPNDR blocks
Short answer
Call LPNDR_ReadGlobalInfo with mode 1 and the hardware identifier of each PROFINET interface to read that device's IP and MAC address from data record 16#F841. Call LPNDR_ReadMRPState with the MRP manager's interface identifier: mrpRingState 1 means the ring is closed, 0 means open. Both blocks run on an S7-1200 with the LPNDR library loaded.

On this page
When a machine reaches you without current documentation, the fastest source of a device's IP and MAC address is the device itself. Call LPNDR_ReadGlobalInfo with mode 1 and hwId wired to that device's own PROFINET interface, and the block returns the interface information, IP and MAC address included, into a program variable. To watch a media redundancy ring from the same program, call LPNDR_ReadMRPState against the interface of the ring's MRP manager: mrpRingState 1 means closed ring, 0 means open. Both blocks belong to the manufacturer's Library for PROFINET data records, and the steps below carry a project from configuration to two verified reads.
What the two blocks read #
The LPNDR library reads device and status information from PROFINET devices through data records, with no separate diagnostic connection and no scan of the device configuration. LPNDR_ReadGlobalInfo covers interface identity: with the interface-information mode selected it reads data record 16#F841, and the remaining modes address MRP data, port data, port connection state and port statistics. LPNDR_ReadMRPState is the dedicated ring read; it addresses the interface of the media redundancy manager and returns the ring state directly.
| Pin | Declaration | Data type | Use |
|---|---|---|---|
execute |
IN | Bool |
Starts the record read |
hwId |
IN | HW_IO |
Hardware identifier of the PROFINET interface to read |
mode |
IN | Int |
1 interface information, 2 MRP information, 3 port information, 4 port connection state, 5 port statistics |
busy |
OUT | Bool |
Command is running |
done |
OUT | Bool |
Command finished |
error |
OUT | Bool |
A fault occurred |
status |
OUT | Word |
Fault detail |
DataRecord |
IN_OUT | depends on the mode | Destination variable; LPNDR_typeInterfaceInformation for interface information |
LPNDR_ReadMRPState keeps the same handshake pins, and two differences matter: its hwId input is documented as the MRP manager's interface hardware identifier, and the result arrives at the mrpRingState output, a Word, instead of a DataRecord buffer.
Set up the project and the ring #
The procedure was worked through in TIA Portal V17 against an S7-1200 CPU, an ET200SP station and a SCALANCE X204 IRT as the ring switch.
- Create the project, add the S7-1200 CPU and the ET200SP, set each device's IP address and PROFINET device name, and download the configuration to the CPU.
- Add the ring switch and draw the ring in the network and topology views so every ring port is accounted for.
- Set the media redundancy roles: the S7-1200 and the ET200SP as media redundancy clients, the SCALANCE X204 IRT as the media redundancy manager.
One manager holds the ring and the clients only forward ring traffic. MRP treats redundancy as a property of the whole ring rather than of one device, and how MRP ring redundancy differs from PROFINET S2 device redundancy separates the two ideas. If the project on your engineering station was rebuilt from an upload rather than the original files, the configured names and addresses can be thinner than the plant assumes; what an S7-1200 upload recovers and what the IO devices need explains that gap.
Read each interface with LPNDR_ReadGlobalInfo #
- Open the manufacturer's Library for PROFINET data records as a global library in TIA Portal and copy the blocks your program needs into the project.
- Call
LPNDR_ReadGlobalInfoonce per interface. For the CPU's own interface, wirehwIdto the system constant of the CPU's PROFINET interface; for the ET200SP, wire the constant of the ET200SP interface. The constants sit in the project's PLC constants table, and naming the wrong object is the first thing to check when a call returns an error. - Set
modeto 1 and connectDataRecordto a variable declared asLPNDR_typeInterfaceInformation. Declare one variable per device so the two reads cannot overwrite each other. - Drive
executewith a trigger bit, wait untilbusyclears anddonesets, then read the IP address and MAC address out of that variable.
Read the ring state with LPNDR_ReadMRPState #
Call LPNDR_ReadMRPState with hwId wired to the manager's interface identifier — in this topology the SCALANCE X204 IRT's interface, not either client's, because the manager is the station that holds the ring state. Trigger execute once per check and follow the handshake: while busy sets, wait; when done sets with error clear, mrpRingState carries the answer, closed ring 1, open ring 0. In alarm logic, hold the open-ring reading as the alarm condition and the closed-ring reading as normal, and treat any other value, or any set error, as unproven until status explains it. For the screen-by-screen version, a separate page works through an MRP ring diagnostic with LPNDR_ReadMRPState in TIA Portal V17.
Worked example: an ET200SP read and a ring test at 192.168.0.0/24 #
Inputs, each with its source:
- CPU 1215C PROFINET interface, for example 192.168.0.1 with subnet mask 255.255.255.0, set in the CPU's device configuration (example addresses; the check below works on any consistent plan).
- ET200SP interface, for example 192.168.0.61 with the same mask, from its device configuration.
- Read settings from the library documentation:
mode1,DataRecorddeclared asLPNDR_typeInterfaceInformation, record16#F841behind the interface read. - Ring-read settings from the block's pin set:
hwIdof the SCALANCE X204 IRT interface, and ring state 1 for closed, 0 for open. - The
hwIdconstants for all three interfaces, from the project's PLC constants table.
Rule: a record read travels over the target device's PROFINET connection, and PROFINET traffic does not cross a router, so the CPU interface and every device it reads must share one subnet. In words: AND each address with the subnet mask; the two network addresses must match before any block setting matters.
Arithmetic for the example addresses:
- CPU interface: 192.168.0.1 AND 255.255.255.0 = 192.168.0.0 (fourth octet 1 AND 0 = 0).
- ET200SP: 192.168.0.61 AND 255.255.255.0 = 192.168.0.0 (61 AND 0 = 0).
- The network addresses match, so this CPU can reach the interface the
hwIdnames.
Ring test: with the ring cabled closed, one execute trigger returns mrpRingState = 1; pull one ring cable, trigger again, and it returns mrpRingState = 0. Pull the ring cable only with the machine stopped or in a maintenance window, because that link carries the traffic of the two devices it connects.
Result: the interface read fills the ET200SP's variable with 192.168.0.61 and the station's MAC address, and the ring read returned 1 closed and 0 open across the two cable states.
Decision: both addresses land on the same network address, so the reads are addressable from this CPU and the program may use the returned data; an address on 192.168.1.x lands on a different network address and fails the check, so the device address gets corrected before anything else. In the running program, the closed-ring reading is normal and the alarm holds on the open-ring reading.
Check the answers and the common faults #
Compare the read-back IP and MAC address against the device configuration octet by octet. A match proves the record path, the hwId and the addressing together; a device that reports an address other than the project believes has been re-addressed outside the project, so correct the project as well as the device.
If error sets on every trigger, suspect the hwId first: the constant must name the interface, not a module or port constant, and it must belong to the device you intend to read. status carries the fault detail and the library documentation lists its values. Judge data only when done sets with error clear — busy, done, error and status are the handshake, not extra outputs.
Identity and ring state are the two reads above; port data, port connection state and port statistics belong to the port modes of the same block. If a read refuses to complete even with a verified hwId and matching subnet, work through an LPNDR_ReadGlobalInfo fault checklist before changing the program.
Which call answers which question #
- A device's address is unknown:
LPNDR_ReadGlobalInfoin the interface-information mode with that device's own interfacehwId; the answer lands in theDataRecordvariable oncedonesets. - Ring health from the program:
LPNDR_ReadMRPStatewith the manager's interfacehwId; normal is the closed-ring reading and the alarm holds on the open-ring reading. - Port state or statistics: the same block's port modes, selected at
mode, with theDataRecordtype each mode documents.
Questions asked
Where does the LPNDR library come from and how is it loaded?
It is the manufacturer's Library for PROFINET data records, published as entry 109753067 in the product support portal. Open the library in TIA Portal under Global libraries and copy the blocks your program needs into the project. The documentation shipped with the entry states which TIA Portal versions and CPU families each block supports, so match it against your installed version before you build the calls into production code.
Does the same library work on an S7-1500?
Yes. The library is released for all S7-1200 and S7-1500 CPUs and reads information from PROFINET devices, so the same calls address remote I/O stations and the ring switch, not only CPU interfaces. What changes is the hwId you pass: always the identifier of the interface you want to read. Mode, handshake pins and DataRecord handling stay the same across the families.
Why does LPNDR_ReadMRPState need the manager's interface and not a client's?
The manager is the station that holds and reports the ring state: with the ring closed it keeps one of its ring ports blocked and opens that port when the ring breaks. Clients are configured only as media redundancy clients and forward ring traffic; they do not report a ring state. That is why the block's hwId input is documented as the MRP manager's interface hardware identifier, which in this topology belonged to the ring switch.
What should the program do when the error output sets?
Read the status output, a Word that carries the fault detail, and match the value against the list in the library documentation. A common cause is a hwId that names the wrong object, such as a module constant where the interface constant is needed. Until status explains the fault, treat that call's data outputs as unproven: alarms and interlocks must not use the contents of DataRecord or mrpRingState for that cycle.
Can one call read several devices at once?
No. The block reads one data record from the one interface named by hwId, so every device needs its own call with its own interface constant and its own DataRecord variable. Give each call its own block instance as well, so the busy, done, error and status handshakes cannot collide, and evaluate each call's done and error separately before using its data.

