Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Commit

Permalink
Added support for Python actors
Browse files Browse the repository at this point in the history
Added support for executing actors written in Python by including
MicroPython as a statically linked libray with actors included as
frozen modules. The library includes a gpiohandler and environmental
calvinsys object.

Contributors:
harald.gustafsson@ericsson.com
Rami Baddour rami.baddour@usi.ch
Amardeep Mehta amardeep@cs.umu.se
  • Loading branch information
fswensson committed Dec 22, 2016
1 parent cf51363 commit 5e5f738
Show file tree
Hide file tree
Showing 57 changed files with 3,170 additions and 588 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,10 @@ calvin_c
calvin_c.hex
_build/
calvin-base/
test/__pycache__/
test/__pycache__/
boards/pca10028/armgcc/_build/
*.P
*.o
libmpy/build
*.a
*.mpy
4 changes: 4 additions & 0 deletions .gitmodules
@@ -1,3 +1,7 @@
[submodule "micropython"]
path = micropython
url = https://github.com/micropython/micropython.git
[submodule "msgpuck"]
path = msgpuck
url = https://github.com/rtsisyk/msgpuck
ignore = dirty
31 changes: 21 additions & 10 deletions README.md
@@ -1,19 +1,30 @@
# calvin-constrained

calvin-constrained is a C based implementation of https://github.com/EricssonResearch/calvin-base for constrained devices with limited memory and processing power. All functionality included in the standard calvin-base implementation is not feasible to include on a constrained device and a subset of the calvin-base functionality is implemented and a calvin-base runtime is required acting as a proxy and for offloading functionality from the constrained runtime.
calvin-constrained is a C based implementation of https://github.com/EricssonResearch/calvin-base targeting constrained devices with limited memory and processing power. All functionality included in the standard calvin-base implementation is not feasible to include on a constrained device and a subset of the calvin-base functionality is implemented and a calvin-base runtime is required and used as a proxy and for offloading functionality from constrained runtimes.

The state of the implementation is experimental and it goes without saying that it should not be used in production in its current state, but it does provide an excellent starting point for further experimentation.

##Clone

git clone --recursive https://github.com/EricssonResearch/calvin-constrained.git

##Setup calvin-base

See https://github.com/EricssonResearch/calvin-base for information on how to install and run calvin-base. When started, the calvin-constrained runtime connects to a calvin-base runtime acting as a proxy and for offloading functionality from the constrained runtime.
See https://github.com/EricssonResearch/calvin-base for information on how to install and start calvin-base.

##Python actors on calvin-constrained

Support for executing Python code is built on MicroPython, https://micropython.org/, setup MicroPython with:

./mp_setup.sh

Then use the makefiles ending with _mpy to include support for Python actors in calvin-constrained, MicroPython is included as a statically-linked library with actors in libmpy/modules/ included as frozen modules.

##Run tests

cd calvin-constrained
./test/test.sh
./test/test.sh mpy # test Python actors

##*nix version

Expand Down Expand Up @@ -44,7 +55,7 @@ Verify that the connection is made by:
curl http://127.0.0.1:5001/node/d6b10ff3-593f-75a2-f07b-d1acc06961b6
{"attributes": {"indexed_public": ["/node/attribute/node_name/////calvin-klein"], "public": {}}, "control_uri": null, "proxy": "acd1e55e-c609-4c00-80ac-a383eb5dbfc5", "authz_server": null, "uri": null}

Actors can now be migrated to the calvin-constrained runtime.
Actors can now be migrated to and from the calvin-constrained runtime.

##Nordic Semiconductors NRF52 DK version

Expand All @@ -61,7 +72,7 @@ Patch the nRF5 IOT SDK to include the MAC address of the connecting peer in the
patch components/iot/medium/ipv6_medium.h < <calvin-constrained_path>/platform/nrf52/sdk_patches/ipv6_medium.h.patch
patch components/iot/medium/ipv6_medium_ble.c < <calvin-constrained_path>/platform/nrf52/sdk_patches/ipv6_medium_ble.c.patch

Download and install J-Link Software and Documentation Pack (https://www.segger.com/downloads/jlink)
And download and install J-Link Software and Documentation Pack (https://www.segger.com/downloads/jlink)

###Build and flash

Expand All @@ -71,16 +82,16 @@ Download and install J-Link Software and Documentation Pack (https://www.segger.

###Run

A Raspberry Pi with a Bluetooth USB dongle is used to connect to the nRF52 and to host the calvin-base runtime acting as a proxy for the calvin-constrained runtimes. On the Raspberry Pi, start with loading and enabling the Bluetooth 6lowpan module:
Enable the bluetooth_6lowpan kernel module:

sudo modprobe bluetooth_6lowpan
sudo sh -c "echo 1 > /sys/kernel/debug/bluetooth/6lowpan_enable"

Then, start the calvin-base runtime:
On the same system, start a calvin-base runtime listening on port 5000:

csruntime -n 192.168.0.110 --name constrained_proxy -p 5000
csruntime -n 192.168.0.110 -p 5000 -c 5001 --name constrained_proxy

The constrained runtime will connect to the link local address of the btX interface on port 5000. The interface 192.168.0.110 is the external interface of the Rapsberry Pi used for enabling external access to the calvin-base runtime and the calvin-constrained runtimes connected to it.
The calvin-base runtime listens on all interfaces for incoming connections, the 192.168.0.110 address is the external address and used here to enable external access to the control API on port 5001.

Next, get the nRF52 device address:

Expand All @@ -90,15 +101,15 @@ Connect to the nRF52 device:

sudo sh -c 'echo "connect 00:33:40:7D:C8:0D 1" > /sys/kernel/debug/bluetooth/6lowpan_control'

When a Bluetooth connection is established the calvin-constrained runtime will connect to the calvin-base runtime, verify that the connection is established:
When a Bluetooth connection is established the calvin-constrained runtime will connect to the calvin-base runtime using the link local address of the btX interface, verify that the connection is established:

curl http://192.168.0.110:5001/nodes
["5ef5de32-e0d9-6ee6-8bab-a7f1d7f72c4a"]

curl http://192.168.0.110:5001/node/5ef5de32-e0d9-6ee6-8bab-a7f1d7f72c4a
{"attributes": {"indexed_public": ["/node/attribute/node_name/////constrained"], "public": {}}, "control_uri": null, "proxy": "3682cb26-0ae0-4965-952b-86d1e1b1bcbb", "authz_server": null, "uri": null}

Actors can now be migrated to the calvin-constrained runtime.
Actors can now be migrated to and from the calvin-constrained runtime.

###Capture logs

Expand Down

0 comments on commit 5e5f738

Please sign in to comment.