Skip to content

brian.motors.motor_port_probe

brian.motors

AutoDetect class objects

class AutoDetect()

Results of the motor port auto-detection.

__init__

def __init__(device_class: DeviceClass, device_type: DeviceType)

Arguments:

  • device_class: Detected device class.
  • device_type: More detailed device type.

device_class

@property
def device_class() -> DeviceClass

Detected device class (PortMode must not be POWER_OFF)

device_type

@property
def device_type() -> DeviceType

More detailed device type

PortMode class objects

class PortMode(Enum)

Operating mode of a motor port.

POWER_OFF

Disabled state

AUTOID_ONLY

Passive probing state

ANALOG_MOTOR

NXT/EV3 motor

MotorPortProbe class objects

class MotorPortProbe()

Read-only snapshot of a motor port, returned by probe_motor().

is_motor_api_handler_registered

True if a Motor object is currently registered on the port

is_connected

True if a device is connected to the port

auto_detect

Result of the port auto-detection

port_mode

Current mode of the port

probe_motor

def probe_motor(port: 'MotorPort') -> 'MotorPortProbe'

Return latest read-only information about a motor connected to a given port. This method can be called

any time (regardless of registered Motor port handler or if it is not registered)

Arguments:

  • port: port motor port to probe.

Returns:

information about the current port usage

probe_motor_with_port_mode_hint

def probe_motor_with_port_mode_hint(port: 'MotorPort',
                                    hint: 'PortMode') -> 'MotorPortProbe'

Return latest read-only information about a motor connected to a given port. It requests a specific mode of the

port, based on the provided PortMode. The hint may be used to initialize a specific software protocol over a detected bus (e.g. use EV3 UART protocol if the detected motor interfaces using UART). When you expect a specific class of motors to be connected, this may be useful to extract more information, for example about supported behavior. This method can be used only, when there is no Motor handler registered.

Arguments:

  • port: port motor port to probe.
  • hint: PortMode target port mode. Only 'PortMode.POWER_OFF' and 'PortMode.AUTOID_ONLY' can be set manually.

Raises:

  • MotorPortAlreadyInUse: When trying to create probe port that is already in use.

Returns:

information about the current port usage