C# Class System.IO.Ports.SerialPortBase

Inheritance: ISerialPort
Afficher le fichier Open project: toxsedyshev/imBMW Class Usage Examples

Méthodes publiques

Свойство Type Description
Encoding System.Text.Encoding
NewLine string

Protected Properties

Свойство Type Description
_bufferSync object
_continueReading bool
_incomingBuffer byte[]
_incomingBufferPosition int
_incomingBufferValidLength int
_readBufferSize int
_readThread Thread
_readToEvent System.Threading.AutoResetEvent
_writeBufferSize int
_writeThread Thread

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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

Private Methods

Méthode Description
ReadTo ( ) : byte[]

Method Details

AdvancePosition() protected méthode

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.
Résultat void

BufferIndexOf() protected méthode

Searches the internal circular read buffer for sequence of bytes.
protected BufferIndexOf ( byte what ) : int
what byte The sequence to look for.
Résultat int

Flush() public abstract méthode

public abstract Flush ( ) : void
Résultat void

GetBufferedData() protected méthode

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.
Résultat byte[]

GetBufferedData() protected méthode

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.
Résultat int

OnBusyChanged() protected méthode

protected OnBusyChanged ( bool busy ) : void
busy bool
Résultat void

OnDataReceived() protected méthode

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.
Résultat void

Read() public méthode

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.
Résultat int

ReadAvailable() public méthode

Reads all available bytes and removes them from the reading buffer.
public ReadAvailable ( ) : byte[]
Résultat byte[]

ReadAvailable() public méthode

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.
Résultat byte[]

ReadDirect() protected abstract méthode

protected abstract ReadDirect ( byte data, int offset, int length ) : int
data byte
offset int
length int
Résultat int

ReadLine() public méthode

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
Résultat string

ReadLoop() protected méthode

protected ReadLoop ( ) : void
Résultat void

SerialPortBase() public méthode

public SerialPortBase ( ) : System
Résultat System

SerialPortBase() public méthode

public SerialPortBase ( int writeBufferSize, int readBufferSize ) : System
writeBufferSize int
readBufferSize int
Résultat System

StartReading() protected méthode

Starts waiting for data in order to fire DataReceived event.
protected StartReading ( ) : void
Résultat void

StopReading() protected méthode

Stops waiting for data.
protected StopReading ( ) : void
Résultat void

Write() public méthode

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
Résultat void

Write() public méthode

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.
Résultat void

Write() public méthode

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.
Résultat void

WriteDirect() protected abstract méthode

protected abstract WriteDirect ( byte data, int offset, int length ) : int
data byte
offset int
length int
Résultat int

WriteLine() public méthode

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.
Résultat void

Property Details

Encoding public_oe property

Encoding to use when reading or writing string data. Default is UTF-8. Only expanding encodings are supported.
public Encoding,System.Text Encoding
Résultat System.Text.Encoding

NewLine public_oe property

A string representing the line delimiter in string data.
public string NewLine
Résultat string

_bufferSync protected_oe property

protected object _bufferSync
Résultat object

_continueReading protected_oe property

protected bool _continueReading
Résultat bool

_incomingBuffer protected_oe property

protected byte[] _incomingBuffer
Résultat byte[]

_incomingBufferPosition protected_oe property

protected int _incomingBufferPosition
Résultat int

_incomingBufferValidLength protected_oe property

protected int _incomingBufferValidLength
Résultat int

_readBufferSize protected_oe property

protected int _readBufferSize
Résultat int

_readThread protected_oe property

protected Thread _readThread
Résultat Thread

_readToEvent protected_oe property

protected AutoResetEvent,System.Threading _readToEvent
Résultat System.Threading.AutoResetEvent

_writeBufferSize protected_oe property

protected int _writeBufferSize
Résultat int

_writeThread protected_oe property

protected Thread _writeThread
Résultat Thread