Struct dynamixel2::Bus

source ·
pub struct Bus<ReadBuffer, WriteBuffer> { /* private fields */ }
Expand description

Dynamixel Protocol 2 communication bus.

Implementations§

Send an action command to trigger a previously registered instruction.

The motor_id parameter may be set to packet_id::BROADCAST, although the Self::broadcast_action is generally easier to use.

Broadcast an action command to all connected motors to trigger a previously registered instruction.

Synchronously read arbitrary data ranges from multiple motors in one command.

Unlike the sync read instruction, a bulk read can be used to read a different amount of data from a different address for each motor.

The data for multi-byte registers is received in little-endian format.

The on_response function is called for the reply from each motor. If the function fails to write the instruction, an error is returned and the function is not called.

Panics

The protocol forbids specifying the same motor ID multiple times. This function panics if the same motor ID is used for more than one read.

Synchronously read arbitrary data ranges from multiple motors in one command.

Unlike the sync read instruction, a bulk read can be used to read a different amount of data from a different address for each motor.

If this function fails to get the data from any of the motors, the entire function retrns an error. If you need access to the data from other motors, or if you want acces to the error for each motor, see Self::bulk_read_cb.

Panics

The protocol forbids specifying the same motor ID multiple times. This function panics if the same motor ID is used for more than one read.

Synchronously write arbitrary data ranges to multiple motors.

Each motor will perform the write as soon as it receives the command. This gives much shorter delays than executing a regular Self::write for each motor individually. Unlike the sync write instruction, a bulk write allows you to write a different amount of data to a different address for each motor.

The data for multi-byte registers should serialized as little-endian.

Panics

The protocol forbids specifying the same motor ID multiple times. This function panics if the same motor ID is used for more than one write.

This function also panics if the data length for a motor exceeds the capacity of a u16.

Clear the multi-revolution counter of a motor.

This will reset the “present position” register to a value between 0 and a whole revolution. It is not possible to clear the revolution counter of a motor while it is moving. Doing so will cause the motor to return an error, and the revolution counter will not be reset.

The motor_id parameter may be set to packet_id::BROADCAST, although the Self::broadcast_clear_revolution_counter is generally easier to use.

Clear the revolution counter of all connected motors.

This will reset the “present position” register to a value between 0 and a whole revolution. It is not possible to clear the mutli-revolution counter of a motor while it is moving. Doing so will cause the motor to return an error, and the revolution counter will not be reset.

Reset the settings of a motor to the factory defaults.

This will reset all registers to the factory default, including the EEPROM registers. The only exceptions are the ID and baud rate settings, which may be kept depending on the kind argument.

The motor_id parameter may be set to packet_id::BROADCAST, although the Self::broadcast_factory_reset is generally easier to use.

Starting with version 42 of the firmware for the MX-series and X-series, motors ignore a broadcast reset command with FactoryResetKind::ResetAll. Motors with older firmware may still execute the command, which would cause multiple motors on the bus to have the same ID. At that point, communication with those motors is not possible anymore. The only way to restore communication is to physically disconnect all but one motor at a time and re-assign unique IDs.

Reset the settings of all connected motors to the factory defaults.

This will reset all registers to the factory default, including the EEPROM registers. The only exceptions are the ID and baud rate settings, which may be kept depending on the kind argument.

Starting with version 42 of the firmware for the MX-series and X-series, motors ignore a broadcast reset command with FactoryResetKind::ResetAll. Motors with older firmware may still execute the command, which would cause multiple motors on the bus to have the same ID. At that point, communication with those motors is not possible anymore. The only way to restore communication is to physically disconnect all but one motor at a time and re-assign unique IDs.

Ping a specific motor by ID.

This will not work correctly if the motor ID is packet_id::BROADCAST. Use Self::scan or Self::scan_cb instead.

Scan a bus for motors with a broadcast ping, returning the responses in a Vec.

Only timeouts are filtered out since they indicate a lack of response. All other responses (including errors) are collected.

Scan a bus for motors with a broadcast ping, calling an FnMut for each response.

Only timeouts are filtered out since they indicate a lack of response. All other responses (including errors) are passed to the handler.

Read an arbitrary number of bytes from a specific motor.

This function will not work correctly if the motor ID is set to packet_id::BROADCAST. Use Self::sync_read to read from multiple motors with one command.

Read an 8 bit register from a specific motor.

This function will not work correctly if the motor ID is set to packet_id::BROADCAST. Use Self::sync_read to read from multiple motors with one command.

Read 16 bit register from a specific motor.

This function will not work correctly if the motor ID is set to packet_id::BROADCAST. Use Self::sync_read to read from multiple motors with one command.

Read 32 bit register from a specific motor.

