Core Serial Library in C#  1.2
Public Member Functions | Properties | List of all members
IZaberPort Interface Reference

An interface for communicating with Zaber devices over a serial port. More...

Inheritance diagram for IZaberPort:
ZaberAsciiPort ZaberBinaryPort

Public Member Functions

void Close ()
 Closes the underlying SerialPort object's connection. More...
 
void Drain ()
 Purges all input waiting on the input buffer, and attemps to drain all incoming data before returning. More...
 
List< IZaberAxisFindAxes ()
 Queries the port to find all connected axes. More...
 
void Open ()
 Opens a new serial port connection. More...
 

Properties

bool IsOpen [get]
 Whether the port is open. More...
 
string PortName [get]
 The name of the port. More...
 
int ReadTimeout [get, set]
 The number of milliseconds before a time-out occurrs when a read operation does not finish. More...
 

Detailed Description

An interface for communicating with Zaber devices over a serial port.

Objects implementing IZaberPort can be thought of as extensions which simplify the built-in System.IO.Ports.SerialPort class. They are configured specifically for communicating with Zaber devices. They are designed to interact primarily with "Command" and "Reply" objects instead of raw strings and byte arrays, though one can work with this class entirely in terms of "string" and "byte[]" if one so wishes.

Member Function Documentation

void Close ( )

Closes the underlying SerialPort object's connection.

This method will only try to close the port if it is open. Attempting to close an already-closed port will do nothing.

Implemented in ZaberAsciiPort, and ZaberBinaryPort.

void Drain ( )

Purges all input waiting on the input buffer, and attemps to drain all incoming data before returning.

This method will block until there is a 100ms period of silence in serial communication, guaranteeing that the next time Read() is called, it will receive a full message sent by the device some time after the call to Drain().

This method is intended to be used when many commands have been sent without receiving any replies. If the user must suddenly read a reply to a certain command and has not been receiving replies otherwise, this method will allow them to immediately read the next incoming reply.

Do not use this method in any setting where a serial line may never be quiet for over 100ms, as it may block forever. Some examples of such a setup are multiple devices chained together being polled constantly for position, or at least one device connected with move tracking enabled.

Exceptions
InvalidOperationExceptionThe specified port is not open.

Implemented in ZaberAsciiPort, and ZaberBinaryPort.

List<IZaberAxis> FindAxes ( )

Queries the port to find all connected axes.

This method will only find axes which respond at the specified baud rate and protocol.

Returns
A list of connected axes.

Implemented in ZaberAsciiPort, and ZaberBinaryPort.

void Open ( )

Opens a new serial port connection.

This method closes and re-opens the port if the port is already open.

Exceptions
UnauthorizedAccessExceptionAccess is denied to the port, or the current process or another process on the system already has the specified COM port open.
System.IO.IOExceptionAn attempt to open the port failed. Often this is caused by a port name being incorrect, or a port being disconnected.

Implemented in ZaberAsciiPort, and ZaberBinaryPort.

Property Documentation

bool IsOpen
get

Whether the port is open.

string PortName
get

The name of the port.

int ReadTimeout
getset

The number of milliseconds before a time-out occurrs when a read operation does not finish.

This property allows you to set the read time-out value. The time-out can be set to any value greater than zero, or set to -1, in which case no time-out occurrs. -1 is the default.


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