public static Memory <byte> TranslateToMemory(S7AckDataDatagram datagram) { var result = S7HeaderDatagram.TranslateToMemory(datagram.Header); S7HeaderErrorCodesDatagram.TranslateToMemory(datagram.Error, result.Slice(datagram.Header.GetHeaderSize())); return(result); }
public static IMemoryOwner <byte> TranslateToMemory(S7AckDataDatagram datagram, out int memoryLength) { var result = S7HeaderDatagram.TranslateToMemory(datagram.Header, datagram.Header.GetHeaderSize() + datagram.Error.GetSize() + datagram.Header.ParamLength + datagram.Header.DataLength, out memoryLength); var take = memoryLength - datagram.Header.GetHeaderSize(); S7HeaderErrorCodesDatagram.TranslateToMemory(datagram.Error, result.Memory.Slice(datagram.Header.GetHeaderSize(), take)); return(result); }
public static Memory <byte> TranslateToMemory(S7HeaderErrorCodesDatagram datagram, Memory <byte> memory) { var result = memory.IsEmpty ? new Memory <byte>(new byte[2]) : memory; // check if we could use ArrayBuffer var span = result.Span; span[0] = datagram.ErrorClass; span[1] = datagram.ErrorCode; return(result); }
public static S7HeaderErrorCodesDatagram TranslateFromMemory(Memory <byte> data) { var span = data.Span; var result = new S7HeaderErrorCodesDatagram { ErrorClass = span[0], ErrorCode = span[1] }; return(result); }
public static S7AckDataDatagram TranslateFromMemory(Memory <byte> data) { var result = new S7AckDataDatagram { Header = S7HeaderDatagram.TranslateFromMemory(data) }; result.Error = S7HeaderErrorCodesDatagram.TranslateFromMemory(data.Slice(result.Header.GetHeaderSize())); return(result); }