caspia.node package

Subpackages

Submodules

caspia.node.binary module

caspia.node.binary.decode_dictionary(data, keyfmt='<B')[source]
caspia.node.binary.decode_list(data)[source]
caspia.node.binary.encode_dictionary(dictionary, keyfmt='<B')[source]
caspia.node.binary.encode_list(lst)[source]

caspia.node.broadcast module

class caspia.node.broadcast.Broadcast(source: int, group: int, data: bytes, error_code: int = None, priority: int = None, timestamp: float = None)[source]

Bases: object

property component_data
property component_id
error_code = None
property is_component_broadcast
property is_system_broadcast
priority = None
timestamp = None
property type

caspia.node.config module

class caspia.node.config.Config[source]

Bases: caspia.toolbox.reprf.ReprFields

classmethod from_bytes(data)[source]
get_bytes()[source]
caspia.node.config.build_node_config(components)[source]
caspia.node.config.calculate_config_hash(data, max_length=1024)[source]
caspia.node.config.parse_node_config(data)[source]

caspia.node.errors module

exception caspia.node.errors.CaspiaError[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.node.errors.InvalidComponentError[source]

Bases: caspia.node.errors.CaspiaError

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception caspia.node.errors.InvalidConfigurationError[source]

Bases: caspia.node.errors.CaspiaError

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

caspia.node.events module

class caspia.node.events.BroadcastEvent(broadcast: caspia.node.broadcast.Broadcast)[source]

Bases: caspia.node.events.Event

Any event, which is backed by a broadcast.

property can_id
property component_id
class caspia.node.events.Event[source]

Bases: object

caspia.node.listener module

class caspia.node.listener.Listener(on_component_event=None, on_system_event=None)[source]

Bases: object

process_broadcast(broadcast)[source]

caspia.node.node module

class caspia.node.node.Node(pollen_client: aiopollen.client.Client, can_id: int)[source]

Bases: object

Initialize a new node.

Parameters
  • pollen_client – Client used for communication with the node.

  • can_id – Pollen identifier of the node.

async configure(force=False, restart=True)[source]

Configure the node to its current configuration.

If the configuration is not complete or valid, raises errors.InvalidConfigurationError.

Parameters
  • force – True if the configuration should be uploaded to the board even if the config hashes are the same.

  • restart – True if the node should be restarted after the configuration is done.

drop_components()[source]

Remove all components except system component.

get_component(identifier) → caspia.node.components.base.Component[source]

Get component with given identifier.

async load_configuration()[source]
register_component(component_cls: Type[C], identifier=None) → Tuple[int, C][source]

Register given component class for the components.

Parameters
  • component_cls – The class to be registered

  • identifier – Optionally the identifier the new component should have.

Returns

tuple with assigned identifier and the new component instance

static request_heartbeats(client, set_online=False)[source]

Send broadcast requesting heartbeat from all nodes.

Parameters
  • client – The client to send the heartbeats over.

  • set_online – If True, nodes will set themselves to Online state.

property system

Return system component (always present component with identifier 0).

caspia.node.pin module

class caspia.node.pin.Pin(number)[source]

Bases: object

property number

caspia.node.pollen_action module

caspia.node.pollen_action.action(builder)[source]
caspia.node.pollen_action.broadcast(builder)[source]
caspia.node.pollen_action.build(func, *args, **kwargs)[source]
caspia.node.pollen_action.request(builder)[source]

caspia.node.reprfields module

caspia.node.reprfields.repr_fields(obj)[source]
caspia.node.reprfields.reprf(obj)[source]
caspia.node.reprfields.reprf_str(obj)[source]

caspia.node.utils module

async caspia.node.utils.assign_can_id_by_hwid(hwid, can_id, client)[source]

Look for a node with given hwid and temporarily change its can_id.

Raises

TimeoutError if there is no response from the node.

async caspia.node.utils.check_node_in_isp_present(bus, wait_interval=1.0)[source]

Return None if no node is present. If is present, returns its hwid.

caspia.node.utils.hwid_read(src)[source]
async caspia.node.utils.invoke_isp_safely(client, hwid=None, can_id=None)[source]
async caspia.node.utils.make_hwid_request(client, hwid, cmd)[source]
caspia.node.utils.parse_broadcast(broadcast)[source]

Creates specific subclass of Event from Broadcast.

async caspia.node.utils.receive_event(accept, client, timeout=5.0)[source]

Wait for a specific broadcast. :param accept: If callable, must accept one argument (Event). Should

return True for the expected broadcast.

Parameters
  • client – pollen_client to use

  • timeout – raise TimeoutError after timeout

Returns

The Event instance.

async caspia.node.utils.reset_node_from_isp(bus, timeout=1.0)[source]
async caspia.node.utils.restart_by_hwid(hwid, client)[source]

Module contents