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 BraiStem Modules and Entities. For more information about Brainstem Modules and Entities, please see the Terminology section of the Acroname BrainStem Reference

class brainstem.module.Entity(module, command, index)[source]

Base class for BrainStem Entity.

Provides the default implementation for a functional entity within the BrainStem. This can include IO like GPIOs, Analogs etc. For a more detailed description of Entities see the Terminology section of the brainstem reference for more information.

call_UEI(option)[source]

Result.error: Call a set UEI on this entity.

Parameters:option (int) – The command option.
Returns:Returns an error result from the list of defined error codes in brainstem.result
Return type:Result.error
command

int – Return the entitiy command.

drain_UEI(option)[source]

drain UEI packets matchin option.

Parameters:option (int) – The command option.
Returns:
Returns a result object, whose value is the number of
packets drained, and the error value set to NO_ERROR
Return type:Result
get_UEI(option)[source]

Result.error: Get a UEI value.

Parameters:option (int) – The command option.
Returns:
Returns a result object, whose value is set,
on with the requested value when the results error is set to NO_ERROR
Return type:Result
get_UEI_with_param(option, param)[source]

Result.error: Get a UEI value based on a parameter.

Parameters:
  • option (int) – The command option.
  • param (byte) – The command parameter
Returns:

Returns a result object, whose value is set,

on with the requested value when the results error is set to NO_ERROR

Return type:

Result

index

int – Return the entity index

module

Module – Return this entities module.

set_UEI16(option, value)[source]

Result.error: Call a set UEI with short param on this entity.

Parameters:
  • option (int) – The command option.
  • value (short) – The short parameter to send.
Returns:

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

Return type:

Result.error

set_UEI32(option, value)[source]

Result.error: Call a set UEI with int param on this entity.

Parameters:
  • option (int) – The command option.
  • value (int) – The int parameter to send.
Returns:

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

Return type:

Result.error

set_UEI32_with_subindex(option, subindex, value)[source]

Result.error: Call a set UEI with a subindex.

Parameters:
  • option (int) – The command option.
  • subindex (byte) – The subindex of the entity.
  • param (byte) – The byte parameter to send.
Returns:

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

Return type:

Result.error

set_UEI8(option, value)[source]

Result.error: Call a set UEI with byte param on this entity.

Parameters:
  • option (int) – The command option.
  • value (byte) – The byte parameter to send.
Returns:

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

Return type:

Result.error

set_UEI8_with_subindex(option, subindex, value)[source]

Result.error: Call a set UEI with a subindex.

Parameters:
  • option (int) – The command option.
  • subindex (byte) – The subindex of the entity.
  • param (byte) – The byte parameter to send.
Returns:

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

Return type:

Result.error

class brainstem.module.Module(address, bAutoNetworking)[source]

Base class for BrainStem Modules.

Provides default implementations for connecting and disconnecting from BrainStem modules via the module’s serial number, a Spec object or through another module.

address

int – Return the Brainstem module address.

bAutoNetworking

bool – Return the current networking mode.

connect(transport, serial_number)[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

connectFromSpec(spec)[source]

Result.error: Connect to a BrainStem module with a Spec.

Parameters:spec (Spec) – The specifier for the connection.
Returns:Returns an error result from the list of defined error codes in brainstem.result
Return type:Result.error
connectThroughLinkModule(module)[source]

Result.error: Connect to network module.

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 connec through.
Returns:Returns an error result from the list of defined error codes in brainstem.result
Return type:Result.error
disconnect()[source]

Disconnect from the Brainstem module.

discoverAndConnect(transport, serial_number=None)[source]

Discover and connect from the Module level.

A disover-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 (int) – The module address to switch to for this module instance.
  • serial_number (int) – The module serial_number to look for.
Returns:

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

Return type:

Result.error

getStatus()[source]

Returns the status of the BrainStem connection

See brainstem.link.Status for the possiable states.

isConnected()[source]

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

Link – return the current link or None.

reconnect()[source]

Reconnect a lost connection to a Brainstem module.

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 (int) – The module address to switch to for this module instance.
Returns:Returns an error result from the list of defined error codes in brainstem.result
Return type:Result.error
setNetworkingMode(mode)[source]

Set the networking mode of the module object.

By default the module object is configured to automatically adjust its address based on the devices current module address. So that, if the device has a software or hardware offset it will still be able to communicate with the device. If advanced networking is required the auto networking mode can be turned off.

Parameters:mode (bool) – True or 1 = Auto networking False or 0 = Manual networking
Returns:Returns an error result from the list of defined error codes in brainstem.result
Return type:Result.error
spec

Spec – Return the current spec object.