Skip to content

Commit

Permalink
refactor: Rename WriteSzlRequestHeader to WriteUserDataRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
mycroes committed Aug 30, 2023
1 parent 2f2dcf7 commit 08078e6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions S7.Net/PLCHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ private static void WriteUserDataHeader(System.IO.MemoryStream stream, int param
WriteS7Header(stream, s7MessageTypeUserData, parameterLength, dataLength);
}

private static void WriteSzlRequestHeader(System.IO.MemoryStream stream, byte functionGroup, byte subFunction, int dataLength)
private static void WriteUserDataRequest(System.IO.MemoryStream stream, byte functionGroup, byte subFunction, int dataLength)
{
WriteUserDataHeader(stream, 8, dataLength);

// Parameter
const byte szlMethodRequest = 0x11;
const byte szlTypeRequest = 0x4;
const byte userDataMethodRequest = 0x11;
const byte userDataTypeRequest = 0x4;

// Parameter head
stream.Write(new byte[] { 0x00, 0x01, 0x12 });
// Parameter length
stream.WriteByte(0x04);
// Method
stream.WriteByte(szlMethodRequest);
stream.WriteByte(userDataMethodRequest);
// Type / function group
stream.WriteByte((byte)(szlTypeRequest << 4 | (functionGroup & 0x0f)));
stream.WriteByte((byte)(userDataTypeRequest << 4 | (functionGroup & 0x0f)));
// Subfunction
stream.WriteByte(subFunction);
// Sequence number
Expand All @@ -84,7 +84,7 @@ private static void WriteSzlReadRequest(System.IO.MemoryStream stream, ushort sz
const byte szlFunctionGroupCpuFunctions = 0b100;
const byte subFunctionReadSzl = 0x01;

WriteSzlRequestHeader(stream, szlFunctionGroupCpuFunctions, subFunctionReadSzl, 8);
WriteUserDataRequest(stream, szlFunctionGroupCpuFunctions, subFunctionReadSzl, 8);

// Data
const byte success = 0xff;
Expand Down

0 comments on commit 08078e6

Please sign in to comment.