This class contains the core functionality to access serial port.
Open/Close |
---|
Close | Closes previously opened communication port. |
Open | Opens specified serial port and sets up its parameters. |
SetSettingsFromString | Sets serial port settings from the string. |
Serial Ports Enumeration |
---|
EnumSerialPorts | Refreshes information about serial ports and returns their number. |
GetSerialPort | Retrieves string value of serial port name. |
GetSerialPortDescription | Retrieves string description of serial port. |
Read/Write |
---|
Read | Reads specified number of bytes from serial port. |
ReadArray | Reads specified number of bytes from serial port to array. |
ReadArrayOverlapped | Performs an asynchronous read operation (overlapped) into safe array of bytes. |
ReadOverlapped | Performs an asynchronous read operation (overlapped). |
Write | Writes specified number of bytes to serial port. |
WriteArray | Writes specified number of bytes from array to serial port. |
WriteArrayOverlapped | Performs an asynchronous write operation (overlapped) of safe array data. |
WriteOverlapped | Performs an asynchronous write operation (overlapped). |
Other Methods |
---|
CancelIO | Cancels all pending I/O operations. |
Flush | Forces a write all buffered data for the FIFO and waits for completion. |
PurgeQueue | Purges input or/and output queue(s). |
SetBreak | Suspends/restores character transmission. |
Port Configuration |
---|
BaudRate | Baud rate serial port communication parameter. |
DataBits | Byte size serial port communications parameter. One of FTSPCDataBits values. |
FlowControl | Handshaking state. One of FTSPCFlowControl values. |
Parity | Specifies if parity checking is enabled. If TRUE, parity checking is performed and errors are reported |
PortName | Name of the serial port. |
StopBits | Number of stop bits to be used. Stop bits separate each unit of data on an asynchronous serial connection. They are also sent continuously when no data is available for transmission. Refer to FTSPCStopBits. |
Line Signals |
---|
Cts | CTS (clear-to-send) signal state. |
Dcd | RLSD (receive-line-signal-detect) signal state. |
Dsr | DSR (data-set-ready) signal state. |
Dtr | DTR (data-terminal-ready) signal state. |
Ring | State of the RING line. |
Rts | RTS (request-to-send) signal state. |
Timeouts |
---|
ReadIntervalTimeout | The maximum time allowed to elapse between the arrival of two bytes on the communications line, in milliseconds. During a Read operation, the time period begins when the first byte is received. If the interval between the arrival of any two bytes exceeds this amount, the Read operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used. |
ReadTotalTimeoutConstant | A constant used to calculate the total time-out period for read operations, in milliseconds. For each read operation, this value is added to the product of the ReadTotalTimeoutMultiplier and the requested number of bytes. |
ReadTotalTimeoutMultiplier | The multiplier used to calculate the total time-out period for read operations, in milliseconds. For each read operation, this value is multiplied by the requested number of bytes to be read. |
WriteTotalTimeoutConstant | A constant used to calculate the total time-out period for write operations, in milliseconds. For each write operation, this value is added to the product of the WriteTotalTimeoutMultiplier and the requested number of bytes. |
WriteTotalTimeoutMultiplier | The multiplier used to calculate the total time-out period for write operations, in milliseconds. For each write operation, this value is multiplied by the number of bytes to be written. |
Special Characters |
---|
EofChar | Specifies the value of the character used to signal the end of data. |
ErrorChar | Specifies the value of the character used to replace bytes received with a parity error. |
EventChar | Specifies the value of the character used to signal an event. |
XoffChar | Value of the XOFF character for both transmission and reception. XOFF is a software control to stop the transmission of data (whereas RTS and CTS are hardware controls). XON resumes the transmission. |
XonChar | Value of the XON character for both transmission and reception. XON is a software control to resume the transmission of data (whereas RTS and CTS are hardware controls). XOFF stops the transmission. |
Other Properties |
---|
AutoOpen | Open COM port automatically, without calling Open method. |
DiscardNull | Gets or sets a value indicating whether null bytes are ignored when transmitted between the port and the receive buffer. |
InQUsedBytes | The current number of bytes in the input queue. |
IsOpened | Retrieves whether serial port is open. |
RxThreshold | Number of the bytes received from the COM port that fires OnReceive event. RxThreshold is set to 1 by default. |
OnBreak | This event is triggered when a break signal is detected in the received input. |
OnCts | This event is triggered when a change of the CTS signal is detected. |
OnDcd | This event is triggered when a change of the DCD signal is detected. |
OnDsr | This event is triggered when a change of the DSR signal is detected. |
OnError | This event is triggered when a line-status error occurs. |
OnEventChar | This event is triggered when the event character was received and placed in the input buffer. The event character is specified in EventChar property. |
OnPortLost | This event is triggered when a COM port is removed while it is opened (e.g. using USB to Serial cable). |
OnReceive | This event occurs when data is received on the serial port. |
OnRing | This event is triggered when a change of the RING signal is detected. |
OnTransmit | This event is triggered when data has been sucessfully written to the serial port. |