Entities

Quick Access:

Entities are also accessed via the module, generally they are represented as an array member of the Module class. However entities that are singular like System can be accessed directly.

>>> stem.system.getBootSlot()
>>> stem.i2c[0].read(0x90, 0x02)

System

class brainstem.stem.Analog(module, index)[source]

The AnalogClass is the interface to analog entities on BrainStem modules.

Analog entities may be configured as a input or output depending on hardware capabilities. Some modules are capable of providing actual voltage readings, while other simply return the raw analog-to-digital converter (ADC) output value. The resolution of the voltage or number of useful bits is also hardware dependent.

Useful constants:
  • CONFIGURATION_INPUT (0)
  • CONFIGURATION_OUTPUT (1)
  • HERTZ_MINIMUM (7,000)
  • HERTZ_MAXIMUM (200,000)
  • BULK_CAPTURE_IDLE (0)
  • BULK_CAPTURE_PENDING (1)
  • BULK_CAPTURE_FINISHED (2)
  • BULK_CAPTURE_ERROR (3)

Back to the top

Analog

class brainstem.stem.Analog(module, index)[source]

The AnalogClass is the interface to analog entities on BrainStem modules.

Analog entities may be configured as a input or output depending on hardware capabilities. Some modules are capable of providing actual voltage readings, while other simply return the raw analog-to-digital converter (ADC) output value. The resolution of the voltage or number of useful bits is also hardware dependent.

Useful constants:
  • CONFIGURATION_INPUT (0)
  • CONFIGURATION_OUTPUT (1)
  • HERTZ_MINIMUM (7,000)
  • HERTZ_MAXIMUM (200,000)
  • BULK_CAPTURE_IDLE (0)
  • BULK_CAPTURE_PENDING (1)
  • BULK_CAPTURE_FINISHED (2)
  • BULK_CAPTURE_ERROR (3)

Back to the top

Digital

class brainstem.stem.Digital(module, index)[source]

The DigitalClass is the interface to digital entities on BrainStem modules.

Digital entities have the following 5 possabilities: Digital Input, Digital Output, RCServo Input, RCServo Output, and HighZ. Other capabilities may be available and not all pins support all configurations. Please see the product datasheet.

Useful Constants:
  • VALUE_LOW (0)
  • VALUE_HIGH (1)
  • CONFIGURATION_INPUT (0)
  • CONFIGURATION_OUTPUT (1)
  • CONFIGURATION_RCSERVO_INPUT (2)
  • CONFIGURATION_RCSERVO_OUTPUT (3)
  • CONFIGURATION_HIGHZ (4)
  • CONFIGURATION_INPUT_PULL_UP (0)
  • CONFIGURATION_INPUT_NO_PULL (4)
  • CONFIGURATION_INPUT_PULL_DOWN (5)
  • CONFIGURATION_SIGNAL_OUTPUT (6)
  • CONFIGURATION_SIGNAL_INPUT (7)

Back to the top

I2C

class brainstem.stem.I2C(module, index)[source]

The I2C class is the interface the I2C busses on BrainStem modules.

The class provides a way to send read and write commands to I2C devices on the entitie’s bus.

Useful Constants:
  • I2C_DEFAULT_SPEED (0)
  • I2C_SPEED_100Khz (1)
  • I2C_SPEED_400Khz (2)
  • I2C_SPEED_1000Khz (3)

Back to the top

Mux

class brainstem.stem.Mux(module, index)[source]

Access MUX specialized entities on certain BrainStem modules.

A MUX is a multiplexer that takes one or more similar inputs (bus, connection, or signal) and allows switching to one or more outputs. An analogy would be the switchboard of a telephone operator. Calls (inputs) come in and by re-connecting the input to an output, the operator (multiplexor) can direct that input to on or more outputs.

One possible output is to not connect the input to anything which essentially disables that input’s connection to anything.

Not every MUX has multiple inputs. Some may simply be a single input that can be enabled (connected to a single output) or disabled (not connected to anything).

Useful Constants:
  • UPSTREAM_STATE_ONBOARD (0)
  • UPSTREAM_STATE_EDGE (1)
  • UPSTREAM_MODE_AUTO (0)
  • UPSTREAM_MODE_ONBOARD (1)
  • UPSTREAM_MODE_EDGE (2)
  • DEFAULT_MODE (UPSTREAM_MODE_AUTO)

Back to the top

Pointer

class brainstem.stem.Pointer(module, index)[source]

Access the reflex scratchpad from a host computer.

The Pointers access the pad which is a shared memory area on a BrainStem module. The interface allows the use of the brainstem scratchpad from the host, and provides a mechanism for allowing the host application and brainstem relexes to communicate.

The Pointer allows access to the pad in a similar manner as a file pointer accesses the underlying file. The cursor position can be set via setOffset. A read of a character short or int can be made from that cursor position. In addition the mode of the pointer can be set so that the cursor position automatically increments or set so that it does not this allows for multiple reads of the same pad value, or reads of multi-record values, via and incrementing pointer.

Useful Constants:
  • POINTER_MODE_STATIC (0)
  • POINTER_MODE_INCREMENT (1)

Back to the top

Rail

class brainstem.stem.Rail(module, index)[source]

Provides power rail functionality on certain modules.

This entity is only available on certain modules. The RailClass can be used to control power to downstream devices, I has the ability to take current and voltage measurements, and depending on hardware, may have additional modes and capabilities.

Useful Constants:
  • KELVIN_SENSING_OFF (0)
  • KELVIN_SENSING_ON (1)
  • OPERATIONAL_MODE_AUTO (0)
  • OPERATIONAL_MODE_LINEAR (1)
  • OPERATIONAL_MODE_SWITCHER (2)
  • OPERATIONAL_MODE_SWITCHER_LINEAR (3)
  • DEFAULT_OPERATIONAL_MODE (OPERATIONAL_MODE_AUTO)
  • OPERATIONAL_STATE_INITIALIZING (0)
  • OPERATIONAL_STATE_POWER_GOOD (1)
  • OPERATIONAL_STATE_POWER_FAULT (2)
  • OPERATIONAL_STATE_LDO_OVERTEMP (3)
  • OPERATIONAL_STATE_LINEAR (4)
  • OPERATIONAL_STATE_SWITCHER (5)

Back to the top

Store

class brainstem.stem.Store(module, index)[source]

Access the store on a BrainStem Module.

The store provides a flat file system on modules that have storage capacity. Files are referred to as slots and they have simple zero-based numbers for access. Store slots can be used for generalized storage and commonly contain compiled reflex code (files ending in .map) or templates used by the system. Slots simply contain bytes with no expected organization but the code or use of the slot may impose a structure.

Stores have fixed indices based on type. Not every module contains a store of each type. Consult the module datasheet for details on which specific stores are implemented, if any, and the capacities of implemented stores.

Useful Constants:
  • INTERNAL_STORE (0)
  • RAM_STORE (1)
  • SD_STORE (2)

Back to the top

Temperature

class brainstem.stem.Temperature(module, index)[source]

Provide interface to temperature sensor.

This entitiy is only available on certain modules, and provides a temperature reading in microcelsius.

Back to the top

Timer

class brainstem.stem.Timer(module, index)[source]

Schedules events to occur at future times.

Reflex routines can be written which will be executed upon expiration of the timer entity. The timer can be set to fire only once, or to repeat at a certain interval.

Useful Constants:
  • SINGLE_SHOT_MODE (0)
  • REPEAT_MODE (1)
  • DEFAULT_MODE (SINGLE_SHOT_MODE)

Back to the top

USB

class brainstem.stem.USB(module, index)[source]

USBClass provides methods to interact with a USB hub and USB switches.

Different USB hub products have varying support; check the datasheet to understand the capabilities of each product.

Useful Constants:
  • UPSTREAM_MODE_AUTO (2)
  • UPSTREAM_MODE_PORT_0 (0)
  • UPSTREAM_MODE_PORT_1 (1)
  • UPSTREAM_MODE_NONE (255)
  • DEFAULT_UPSTREAM_MODE (UPSTREAM_MODE_AUTO)
  • UPSTREAM_STATE_PORT_0 (0)
  • UPSTREAM_STATE_PORT_1 (1)
  • BOOST_0_PERCENT (0)
  • BOOST_4_PERCENT (1)
  • BOOST_8_PERCENT (2)
  • BOOST_12_PERCENT (3)
  • PORT_MODE_SDP (0)
  • PORT_MODE_CDP (1)
  • PORT_MODE_CHARGING (2)
  • PORT_MODE_PASSIVE (3)
  • PORT_MODE_USB2_A_ENABLE (4)
  • PORT_MODE_USB2_B_ENABLE (5)
  • PORT_MODE_VBUS_ENABLE (6)
  • PORT_MODE_SUPER_SPEED_1_ENABLE (7)
  • PORT_MODE_SUPER_SPEED_2_ENABLE (8)
  • PORT_MODE_USB2_BOOST_ENABLE (9)
  • PORT_MODE_USB3_BOOST_ENABLE (10)
  • PORT_MODE_AUTO_CONNECTION_ENABLE (11)
  • PORT_MODE_CC1_ENABLE (12)
  • PORT_MODE_CC2_ENABLE (13)
  • PORT_MODE_SBU_ENABLE (14)
  • PORT_MODE_CC_FLIP_ENABLE (15)
  • PORT_MODE_SS_FLIP_ENABLE (16)
  • PORT_MODE_SBU_FLIP_ENABLE (17)
  • PORT_MODE_USB2_FLIP_ENABLE (18)
  • PORT_MODE_CC1_INJECT_ENABLE (19)
  • PORT_MODE_CC2_INJECT_ENABLE (20)
  • PORT_SPEED_NA (0)
  • PORT_SPEED_HISPEED (1)
  • PORT_SPEED_SUPERSPEED (2)

Back to the top

RCServo

class brainstem.stem.RCServo(module, index)[source]

Provides RCServo functionality on certain modules.

This entity is only available on certain modules. The RCServoClass can be used to interpret and control RC Servo signals and motors via the digital pins.

Useful Constants:
  • SERVO_DEFAULT_POSITION (128)
  • SERVO_DEFAULT_MIN (64)
  • SERVO_DEFAULT_MAX (192)

Back to the top

USB

class brainstem.stem.Relay(module, index)[source]

The RelayClass is the interface to relay entities on BrainStem modules.

Relay entities may be enabled (set) or disabled (cleared low). Other capabilities may be available, please see the product datasheet.

Useful Constants:
  • VALUE_LOW (0)
  • VALUE_HIGH (1)

Back to the top