C# 클래스 Com.Aote.Utils.SerialPort

상속: IDisposable
파일 보기 프로젝트 열기: DuBin1988/restv2

공개 프로퍼티들

프로퍼티 타입 설명
Opened bool

공개 메소드들

메소드 설명
Close ( ) : void
ConvertHexChar ( char ch ) : int
Dispose ( ) : void

Disconnects and disposes of the SerialCom instance.

Flush ( ) : bool

Flushes the serial I/O buffers.

Open ( ) : bool

Opens and initializes the serial connection.

Read ( byte data ) : int

Reads any bytes that have been received and writes them to the specified array.

ReadString ( int maxBytesToRead ) : string

Reads any data that has been received as a string.

SerialPort ( string portName, int baudRate, StopBits stopBits, Parity parity ) : System

Creates a new instance of SerialCom.

SerialPort ( string portName, int baudRate, StopBits stopBits, Parity parity, byte byteSize ) : System

Creates a new instance of SerialCom.

String2Hex ( string str, byte senddata ) : int
Write ( byte data ) : int

Transmits the specified array of bytes.

Write ( int data ) : int

Transmits the specified string.

WriteLine ( int data ) : int

Transmits the specified string and appends the carriage return to the end if it does not exist.

Note that the string must end in '\r\n' before any serial device will interpret the data sent. For ease of programmability, this method should be used instead of Write() when you want to automatically execute the specified command string.

비공개 메소드들

메소드 설명
CloseHandle ( IntPtr hObject ) : bool
ConfigureSerialPort ( ) : bool

Configures the serial device based on the connection parameters pased in by the user.

CreateFile ( string fileName, [ fileAccess, [ fileShare, IntPtr securityAttributes, [ creationDisposition, int flags, IntPtr template ) : IntPtr
FailIfNotConnected ( ) : void

Helper that throws a InvalidOperationException if we don't have a serial connection.

GetCommState ( IntPtr hFile, DCB &lpDCB ) : bool
PurgeComm ( IntPtr hFile, int dwFlags ) : bool
ReadFile ( IntPtr hFile, byte lpBuffer, int nNumberOfBytesToRead, int &lpNumberOfBytesRead, int lpOverlapped ) : bool
SetCommState ( IntPtr hFile, [ lpDCB ) : bool
SetCommTimeouts ( IntPtr hFile, COMMTIMEOUTS &lpCommTimeouts ) : bool
WriteFile ( IntPtr hFile, byte lpBuffer, int nNumberOfBytesToWrite, int &lpNumberOfBytesWritten, int lpOverlapped ) : bool

메소드 상세

Close() 공개 메소드

public Close ( ) : void
리턴 void

ConvertHexChar() 공개 정적인 메소드

public static ConvertHexChar ( char ch ) : int
ch char
리턴 int

Dispose() 공개 메소드

Disconnects and disposes of the SerialCom instance.
public Dispose ( ) : void
리턴 void

Flush() 공개 메소드

Flushes the serial I/O buffers.
public Flush ( ) : bool
리턴 bool

Open() 공개 메소드

Opens and initializes the serial connection.
public Open ( ) : bool
리턴 bool

Read() 공개 메소드

Reads any bytes that have been received and writes them to the specified array.
public Read ( byte data ) : int
data byte
리턴 int

ReadString() 공개 메소드

Reads any data that has been received as a string.
public ReadString ( int maxBytesToRead ) : string
maxBytesToRead int
리턴 string

SerialPort() 공개 메소드

Creates a new instance of SerialCom.
public SerialPort ( string portName, int baudRate, StopBits stopBits, Parity parity ) : System
portName string
baudRate int
stopBits StopBits
parity Parity
리턴 System

SerialPort() 공개 메소드

Creates a new instance of SerialCom.
public SerialPort ( string portName, int baudRate, StopBits stopBits, Parity parity, byte byteSize ) : System
portName string
baudRate int
stopBits StopBits
parity Parity
byteSize byte
리턴 System

String2Hex() 공개 정적인 메소드

public static String2Hex ( string str, byte senddata ) : int
str string
senddata byte
리턴 int

Write() 공개 메소드

Transmits the specified array of bytes.
public Write ( byte data ) : int
data byte
리턴 int

Write() 공개 메소드

Transmits the specified string.
public Write ( int data ) : int
data int
리턴 int

WriteLine() 공개 메소드

Transmits the specified string and appends the carriage return to the end if it does not exist.
Note that the string must end in '\r\n' before any serial device will interpret the data sent. For ease of programmability, this method should be used instead of Write() when you want to automatically execute the specified command string.
public WriteLine ( int data ) : int
data int
리턴 int

프로퍼티 상세

Opened 공개적으로 프로퍼티

public bool Opened
리턴 bool