diff --git a/PInvokeSerialPort/SerialPort.cs b/PInvokeSerialPort/SerialPort.cs index 5ed0719..69d823a 100755 --- a/PInvokeSerialPort/SerialPort.cs +++ b/PInvokeSerialPort/SerialPort.cs @@ -34,115 +34,6 @@ namespace PInvokeSerialPort /// public bool AutoReopen; - /// - /// Baud Rate (default: 2400) unsupported rates will throw "Bad settings" - /// - public int BaudRate = 115200; - - /// - /// If true, subsequent Send commands wait for completion of earlier ones enabling the results - /// to be checked. If false, errors, including timeouts, may not be detected, but performance - /// may be better. - /// - public bool CheckAllSends = true; - - /// - /// Number of databits 1..8 (default: 8) unsupported values will throw "Bad settings" - /// - public int DataBits = 8; - - /// - /// The parity checking scheme (default: none) - /// - public Parity Parity = Parity.None; - - /// - /// If true, Xon and Xoff characters are sent to control the data flow from the remote station (default: false) - /// - public bool RxFlowX; - - /// - /// If true, received characters are ignored unless DSR is asserted by the remote station (default: false) - /// - public bool RxGateDsr; - - /// - /// The number of free bytes in the reception queue at which flow is disabled (default: 2048) - /// - public int RxHighWater = 2048; - - /// - /// The number of bytes in the reception queue at which flow is re-enabled (default: 512) - /// - public int RxLowWater = 512; - - /// - /// Requested size for receive queue (default: 0 = use operating system default) - /// - public int RxQueue; - - /// - /// Constant. Max time for Send in ms = (Multiplier * Characters) + Constant (default: 0) - /// - public int SendTimeoutConstant; - - /// - /// Multiplier. Max time for Send in ms = (Multiplier * Characters) + Constant - /// (default: 0 = No timeout) - /// - public int SendTimeoutMultiplier; - - /// - /// Number of stop bits (default: one) - /// - public StopBits StopBits = StopBits.One; - - /// - /// If true, transmission is halted unless CTS is asserted by the remote station (default: false) - /// - public bool TxFlowCts; - - /// - /// If true, transmission is halted unless DSR is asserted by the remote station (default: false) - /// - public bool TxFlowDsr; - - /// - /// If true, transmission is halted when Xoff is received and restarted when Xon is received (default: false) - /// - public bool TxFlowX; - - /// - /// Requested size for transmit queue (default: 0 = use operating system default) - /// - public int TxQueue; - - /// - /// If false, transmission is suspended when this station has sent Xoff to the remote station (default: true) - /// Set false if the remote station treats any character as an Xon. - /// - public bool TxWhenRxXoff = true; - - /// - /// Specidies the use to which the DTR output is put (default: none) - /// - public HsOutput UseDtr = HsOutput.None; - - /// - /// Specifies the use to which the RTS output is put (default: none) - /// - public HsOutput UseRts = HsOutput.None; - - /// - /// The character used to signal Xoff for X flow control (default: DC3) - /// - public ASCII XoffChar = ASCII.DC3; - - /// - /// The character used to signal Xon for X flow control (default: DC1) - /// - public ASCII XonChar = ASCII.DC1; - /// /// Class constructor /// @@ -151,15 +42,125 @@ namespace PInvokeSerialPort PortName = portName; } + /// /// /// Class constructor /// - public SerialPort(string portName, int baudRate) + public SerialPort(string portName, int baudRate) : this(portName) { - PortName = portName; BaudRate = baudRate; } + /// + /// Baud Rate (default: 115200) + /// + /// Unsupported rates will throw "Bad settings". + public int BaudRate { get; set; } = 115200; + + /// + /// If true, subsequent Send commands wait for completion of earlier ones enabling the results + /// to be checked. If false, errors, including timeouts, may not be detected, but performance + /// may be better. + /// + public bool CheckAllSends { get; set; } = true; + + /// + /// Number of databits 1..8 (default: 8) unsupported values will throw "Bad settings" + /// + public int DataBits { get; set; } = 8; + + /// + /// The parity checking scheme (default: none) + /// + public Parity Parity { get; set; } = Parity.None; + + /// + /// If true, Xon and Xoff characters are sent to control the data flow from the remote station (default: false) + /// + public bool RxFlowX { get; set; } + + /// + /// If true, received characters are ignored unless DSR is asserted by the remote station (default: false) + /// + public bool RxGateDsr { get; set; } + + /// + /// The number of free bytes in the reception queue at which flow is disabled (default: 2048) + /// + public int RxHighWater { get; set; } = 2048; + + /// + /// The number of bytes in the reception queue at which flow is re-enabled (default: 512) + /// + public int RxLowWater { get; set; } = 512; + + /// + /// Requested size for receive queue (default: 0 = use operating system default) + /// + public int RxQueue { get; set; } + + /// + /// Constant. Max time for Send in ms = (Multiplier * Characters) + Constant (default: 0) + /// + public int SendTimeoutConstant { get; set; } + + /// + /// Multiplier. Max time for Send in ms = (Multiplier * Characters) + Constant + /// (default: 0 = No timeout) + /// + public int SendTimeoutMultiplier { get; set; } + + /// + /// Number of stop bits (default: one) + /// + public StopBits StopBits { get; set; } = StopBits.One; + + /// + /// If true, transmission is halted unless CTS is asserted by the remote station (default: false) + /// + public bool TxFlowCts { get; set; } + + /// + /// If true, transmission is halted unless DSR is asserted by the remote station (default: false) + /// + public bool TxFlowDsr { get; set; } + + /// + /// If true, transmission is halted when Xoff is received and restarted when Xon is received (default: false) + /// + public bool TxFlowX { get; set; } + + /// + /// Requested size for transmit queue (default: 0 = use operating system default) + /// + public int TxQueue { get; set; } + + /// + /// If false, transmission is suspended when this station has sent Xoff to the remote station (default: true) + /// Set false if the remote station treats any character as an Xon. + /// + public bool TxWhenRxXoff { get; set; } = true; + + /// + /// Specidies the use to which the DTR output is put (default: none) + /// + public HsOutput UseDtr { get; set; } = HsOutput.None; + + /// + /// Specifies the use to which the RTS output is put (default: none) + /// + public HsOutput UseRts { get; set; } = HsOutput.None; + + /// + /// The character used to signal Xoff for X flow control (default: DC3) + /// + public ASCII XoffChar { get; set; } = ASCII.DC3; + + /// + /// The character used to signal Xon for X flow control (default: DC1) + /// + public ASCII XonChar { get; set; } = ASCII.DC1; + /// /// True if online. /// @@ -586,7 +587,7 @@ namespace PInvokeSerialPort } /// - /// Override this to provide processing after the port is openned (i.e. to configure remote + /// Override this to provide processing after the port is opened (i.e. to configure remote /// device or just check presence). /// /// false to close the port again @@ -695,7 +696,7 @@ namespace PInvokeSerialPort if ((errs & Win32Com.CE_FRAME) != 0) s = s.Append("Framing,"); if ((errs & Win32Com.CE_IOE) != 0) s = s.Append("IO,"); if ((errs & Win32Com.CE_OVERRUN) != 0) s = s.Append("Overrun,"); - if ((errs & Win32Com.CE_RXOVER) != 0) s = s.Append("Receive Cverflow,"); + if ((errs & Win32Com.CE_RXOVER) != 0) s = s.Append("Receive Overflow,"); if ((errs & Win32Com.CE_RXPARITY) != 0) s = s.Append("Parity,"); if ((errs & Win32Com.CE_TXFULL) != 0) s = s.Append("Transmit Overflow,"); s.Length = s.Length - 1;