Class SerialPortConnection
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
Inherited Members
Namespace: RGB.NET.Devices.WS281X
Assembly: RGB.NET.Devices.WS281X.dll
Syntax
public sealed class SerialPortConnection : ISerialConnection, IDisposable
Constructors
| Edit this page View SourceSerialPortConnection(string, int)
Initializes a new instance of the SerialPortConnection class.
Declaration
public SerialPortConnection(string port, int baudRate)
Parameters
| Type | Name | Description |
|---|---|---|
| string | port | The name of the serial-port to connect to. |
| int | baudRate | The baud-rate used by the serial-connection. |
Properties
| Edit this page View SourceBaudRate
Gets the baud-rate used by the serial connection.
Declaration
public int BaudRate { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsOpen
Gets the connection-status of the serial connection.
true if connected; otherwise false.
Declaration
public bool IsOpen { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Port
Gets the COM-port used by the serial connection.
Declaration
public string Port { get; }
Property Value
| Type | Description |
|---|---|
| string |
SerialPort
The SerialPort used for the connection.
Declaration
public SerialPort SerialPort { get; }
Property Value
| Type | Description |
|---|---|
| SerialPort |
Methods
| Edit this page View SourceDiscardInBuffer()
Discards the in-buffer of the serial connection.
Declaration
public void DiscardInBuffer()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Open()
Opens the serial connection.
Declaration
public void Open()
ReadByte()
Reads a single byte from the serial connection
Declaration
public byte ReadByte()
Returns
| Type | Description |
|---|---|
| byte | The byte read. |
ReadTo(char)
Blocks till the provided char is received from the serial connection.
Declaration
public void ReadTo(char target)
Parameters
| Type | Name | Description |
|---|---|---|
| char | target | The target-character to read to. |
Write(byte[], int, int)
Writes the provided data to the serial connection.
Declaration
public void Write(byte[] buffer, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | buffer | The buffer containing the data to write. |
| int | offset | The offset of the data in the buffer. |
| int | length | The amount of data to write. |
WriteLine(string)
Write the provided text to the serial connection followed by a line break.
Declaration
public void WriteLine(string line)
Parameters
| Type | Name | Description |
|---|---|---|
| string | line | The text to write. |