The following examples illustrate how you can obtain an instance of this type:
from zaber_motion.ascii import Connection
connection = Connection.open_serial_port('COM3')connection.alertAlertEvent Alert message received from the device.connection.disconnectedMotionLibException Error that caused disconnection.connection.unknown_responseUnknownResponseEvent Reply that could not be matched to a request.connection.detect_devices(identify_devices = True)| Name | Type | Description |
|---|---|---|
| identify_devices | bool | Determines whether device identification should be performed as well. |
List[Device] Array of detected devices.connection.generic_command(command, device = 0, axis = 0, check_errors = True, timeout = 0)| Name | Type | Description |
|---|---|---|
| command | str | Command and its parameters. |
| device | int | Optional device address to send the command to. |
| axis | int | Optional axis number to send the command to. |
| check_errors | bool | Controls whether to throw an exception when the device rejects the command. |
| timeout | int | The timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout. |
Response A response to the command.connection.generic_command_multi_response(command, device = 0, axis = 0, check_errors = True, timeout = 0)| Name | Type | Description |
|---|---|---|
| command | str | Command and its parameters. |
| device | int | Optional device address to send the command to. |
| axis | int | Optional axis number to send the command to. |
| check_errors | bool | Controls whether to throw an exception when a device rejects the command. |
| timeout | int | The timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout. |
List[Response] All responses to the command.connection.generic_command_no_response(command, device = 0, axis = 0)| Name | Type | Description |
|---|---|---|
| command | str | Command and its parameters. |
| device | int | Optional device address to send the command to. Specifying -1 omits the number completely. |
| axis | int | Optional axis number to send the command to. Specifying -1 omits the number completely. |
connection.get_device(device_address)| Name | Type | Description |
|---|---|---|
| device_address | int | Address of device intended to control. Address is configured for each device. |
Device Device instance.connection.home_all(wait_until_idle = True)| Name | Type | Description |
|---|---|---|
| wait_until_idle | bool | Determines whether the function should return immediately or wait until the devices are homed. |
List[int] The addresses of the devices that were homed by this command.Connection.open_custom(transport)| Name | Type | Description |
|---|---|---|
| transport | Transport | The custom connection transport. |
Connection An object representing the connection.Connection.open_iot(cloud_id, token = "unauthenticated", connection_name = None, realm = None, api = "https://api.zaber.io")| Name | Type | Description |
|---|---|---|
| cloud_id | str | The cloud ID to connect to. |
| token | str | The token to authenticate with. By default the connection will be unauthenticated. |
| connection_name | Optional[str] | The name of the connection to open. Can be left empty to default to the only connection present. Otherwise, use serial port name for serial port connection or hostname:port for TCP connection. |
| realm | Optional[str] | The realm to connect to. Can be left empty for the default account realm. |
| api | str | The URL of the API to receive connection info from. |
Connection An object representing the connection.Connection.open_serial_port(port_name, baud_rate = DEFAULT_BAUD_RATE, direct = False, test_port = False)| Name | Type | Description |
|---|---|---|
| port_name | str | Name of the port to open. |
| baud_rate | int | Optional baud rate (defaults to 115200). |
| direct | bool | If true will connect to the serial port directly, failing if the connection is already opened by a message router instance. |
| test_port | bool | Some operating systems may allow opening a serial port that is not writable. Tests if the serial port is writable, and throws an exception if it is not. |
Connection An object representing the port.Connection.open_tcp(host_name, port = TCP_PORT_CHAIN)| Name | Type | Description |
|---|---|---|
| host_name | str | Hostname or IP address. |
| port | int | Optional port number (defaults to 55550). |
Connection An object representing the connection.connection.renumber_devices(first_address = 1)| Name | Type | Description |
|---|---|---|
| first_address | int | This is the address that the device closest to the computer is given. Remaining devices are numbered consecutively. |
int Total number of devices that responded to the renumber.connection.stop_all(wait_until_idle = True)| Name | Type | Description |
|---|---|---|
| wait_until_idle | bool | Determines whether the function should return immediately or wait until the devices are stopped. |
List[int] The addresses of the devices that were stopped by this command.