Modules

Quick Access:

Each type of BrainStem module is represented by a corresponding concrete Module implementation. The following classes are instantiated to allow communication through to the corresponding BrainStem module hardware.

The instantiation and subsequent connection to each module is as follows

>>> stem = USBStem()
# 0xXXXXXXXX is the serial number of the module.
>>> stem.connect(0xXXXXXXXX)

Connecting to the BrainStem module can take multiple forms, the simplest way to connect when you know the module’s serial number is to call connect with the serial number, as in the above code snippet. If you don’t know the serial number of the module, you can perform a discovery of the modules currently connected and print that information. For details of the connection functions API please see Connections in this reference.

USBStem

class brainstem.stem.USBStem(address=2, bAutoNetworking=True)[source]

Concrete Module implementation for 40Pin USBStem modules

USBStem modules contain contain the following entities:
  • system
  • analog[0-3]
  • app[0-3]
  • clock
  • digital[0-14]
  • i2c[0-1]
  • pointer[0-3]
  • servo[0-7]
  • store[0-2]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (2)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_SD_SLOTS (255)
  • NUMBER_OF_ANALOGS (4)
  • DAC_ANALOG_INDEX (3)
  • FIXED_DAC_ANALOG (False)
  • NUMBER_OF_DIGITALS (15)
  • NUMBER_OF_I2C (2)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_SERVOS (8)
  • NUMBER_OF_SERVO_OUTPUTS (4)
  • NUMBER_OF_SERVO_INPUTS (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

EtherStem

class brainstem.stem.EtherStem(address=2, bAutoNetworking=True)[source]

Concrete Module implementation for 40Pin EtherStem modules

EtherStem modules contain the following entities:
  • system
  • analog[0-3]
  • app[0-3]
  • clock
  • digital[0-14]
  • i2c[0-1]
  • pointer[0-3]
  • servo[0-7]
  • store[0-2]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (2)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_SD_SLOTS (255)
  • NUMBER_OF_ANALOGS (4)
  • DAC_ANALOG_INDEX (3)
  • FIXED_DAC_ANALOG (False)
  • NUMBER_OF_DIGITALS (15)
  • NUMBER_OF_I2C (2)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_SERVOS (8)
  • NUMBER_OF_SERVO_OUTPUTS (4)
  • NUMBER_OF_SERVO_INPUTS (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMEtherStem

class brainstem.stem.MTMEtherStem(address=4, bAutoNetworking=True)[source]

Concrete Module implementation for MTM EtherStem modules

USBStem modules contain the following entities:
  • system
  • analog[0-3]
  • app[0-3]
  • clock
  • digital[0-14]
  • i2c[0-1]
  • pointer[0-3]
  • servo[0-7]
  • store[0-2]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (4)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_SD_SLOTS (255)
  • NUMBER_OF_ANALOGS (4)
  • DAC_ANALOG_INDEX (3)
  • FIXED_DAC_ANALOG (False)
  • NUMBER_OF_DIGITALS (15)
  • NUMBER_OF_I2C (2)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_SERVOS (8)
  • NUMBER_OF_SERVO_OUTPUTS (4)
  • NUMBER_OF_SERVO_INPUTS (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMIOSerial

class brainstem.stem.MTMIOSerial(address=8, bAutoNetworking=True)[source]

Concrete Module implementation for MTM-IO-Serial module

MTM-IO-SERIAL modules contain contain the following entities:
  • system
  • app[0-3]
  • digital[0-8]
  • i2c[0]
  • pointer[0-3]
  • servo[0-7]
  • store[0-1]
  • temperature
  • timer[0-7]
  • uart[0-3]
  • rail[0-2]
Useful Constants:
  • BASE_ADDRESS (8)
  • NUMBER_OF_STORES (2)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_DIGITALS (8)
  • NUMBER_OF_I2C (1)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_UART (1)
  • NUMBER_OF_RAILS (3)
  • NUMBER_OF_SERVOS (8)
  • NUMBER_OF_SERVO_OUTPUTS (4)
  • NUMBER_OF_SERVO_INPUTS (4)
  • aMTMIOSERIAL_USB_VBUS_ENABLED (0)
  • aMTMIOSERIAL_USB2_DATA_ENABLED (1)
  • aMTMIOSERIAL_USB_ERROR_FLAG (19)
  • aMTMIOSERIAL_USB2_BOOST_ENABLED (20)
  • aMTMIOSERIAL_ERROR_VBUS_OVERCURRENT (0)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMUSBStem

class brainstem.stem.MTMUSBStem(address=4, bAutoNetworking=True)[source]

Concrete Module implementation for MTM USBStem modules

MTMUSBStem modules contain the following entities:
  • system
  • analog[0-3]
  • app[0-3]
  • clock
  • digital[0-14]
  • i2c[0-1]
  • pointer[0-3]
  • servo[0-7]
  • store[0-2]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (4)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_SD_SLOTS (255)
  • NUMBER_OF_ANALOGS (4)
  • DAC_ANALOG_INDEX (3)
  • FIXED_DAC_ANALOG (True)
  • NUMBER_OF_DIGITALS (15)
  • NUMBER_OF_I2C (2)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_SERVOS (8)
  • NUMBER_OF_SERVO_OUTPUTS (4)
  • NUMBER_OF_SERVO_INPUTS (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMPM1

class brainstem.stem.MTMPM1(address=6, bAutoNetworking=True)[source]

Concrete Module implementation for MTM-PM-1 module

MTM-PM-1 modules contain contain the following entities:
  • system
  • app[0-3]
  • digital[0-1]
  • i2c[0]
  • pointer[0-3]
  • store[0-1]
  • timer[0-7]
  • rail[0-1]
  • temperature
Useful Constants:
  • BASE_ADDRESS (6)
  • NUMBER_OF_STORES (2)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_DIGITALS (2)
  • NUMBER_OF_I2C (1)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_RAILS (2)
  • NUMBER_OF_TEMPERATURES (1)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMRelay

class brainstem.stem.MTMRelay(address=12, bAutoNetworking=True)[source]

Concrete Module implementation for MTM-RELAY module

MTM-RELAY modules contain contain the following entities:
  • system
  • app[0-3]
  • digital[0-3]
  • i2c[0]
  • pointer[0-3]
  • store[0-1]
  • timer[0-7]
  • relay[0-3]
  • temperature
Useful Constants:
  • BASE_ADDRESS (12)
  • NUMBER_OF_STORES (2)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_DIGITALS (4)
  • NUMBER_OF_I2C (1)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_RELAYS (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

USBHub2x4

class brainstem.stem.USBHub2x4(address=6, bAutoNetworking=True)[source]

Concrete Module implementation for the USBHub2x4.

The module contains the USB entity as well as the following.

Entities:
  • system
  • app[0-3]
  • pointer[0-3]
  • usb
  • mux
  • store[0-1]
  • temperature
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (6)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_DOWNSTREAM_USB (4)
  • NUMBER_OF_UPSTREAM_USB (2)
  • aUSBHUB2X4_USB_VBUS_ENABLED (0)
  • aUSBHUB2X4_USB2_DATA_ENABLED (1)
  • aUSBHUB2X4_USB_ERROR_FLAG (19)
  • aUSBHUB2X4_USB2_BOOST_ENABLED (20)
  • aUSBHUB2X4_DEVICE_ATTACHED (23)
  • aUSBHUB2X4_CONSTANT_CURRENT (24)
  • aUSBHUB2X4_ERROR_VBUS_OVERCURRENT (0)
  • aUSBHUB2X4_ERROR_OVER_TEMPERATURE (3)
  • aUSBHub2X4_ERROR_DISCHARGE (4)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

USBHub3p

class brainstem.stem.USBHub3p(address=6, bAutoNetworking=True)[source]

Concrete Module implementation for the USBHub3p.

The module contains the USB entity as well as the following.

Entities:
  • system
  • app[0-3]
  • pointers[0-3]
  • usb
  • store[0-1]
  • temperature
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (6)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_DOWNSTREAM_USB (8)
  • NUMBER_OF_UPSTREAM_USB (2)
  • aUSBHUB3P_USB_VBUS_ENABLED (0)
  • aUSBHUB3P_USB2_DATA_ENABLED (1)
  • aUSBHUB3P_USB3_DATA_ENABLED (3)
  • aUSBHUB3P_USB_SPEED_USB2 (11)
  • aUSBHUB3P_USB_SPEED_USB3 (12)
  • aUSBHUB3P_USB_ERROR_FLAG (19)
  • aUSBHUB3P_USB2_BOOST_ENABLED (20)
  • aUSBHUB3P_DEVICE_ATTACHED (23)
  • aUSBHUB3P_ERROR_VBUS_OVERCURRENT (0)
  • aUSBHUB3P_ERROR_VBUS_BACKDRIVE (1)
  • aUSBHUB3P_ERROR_HUB_POWER (2)
  • aUSBHUB3P_ERROR_OVER_TEMPERATURE (3)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

USBCSwitch

class brainstem.stem.USBCSwitch(address=6, bAutoNetworking=True)[source]

Concrete Module implementation for the USBC-Switch.

The module contains the USB entity as well as the following.

Entities:
  • system
  • app[0-3]
  • pointer[0-3]
  • usb
  • mux
  • store[0-1]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (6)
  • NUMBER_OF_STORES (3)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_USB (1)
  • NUMBER_OF_MUXS (1)
  • usbPortStateVBUS (0)
  • usbPortStateHiSpeed (1)
  • usbPortStateSBU (2)
  • usbPortStateSS1 (3)
  • usbPortStateSS2 (4)
  • usbPortStateCC1 5)
  • usbPortStateCC2 (6)
  • usbPortStateCCFlip (13)
  • usbPortStateSSFlip (14)
  • usbPortStateSBUFlip (15)
  • usbPortStateErrorFlag (19)
  • usbPortStateUSB2Boost (20)
  • usbPortStateUSB3Boost (21)
  • usbPortStateConnectionEstablished (22)
  • usbPortStateCC1Inject (26)
  • usbPortStateCC2Inject (27)
  • usbPortStateCC1Detect (28)
  • usbPortStateCC2Detect (29)
  • usbPortStateCC1LogicState (30)
  • usbPortStateCC2LogicState 31)
  • usbPortStateOff (0)
  • usbPortStateSideA (1)
  • usbPortStateSideB (2)
  • usbPortStateSideUndefined (3)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top

MTMDAQ1

class brainstem.stem.MTMDAQ1(address=10, bAutoNetworking=True)[source]

Concrete Module implementation for MTM-DAQ-1 module

MTM-DAQ-1 modules contain contain the following entities:
  • system
  • app[0-3]
  • digital[0-1]
  • analog[0-19]
  • i2c[0]
  • pointer[0-3]
  • store[0-1]
  • timer[0-7]
Useful Constants:
  • BASE_ADDRESS (10)
  • NUMBER_OF_STORES (2)
  • NUMBER_OF_INTERNAL_SLOTS (12)
  • NUMBER_OF_RAM_SLOTS (1)
  • NUMBER_OF_DIGITALS (2)
  • NUMBER_OF_ANALOGS (20)
  • NUMBER_OF_I2C (1)
  • NUMBER_OF_POINTERS (4)
  • NUMBER_OF_TIMERS (8)
  • NUMBER_OF_APPS (4)
  • ANALOG_RANGE_P0V064N0V064 (0)
  • ANALOG_RANGE_P0V64N0V64 (1)
  • ANALOG_RANGE_P0V128N0V128 (2)
  • ANALOG_RANGE_P1V28N1V28 (3)
  • ANALOG_RANGE_P1V28N0V0 (4)
  • ANALOG_RANGE_P0V256N0V256 (5)
  • ANALOG_RANGE_P2V56N2V56 (6)
  • ANALOG_RANGE_P2V56N0V0 (7)
  • ANALOG_RANGE_P0V512N0V512 (8)
  • ANALOG_RANGE_P5V12N5V12 (9)
  • ANALOG_RANGE_P5V12N0V0 (10)
  • ANALOG_RANGE_P1V024N1V024 (11)
  • ANALOG_RANGE_P10V24N10V24 (12)
  • ANALOG_RANGE_P10V24N0V0 (13)
  • ANALOG_RANGE_P2V048N0V0 (14)
  • ANALOG_RANGE_P4V096N0V0 (15)
connect(serial_number, **kwargs)[source]

Result.error: Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – The transport to connect over.
  • serial_number (int) – Serial number of the module.
Returns:

Returns an error result from the list of defined error codes in brainstem.result

Return type:

Result.error

Back to the top