Represents a port connected to devices using the ASCII protocol.
More...
|
const int | InfiniteTimeout = System.IO.Ports.SerialPort.InfiniteTimeout |
| Indicates that no time-out should occur. More...
|
|
Represents a port connected to devices using the ASCII protocol.
Initializes a new instance of the ZaberAsciiPort 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. |
Initializes a new instance of the ZaberAsciiPort class using the specified port name and baud rate.
- Parameters
-
portName | The port to use (for example, COM1). |
baudRate | The baud rate. |
- Exceptions
-
ArgumentException | portName is either null, or does not begin with "COM". |
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.
Queries the port to find all connected devices.
This method will only find devices which respond at the specified baud rate and protocol.
In general, it is recommended to use FindAxes() to get all of the axes connected to a port. There are plenty of good reasons for getting a list of devices instead, but we encourage sending movement commands to individual axes, even if the device has only one axis. In any case, communication with devices should be done in terms of the device's axes, which can be done from FindDevices() like so:
foreach (ZaberAsciiDevice device in port.FindDevices())
{
device.GetAxis(1).Home();
}
- Returns
- A list of connected devices.
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 |
( |
string |
command | ) |
|
|
inline |
Writes a command string to the port.
This method checks whether the command passed starts with '/' and ends with '\n', and adds them if they are absent.
- Parameters
-
command | A string 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.
Gets the serial baud rate.
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: