Skip to main content

Interface ISerialMessagePort

Contract for a serial port that provides predictable messaging.

Assembly: Meadow.Contracts.dll
View Source
Declaration
public interface ISerialMessagePort

Properties

BaudRate

Gets or sets the serial baud rate.

View Source
Declaration
int BaudRate { get; set; }

DataBits

Gets or sets the standard length of data bits per byte.

View Source
Declaration
int DataBits { get; }

IsOpen

Gets a value indicating the open or closed status of the SerialPort object.

View Source
Declaration
bool IsOpen { get; }

Parity

Gets or sets the parity-checking protocol.

View Source
Declaration
Parity Parity { get; }

StopBits

Gets or sets the standard number of stop bits per byte.

View Source
Declaration
StopBits StopBits { get; }

PortName

Gets the port name used for communications.

View Source
Declaration
string PortName { get; }

ReceiveBufferSize

The size, in bytes, of the receive buffer that caches message data from the attached peripheral.

View Source
Declaration
int ReceiveBufferSize { get; }

Methods

Close()

Closes the port connection and sets the IsOpen property to false.

View Source
Declaration
void Close()

Open()

Opens a new serial port connection.

View Source
Declaration
void Open()

Write(byte[])

Writes data to the serial port.

View Source
Declaration
int Write(byte[] buffer)
Returns

System.Int32

Parameters
TypeName
System.Byte[]buffer

Write(byte[], int, int)

Writes a specified number of bytes to the serial port using data from a buffer.

View Source
Declaration
int Write(byte[] buffer, int offset, int count)
Returns

System.Int32

Parameters
TypeNameDescription
System.Byte[]bufferThe byte array that contains the data to write to the port.
System.Int32offsetThe zero-based byte offset in the buffer parameter at which to begin copying bytes to the port.
System.Int32countThe number of bytes to write.

ClearReceiveBuffer()

Discards all data from the receive buffer.

View Source
Declaration
void ClearReceiveBuffer()

Events

MessageReceived

Indicates that a message has been received through a port represented by the SerialMessagePort object.

View Source
Declaration
event EventHandler<SerialMessageData> MessageReceived
Event Type

System.EventHandler<Meadow.Hardware.SerialMessageData>