C# 클래스 PInvokeSerialPort.SerialPort

PInvokeSerialPort main class. Borrowed from http://msdn.microsoft.com/en-us/magazine/cc301786.aspx ;)
상속: IDisposable
파일 보기 프로젝트 열기: ebraminio/PInvokeSerialPort 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
AutoReopen bool
BaudRate int
CheckAllSends bool
DataBits int
Parity Parity
RxFlowX bool
RxGateDsr bool
RxHighWater int
RxLowWater int
RxQueue int
SendTimeoutConstant int
SendTimeoutMultiplier int
StopBits StopBits
TxFlowCts bool
TxFlowDsr bool
TxFlowX bool
TxQueue int
TxWhenRxXoff bool
UseDtr HsOutput
UseRts HsOutput
XoffChar ASCII
XonChar ASCII

공개 메소드들

메소드 설명
Close ( ) : void

Closes the com port.

Dispose ( ) : void

For IDisposable

Flush ( ) : void

Block until all bytes in the queue have been transmitted.

Open ( ) : bool

Opens the com port and configures it with the required settings

SendImmediate ( byte tosend ) : void

Sends a protocol byte immediately ahead of any queued bytes.

SerialPort ( string portName ) : System

Class contructor

SerialPort ( string portName, int baudRate ) : System

Class contructor

Write ( byte toSend ) : void

Queues bytes for transmission.

Write ( char toSend ) : void

Queues a single char for transmission.

Write ( string toSend ) : void

Queues string for transmission.

WriteLine ( string toSend ) : void

Queues string with a new line ("\r\n") for transmission.

보호된 메소드들

메소드 설명
AfterOpen ( ) : bool

Override this to provide processing after the port is openned (i.e. to configure remote device or just check presence).

BeforeClose ( bool error ) : void

Override this to provide processing prior to port closure.

GetModemStatus ( ) : ModemStatus

Gets the status of the modem control input signals.

GetQueueStatus ( ) : QueueStatus

Get the status of the queues

OnBreak ( ) : void

Override this to take action when a break condition is detected on the input line.

OnRing ( ) : void

Override this to take action when a ring condition is signalled by an attached modem.

OnRxChar ( byte ch ) : void

Override this to process received bytes.

OnRxException ( Exception e ) : void

Override this to take action when the reception thread closes due to an exception being thrown.

OnStatusChange ( ModemStatus mask, ModemStatus state ) : void

Override this to take action when one or more modem status inputs change state

OnTxDone ( ) : void

Override this to take action when transmission is complete (i.e. all bytes have actually been sent, not just queued).

Sleep ( int milliseconds ) : void

Delay processing.

ThrowException ( string reason ) : void

Use this to throw exceptions in derived classes. Correctly handles threading issues and closes the port if necessary.

비공개 메소드들

메소드 설명
CheckOnline ( ) : bool
CheckResult ( ) : void
InternalClose ( ) : void
ReceiveThread ( ) : void

메소드 상세

AfterOpen() 보호된 메소드

Override this to provide processing after the port is openned (i.e. to configure remote device or just check presence).
protected AfterOpen ( ) : bool
리턴 bool

BeforeClose() 보호된 메소드

Override this to provide processing prior to port closure.
protected BeforeClose ( bool error ) : void
error bool True if closing due to an error
리턴 void

Close() 공개 메소드

Closes the com port.
public Close ( ) : void
리턴 void

Dispose() 공개 메소드

For IDisposable
public Dispose ( ) : void
리턴 void

Flush() 공개 메소드

Block until all bytes in the queue have been transmitted.
public Flush ( ) : void
리턴 void

GetModemStatus() 보호된 메소드

Gets the status of the modem control input signals.
protected GetModemStatus ( ) : ModemStatus
리턴 ModemStatus

GetQueueStatus() 보호된 메소드

Get the status of the queues
protected GetQueueStatus ( ) : QueueStatus
리턴 QueueStatus

OnBreak() 보호된 메소드

Override this to take action when a break condition is detected on the input line.
protected OnBreak ( ) : void
리턴 void

OnRing() 보호된 메소드

Override this to take action when a ring condition is signalled by an attached modem.
protected OnRing ( ) : void
리턴 void

OnRxChar() 보호된 메소드

Override this to process received bytes.
protected OnRxChar ( byte ch ) : void
ch byte The byte that was received
리턴 void

OnRxException() 보호된 메소드

Override this to take action when the reception thread closes due to an exception being thrown.
protected OnRxException ( Exception e ) : void
e System.Exception The exception which was thrown
리턴 void

OnStatusChange() 보호된 메소드

Override this to take action when one or more modem status inputs change state
protected OnStatusChange ( ModemStatus mask, ModemStatus state ) : void
mask ModemStatus The status inputs that have changed state
state ModemStatus The state of the status inputs
리턴 void

OnTxDone() 보호된 메소드

Override this to take action when transmission is complete (i.e. all bytes have actually been sent, not just queued).
protected OnTxDone ( ) : void
리턴 void

Open() 공개 메소드

Opens the com port and configures it with the required settings
public Open ( ) : bool
리턴 bool

SendImmediate() 공개 메소드

Sends a protocol byte immediately ahead of any queued bytes.
public SendImmediate ( byte tosend ) : void
tosend byte Byte to send
리턴 void

SerialPort() 공개 메소드

Class contructor
public SerialPort ( string portName ) : System
portName string
리턴 System

SerialPort() 공개 메소드

Class contructor
public SerialPort ( string portName, int baudRate ) : System
portName string
baudRate int
리턴 System

Sleep() 보호된 메소드

Delay processing.
protected Sleep ( int milliseconds ) : void
milliseconds int Milliseconds to delay by
리턴 void

ThrowException() 보호된 메소드

Use this to throw exceptions in derived classes. Correctly handles threading issues and closes the port if necessary.
protected ThrowException ( string reason ) : void
reason string Description of fault
리턴 void

Write() 공개 메소드

Queues bytes for transmission.
public Write ( byte toSend ) : void
toSend byte Array of bytes to be sent
리턴 void

Write() 공개 메소드

Queues a single char for transmission.
public Write ( char toSend ) : void
toSend char Byte to be sent
리턴 void

Write() 공개 메소드

Queues string for transmission.
public Write ( string toSend ) : void
toSend string Array of bytes to be sent
리턴 void

WriteLine() 공개 메소드

Queues string with a new line ("\r\n") for transmission.
public WriteLine ( string toSend ) : void
toSend string Array of bytes to be sent
리턴 void

프로퍼티 상세

AutoReopen 공개적으로 프로퍼티

If true, the port will automatically re-open on next send if it was previously closed due to an error (default: false)
public bool AutoReopen
리턴 bool

BaudRate 공개적으로 프로퍼티

Baud Rate (default: 2400) unsupported rates will throw "Bad settings"
public int BaudRate
리턴 int

CheckAllSends 공개적으로 프로퍼티

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
리턴 bool

DataBits 공개적으로 프로퍼티

Number of databits 1..8 (default: 8) unsupported values will throw "Bad settings"
public int DataBits
리턴 int

Parity 공개적으로 프로퍼티

The parity checking scheme (default: none)
public Parity Parity
리턴 Parity

RxFlowX 공개적으로 프로퍼티

If true, Xon and Xoff characters are sent to control the data flow from the remote station (default: false)
public bool RxFlowX
리턴 bool

RxGateDsr 공개적으로 프로퍼티

If true, received characters are ignored unless DSR is asserted by the remote station (default: false)
public bool RxGateDsr
리턴 bool

RxHighWater 공개적으로 프로퍼티

The number of free bytes in the reception queue at which flow is disabled (default: 2048)
public int RxHighWater
리턴 int

RxLowWater 공개적으로 프로퍼티

The number of bytes in the reception queue at which flow is re-enabled (default: 512)
public int RxLowWater
리턴 int

RxQueue 공개적으로 프로퍼티

Requested size for receive queue (default: 0 = use operating system default)
public int RxQueue
리턴 int

SendTimeoutConstant 공개적으로 프로퍼티

Constant. Max time for Send in ms = (Multiplier * Characters) + Constant (default: 0)
public int SendTimeoutConstant
리턴 int

SendTimeoutMultiplier 공개적으로 프로퍼티

Multiplier. Max time for Send in ms = (Multiplier * Characters) + Constant (default: 0 = No timeout)
public int SendTimeoutMultiplier
리턴 int

StopBits 공개적으로 프로퍼티

Number of stop bits (default: one)
public StopBits StopBits
리턴 StopBits

TxFlowCts 공개적으로 프로퍼티

If true, transmission is halted unless CTS is asserted by the remote station (default: false)
public bool TxFlowCts
리턴 bool

TxFlowDsr 공개적으로 프로퍼티

If true, transmission is halted unless DSR is asserted by the remote station (default: false)
public bool TxFlowDsr
리턴 bool

TxFlowX 공개적으로 프로퍼티

If true, transmission is halted when Xoff is received and restarted when Xon is received (default: false)
public bool TxFlowX
리턴 bool

TxQueue 공개적으로 프로퍼티

Requested size for transmit queue (default: 0 = use operating system default)
public int TxQueue
리턴 int

TxWhenRxXoff 공개적으로 프로퍼티

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
리턴 bool

UseDtr 공개적으로 프로퍼티

Specidies the use to which the DTR output is put (default: none)
public HsOutput UseDtr
리턴 HsOutput

UseRts 공개적으로 프로퍼티

Specifies the use to which the RTS output is put (default: none)
public HsOutput UseRts
리턴 HsOutput

XoffChar 공개적으로 프로퍼티

The character used to signal Xoff for X flow control (default: DC3)
public ASCII XoffChar
리턴 ASCII

XonChar 공개적으로 프로퍼티

The character used to signal Xon for X flow control (default: DC1)
public ASCII XonChar
리턴 ASCII