Interface ISerialMessagePort
Contract for a serial port that provides predictable messaging.
Assembly: Meadow.Contracts.dll
View Source
public interface ISerialMessagePort
Properties
BaudRate
Gets or sets the serial baud rate.
View Source
int BaudRate { get; set; }
DataBits
Gets or sets the standard length of data bits per byte.
View Source
int DataBits { get; }
IsOpen
Gets a value indicating the open or closed status of the SerialPort object.
View Source
bool IsOpen { get; }
Parity
Gets or sets the parity-checking protocol.
View Source
Parity Parity { get; }
StopBits
Gets or sets the standard number of stop bits per byte.
View Source
StopBits StopBits { get; }
PortName
Gets the port name used for communications.
View Source
string PortName { get; }
ReceiveBufferSize
The size, in bytes, of the receive buffer that caches message data from the attached peripheral.
View Source
int ReceiveBufferSize { get; }
Methods
Close()
Closes the port connection and sets the IsOpen property to false.
View Source
void Close()
Open()
Opens a new serial port connection.
View Source
void Open()
Write(byte[])
Writes data to the serial port.
View Source
int Write(byte[] buffer)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.Byte[] | buffer |
Write(byte[], int, int)
Writes a specified number of bytes to the serial port using data from a buffer.
View Source
int Write(byte[] buffer, int offset, int count)
Returns
System.Int32
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The byte array that contains the data to write to the port. |
System.Int32 | offset | The zero-based byte offset in the buffer parameter at which to begin copying bytes to the port. |
System.Int32 | count | The number of bytes to write. |
ClearReceiveBuffer()
Discards all data from the receive buffer.
View Source
void ClearReceiveBuffer()
Events
MessageReceived
Indicates that a message has been received through a port represented by the SerialMessagePort object.
View Source
event EventHandler<SerialMessageData> MessageReceived
Event Type
System.EventHandler<Meadow.Hardware.SerialMessageData>