Feetech.Error (feetech v0.2.2)

Copy Markdown View Source

Error handling for Feetech servo responses.

The status byte in response packets contains bit flags indicating various error conditions and the torque enable state.

Status Byte Bits

BitNameDescription
0VoltageOver/under voltage detected
1SensorMagnetic encoder error
2TemperatureOver temperature
3CurrentOver current
4TorqueTorque is enabled (not an error)
5OverloadOverload protection triggered

Summary

Functions

Converts error atoms to human-readable descriptions.

Returns true if the status byte indicates any error.

Parses a status byte into a structured result.

Types

error()

@type error() ::
  :voltage_error
  | :sensor_error
  | :temperature_error
  | :current_error
  | :overload_error
  | :no_response
  | :invalid_checksum
  | :invalid_packet
  | :incomplete_packet
  | :invalid_header
  | :unknown_register
  | :timeout

status_info()

@type status_info() :: %{errors: [error()], torque_enabled: boolean()}

Functions

describe(other)

@spec describe(error()) :: String.t()

Converts error atoms to human-readable descriptions.

error?(status)

@spec error?(non_neg_integer()) :: boolean()

Returns true if the status byte indicates any error.

parse_status(status)

@spec parse_status(non_neg_integer()) :: status_info()

Parses a status byte into a structured result.

Returns a map with detected errors and torque state.

Examples

iex> Feetech.Error.parse_status(0x00)
%{errors: [], torque_enabled: false}

iex> Feetech.Error.parse_status(0x10)
%{errors: [], torque_enabled: true}

iex> Feetech.Error.parse_status(0x25)
%{errors: [:voltage_error, :temperature_error, :overload_error], torque_enabled: false}