Click or drag to resize

SerialPort Properties

The SerialPort type exposes the following members.

Properties
 NameDescription
Public propertyAutoReceive Set this property to true, if you want to receive the incoming data automatically in the Received event. Otherwise you have to use ReadBuffer method to get the received data. The default value is true.
Public propertyAutoReconnect Set this property to true, if you want to automatically reconnect to the serial port after a Faulted event, when the port is available again. Set AutoReconnect to true, before the port is faulted, otherwise it will have no effect. The default value is false.
Public propertyAutoReconnectCheckInterval The time interval in milliseconds the serial port is trying to periodically reconnect, after a Faulted event occur, if AutoReconnect is set to true. It must be a positive value. The default value is 4000.
Public propertyBaudRate Baud rate at which the communications device operates.
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event.
(Inherited from Component)
Public propertyCloseWhenLineStatusIsZero When this property is true and LineStatus becomes 0 (supposing that it was non 0 after the port has been opened), the port will be closed automatically. Set it to true, for improved fault detection. If you have problems with the port closing itself automatically immediately after open, set this property to false. The default value is true.
Public propertyConnectedTo Returns the port where the component is connected to.
Public propertyConnectionTime Indicates when the last connection was established.
Public propertyContainerGets the IContainer that contains the Component.
(Inherited from Component)
Public propertyCustomBaudRate Custom baud rate value, used when BaudRate is set to Custom.
Public propertyCustomPortName Custom port name can be used when Port is set to Custom. You can use any name, different from COMMxx.
Public propertyDataWidth Number of bits in the bytes transmitted and received.
Public propertyDelayObsolete.
Time interval between two receivings in milliseconds (frequency). Same as Interval.
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode.
(Inherited from Component)
Public propertyDiscardNulls Specifies whether null bytes are discarded. If this member is true, null bytes are discarded when received. The default value is false.
Public propertyDsrSensitivity Specifies whether the communications driver is sensitive to the state of the DSR signal. If this member is true, the driver ignores any bytes received, unless the DSR modem input line is high. The default value is false.
Public propertyEnableDtrOnOpen Enable DTR when the port is opening. The default value is true.
Public propertyEnableRtsOnOpen Enable RTS when the port is opening. The default value is true.
Public propertyEofChar Value of the character used to signal the end of data (ANSI: 0 - 255). The default value is (char)26.
Public propertyErrorChar Value of the character used to replace bytes received with a parity error (ANSI: 0 - 255). The default value is (char)0.
Protected propertyEventsGets the list of event handlers that are attached to this Component.
(Inherited from Component)
Public propertyEvtChar Value of the character used to signal an event (ANSI: 0 - 255). The default value is (char)26.
Public propertyHandle The Windows handle of the serial port. You can use it in some Windows API methods.
Public propertyHardwareFlowControl Hardware flow control of the serial port.
Public propertyIdleInterval Idle time interval in milliseconds. If the elapsed time from the last receive is higher than IdleInterval, Idle event occurs. If IdleInterval is 0, Idle event never occurs. It works only for AutoReceive = true.
Public propertyIdleTimeoutInterval You can set a time-out value to automatically close the connection and fire the IdleTimeout event, if there is no data received in several milliseconds. A value of zero indicates that time-out is not used.
Public propertyInputBuffer Recommended size of the device's internal input buffer, in bytes. The device driver receives the recommended buffer sizes, but is free to use any input and output (I/O) buffering scheme, as long as it provides reasonable performance and data is not lost due to overrun (except under extreme circumstances).
Public propertyInterval Time interval between two receivings in milliseconds (frequency). It must be a positive value. The default value is 100.
Public propertyCode exampleIsFaulted Indicates that the last connection was faulted.
Public propertyIsIdle True if Idle occurred, until Resumed. It works only for AutoReceive = true.
Public propertyIsReceiving This property is false when the component is receiving data from the port, otherwise is false. Use this property to check if the component is inside a receiving process.
Public propertyIsSending This property is true when the component is sending data to the port, otherwise is false. Use this property to check if the component is inside a sending process.
Public propertyLastDataReceived Last data received from the serial port.
Public propertyLastTimeReceived Last date-time when data received from the serial port.
Public propertyLineStatus Line status of the serial port. The first 4 bits (LSB) of the result contains CTS, DSR, RING and DCD (RLSD or CD) signals status.
Public propertyLogDateTime When this property is true, a date-time stamp will be added before the logged data.
Public propertyLogFile Name and path of the log file.
Public propertyLogInput Enables or disables input logging. If you enable it, all the incoming data will be logged to the LogFile.
Public propertyMaxLineLength The maximum length of a line, when ReadStringLine or ReadStringUpToEndChars methods are used in synchronous mode (AutoReceive = false). If maximum length is reached, the methods return with empty string. If this value is 0, there is no maximum length. The default value is 0.
Public propertyMinCheckDisconnectedInterval The minimum time interval in milliseconds, for which the port availability is checked. For time critical usage it's recommended to set it to a higher value. The default value is 25.
Public propertyNeedSynchronization Set this property to true for thread safety. The default value is false. Note: if you set it to true, you may experiment thread interblocking and lower speed.
Public propertyNewLine Gets or sets the value used to interpret the end of line in the ReadLine or SendAsciiStringLine methods. Default value is Environment.NewLine, a string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.
Public propertyOutputBuffer Recommended size of the device's internal output buffer, in bytes. The device driver receives the recommended buffer sizes, but is free to use any input and output (I/O) buffering scheme, as long as it provides reasonable performance and data is not lost due to overrun (except under extreme circumstances).
Public propertyPacketSize The size of the packets in bytes you want to receive automatically in the Received event. Use this property, if you want to receive packets of equal size in the Received event. If the value is 0, this property will be ignored. It works only for AutoReceive = true. Default value is 0.
Public propertyParityBits Parity scheme to be used.
Public propertyParityCheck If this property is true, parity checking is performed and parity errors are reported. This should not be confused with the Parity member, which controls the type of parity used in communications. The default value is false.
Public propertyPort Physical name of the serial port.
Public propertyPriority Priority of the receiver thread.
Public propertyReadIntervalTimeout Maximum time allowed to elapse between the arrival of two characters on the communications line, in milliseconds. During a ReadFile operation, the time period begins when the first character is received. If the interval between the arrival of any two characters exceeds this amount, the ReadFile operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used. A value of MAXDWORD, combined with zero values for both the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members, specifies that the read operation is to return immediately with the characters that have already been received, even if no characters have been received.
Public propertyReadTotalTimeoutConstant 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 member and the requested number of bytes. A value of zero for both the ReadTotalTimeoutMultiplier and ReadTotalTimeoutConstant members indicates that total time-outs are not used for read operations.
Public propertyReadTotalTimeoutMultiplier 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.
Public propertyReplaceParityErrors Specifies whether bytes received with parity errors are replaced with the character specified by the ErrorChar member. If this member is true and the ParityCheck member is true, replacement occurs. The default value is false.
Public propertySiteGets or sets the ISite of the Component.
(Inherited from Component)
Public propertySkipSetupFailed When this property is true, if setting serial parameters like DCB in the Open method fails, will ignore this. Otherwise method Open will return false and the port will not be opened. The default value is false.
Public propertySoftwareFlowControl Software flow control of the serial port.
Public propertyStopBits Number of stop bits to be used.
Public propertyTxContinueOnXoff Specifies whether transmission stops when the input buffer is full and the driver has transmitted the Xoff character. If this member is true, transmission continues after the Xoff character has been sent. If this member is false, transmission does not continue until the input buffer is within XonLim bytes of being empty and the driver has transmitted the Xon character. The default value is false.
Public propertyStatic memberUnlockKey Unlock key.
Public propertyWriteTotalTimeoutConstant 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 member and the number of bytes to be written. A value of zero for both the WriteTotalTimeoutMultiplier and WriteTotalTimeoutConstant members indicates that total time-outs are not used for write operations.
Public propertyWriteTotalTimeoutMultiplier 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.
Public propertyXoffChar Value of the XOFF character for both transmission and reception (ANSI: 0 - 255). The default value is (char)19.
Public propertyXoffLim Maximum number of bytes allowed in the input buffer before the XOFF character is sent. The maximum number of bytes allowed is calculated by subtracting this value from the size, in bytes, of the input buffer. The default value is 1.
Public propertyXonChar Value of the XON character for both transmission and reception (ANSI: 0 - 255). The default value is (char)17.
Public propertyXonLim Minimum number of bytes allowed in the input buffer before the XON character is sent. The default value is 0, which means InputBuffer div 4.
Top
See Also