From 970e9d43950f7ed7504b9ff69d2e76fb5c06c927 Mon Sep 17 00:00:00 2001 From: Michael Croes Date: Tue, 1 Aug 2023 22:55:19 +0200 Subject: [PATCH] feat: Add sync version of ReadStatus --- S7.Net/PlcSynchronous.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/S7.Net/PlcSynchronous.cs b/S7.Net/PlcSynchronous.cs index c30e0cf..1b3af97 100644 --- a/S7.Net/PlcSynchronous.cs +++ b/S7.Net/PlcSynchronous.cs @@ -492,6 +492,18 @@ namespace S7.Net } } + /// + /// Read the current status from the PLC. A value of 0x08 indicates the PLC is in run status, regardless of the PLC type. + /// + /// The current PLC status. + public byte ReadStatus() + { + var dataToSend = BuildSzlReadRequestPackage(0x0424, 0); + var s7data = RequestTsdu(dataToSend); + + return (byte) (s7data[37] & 0x0f); + } + private byte[] RequestTsdu(byte[] requestData) => RequestTsdu(requestData, 0, requestData.Length); private byte[] RequestTsdu(byte[] requestData, int offset, int length)