C# Class SerialPortLib.SerialPortInput

Serial port I/O
显示文件 Open project: genielabs/serialport-lib-dotnet Class Usage Examples

Public Methods

Method Description
Connect ( ) : bool

Connect to the serial port.

Disconnect ( ) : void

Disconnect the serial port.

SendMessage ( byte message ) : bool

Sends the message.

SetPort ( string portname, int baudrate = 115200, StopBits stopbits = StopBits.One, Parity parity = Parity.None ) : void

Sets the serial port options.

Protected Methods

Method Description
OnConnectionStatusChanged ( SerialPortLib.ConnectionStatusChangedEventArgs args ) : void

Raises the connected state changed event.

OnMessageReceived ( SerialPortLib.MessageReceivedEventArgs args ) : void

Raises the message received event.

Private Methods

Method Description
Close ( ) : void
ConnectionWatcherTask ( ) : void
HandleErrorReceived ( object sender, System.IO.Ports.SerialErrorReceivedEventArgs e ) : void
Open ( ) : bool
ReaderTask ( ) : void

Method Details

Connect() public method

Connect to the serial port.
public Connect ( ) : bool
return bool

Disconnect() public method

Disconnect the serial port.
public Disconnect ( ) : void
return void

OnConnectionStatusChanged() protected method

Raises the connected state changed event.
protected OnConnectionStatusChanged ( SerialPortLib.ConnectionStatusChangedEventArgs args ) : void
args SerialPortLib.ConnectionStatusChangedEventArgs Arguments.
return void

OnMessageReceived() protected method

Raises the message received event.
protected OnMessageReceived ( SerialPortLib.MessageReceivedEventArgs args ) : void
args SerialPortLib.MessageReceivedEventArgs Arguments.
return void

SendMessage() public method

Sends the message.
public SendMessage ( byte message ) : bool
message byte Message.
return bool

SetPort() public method

Sets the serial port options.
public SetPort ( string portname, int baudrate = 115200, StopBits stopbits = StopBits.One, Parity parity = Parity.None ) : void
portname string Portname.
baudrate int Baudrate.
stopbits StopBits Stopbits.
parity Parity Parity.
return void