Class DeviceFramers

Namespace
ProtoTest.Devices
Assembly
ProtoTest.Devices.dll

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

delimiter ReadOnlyMemory<byte>
mediaType string

Returns

IDeviceFramer

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

start ReadOnlyMemory<byte>
end ReadOnlyMemory<byte>
mediaType string

Returns

IDeviceFramer

FixedLength(int, string)

Frames of exactly bytes bytes each.

public static IDeviceFramer FixedLength(int bytes, string mediaType = "application/octet-stream")

Parameters

bytes int
mediaType string

Returns

IDeviceFramer

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

headerBytes int
bigEndian bool
mediaType string

Returns

IDeviceFramer

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

terminator string

Returns

IDeviceFramer