Interface IDeviceFramer
Cuts a byte stream into device frames and writes frames back. A stream transport (TCP, serial) has no message boundaries of its own, so the framer is the one piece of protocol knowledge it carries; what a frame means stays in the device class.
public interface IDeviceFramer
- Extension Methods
Methods
TryRead(ReadOnlySpan<byte>, out DeviceFrame, out int)
Reads one frame from the start of buffered. Returns false while the bytes do not
hold a whole frame yet. consumed is how many bytes to drop from the front in
either case: the frame and its delimiters, or noise a framer skips before a frame starts.
bool TryRead(ReadOnlySpan<byte> buffered, out DeviceFrame frame, out int consumed)
Parameters
bufferedReadOnlySpan<byte>frameDeviceFrameconsumedint
Returns
Write(DeviceFrame, IBufferWriter<byte>)
Writes one frame with the delimiters or header the protocol needs.
void Write(DeviceFrame frame, IBufferWriter<byte> output)
Parameters
frameDeviceFrameoutputIBufferWriter<byte>