Represents a port connected to devices using the binary protocol.
More...
|
const int | InfiniteTimeout = System.IO.Ports.SerialPort.InfiniteTimeout |
| Indicates that no time-out should occur. More...
|
|
|
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...
|
|
Represents a port connected to devices using the binary protocol.
Initializes a new instance of the ZaberBinaryPort class using the specified port name.
- Parameters
-
portName | The port to use (for example, COM1). |
- Exceptions
-
System.IO.IOException | The specified port could not be found or opened. |
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.
Implements IZaberPort.
Releases the resources used by the underlying SerialPort object.
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
-
InvalidOperationException | The specified port is not open. |
Implements IZaberPort.
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.
Implements IZaberPort.
Opens a new serial port connection.
This method closes and re-opens the port if the port is already open.
- Exceptions
-
UnauthorizedAccessException | Access is denied to the port, or the current process or another process on the system already has the specified COM port open. |
System.IO.IOException | An attempt to open the port failed. Often this is caused by a port name being incorrect, or a port being disconnected. |
Implements IZaberPort.
Reads a reply from a device.
- Returns
- The reply read.
- Exceptions
-
InvalidOperationException | The specified port is not open. |
TimeoutException | No bytes were available to read. |
Sends a command to the port's devices.
- Parameters
-
command | The command to be sent. |
- Exceptions
-
ArgumentNullException | The command passed is null. |
InvalidOperationException | The specified port is not open. |
void Write |
( |
byte[] |
command | ) |
|
|
inline |
Writes an array of bytes to the port.
This method will always write the first six bytes of command to the port. In order to behave as intended, the last four bytes must encode the desired data in a little-endian representation, as specified by Zaber's Binary Protocol Manual.
- Parameters
-
command | An array of "raw" bytes to be sent. |
- Exceptions
-
ArgumentNullException | The command passed is null. |
InvalidOperationException | The specified port is not open. |
const int InfiniteTimeout = System.IO.Ports.SerialPort.InfiniteTimeout |
Indicates that no time-out should occur.
Whether the port is open.
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 class was generated from the following file: