Helper Class Reference  1.3
HomeGenie - Automation Programs' Engine API
Public Member Functions | Properties | List of all members
SerialPortHelper Class Reference

Serial port helper.
Class instance accessor: SerialPort More...

Public Member Functions

SerialPortHelper WithName (string port)
 Selects the serial port with the specified name. More...
 
bool Connect ()
 Connect the serial port (@115200bps). More...
 
bool Connect (int baudRate, StopBits stopBits=StopBits.One, Parity parity=Parity.None)
 Connect the serial port at the specified speed. More...
 
SerialPortHelper Disconnect ()
 Disconnects the serial port. More...
 
void SendMessage (string message)
 Sends a string message. More...
 
void SendMessage (byte[] message)
 Sends a raw data message. More...
 
SerialPortHelper OnStringReceived (Action< string > receivedAction)
 Sets the function to call when a new string message is received. More...
 
SerialPortHelper OnMessageReceived (Action< byte[]> receivedAction)
 Sets the function to call when a new raw message is received. More...
 
SerialPortHelper OnStatusChanged (Action< bool > statusChangeAction)
 Sets the function to call when the status of the serial connection changes. More...
 

Properties

bool IsConnected [get]
 Gets a value indicating whether the serial port is connected. More...
 
string EndOfLine [get, set]
 Gets or sets the end of line delimiter used in text messaging. More...
 

Detailed Description

Serial port helper.
Class instance accessor: SerialPort

Member Function Documentation

◆ WithName()

SerialPortHelper WithName ( string  port)

Selects the serial port with the specified name.

Returns
SerialPortHelper.
Parameters
portPort name.

◆ Connect() [1/2]

bool Connect ( )

Connect the serial port (@115200bps).

◆ Connect() [2/2]

bool Connect ( int  baudRate,
StopBits  stopBits = StopBits.One,
Parity  parity = Parity.None 
)

Connect the serial port at the specified speed.

Parameters
baudRateBaud rate.
stopBitsStop Bits.
parityParity.

◆ Disconnect()

SerialPortHelper Disconnect ( )

Disconnects the serial port.

◆ SendMessage() [1/2]

void SendMessage ( string  message)

Sends a string message.

Parameters
messageMessage.

◆ SendMessage() [2/2]

void SendMessage ( byte[]  message)

Sends a raw data message.

Parameters
messageMessage.

◆ OnStringReceived()

SerialPortHelper OnStringReceived ( Action< string >  receivedAction)

Sets the function to call when a new string message is received.

Parameters
receivedActionFunction or inline delegate.

◆ OnMessageReceived()

SerialPortHelper OnMessageReceived ( Action< byte[]>  receivedAction)

Sets the function to call when a new raw message is received.

Parameters
receivedActionFunction or inline delegate.

◆ OnStatusChanged()

SerialPortHelper OnStatusChanged ( Action< bool >  statusChangeAction)

Sets the function to call when the status of the serial connection changes.

Parameters
statusChangeActionFunction or inline delegate.

Property Documentation

◆ IsConnected

bool IsConnected
get

Gets a value indicating whether the serial port is connected.

true if connected; otherwise, false.

◆ EndOfLine

string EndOfLine
getset

Gets or sets the end of line delimiter used in text messaging.

The end of line.


The documentation for this class was generated from the following file: