API Reference v9.2.0
Connectionclass
Module: zaber_motion.binary
Class representing access to particular connection (serial port, TCP connection) using the legacy Binary protocol.
To use this type, add from zaber_motion.binary import Connection to the top of your source code.
Index
pProperties
Constants
c
c
c
Properties
p
p
Events
e
connection.disconnectedEvent invoked when connection is interrupted or closed.
Emitted Data
MotionLibException Error that caused disconnection.e
connection.reply_onlyEvent invoked when a reply-only command such as a move tracking message is received from a device.
Emitted Data
ReplyOnlyEvent Reply-only message received from the device.e
connection.unknown_responseEvent invoked when a response from a device cannot be matched to any known request.
Emitted Data
UnknownResponseEvent Reply that could not be matched to a request.Methods
m
connection.detect_devices(identify_devices = True)Attempts to detect any devices present on this connection.
Arguments
| Name | Type | Description |
|---|---|---|
| identify_devices | bool | Determines whether device identification should be performed as well. |
Return Value
List[Device] Array of detected devices.m
connection.generic_command(device, command, data = 0, timeout = 0.0, check_errors = True)Sends a generic Binary command to this connection. For more information please refer to the Binary Protocol Manual.
Arguments
| Name | Type | Description |
|---|---|---|
| device | int | Device address to send the command to. Use zero for broadcast. |
| command | CommandCode | Command to send. |
| data | int | Optional data argument to the command. Defaults to zero. |
| timeout | float | Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s. |
| check_errors | bool | Controls whether to throw an exception when the device rejects the command. |
Return Value
Message A response to the command.m
connection.generic_command_multi_response(command, data = 0, timeout = 0.0, check_errors = True)Sends a generic Binary command to this connection and expects responses from one or more devices. Responses are returned in order of arrival. For more information please refer to the Binary Protocol Manual.
Arguments
| Name | Type | Description |
|---|---|---|
| command | CommandCode | Command to send. |
| data | int | Optional data argument to the command. Defaults to zero. |
| timeout | float | Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s. |
| check_errors | bool | Controls whether to throw an exception when any device rejects the command. |
Return Value
List[Message] All responses to the command.m
connection.generic_command_no_response(device, command, data = 0)Sends a generic Binary command to this connection without expecting a response. For more information please refer to the Binary Protocol Manual.
Arguments
| Name | Type | Description |
|---|---|---|
| device | int | Device address to send the command to. Use zero for broadcast. |
| command | CommandCode | Command to send. |
| data | int | Optional data argument to the command. Defaults to zero. |
m
connection.get_device(device_address)Gets a Device class instance which allows you to control a particular device on this connection. Devices are numbered from 1.
Arguments
| Name | Type | Description |
|---|---|---|
| device_address | int | Address of device intended to control. Address is configured for each device. |
Return Value
Device Device instance.s
Connection.open_serial_port(port_name, baud_rate = DEFAULT_BAUD_RATE, use_message_ids = False)Opens a serial port.
Arguments
| Name | Type | Description |
|---|---|---|
| port_name | str | Name of the port to open. |
| baud_rate | int | Optional baud rate (defaults to 9600). |
| use_message_ids | bool | Enable use of message IDs (defaults to disabled). All your devices must be pre-configured to match. |
Return Value
Connection An object representing the port.s
Connection.open_tcp(host_name, port = TCP_PORT_CHAIN, use_message_ids = False)Opens a TCP connection.
Arguments
| Name | Type | Description |
|---|---|---|
| host_name | str | Hostname or IP address. |
| port | int | Optional port number (defaults to 55550). |
| use_message_ids | bool | Enable use of message IDs (defaults to disabled). All your devices must be pre-configured to match. |
Return Value
Connection An object representing the connection.m