Class ComPort
- Namespace
- NominalSystems.External
- Assembly
- NominalSystems.External.dll
The base class for all ComPort Integrations
public class ComPort
- Inheritance
-
ComPort
Constructors
ComPort()
Default constructor for the software
public ComPort()
Fields
USBBaudRate
The BaudRate of the Serial Port Connection. The value is less than zero if unconfigured or the close function has been called
public int USBBaudRate
Field Value
USBPortName
The COMPort the SerialPort has connected to. The Length is zero when unconfigured or the close function has been called
public string USBPortName
Field Value
Properties
IsCDHolding
Boolean to store the status of CDHolding for the ComPort, true if Carrier detected
public bool IsCDHolding { get; }
Property Value
IsDsrHolding
Boolean to store the status of DsrHolding, true if a Data Set Ready signal has been sent to the port
public bool IsDsrHolding { get; }
Property Value
IsOpen
Boolean to store the status of the ComPort, true is Open
public bool IsOpen { get; }
Property Value
NumBytesInBuffer
The Number of Bytes available in the read buffer
public int NumBytesInBuffer { get; }
Property Value
Methods
Close()
Called to close a Serial Port connection
public bool Close()
Returns
- bool
Returns if closing the comport was successful
Flush()
Called to clear the ComPort buffer
public void Flush()
ListComPorts()
Called to list ComPorts that can be used for a connection
public static string[] ListComPorts()
Returns
- string[]
An array of available Serial Ports as a String
Open(string, int)
Called to Create and open a Serial Port connection
public bool Open(string portName, int baudRate)
Parameters
Returns
- bool
Returns if opening the comport was successful
PublishByte(byte, bool)
Called to write a Byte to the ComPort
public void PublishByte(byte bytePayload, bool useLengthHeader = false)
Parameters
bytePayload
byteThe Byte to write to the ComPort
useLengthHeader
boolEnables sending the size of the Byte before the value of the Byte
PublishByteArray(byte[], bool)
Called to write a Byte array to the ComPort
public void PublishByteArray(byte[] byteArrayPayload, bool useLengthHeader = false)
Parameters
byteArrayPayload
byte[]The Byte array to write to the ComPort
useLengthHeader
boolEnables sending the length of the Byte array before the array
PublishDouble(double, bool)
Called to write a Double to the ComPort
public void PublishDouble(double doublePayload, bool useLengthHeader = false)
Parameters
doublePayload
doubleThe Double to write to the ComPort
useLengthHeader
boolEnables sending the size of the Double before the value of the Double
PublishDoubleArray(double[], bool)
Called to write an array of Doubles to the ComPort
public void PublishDoubleArray(double[] doubleArrayPayload, bool useLengthHeader = true)
Parameters
doubleArrayPayload
double[]The Double array to write to the ComPort
useLengthHeader
boolEnables sending the size of the Double array before the values of the Double array. Required for the matching Receive functions
PublishFloat(float, bool)
Called to write a Float to the ComPort
public void PublishFloat(float floatPayload, bool useLengthHeader = false)
Parameters
floatPayload
floatThe Float to write to the ComPort
useLengthHeader
boolEnables sending the size of the Float before the value of the Float as a byte array
PublishFloatArray(float[], bool, bool)
Called to write a Float array to the ComPort
public void PublishFloatArray(float[] floatArrayPayload, bool useLengthHeader = false, bool useArrayLengthHeader = true)
Parameters
floatArrayPayload
float[]The Float array to write to the ComPort
useLengthHeader
boolEnables sending the size of the Float before the value of the Float as a byte array
useArrayLengthHeader
boolEnables sending the length of the Float array before the array. Required for the matching Receive functions
PublishInt(int, bool)
Called to write a Integer to the ComPort
public void PublishInt(int intPayload, bool useLengthHeader = false)
Parameters
intPayload
intThe Integer to write to the ComPort
useLengthHeader
boolEnables sending the size of the Integer before the value of the Integer
PublishIntArray(int[], bool, bool)
Called to write a Integer array to the ComPort
public void PublishIntArray(int[] integerArrayPayload, bool useLengthHeader = false, bool useArrayLengthHeader = true)
Parameters
integerArrayPayload
int[]The Integer array to write to the ComPort
useLengthHeader
boolEnables sending the size of the Integer before the value of the Integer as a byte array
useArrayLengthHeader
boolEnables sending the length of the Integer array before the array. Required for the matching Receive functions
PublishLine(string, bool)
Called to write a String to the ComPort with a NewLine terminator included after the String
public void PublishLine(string stringPayload, bool useLengthHeader = false)
Parameters
stringPayload
stringThe String to write to the ComPort
useLengthHeader
boolEnables sending the length of the String with the NewLine terminator included before the String as Bytes
PublishString(string, bool)
Called to write a String to the ComPort
public void PublishString(string stringPayload, bool useLengthHeader = false)
Parameters
stringPayload
stringThe String to write to the ComPort
useLengthHeader
boolEnables sending the length of the String before the String as Bytes
PublishStringArray(string[], bool, bool)
Called to write an array of Strings to the ComPort
public void PublishStringArray(string[] stringArrayPayload, bool useLengthHeader = true, bool useArrayLengthHeader = true)
Parameters
stringArrayPayload
string[]The String array to write to the ComPort
useLengthHeader
boolEnables sending the length of the String before each String as Bytes. Required for the matching Receive functions
useArrayLengthHeader
boolEnables sending the length of the String array before the array. Required for the matching Receive functions
PublishStringLineArray(string[], bool, bool)
Called to write an array of Strings with a NewLine terminator included after each String
public void PublishStringLineArray(string[] stringArrayPayload, bool useLengthHeader = false, bool useArrayLengthHeader = true)
Parameters
stringArrayPayload
string[]The String array to write to the ComPort
useLengthHeader
boolEnables sending the length of the String with the NewLine terminator included before each String as Bytes
useArrayLengthHeader
boolEnables sending the length of the String array before the array. Required for the matching Receive functions
ReceiveAll()
Called to read the entire contents of the ComPorts buffer
public string ReceiveAll()
Returns
- string
The read data as a String
ReceiveByte()
Called to read a Byte from the ComPort buffer
public byte ReceiveByte()
Returns
- byte
The read Byte
ReceiveByte(int)
Called to read a Byte from the ComPort buffer with a specified timeout
public byte ReceiveByte(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- byte
The read Byte
ReceiveByteArray(int)
Called to read the ComPort buffer as a Byte array
public byte[] ReceiveByteArray(int NumBytesToRead = -1)
Parameters
NumBytesToRead
intThe number of Bytes to read. If -1, all available bytes are read
Returns
- byte[]
The read Byte array
ReceiveByteArray(int, int)
Called to read the ComPort buffer as a Byte array with a specified timeout
public byte[] ReceiveByteArray(int NumBytesToRead, int timeout)
Parameters
NumBytesToRead
intThe number of Bytes to read. If -1, all available bytes are read
timeout
int[ms] The specified timeout
Returns
- byte[]
The read Byte array
ReceiveDouble()
Called to read a Double from the ComPorts buffer
public double ReceiveDouble()
Returns
- double
The read data as a Double
ReceiveDouble(int)
Called to read a Double from the ComPorts buffer with a specified timeout
public double ReceiveDouble(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- double
The read data as a Double
ReceiveDoubleArray()
Called to read a Double array from the ComPorts buffer
public double[] ReceiveDoubleArray()
Returns
- double[]
The read data as a Double array
ReceiveDoubleArray(int)
Called to read a Double array from the ComPorts buffer
public double[] ReceiveDoubleArray(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- double[]
The read data as a Double array
ReceiveFloat()
Called to read a Float from the ComPorts buffer
public float ReceiveFloat()
Returns
- float
The read data as a Float
ReceiveFloat(int)
Called to read a Float from the ComPorts buffer with a specified timeout
public float ReceiveFloat(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- float
The read data as a Float
ReceiveFloatArray()
Called to read a Float array from the ComPorts buffer
public float[] ReceiveFloatArray()
Returns
- float[]
The read data as a Float array
ReceiveFloatArray(int)
Called to read a Float array from the ComPorts buffer with a specified timeout
public float[] ReceiveFloatArray(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- float[]
The read data as a Float array
ReceiveInt()
Called to read a Integer from the ComPorts buffer
public int ReceiveInt()
Returns
- int
The read data as a Integer
ReceiveInt(int)
Called to read a Integer from the ComPorts buffer with a specified timeout
public int ReceiveInt(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- int
The read data as a Integer
ReceiveIntArray()
Called to read a Integer array from the ComPorts buffer
public int[] ReceiveIntArray()
Returns
- int[]
The read data as a Integer array
ReceiveIntArray(int)
Called to read a Integer array from the ComPorts buffer
public int[] ReceiveIntArray(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- int[]
The read data as a Integer array
ReceiveLine()
Called to read the ComPorts buffer until the NewLine Value
public string ReceiveLine()
Returns
- string
The read data as a String
ReceiveLine(int)
Called to read the ComPorts buffer until the NewLine Value with a specified timeout
public string ReceiveLine(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- string
The read data as a String
ReceiveLineArray()
Called to read an array of Strings with a NewLine terminator from the ComPorts buffer
public string[] ReceiveLineArray()
Returns
- string[]
The read data as a String array
ReceiveLineArray(int)
Called to read an array of Strings with a NewLine terminator from the ComPorts buffer
public string[] ReceiveLineArray(int timeout)
Parameters
timeout
int[ms] The specified timeout
Returns
- string[]
The read data as a String array
ReceiveStringUntil(string)
Called to read the ComPorts buffer until a designated terminator
public string ReceiveStringUntil(string terminator)
Parameters
terminator
stringThe terminator to read the buffer to
Returns
- string
The read data as a String
ReceiveStringUntil(string, int)
Called to read the ComPorts buffer until a designated terminator with a specified timeout
public string ReceiveStringUntil(string terminator, int timeout)
Parameters
Returns
- string
The read data as a String