descriptionRPC framework for interaction with c firmware from python host applications
homepage URLhttps://github.com/jaseg/cerebrum
repository URLhttps://github.com/jaseg/cerebrum.git
owners@jaseg.de
last changeWed, 10 Dec 2014 20:22:39 +0000 (10 21:22 +0100)
last refreshSat, 4 May 2024 19:59:50 +0000 (4 21:59 +0200)
content tags
add:
readme

Cerebrum

Cerebrum is a RPC-like protocol for calling C functions on AVRs from a host application connected via serial port. Currently, the only viable host ist a still incomplete python library. The line protocol is very simple. A short description is in PROTOCOL. When a new device is connected, the host pulls the device's exported functions and parameters via a standardized, special function at address 0x0000.

Build process

The device-side code is generated by a python script (generate.py) living in the device directory according to a json configuration file passed to the top-level build script (generatefw.py).

When the device firmware is built, a build config file containing information on the actual ids of the callbacks and so on is generated. One copy is put in the builds/ folder, another is lzma-compressed and hardcoded into the firmware to be used by host libraries for device discovery.

Adding Modules

More modules can be added in form of "module-name.c.tp" files in the respective device directories (currently implemented are avr and msp430 versions). If possible, when adding a new module generate.py should not be touched. These .tp files are mako templates which will be included once for each time the module is included in the device configuration .json.

Parameters

A parameter is defined with a format and a function id. The parameter has two functions: a "getter" and a "setter" function. The getter can be found at the function id in the parameter spec, to address the setter the id must be incremented by 1. The getter takes no arguments and returns the current value of the parameter. The setter takes the new value of the parameter as an argument.

Format strings

The format strings are as used in the python struct module. Between host and device, values are exchanged in binary form as marshaled by the beforementioned python struct module according to the format strings given for function parameters or return values. On the device side, the marshaling and unmarshaling of the module names still is done by hand, the automation of that is on the to-do list.

Module support functions

There are a few python functions which can be used from module templates.

On top of that the templates can access pretty much all of python thanks to mako.

For more details on the invocation of these helper functions please have a look at the existing templates as well as the python code.

shortlog
2014-12-10 jasegMerge branch 'master' of c-leuse:cerebrummaster
2014-12-10 jasegMore relays and some auxiliary stuff
2014-11-30 jasegAdded some test code for the relays
2014-11-30 jasegFixed the relays config for more relays
2014-05-31 jasegMerge branch 'master' of 10.0.1.24:cerebrum
2014-05-31 jasegFixed the trafotron
2014-03-24 jasegMerge branch 'master' of 10.0.1.24:cerebrum
2014-03-24 jasegAdded the Ampel and fixed an python lib escape handling bug
2014-02-15 jasegMerge branch 'master' of 10.0.1.24:cerebrum
2014-02-15 jasegAdded c-locc to trafotron barstatus targets
2014-02-15 jasegFixed mainhallrgb SSL foo
2013-10-31 jasegBasic REST interface working
2013-10-28 jasegFirst REST interface code
2013-10-26 jasegMerge branch 'master' of nerdctrl.cbrp3.c-base.org...
2013-10-26 jasegFixed the switch's jsonrpc interface
2013-10-26 jasegMerge branch 'master' of nerdctrl.cbrp3.c-base.org...
...
heads
9 years ago master
11 years ago multimaster-2
11 years ago minus-testcode
11 years ago gamma-correction