Class DeviceFramers
The framers most device protocols need. A protocol with its own envelope implements IDeviceFramer.
public static class DeviceFramers
- Inheritance
-
DeviceFramers
- Inherited Members
Methods
Delimited(ReadOnlyMemory<byte>, string)
Frames ended by delimiter, which is not part of the frame.
public static IDeviceFramer Delimited(ReadOnlyMemory<byte> delimiter, string mediaType = "application/octet-stream")
Parameters
delimiterReadOnlyMemory<byte>mediaTypestring
Returns
Enveloped(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>, string)
Frames wrapped in a start and an end marker, such as STX (0x02) and ETX (0x03). Bytes before a start marker are skipped as line noise; the markers are not part of the frame.
public static IDeviceFramer Enveloped(ReadOnlyMemory<byte> start, ReadOnlyMemory<byte> end, string mediaType = "application/octet-stream")
Parameters
startReadOnlyMemory<byte>endReadOnlyMemory<byte>mediaTypestring
Returns
FixedLength(int, string)
Frames of exactly bytes bytes each.
public static IDeviceFramer FixedLength(int bytes, string mediaType = "application/octet-stream")
Parameters
Returns
LengthPrefixed(int, bool, string)
Frames preceded by their payload length in a 1, 2 or 4 byte unsigned header, big-endian unless
bigEndian is false. The header is not part of the frame.
public static IDeviceFramer LengthPrefixed(int headerBytes = 4, bool bigEndian = true, string mediaType = "application/octet-stream")
Parameters
Returns
Lines(string)
Text lines: each frame is the text before terminator, read and written as UTF-8.
Use "\r\n" for CRLF protocols. The terminator is not part of the frame.
public static IDeviceFramer Lines(string terminator = "\n")
Parameters
terminatorstring