# API Reference v10.3.1 (Python)

## Device (class)

Module: zaber_motion.binary

Represents a device using the binary protocol.

To use this type, add `from zaber_motion.binary import Device` to the top of your source code.

### Constants

#### `DEFAULT_MOVEMENT_TIMEOUT`

`Device.DEFAULT_MOVEMENT_TIMEOUT`

Type: `float`

Default timeout for move commands in seconds.

##### Value

`60`

### Properties

#### `connection` (read-only)

`device.connection`

Type: [`Connection`](https://software.zaber.com/motion-library/api/py/binary/connection.md)

Connection of this device.

#### `device_address` (read-only)

`device.device_address`

Type: `int`

The device address uniquely identifies the device on the connection. It can be configured or automatically assigned by the renumber command.

#### `device_id` (read-only)

`device.device_id`

Type: `int`

Unique ID of the device hardware.

#### `device_type` (read-only)

`device.device_type`

Type: [`DeviceType`](https://software.zaber.com/motion-library/api/py/binary/devicetype.md)

Determines the type of an device and units it accepts.

#### `firmware_version` (read-only)

`device.firmware_version`

Type: [`FirmwareVersion`](https://software.zaber.com/motion-library/api/py/root/firmwareversion.md)

Version of the firmware.

#### `identity` (read-only)

`device.identity`

Type: [`DeviceIdentity`](https://software.zaber.com/motion-library/api/py/binary/deviceidentity.md)

Identity of the device.

#### `is_identified` (read-only)

`device.is_identified`

Type: `bool`

Indicates whether or not the device has been identified.

#### `is_peripheral` (read-only)

`device.is_peripheral`

Type: `bool`

Indicates whether the device is a peripheral or part of an integrated device.

#### `name` (read-only)

`device.name`

Type: `str`

Name of the product.

#### `peripheral_id` (read-only)

`device.peripheral_id`

Type: `int`

Unique ID of the peripheral hardware.

#### `peripheral_name` (read-only)

`device.peripheral_name`

Type: `str`

Name of the peripheral hardware.

#### `serial_number` (read-only)

`device.serial_number`

Type: `int`

Serial number of the device. Requires at least Firmware 6.15 for devices or 6.24 for peripherals.

#### `settings` (read-only)

`device.settings`

Type: [`DeviceSettings`](https://software.zaber.com/motion-library/api/py/binary/devicesettings.md)

Settings and properties of this axis.

### Methods

#### `generic_command()` (async available)

`device.generic_command(command, data = 0, timeout = 0.0, check_errors = True)`

Sends a generic Binary command to this device. For more information please refer to the [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `command` | [`CommandCode`](https://software.zaber.com/motion-library/api/py/binary/commandcode.md) | 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

Type: [`Message`](https://software.zaber.com/motion-library/api/py/binary/message.md)

A response to the command.

#### `generic_command_no_response()` (async available)

`device.generic_command_no_response(command, data = 0)`

Sends a generic Binary command to this device without expecting a response. For more information please refer to the [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `command` | [`CommandCode`](https://software.zaber.com/motion-library/api/py/binary/commandcode.md) | Command to send. |
| `data` | `int` | Optional data argument to the command. Defaults to zero. |

#### `generic_command_with_units()` (async available)

`device.generic_command_with_units(command, data = 0, from_unit = Units.NATIVE, to_unit = Units.NATIVE, timeout = 0.0)`

Sends a generic Binary command to this device with unit conversions for both sent data and retrieved data.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `command` | [`CommandCode`](https://software.zaber.com/motion-library/api/py/binary/commandcode.md) | Command to send. |
| `data` | `float` | Data argument to the command. Defaults to zero. |
| `from_unit` | [`UnitsAndLiterals`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit to convert sent data from. |
| `to_unit` | [`UnitsAndLiterals`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit to convert retrieved data to. |
| `timeout` | `float` | Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s. |

##### Return Value

Type: `float`

Data that has been converted to the provided unit.

#### `get_position()` (async available)

`device.get_position(unit = Units.NATIVE)`

Returns current device position.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `unit` | [`LengthUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Units of position. |

##### Return Value

Type: `float`

Axis position.

#### `home()` (async available)

`device.home(unit = Units.NATIVE, timeout = DEFAULT_MOVEMENT_TIMEOUT)`

Homes device. Device returns to its homing position.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `unit` | [`LengthUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit to convert returned position to. |
| `timeout` | `float` | Number of seconds to wait for response from the device chain (defaults to 60s). |

##### Return Value

Type: `float`

Current position that has been converted to the provided unit.

#### `identify()` (async available)

`device.identify(assume_version = None)`

Queries the device and the database, gathering information about the product. Without this information features such as unit conversions will not work. Usually, called automatically by detect devices method.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `assume_version` | [`Optional[FirmwareVersion]`](https://software.zaber.com/motion-library/api/py/root/firmwareversion.md) | The identification assumes the specified firmware version instead of the version queried from the device. Providing this argument can lead to unexpected compatibility issues. |

##### Return Value

Type: [`DeviceIdentity`](https://software.zaber.com/motion-library/api/py/binary/deviceidentity.md)

Device identification data.

#### `is_busy()` (async available)

`device.is_busy()`

Check whether the device is moving.

##### Return Value

Type: `bool`

True if the device is currently executing a motion command.

#### `is_parked()` (async available)

`device.is_parked()`

Returns bool indicating whether the axis is parked or not.

Requires at least Firmware 6.06.

##### Return Value

Type: `bool`

True if the axis is currently parked. False otherwise.

#### `move_absolute()` (async available)

`device.move_absolute(position, unit = Units.NATIVE, timeout = DEFAULT_MOVEMENT_TIMEOUT)`

Move device to absolute position.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `position` | `float` | Absolute position. |
| `unit` | [`LengthUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit for the provided position as well as position returned by the device. |
| `timeout` | `float` | Number of seconds to wait for response from the device chain (defaults to 60s). |

##### Return Value

Type: `float`

Current position that has been converted to the provided unit.

#### `move_relative()` (async available)

`device.move_relative(position, unit = Units.NATIVE, timeout = DEFAULT_MOVEMENT_TIMEOUT)`

Move device to position relative to current position.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `position` | `float` | Relative position. |
| `unit` | [`LengthUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit for the provided position as well as position returned by the device. |
| `timeout` | `float` | Number of seconds to wait for response from the device chain (defaults to 60s). |

##### Return Value

Type: `float`

Current position that has been converted to the provided unit.

#### `move_velocity()` (async available)

`device.move_velocity(velocity, unit = Units.NATIVE)`

Begins to move device at specified speed.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `velocity` | `float` | Movement velocity. |
| `unit` | [`VelocityUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit to convert returned velocity to. |

##### Return Value

Type: `float`

Device velocity that has been converted to the provided unit.

#### `park()` (async available)

`device.park()`

Parks the axis. Motor drivers remain enabled and hold current continues to be applied until the device is powered off. It can later be unparked and moved without first having to home it.

Requires at least Firmware 6.06.

#### `stop()` (async available)

`device.stop(unit = Units.NATIVE, timeout = DEFAULT_MOVEMENT_TIMEOUT)`

Stops ongoing device movement. Decelerates until zero speed.

##### Arguments

| Name | Type | Description |
| --- | --- | --- |
| `unit` | [`LengthUnits`](https://software.zaber.com/motion-library/api/py/root/units.md) | Unit to convert returned position to. |
| `timeout` | `float` | Number of seconds to wait for response from the device chain (defaults to 60s). |

##### Return Value

Type: `float`

Current position that has been converted to the provided unit.

#### `__repr__()`

`device.__repr__()`

Returns a string that represents the device.

##### Return Value

Type: `str`

A string that represents the device.

#### `unpark()` (async available)

`device.unpark()`

Unparks axis. Axis will now be able to move.

Requires at least Firmware 6.06.

#### `wait_until_idle()` (async available)

`device.wait_until_idle()`

Waits until device stops moving.
