brian.sensors.sensor_port_probe package

Module contents

class brian.sensors.sensor_port_probe.AutoDetect(*values)

Bases: Enum

NOT_CONNECTED = (64,)
ANALOG_P1 = (0,)
ANALOG_P1_HACKER = 4

Force P1 ADC mode, regardless of what AD thinks

ANALOG_P6 = (2,)
ANALOG_P6_HACKER = 6

Force P6 ADC mode, regardless of what AD thinks

I2C_9K6 = 3

NXT ultrasonic uses bit banging I2C implementation and cannot operate faster than 9600 bits/s

I2C_100K = 7

Some other 3rd party sensors may support only standard I2C speed

I2C_400K = 11

Most other 3rd party sensors support fast I2C speeds

UART_2400 = 1
UART_9600 = 5
UART_115K = 9

115200 baud

UART_MULTI_BRIAN_MASTER = 41
UART_MULTI_BRIAN_SLAVE = 57

Slave has uart RX/TX pins swapped

PROTOCOL_UART_EV3 = 17
PROTOCOL_I2C_NXT_REG = 19
ERROR = (128, ' MSB is error flag, the rest can be used as an error code')
class brian.sensors.sensor_port_probe.SensorInfo

Bases: object

i2c protocol specifies type as 8char string; uart ev3 as a single byte 0-255 when uart ev3 protocol is used, the name can be something like: “Uart 39” and the code will contain the actual value when i2c protocol is used, the code can be = 0

property sensor_type_name: str

The sensor type name as a string.

property sensor_type_code: int

Represents the sensor type code.

property selected_mode: int

The currently selected mode of the sensor.

property mode_name: str

The name of the current mode.

property mode_count: int

Set by sensor handler. EV3 sensors report their mode count. Generic I2C sensor will have 0. Specific I2C sensors (NXT US) will have constant mode count. Even analog sensor, such as NXT light can have multiple modes and mode count - active, passive, blinking differential handled by ST code

property unit_name: str

Name of the measurement unit.

property raw_min: float

Minimum raw sensor value.

property raw_max: float

Maximum raw sensor value.

property pct_min: float

Percent value corresponding to the minimum raw value.

property pct_max: float

Percent value corresponding to the maximum raw value.

property si_min: float

Scaled International (SI) value corresponding to the minimum raw value.

property si_max: float

Scaled International (SI) value corresponding to the maximum raw value.

class brian.sensors.sensor_port_probe.SensorPortProbe

Bases: object

is_sensor_api_handler_registered: bool
is_connected: bool
auto_detect: AutoDetect
auto_detect_hint: AutoDetect
info: SensorInfo
brian.sensors.sensor_port_probe.probe_sensor(port: SensorPort) SensorPortProbe

Return latest read-only information about a sensor connected to a given port. This method can be called any time (regardless of registered Sensor port handler or if it is not registered) :param port: sensor port to probe. :return: information about the current port usage

brian.sensors.sensor_port_probe.probe_sensor_with_autodetect_hint(port: SensorPort, hint: AutoDetect) SensorPortProbe

Return latest read-only information about a sensor connected to a given port. It requests a specific handling of the sensor, based on the autodetect hint. The hint may be used to initialize a specific software protocol over a detected bus (e.g. use EV3 UART protocol if the detected sensor interfaces using UART). When you expect a specific class of sensors to be connected, this may be useful to extract more information, for example about the sensor modes. This method can be used only, when there is no Sensor handler registered. :param port: sensor port to probe. :param hint: hint to for autodetect (e.g. software protocol over detected hw bus) :return: information about the current port usage

Raises:

SensorPortAlreadyInUse – When trying to probe port that is already in use.

brian.sensors.sensor_port_probe.reboot(port: SensorPort) None

Turn off power to the port and turn it back on. This will forcibly reboot the sensor. The powered-down state lasts about 100ms. In case of some (mostly digital) sensors, there can be some additional time (~1s or more) to boot up and process connection handshake with Brian. This method can be used only, when there is no Sensor handler registered. When there is, use the method in the Sensor handler itself. :param port: sensor port to force reboot.