How-to
Read PROFINET device status on an S7-400 with SFC 51 SSL 0x0194
Short answer
On an S7-400 programmed in SIMATIC Manager there is no DeviceStates block; read PROFINET device connection state by calling SFC 51 RDSYSST with SSL_ID 16#0194, check that RET_VAL is zero, and decode the returned array per the system status list definition. Devices that support automatic channel-driver generation report their state through that driver instead.
On this page
- Which block reads PROFINET device status on an S7-400 in SIMATIC Manager?
- Why can't you use DeviceStates in STEP 7 V5.x?
- When should you take the channel-driver route instead?
- How do you set up the SFC 51 call in SIMATIC Manager?
- What does the returned array contain and how do you decode it?
- When do you trust the data, and what does RET_VAL tell you?
- How do you test the mapping before trusting it in logic?
- Questions asked
On an S7-400 programmed in SIMATIC Manager, read the connection state of your PROFINET devices by calling SFC 51 RDSYSST with SSL_ID 16#0194: it returns a partial system status list covering the stations of the PROFINET IO controller system. There is no DeviceStates block in STEP 7 V5.x — that block belongs to TIA Portal — and the other manufacturer route, device-state reporting through an automatically generated channel-driver block, works only for devices that support that generation. This article shows how to set up the call, check the result, decode the array and test the mapping before the logic depends on it.
Which block reads PROFINET device status on an S7-400 in SIMATIC Manager? #
The block is SFC 51 RDSYSST called with SSL_ID 16#0194: it reads a partial system status list that reports the activation and connection state of the stations of the PROFINET IO controller system, one record per configured device. STEP 7 V5.x offers no ready-made "device states" function for this, so the SSL read is the route you build yourself. The same SFC reads other diagnostic lists too — it is also how you read DP slave diagnostic addresses with SFC51 on an S7-300 — so the mechanism is not exotic, only the list ID is specific to PROFINET.
Note what this is not: PROFIBUS-oriented diagnostic reads are a separate mechanism with their own return codes, and a fix like SFC 13 RET_VAL 35 fix on an ET 200 PROFIBUS read has no bearing on this PROFINET list. Do not carry PROFIBUS diagnostic blocks over to a PROFINET device question.
Why can't you use DeviceStates in STEP 7 V5.x? #
DeviceStates is a TIA Portal system block and does not exist in the STEP 7 V5.x block set, so a SIMATIC Manager project cannot call it — the SSL read replaces it there. Both environments program the S7-400, but the block libraries differ, and moving from STEP 7 V5.5 to TIA Portal changes more than the editor. If the project stays in SIMATIC Manager, commit to SFC 51; if the project migrates later, DeviceStates becomes the natural replacement and the mapping you build now translates directly, because both report per-device state.
When should you take the channel-driver route instead? #
For a device that supports automatic channel-driver generation, the generated channel-driver block reports its state through its own interface, and that is the intended path for those devices — reserve the SSL read for devices without that support. In practice this splits your inventory in two: Siemens devices with a generated driver on one side, third-party devices without one on the other. You can run both routes in one program, but keep them separate in the logic, because the driver's state semantics are its own and should not be reinterpreted through the SSL encoding.
Either way, keep connection state separate from process readiness. A device can be connected while its measurements are invalid, and a connection bit alone must never permit a sequence to start; define which condition the logic actually needs.
How do you set up the SFC 51 call in SIMATIC Manager? #
Set it up as a level-triggered call that writes into a data block you size yourself: the SFC fills a two-word header followed by the list records, and your code consumes the result only after the busy output clears. Work through these steps:
- Inventory the PROFINET devices in the hardware configuration and mark which ones support automatic channel-driver generation. Those keep their driver route; the rest are covered by this read.
- Create a destination data block. The example below is illustrative —
PN_status,header,length,nRecordsandrecordsare names this example chose, not vendor identifiers:
// Example data block for the SFC 51 destination area
DATA_BLOCK "PN_status"
NON_RETAIN
STRUCT
header : STRUCT // written by the SFC
length : WORD; // bytes of list data that followed
nRecords : WORD; // number of records transferred
END_STRUCT;
records : ARRAY[1..64] OF BYTE; // example size: resize per the SSL definition
END_STRUCT;
BEGIN
length := 16#0000;
nRecords := 16#0000;
END_DATA_BLOCK
- Call SFC 51 from a cyclic program part. Feed the request input from a trigger that is true for one edge, hand the whole
PN_statusarea to the destination-area parameter, set SSL_ID := W#16#0194, and leave the index input at zero unless the list definition requires a subset. - Hold the request until the busy output goes false; if your trigger is a periodic bit, latch the request internally so the call is not re-armed mid-job.
- Evaluate RET_VAL before anything else touches the buffer. A zero return means the read completed; anything else means it did not.
- Only after a good read, evaluate
header.nRecordsand decoderecordsper the system status list definition for your CPU. - Map each record to a configured device with an explicit table in your code, not an assumed order.
Do not guess the buffer size, the record layout, the state encoding or the device-to-record ordering: take all four from the system status list documentation for the S7-400 CPU family. The 64 record bytes above are an example, sized up or down to what that definition says the list needs for your device count.
What does the returned array contain and how do you decode it? #
The destination area holds the two-word header — length in bytes and number of records — followed by one record per station of the IO controller system, and the state encoding inside each record comes from the system status list definition, not from the hardware configuration order. Decode in three passes: read the header to learn how many records are valid, walk the records, and match each against your explicit device mapping. Keep the mapping in one place — a constants block or an array initialized once — because a reconfigured network that adds or renumbers devices invalidates it, and a silent mis-mapping is worse than no mapping: the logic would fault a healthy device and trust a dead one.
Preserve the last good decoded state in a separate copy. That is what lets the program distinguish "device disconnected" from "diagnostic read failed", which are different alarms with different owners.
When do you trust the data, and what does RET_VAL tell you? #
Trust the buffer only when the busy output is false and RET_VAL is zero; a nonzero RET_VAL means the read failed and the buffer holds stale, partial or header-only content, so raise a diagnostic-read alarm and use your preserved last good state instead. Two failure classes matter here. A buffer that is too small is rejected rather than truncated silently — the return value tells you, and the header's length field then tells you what the list wanted, so you resize and re-test. A read that fails while devices are healthy is a program or buffer problem, not a network problem; do not chase the network for it.
The reverse mistake is just as bad: logic that ignores the return value will read a frozen "connected" pattern after a failed call and conclude the network is fine. Wire the check in before the decode, permanently.
How do you test the mapping before trusting it in logic? #
Test with three controlled conditions, and accept the mapping only when all three pass: with a once-per-second poll and a 50 ms scan, a pulled device should raise its alarm within about 1.05 s of the drop. The arithmetic: the drop is seen at the next poll, up to 1.0 s later, plus one scan of 0.05 s to latch the alarm, so 1.0 s + 0.05 s = 1.05 s worst case.
- Good read on a healthy network. Confirm RET_VAL is zero,
header.nRecordsmatches the configured device count, and every mapped entry shows the connected encoding from the SSL definition. - Controlled disconnection. Pull one device's patch cable and watch its entry change to the disconnected encoding within the calculated window, while every unrelated entry keeps its state. Restore the cable and confirm the entry returns.
- Forced read failure. Shrink the buffer in a test copy of the project and confirm the program raises the diagnostic-read alarm instead of reporting stale device states, then restore the correct size.
Record the results against the configuration revision. The final check is that after both a successful read and a controlled connection loss, the intended device maps to the correct documented state — that is the evidence the logic can run on.
Questions asked
Can an S7-300 use the same SFC 51 read?
SFC 51 RDSYSST is available on S7-300 and S7-400 CPUs, but the PROFINET list only has content where the CPU is the IO controller of a PROFINET system. On an S7-300 with a PROFINET interface in that role the same call works; on a PROFIBUS-only CPU there is no PROFINET device array to read.
Does a connected state mean the device is working?
No. The connection state says only that the IO controller and the device exchange PROFINET data. A device can stay connected while reporting a process or measurement fault through its own data. If the sequence logic needs process health, wire the device's fault indication separately and never use the connection bit as its proxy.
How often should the SFC be called?
Slower than your alarm requirement, because each call is an acyclic job that loads the CPU and the device. The once-per-second trigger in the worked example suits general alarm annunciation; go faster only when an interlock genuinely needs the shorter detection time, and always trigger on a fresh edge rather than every scan.
What does it mean when several devices drop at the same time?
A shared cause. One device changing state points at that device and its own cable path; several changing together point at the common equipment between them and the controller, so check the switch, its uplink and the controller's PROFINET port first. Your mapping should therefore log which entries changed together, not just that an entry changed.
Can one buffer serve several SSL reads?
Yes. The header the SFC writes at the start of the destination area carries the length in bytes and the number of records actually transferred, so a buffer sized for the largest list you read can be reused for smaller ones. Separate buffers per list keep the decode logic simpler and stop a failed read on one list from overwriting another list's last good data.