From 18c3883dc0e37b7a1d2ddcd5ee505fde7d4f5587 Mon Sep 17 00:00:00 2001 From: Michael Croes Date: Fri, 21 Jul 2023 22:27:30 +0200 Subject: [PATCH] feat: Add WriteUserDataHeader --- S7.Net/PLCHelpers.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/S7.Net/PLCHelpers.cs b/S7.Net/PLCHelpers.cs index d3c66d8..fc24a3a 100644 --- a/S7.Net/PLCHelpers.cs +++ b/S7.Net/PLCHelpers.cs @@ -47,6 +47,15 @@ namespace S7.Net stream.WriteByte((byte)amount); } + private static void WriteUserDataHeader(System.IO.MemoryStream stream, int parameterLength, int dataLength) + { + const byte s7MessageTypeUserData = 0x07; + + WriteTpktHeader(stream, 17 + parameterLength + dataLength); + WriteDataHeader(stream); + WriteS7Header(stream, s7MessageTypeUserData, parameterLength, dataLength); + } + /// /// Create the bytes-package to request data from the PLC. You have to specify the memory type (dataType), /// the address of the memory, the address of the byte and the bytes count.