VectorNav .NET Library
Public Member Functions | Static Public Member Functions | Properties | List of all members
VectorNav.Communication.SerialPort Class Reference

Provides access to a serial port. More...

Inheritance diagram for VectorNav.Communication.SerialPort:
VectorNav.Communication.ISimplePort

Public Member Functions

void Open ()
 Opens the simple port. More...
 
void Close ()
 Closes the simple port. More...
 
void Write (byte[] buffer, int index, int length)
 Writes out data to the simple port. More...
 
int Read (byte[] buffer, int index, int numOfBytesToRead)
 Allows reading data from the simple port. More...
 
void Dispose ()
 
 SerialPort (string portName, UInt32 baudrate)
 Creates a new SerialPort with the provided connection parameters. More...
 
void Open (bool checkAndToggleIsOpenFlag)
 
void ChangeBaudRate (uint br)
 Changes the connected baud rate of the port. More...
 

Static Public Member Functions

static string[] GetPortNames ()
 Gets the list of all available serial ports on the computer. More...
 

Properties

EventHandler DataReceived
 
bool IsOpen [get]
 
int BytesToRead [get]
 Returns the number of bytes available to read in the received buffer. More...
 
- Properties inherited from VectorNav.Communication.ISimplePort
bool IsOpen [get]
 Indicates if the simple port is open. More...
 
int BytesToRead [get]
 Returns the number of bytes available to read in the received buffer. More...
 

Additional Inherited Members

- Events inherited from VectorNav.Communication.ISimplePort
EventHandler DataReceived
 Raised whenever the simple port receives new data. More...
 

Detailed Description

Provides access to a serial port.

When the SerialPort is first created and the connection opened, the user will normally have to poll the method Read to see if any new data is available on the serial port. However, if the user code registers a handler with the event DataReceived, the SerialPort object will start an internal thread that monitors the serial port for new data, and when new data is available, it will alert the user code through the registered event handler. Then the user can call Read to retrieve the data.

Constructor & Destructor Documentation

VectorNav.Communication.SerialPort.SerialPort ( string  portName,
UInt32  baudrate 
)

Creates a new SerialPort with the provided connection parameters.

Parameters
portNameThe name of the serial port.
baudrateThe baudrate to open the serial port at.

Member Function Documentation

void VectorNav.Communication.SerialPort.ChangeBaudRate ( uint  br)

Changes the connected baud rate of the port.

Parameters
brThe baud rate to change the port to.
void VectorNav.Communication.SerialPort.Close ( )

Closes the simple port.

Implements VectorNav.Communication.ISimplePort.

static string [] VectorNav.Communication.SerialPort.GetPortNames ( )
static

Gets the list of all available serial ports on the computer.

Returns
The list of found serial ports.
void VectorNav.Communication.SerialPort.Open ( )

Opens the simple port.

Implements VectorNav.Communication.ISimplePort.

int VectorNav.Communication.SerialPort.Read ( byte[]  buffer,
int  index,
int  numOfBytesToRead 
)

Allows reading data from the simple port.

Parameters
bufferThe buffer to place any read bytes.
indexThe index to start placing any read bytes.
numOfBytesToReadThe maximum number of bytes to read.
Returns
The actual number of bytes read.

Implements VectorNav.Communication.ISimplePort.

void VectorNav.Communication.SerialPort.Write ( byte[]  buffer,
int  index,
int  length 
)

Writes out data to the simple port.

Parameters
bufferThe buffer containing the data to write out.
indexThe index in the buffer to start writing data out.
lengthThe number of bytes to write out.

Implements VectorNav.Communication.ISimplePort.

Property Documentation

int VectorNav.Communication.SerialPort.BytesToRead
get

Returns the number of bytes available to read in the received buffer.


The documentation for this class was generated from the following file: