Module

A module that provides base classes for BrainStem Modules and Entities.

The Module and Entity classes are designed to be extended for specific types of BrainStem Modules and Entities. For more information about Brainstem Modules and Entities, please see the Terminology section of the Acroname BrainStem Reference

class brainstem.module.Module(address, enable_auto_networking=True, model=0)[source]

The Module Entity provides a generic interface to a BrainStem hardware module. The Module Class is the parent class for all BrainStem modules. Each module inherits from Module and implements its hardware specific features.

property address

Module address of the device

Type:

unsigned byte

property bAutoNetworking

Return the current networking mode.

Type:

bool

classQuantity(command)[source]

Queries the module to determine how many entities of the specified class are implemented by the module. Zero is a valid return value. For example, calling classQuantity with the command parameter of cmdANALOG would return the number of analog entities implemented by the module.

Parameters:

command (unsigned byte) – One of the UEI commands (cmdXXX).

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

connect(transport, serial_number)[source]

Connect to a Module with a transport type and serial number.

Parameters:
  • transport (Spec.transport) – (Spec.transport): One of USB, TCPIP, SERIAL or AETHER.

  • serial_number (unsigned int) – The module serial_number to look for.

Returns:

An error result from the list of defined error codes in brainstem.result

connectFromSpec(spec)[source]

Connect to a BrainStem module with a Spec.

Parameters:

spec (Spec) – The specifier for the connection.

Returns:

An error result from the list of defined error codes in brainstem.result

connectThroughLinkModule(module)[source]

Connects to a Brainstem module on a BrainStem network, through the module given as an argument. The module passed in must have an active valid connection.

Parameters:

module (Module) – The brainstem module to connect through.

Returns:

An error result from the list of defined error codes in brainstem.result

disconnect()[source]

Disconnect from the Brainstem module.

discoverAndConnect(transport, serial_number=0)[source]

Discover and connect from the Module level.

A discover-based connect. This member function will connect to the first available BrainStem found on the given transport. If the serial number is passed, it will only connect to the module with that serial number. Passing 0 or None as the serial number will create a link to the first link module found on the specified transport.

Parameters:
  • transport (Spec.transport) – (Spec.transport): One of USB, TCPIP, SERIAL or AETHER.

  • serial_number (unsigned int) – The module serial_number to look for.

Returns:

An error result from the list of defined error codes in brainstem.result

entityGroup(command, index)[source]

Queries the module the group assigned to an entity and index. Entities groups are used to specify when certain hardware features are fundamentally related. E.g. certain hardware modules may have some digital pins associated with an adjustable voltage rail; these digitals would be in the same group as the rail. Zero is the default group.

Parameters:

command (unsigned byte) – One of the UEI commands (cmdXXX).

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

getBuild()[source]

Get the modules firmware build number The build number is a unique hash assigned to a specific firmware.

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

getConfig()[source]

Gets the links current aEther configuration

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result containing a aEtherConfig

getModuleAddress()[source]

Get the address of the module object.

This method changes the local address of the module, not of the device. It is possible to get the module address of the device via system.getModuleSoftwareOffset().

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

getStatus()[source]

Returns the status of the BrainStem connection See brainstem.link.Status for the possible states.

hasUEI(command, option, index, flags)[source]

Queries the module to determine if it implements a UEI. Each UEI has a command, option or variant, index and flag. The hasUEI method queries for a fully specified UEI. Returns aErrNone if the variation is supported and an appropriate error if not. This call is blocking for up to the nMSTimeout period.

Parameters:
  • command (unsigned byte) – One of the UEI commands (cmdXXX).

  • option (unsigned byte) – The option or variant of the command.

  • index (unsigned byte) – The entity index.

  • flags (unsigned byte) – The flags (ueiOPTION_SET or ueiOPTION_GET).

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

property id

A unique identifier of the associated module

Type:

unsigned int

isConnected()[source]

Returns true if the Module has an active connection or false otherwise

return the current link or None.

Type:

Link

property model

Model number of the device

Type:

unsigned byte

reconnect()[source]

Reconnect a lost connection to a Brainstem module.

setConfig(config)[source]

Sets the links aEther configuration. Note: Configuration must be set BEFORE connection.

Parameters:

config (aEtherConfig) – (aEtherConfig object): aEther configuration to be set.

Returns:

An error result from the list of defined error codes in brainstem.result

setModuleAddress(address)[source]

Set the address of the module object.

This method changes the local address of the module, not of the device. It is possible to set the module address of the device via system.setModuleSoftwareOffset().

Parameters:

address (unsigned byte) – The module address to switch to for this module instance.

Returns:

An error result from the list of defined error codes in brainstem.result

setNetworkingMode(mode)[source]

Changes the networking mode of the stem object. Auto mode is enabled by default which allows automatic adjustment of the module/stems networking configuration. Refer to BrainStem Networking at www.acroname.com/support

Parameters:

mode (bool) – Mode to be set. True = Auto; False = Manual

Returns:

An error result from the list of defined error codes in brainstem.result

subClassQuantity(command, index)[source]

Queries the module to determine how many subclass entities of the specified class are implemented by the module for a given entity index. This is used for entities which may be 2-dimensional. E.g. cmdMUX subclasses are the number of channels supported by a particular mux type (index); as a specific example, a module may support 4 UART channels, so subClassQuantity(cmdMUX, aMUX_UART…) could return 4. Zero is a valid return value.

Parameters:

command (unsigned byte) – One of the UEI commands (cmdXXX).

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)