canberry package

Submodules

canberry.can_utils module

Implementation of the protocol for the MOVIDRIVE traction converter of SEW EURODRIVE

class canberry.can_utils.Service[source]

Bases: object

Namespace for convenient and consistent naming

NO_SERVICE = 'no_service'
READ_ATTR = 'attribute'
READ_DEFAULT = 'default'
READ_MAX = 'maximum'
READ_MIN = 'minimum'
READ_PARAM = 'parameter'
READ_SCALE = 'scale'
WRITE_PARAM = 'write_parameter'
WRITE_PARAM_VOLATILE = 'write_parameter_volatile'
code = {'minimum': 4, 'write_parameter_volatile': 3, 'scale': 7, 'default': 6, 'attribute': 8, 'write_parameter': 2, 'no_service': 0, 'parameter': 1, 'maximum': 5}
canberry.can_utils.bytes_to_int(bytes)[source]

Convert a bytearray to an integer

Parameters:bytes – bytearray
Returns:integer
canberry.can_utils.make_mgt_byte(service, sync=False)[source]

Creates the management byte according to the protocol

Parameters:
  • service – Service code as defined in Service
  • sync – boolean if synchronized mode should be used
Returns:

integer

canberry.can_utils.make_sdo(recipient, index, service=None, value=None, sync=False)[source]

Creates a Service Data Object message

Parameters:
  • recipient – the recipient as integer
  • index – integer for the sensor
  • service – requested service from Service
  • value – None to read a value otherwise write value
  • sync – Synchronized protocol
Returns:

Service Data Object message

canberry.cli module

The command line interface for canberry

canberry.cli.main(args)[source]
canberry.cli.parse_args(args)[source]

Parse command line parameters

Parameters:args – command line parameters as list of strings
Returns:command line parameters as dictionary
canberry.cli.run()[source]

canberry.logic module

High-level functions to read and write a sensor of the MOVIDRIVE traction converter

class canberry.logic.Sensor[source]

Bases: object

Namespace for convenient and consistent naming

DUMMY1 = 'dummy1'
DUMMY2 = 'dummy2'
SPEED = 'speed'
code = {'dummy2': 65535, 'dummy1': 65535, 'speed': 8318}
classmethod list_all()[source]
canberry.logic.is_sensor_known(sensor)[source]

Check if sensor is known

Parameters:sensor – sensor as string
Returns:boolean
canberry.logic.read_sensor(sensor)[source]

Retrieve the data from a sensor

Parameters:sensor – name of a sensor according to inSensor
Returns:sensor data as dictionary
canberry.logic.write_sensor(sensor, value, volatile=False)[source]

Write a value to a sensor

Parameters:
  • sensor – name of a sensor according to inSensor
  • value – value to write
  • volatile – write parameter volatile as boolean

canberry.utils module

Additional utilities

class canberry.utils.DummySensor(trans=0.0, scale=1.0)[source]

Bases: object

A dummy sensor for test purposes

read()[source]
set(freq)[source]
canberry.utils.add_timestamp(dct)[source]

Adds a timestamp attribute in miliseconds to a dictionary

Parameters:dct – dictionary
canberry.utils.list_attributes(obj)[source]

Lists all attributes of an object or class

Parameters:obj – object or class
Returns:dictionary of user-defined attributes
canberry.utils.read_config()[source]

Read the configuration files .canrc, can.conf etc. as defined by python can in order to retrieve all settings from the section [canberry]. :return: dictionary

canberry.utils.static_vars(**kwargs)[source]

Decorator for adding a static variable to a function

Parameters:kwargs – initializations of the static variables
canberry.utils.str2bool(txt)[source]

Convert a string to a boolean

Parameters:txt – string object
Returns:boolean

canberry.views module

Views of the flask application

canberry.views.handle_dummy1()[source]
canberry.views.handle_dummy2()[source]
canberry.views.index()[source]
canberry.views.list_sensors()[source]
canberry.views.read_sensor(sensor)[source]
canberry.views.write_sensor(sensor)[source]

Module contents