We demonstrate Marionette, which allows a programmer to easily interact with a wireless sensor network from within a Python shell on the PC. It provides the equivalent of a remote terminal to a mote network: the user opens a shell and is presented with a set of objects representing the TinyOS modules actually running on the nodes. Through these objects, the nodes' functions can be called, their variables can be read and written, and their enumerations and data structures can be accessed. The user does not need to write any special code to use Marionette; all necessary libraries are automatically added to a standard TinyOS application at compile time. These libraries have minimal impact on the node, requiring only 100 bytes of program memory for each function that is remotely accessible and only 140 bytes of RAM total.
The goal of Marionette is to improve the experience of programming a mote network. TinyOS applications have almost no user interface by default and traditional tools for embedded devices such as JTAG are difficult to deploy on more than one mote at a time. The TinyOS tool chains like Java and Matlab allow the user to design and build a messaging-based interface for each new TinyOS application, but this low-level of abstraction can be cumbersome and often takes as much or more code to build than the application itself. Marionette aims to solve this problem by providing a rich interface to TinyOS applications by default by allowing the programmer to remotely call any function and access any variable.
In interactive mode, Marionette can function as a rudimentary debugger; the programmer can trigger an operation and can examine or change the node's variables during or after execution, but cannot step through programs or set break points and watches. Marionette can also be used to quickly write new sensor network functionality; new applications can be written as a Python script and executed on the PC, remotely accessing functions and variables on the nodes only when necessary. In the latter scenario, the programmer can easily integrate plotting or other scientific analysis tools into the sensor network application. Furthermore, he/she can utilize all features of a modern debugging environment, except on those functions which are called remotely.
The core of Marionette is Embedded RPC (ERPC), which allows the PC to directly call functions on an embedded application. ERPC is then used to provide poke and peek commands, which allow any variable on the node's heap to be read and written. All types and enumerations from the TinyOS application are parsed from the TinyOS code in order to correctly format parameters and return arguments. All information extracted from the TinyOS application is stored in an XML file, allowing any PC client to import that information and immediately interact with the nodes. While our first client implementation is Python based, the Marionette architecture can be used to provide access to embedded devices through any programming environment, including Java GUIs, web services, or .NET. Finally, the XML file is stored directly on the node and can be retrieved by the PC for the ability to introspect and control a node with unknown or outdated code.
The main drawback of Marionette is that each remote function call or variable access requires significant network traffic. Generally, calling each operation requires a flood of the entire network and returning the response requires a single message from each node to be routed back to the base station. While this cost is quite high, it can be acceptable during development and debugging. Furthermore, the programmer can move components of the application across the machine boundary to manage the trade-off between local and remote execution. When developing new and complex functionality, it may be worthwhile to execute mainly on the PC for increased visibility and control. As the logic becomes more mature, it can migrate to the node for efficiency reasons if necessary. Thus, an application may be very inefficient during development and debugging and asymptotically approach the desired efficiency as it nears deployment.
In this demonstration, we provide several motes running a very simple TinyOS application. On the PC, we have an interactive shell from which the user can interact with this application, including starting and stopping the sensors, sounding the buzzer on one or all nodes, and even peering at and changing the state of the routing layer. We also demonstrate the Marionette version of Listen, which uses the type and enumeration information extracted from the TinyOS application to automatically parse all incoming packets and display their structure instead of merely a hexadecimal byte stream. Finally, we demonstrate a Python script which uses Marionette and the simple functionality on the mote to quickly prototype a new sensing application.
Marionette has been part of the core TinyOS release as of 1.1.15. Online instructions should for referenced for setting up and using Marionette. The technical paper [1] should be referenced for further details on the implementation.
[1] Kamin Whitehouse, Gilman Tolle, Jay Taneja, Cory Sharp, Sukun Kim, Jaein Jong, Jonathan Hui, Prabal Dutta, and David Culler. "Marionette: Using RPC for Interactive Development and Debugging of Wireless Embedded Networks". The Fifth International Conference on Information Processing in Sensor Networks: Special Track on Sensor Platform, Tools, and Design Methods for Network Embedded Systems (IPSN/SPOTS '06). Nashville, TN, April 21, 2006.