This function will not work correctly if the motor ID is set to packet_id::BROADCAST. Use Self::sync_read to read from multiple motors with one command.

Send a reboot command to a specific motor.

Certain error conditions can only be cleared by rebooting a motor. When a motor reboots, all volatile (non-EEPROM) registers are reset to their initial value. This also has the effect of disabling motor torque and resetting the multi-revolution information.

The motor_id parameter may be set to packet_id::BROADCAST, although the Self::broadcast_reboot is generally easier to use.

Broadcast an reboot command to all connected motors to trigger a previously registered instruction.

Register a write of an arbitrary number of bytes, to be triggered later by an action command.

Only one write command can be registered per motor.

You can have all connected motors execute their registered write using Self::broadcast_action, or a single motor using Self::action.

Register a write command for a 8 bit value to a specific motor.

Only one write command can be registered per motor.

You can have all connected motors execute their registered write using Self::broadcast_action, or a single motor using Self::action.

Register a write command for a 16 bit value to a specific motor.

Only one write command can be registered per motor.

You can have all connected motors execute their registered write using Self::broadcast_action, or a single motor using Self::action.

Register a write command for a 32 bit value to a specific motor.

Only one write command can be registered per motor.

You can have all connected motors execute their registered write using Self::broadcast_action, or a single motor using Self::action.

Synchronously read an arbitrary number of bytes from multiple motors in one command.

The on_response function is called for the reply from each motor. If the function fails to write the instruction, an error is returned and the function is not called.

Synchronously read an 8 bit value from multiple motors in one command.

The on_response function is called for the reply from each motor. If the function fails to write the instruction, an error is returned and the function is not called.

Synchronously read a 16 bit value from multiple motors in one command.

The on_response function is called for the reply from each motor. If the function fails to write the instruction, an error is returned and the function is not called.

Synchronously read a 32 bit value from multiple motors in one command.

The on_response function is called for the reply from each motor. If the function fails to write the instruction, an error is returned and the function is not called.

Synchronously read an arbitrary number of bytes from multiple motors in one command.

If this function fails to get the data from any of the motors, the entire function retrns an error. If you need access to the data from other motors, or if you want acces to the error for each motor, see Self::sync_read_cb.

Synchronously read an 8 bit value from multiple motors in one command.

If this function fails to get the data from any of the motors, the entire function retrns an error. If you need access to the data from other motors, or if you want acces to the error for each motor, see Self::sync_read_u8_cb.

Synchronously read a 16 bit value from multiple motors in one command.

If this function fails to get the data from any of the motors, the entire function retrns an error. If you need access to the data from other motors, or if you want acces to the error for each motor, see Self::sync_read_u16_cb.

Synchronously read a 32 bit value from multiple motors in one command.

If this function fails to get the data from any of the motors, the entire function retrns an error. If you need access to the data from other motors, or if you want acces to the error for each motor, see Self::sync_read_u32_cb.

Synchronously write an arbitrary number of bytes to multiple motors.

Each motor will perform the write as soon as it receives the command. This gives much shorter delays than executing a regular Self::write for each motor individually.

Panics

The amount of data to write for each motor must be exactly count bytes. This function panics if that is not the case.

Synchronously write a 8 bit value to multiple motors.

Each motor will perform the write as soon as it receives the command. This gives much shorter delays than executing a regular Self::write for each motor individually.

Synchronously write a 16 bit value to multiple motors.

Each motor will perform the write as soon as it receives the command. This gives much shorter delays than executing a regular Self::write for each motor individually.

Synchronously write a 32 bit value to multiple motors.

Each motor will perform the write as soon as it receives the command. This gives much shorter delays than executing a regular Self::write for each motor individually.

Write an arbitrary number of bytes to a specific motor.

Write an 8 bit value to a specific motor.

Write an 16 bit value to a specific motor.

Write an 32 bit value to a specific motor.

Open a serial port with the given baud rate.

This will allocate a new read and write buffer of 128 bytes each. Use Self::open_with_buffers() if you want to use a custom buffers.

Create a new bus for an open serial port.

This will allocate a new read and write buffer of 128 bytes each. Use Self::with_buffers() if you want to use a custom buffers.

Open a serial port with the given baud rate.

This will allocate a new read and write buffer of 128 bytes each.

Create a new bus using pre-allocated buffers.

Write a raw instruction to a stream, and read a single raw response.

This function also checks that the packet ID of the status response matches the one from the instruction.

This is not suitable for broadcast instructions. For broadcast instructions, each motor sends an individual response or no response is send at all. Instead, use Self::write_instruction and Self::read_status_response.

Write an instruction message to the bus.

Read a raw status response from the bus.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.