Skip to main content

Class SerialMessageProcessor

A serial message processor class to accept data, parse and raise notifications when complete messages are received

Assembly: Meadow.Contracts.dll
View Source
Declaration
public class SerialMessageProcessor

Derived:
Meadow.Hardware.SerialMessagePort

Properties

ReceiveBufferSize

The buffer size, in bytes

View Source
Declaration
public virtual int ReceiveBufferSize { get; protected set; }

NullDataValue

Optional null data value Value will be removed from data before being added to the buffer

View Source
Declaration
public byte? NullDataValue { get; set; }

Fields

messageMode

The current message mode used by the SerialMessageProcessor.

View Source
Declaration
protected SerialMessageProcessor.SerialMessageMode messageMode

messageDelimiterTokens

The tokens used as delimiters to identify the end of a message.

View Source
Declaration
protected byte[] messageDelimiterTokens

messageLength

The expected length of each message.

View Source
Declaration
protected int messageLength

preserveDelimiter

Indicates whether the delimiter should be preserved in the received message.

View Source
Declaration
protected bool preserveDelimiter

readBuffer

The read buffer used by the SerialMessageProcessor to store received data.

View Source
Declaration
protected CircularBuffer<byte> readBuffer

msgParseLock

The lock object used for thread synchronization during message parsing.

View Source
Declaration
protected object msgParseLock

Methods

Process(byte[])

View Source
Declaration
public void Process(byte[] data)
Parameters
TypeNameDescription
System.Byte[]datareturns true if end of stream (suffix delimiter found at end, or prefix found without new prefix)

RaiseMessageReceivedAndNotify(SerialMessageData)

Raise message received notification to subscribers

View Source
Declaration
protected void RaiseMessageReceivedAndNotify(SerialMessageData messageData)
Parameters
TypeName
Meadow.Hardware.SerialMessageDatamessageData

Events

MessageReceived

Raised when a message, as defined in the constructor, arrives.

View Source
Declaration
public event EventHandler<SerialMessageData> MessageReceived
Event Type

System.EventHandler<Meadow.Hardware.SerialMessageData>