C# Класс System.IO.Ports.SerialPortBase

Наследование: ISerialPort
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Encoding System.Text.Encoding
NewLine string

Защищенные свойства (Protected)

Свойство Тип Описание
_bufferSync object
_continueReading bool
_incomingBuffer byte[]
_incomingBufferPosition int
_incomingBufferValidLength int
_readBufferSize int
_readThread Thread
_readToEvent System.Threading.AutoResetEvent
_writeBufferSize int
_writeThread Thread

Открытые методы

Метод Описание
Flush ( ) : void
Read ( byte buffer, int offset, int count ) : int

Reads data from a serial port.

ReadAvailable ( ) : byte[]

Reads all available bytes and removes them from the reading buffer.

ReadAvailable ( int maxCount ) : byte[]

Reads desired number of bytes and removes them from the reading buffer.

ReadLine ( ) : string

Reads data from a serial port up to the NewLine value and decodes them as string using Encoding.

This method does not return until NewLine sequence is received.

SerialPortBase ( ) : System
SerialPortBase ( int writeBufferSize, int readBufferSize ) : System
Write ( ) : void

Writes data to a serial port.

The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.

Write ( byte data, int offset, int length ) : void

Writes data to a serial port.

The method does not return until all data is sent, including output buffer pauses and/or hardware flow control pauses, if applicable.

Write ( string text ) : void

Encodes string data using Encoding and sends them to a serial port.

The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.

WriteLine ( string text ) : void

Appends NewLine to the string, encodes it using Encoding and sends it to a serial port.

The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.

Защищенные методы

Метод Описание
AdvancePosition ( int count ) : void

Advances the internal circular read bufer position by specified amount and updates the valid length field accordingly.

BufferIndexOf ( byte what ) : int

Searches the internal circular read buffer for sequence of bytes.

GetBufferedData ( int arraySize ) : byte[]

Returns specified amount of data from internal circular read buffer. If there is not enough data available, remaining bytes are filled with zeros.

GetBufferedData ( byte buffer, int offset, int count ) : int

Copies specified amount of data from internal circular read buffer to the specified linear buffer.

OnBusyChanged ( bool busy ) : void
OnDataReceived ( byte data, int validLength ) : void

Adds the received data into internal circular read buffer and fires DataReceived event.

ReadDirect ( byte data, int offset, int length ) : int
ReadLoop ( ) : void
StartReading ( ) : void

Starts waiting for data in order to fire DataReceived event.

StopReading ( ) : void

Stops waiting for data.

WriteDirect ( byte data, int offset, int length ) : int

Приватные методы

Метод Описание
ReadTo ( ) : byte[]

Описание методов

AdvancePosition() защищенный Метод

Advances the internal circular read bufer position by specified amount and updates the valid length field accordingly.
protected AdvancePosition ( int count ) : void
count int The number of bytes to move forward.
Результат void

BufferIndexOf() защищенный Метод

Searches the internal circular read buffer for sequence of bytes.
protected BufferIndexOf ( byte what ) : int
what byte The sequence to look for.
Результат int

Flush() публичный абстрактный Метод

public abstract Flush ( ) : void
Результат void

GetBufferedData() защищенный Метод

Returns specified amount of data from internal circular read buffer. If there is not enough data available, remaining bytes are filled with zeros.
protected GetBufferedData ( int arraySize ) : byte[]
arraySize int The number of bytes to return.
Результат byte[]

GetBufferedData() защищенный Метод

Copies specified amount of data from internal circular read buffer to the specified linear buffer.
protected GetBufferedData ( byte buffer, int offset, int count ) : int
buffer byte The linear buffer that stores the data read from the internal read buffer.
offset int The offset value that indicates where writing to the linear buffer from the internal read buffer is to begin.
count int The number of bytes of data to be copied.
Результат int

OnBusyChanged() защищенный Метод

protected OnBusyChanged ( bool busy ) : void
busy bool
Результат void

OnDataReceived() защищенный Метод

