CANberry¶
A small web app that displays sensor data and controls a MOVIDRIVE Antriebsumrichter (traction converter) of SEW EURODRIVE connected to the Raspberry Pi with the help of a controller area network (CAN) bus.
Manuals¶
- MOVIDRIVE Serielle Kommunikation (10531602)
- MOVIDRIVE Handbuch (09191607)
- MOVIDRIVE Betriebsanleitung (10532609)
- MOVIDRIVE Operating Instruction (10532617)
Installation¶
In order to install CANberry just create a virtual environment and use pip:
pip install canberry
Configuration¶
Create a configuration file .canrc with following content in your home directory:
[default]
interface = socketcan
channel = can0
[canberry]
identifier = 16
# Is server externally visible? 'true' or 'false'
external = true
# Run the server in debug mode? 'true' or 'false'
debug = false
The identifier is the default target address.
Note
Running an externally visible server in debug mode is not recommended!
Development¶
Installation:
- Create a virtual environment virtualenv venv and activate it with source venv/bin/activate.
- Install all dependencies with pip install -r requirements.txt.
- Run python setup.py develop to install CANberry in your virtual environment.
- Run canberry from the command line to start the web application. Try canberry -h for help on more options.
Updating the javascript components with:
- Install npm with sudo apt-get install nodejs.
- Install bower with sudo npm install -g bower.
- Use bower install -S to install and update js dependencies like concise, ractive, jquery, flotcharts.
Note¶
This project has been set up using PyScaffold. For details and usage information on PyScaffold see http://pyscaffold.readthedocs.org/.
Contents¶
License¶
Copyright (c) 2015, Florian Wilhelm
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Developers¶
- Andreas Wilhelm <Andreas_Wilhelm@gmx.de>
- Florian Wilhelm <Florian.Wilhelm@gmail.com>
Changelog¶
Version 0.4¶
- Some more configuration options added
Version 0.3¶
- Sending data is possible via the WebUI
Version 0.2¶
- Removed python-can contrib again
- Extended the documentation
Version 0.1.1¶
- Attempt to fix the python-can imports
Version 0.1¶
- First beta-like release
canberry¶
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
- service – Service code as defined in
-
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.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}¶
-
-
canberry.logic.
is_sensor_known
(sensor)[source]¶ Check if sensor is known
Parameters: sensor – sensor as string Returns: 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
-
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.views module¶
Views of the flask application