C# Class LitDev.LDCommPort

Show file Open project: litdev1/LitDev

Public Methods

Method Description
AvailablePorts ( ) : Primitive

Returns a list of available serial ports.

ClosePort ( ) : Primitive

Closes the open serial port.

OpenPort ( Primitive portName, Primitive baudRate ) : Primitive

Opens a serial port for use. Assumes 8 databits, no parity.

RXAll ( ) : Primitive

Reads all available bytes in the open comm port input buffer.

RXByte ( ) : Primitive

Reads one byte from the open serial port and returns that byte as an integer.

RXChar ( ) : Primitive

Reads one byte from the open serial port and returns that byte as a unicode character.

SetDataBits ( Primitive dataBits ) : Primitive

Sets current port data bits. 5 to 8 (default).

SetEncoding ( Primitive encoding ) : Primitive

Sets current port encoding for send and receive text conversion.

SetHandshake ( Primitive handshake ) : Primitive

Sets or clears hardware flow control for the current port.

SetParity ( Primitive parity ) : Primitive

Sets current port parity.

SetStopBits ( Primitive stopBits ) : Primitive

Current port stop bits.

SwapPort ( Primitive portName ) : Primitive

Switch the current active port to a previously opened port.

TXByte ( Primitive dataByte ) : Primitive

Sends one byte to the serial port.

TXString ( Primitive dataString ) : Primitive

Sends a string to the serial port.

Private Methods

Method Description
DataReceivedEvent ( Object sender, System.IO.Ports.SerialDataReceivedEventArgs e ) : void
ErrorReceivedEvent ( Object sender, System.IO.Ports.SerialErrorReceivedEventArgs e ) : void

Method Details

AvailablePorts() public static method

Returns a list of available serial ports.
public static AvailablePorts ( ) : Primitive
return Primitive

ClosePort() public static method

Closes the open serial port.
public static ClosePort ( ) : Primitive
return Primitive

OpenPort() public static method

Opens a serial port for use. Assumes 8 databits, no parity.
public static OpenPort ( Primitive portName, Primitive baudRate ) : Primitive
portName Primitive /// String identifying which port to open in the form of "COM8". ///
baudRate Primitive /// Integer baud rate, for example 9600. ///
return Primitive

RXAll() public static method

Reads all available bytes in the open comm port input buffer.
public static RXAll ( ) : Primitive
return Primitive

RXByte() public static method

Reads one byte from the open serial port and returns that byte as an integer.
public static RXByte ( ) : Primitive
return Primitive

RXChar() public static method

Reads one byte from the open serial port and returns that byte as a unicode character.
public static RXChar ( ) : Primitive
return Primitive

SetDataBits() public static method

Sets current port data bits. 5 to 8 (default).
public static SetDataBits ( Primitive dataBits ) : Primitive
dataBits Primitive The data bits: /// 5 to 8 (default). ///
return Primitive

SetEncoding() public static method

Sets current port encoding for send and receive text conversion.
public static SetEncoding ( Primitive encoding ) : Primitive
encoding Primitive The encoding: /// "Ascii" (default), "Unicode", "UTF7", "UTF8", "UTF32" or "BigEndianUnicode". ///
return Primitive

SetHandshake() public static method

Sets or clears hardware flow control for the current port.
public static SetHandshake ( Primitive handshake ) : Primitive
handshake Primitive /// "H" to select hardware flow control, "HX" for hardware and software flow control, "X" for software fow control, any other character to clear. ///
return Primitive

SetParity() public static method

Sets current port parity.
public static SetParity ( Primitive parity ) : Primitive
parity Primitive The parity: /// "None" (default), "Even", "Mark", "Odd" or "Space". ///
return Primitive

SetStopBits() public static method

Current port stop bits.
public static SetStopBits ( Primitive stopBits ) : Primitive
stopBits Primitive The stop bits: /// "One" (default), "None", "OnePointFive" or "Two". ///
return Primitive

SwapPort() public static method

Switch the current active port to a previously opened port.
public static SwapPort ( Primitive portName ) : Primitive
portName Primitive String identifying a port that is already opened.
return Primitive

TXByte() public static method

Sends one byte to the serial port.
public static TXByte ( Primitive dataByte ) : Primitive
dataByte Primitive /// The byte to be written to the port. ///
return Primitive

TXString() public static method

Sends a string to the serial port.
public static TXString ( Primitive dataString ) : Primitive
dataString Primitive /// String value to be sent. ///
return Primitive