Adds the received data into internal circular read buffer and fires DataReceived event.
protected OnDataReceived ( byte data, int validLength ) : void
data byte An array with data received.
validLength int Number of valid bytes in the array.
Результат void

Read() публичный Метод

Reads data from a serial port.
public Read ( byte buffer, int offset, int count ) : int
buffer byte The output buffer that stores the data read from the serial port.
offset int The offset value that indicates where writing to the output buffer from the serial port is to begin.
count int The number of bytes of data to be read.
Результат int

ReadAvailable() публичный Метод

Reads all available bytes and removes them from the reading buffer.
public ReadAvailable ( ) : byte[]
Результат byte[]

ReadAvailable() публичный Метод

Reads desired number of bytes and removes them from the reading buffer.
public ReadAvailable ( int maxCount ) : byte[]
maxCount int The maximum count of bytes to return.
Результат byte[]

ReadDirect() защищенный абстрактный Метод

protected abstract ReadDirect ( byte data, int offset, int length ) : int
data byte
offset int
length int
Результат int

ReadLine() публичный Метод

Reads data from a serial port up to the NewLine value and decodes them as string using Encoding.
This method does not return until NewLine sequence is received.
public ReadLine ( ) : string
Результат string

ReadLoop() защищенный Метод

protected ReadLoop ( ) : void
Результат void

SerialPortBase() публичный Метод

public SerialPortBase ( ) : System
Результат System

SerialPortBase() публичный Метод

public SerialPortBase ( int writeBufferSize, int readBufferSize ) : System
writeBufferSize int
readBufferSize int
Результат System

StartReading() защищенный Метод

Starts waiting for data in order to fire DataReceived event.
protected StartReading ( ) : void
Результат void

StopReading() защищенный Метод

Stops waiting for data.
protected StopReading ( ) : void
Результат void

Write() публичный Метод

Writes data to a serial port.
The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.
public Write ( ) : void
Результат void

Write() публичный Метод

Writes data to a serial port.
The method does not return until all data is sent, including output buffer pauses and/or hardware flow control pauses, if applicable.
public Write ( byte data, int offset, int length ) : void
data byte The input buffer that is to write to the serial port.
offset int The offset value that indicates where writing from the input buffer to the serial port is to begin.
length int The number of bytes of data to be written to the serial port.
Результат void

Write() публичный Метод

Encodes string data using Encoding and sends them to a serial port.
The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.
public Write ( string text ) : void
text string String data to send.
Результат void

WriteDirect() защищенный абстрактный Метод

protected abstract WriteDirect ( byte data, int offset, int length ) : int
data byte
offset int
length int
Результат int

WriteLine() публичный Метод

Appends NewLine to the string, encodes it using Encoding and sends it to a serial port.
The method does not return until all data are sent, including output buffer pauses and/or hardware flow control pauses, if applicable.
public WriteLine ( string text ) : void
text string String data to send.
Результат void

Описание свойств

Encoding публичное свойство

Encoding to use when reading or writing string data. Default is UTF-8. Only expanding encodings are supported.
public Encoding,System.Text Encoding
Результат System.Text.Encoding

NewLine публичное свойство

A string representing the line delimiter in string data.
public string NewLine
Результат string

_bufferSync защищенное свойство

protected object _bufferSync
Результат object

_continueReading защищенное свойство

protected bool _continueReading
Результат bool

_incomingBuffer защищенное свойство

protected byte[] _incomingBuffer
Результат byte[]

_incomingBufferPosition защищенное свойство

protected int _incomingBufferPosition
Результат int

_incomingBufferValidLength защищенное свойство

protected int _incomingBufferValidLength
Результат int

_readBufferSize защищенное свойство

protected int _readBufferSize
Результат int

_readThread защищенное свойство

protected Thread _readThread
Результат Thread

_readToEvent защищенное свойство

protected AutoResetEvent,System.Threading _readToEvent
Результат System.Threading.AutoResetEvent

_writeBufferSize защищенное свойство

protected int _writeBufferSize
Результат int

_writeThread защищенное свойство

protected Thread _writeThread
Результат Thread