PC-side tools
From NESTFE Wiki
The nestFE demos use three sets of pc-side tools: Python, Java, and Matlab. Python and Java are used to interact with the network while Matlab is for running high level applications on the basestation that process the information returned from the sensor network. This page is divided into two sections. The UI Tools section describes the tools that will be used and shown in a particular demo. The pc-side libraries describes the tools and libraries that are used in the background.
Contents |
User-Interface Tools
Nucleus Mote Map
Here are a few images taken from the Nucleus Mote Map visualization tool.
http://www.cs.berkeley.edu/~get/rfs
The Macroscope Web Interface
Allow users to zoom in and out to see the RFS deployment.
PyTos Command-line Interface
A development environment that imports the enums, types, typedefs, message definitions, module names, ram symbols, and rpc functions from a nesC application into python, connects to the network through SerialForwarder, and provides a command-line interface to the user. It is located in contrib/python, and can be run as follows:
$ cd /nestfe/nesc/apps/MyApp $ PytosBasic.py <platform> <motecom>
More details on how to run and use this tool is found at: Development Environment Demo
Detection Python Gui
Detection GUI processes DetectionEvent messages and updates a graphical display to show the locations of detected events. It is located in nestfe/nesc/apps/TestDetectionEvent and should be run as follows:
$ cd nestfe/nesc/apps/TestDetectionGui $ TestDetectionGui.py <platform> <motecom>
Currently, this application assumes that the nodes do not have their own locations, and so it sets them. It also connects to only a single serial forwarder, and must be made to connect to all serial forwarders in the network.
Once the gui is running, the Pytos.py script should then be run from another window, and Rpc commands can be used to command the nodes to start detecting. The following Rpc commands have the following results:
Create a single detection event with value strength:
result_t DummyEventGenM.fakeDetect( uint16_t strength )
Set the node's location:
void DummyLocationM.setLocation( int32_t x, int32_t y )
Create detection events with a particular frequency:
result_t RegistryC.DummyDetectionTimer.set( uint16_t val )
Set the frequency with which the PIR is read by the ADC, and then create detectionEvents whenever the PIR value crosses a particular threshold val:
uint16_t RegistryC.PirSampleTimer.get( )
result_t RegistryC.PIRRawThresh.set( uint16_t val )
Enable the user button to create an event:
result_t RegistryC.UserButtonEventEnable.set( bool val )
Deluge Python Gui
Straw Python Gui
GPS Python Gui
GPS GUI is an interactive deployment tool that retrieves coordinates from a GPS device and then sets the location of a mote using the PyTos Registry tools. This GUI provides ground truth to the nodes, as well as populating a database of node ID, node height at deployment, grass height at deployment, and GPS coordinates.
In order to run the system, the server must first be started. The server is located in python/apps and can be run on a Linux machine. It is easiest to ssh to the linux machine from the tablet and run the server. It should be run as follows:
$ cd python/apps $ python server.py
The GUI is also located in python/apps/ but should be run from the TestLocalization directory (nestfe/nesc/apps/. It should be run on the Tablet PC (or any compatible PDA) as follows:
$ cd python/apps $ python $TOSHOME/contrib/python/apps/GPS-GUI.py
The GUI is designed to work best with a barcode scanner as the input device plugged into the tablet PC the GUI is running on. Since the barcode scanner sends a carriage return (<CR>) after each input, the GUI responds by moving from field to field on each carriage return. As a result, the user can scan grass height, node ID, and node height in succession, and the GUI will immediately log the information and set the node's GPS coordinates. Thus, the only input device needed is the barcode scanner. Additionally, a logfile is created in the directory the application is executed from. Here is an example logfile:
Node ID GPS X Pos. GPS Y Pos. Node Height (in.) Grass Height (in.) ---------------------------------------------------------------------------------------- 1 20748.409901 84.492503 21 18 39 20748.409901 84.492503 36 32
The GUI works by connecting to a GPS server that is running on a Linux machine that is accessible by 802.11. The GUI creates a TCP socket connection with the server and sends "GPS_REQUEST" messages to the server. The server responds by iterating and requesting a new position from the GPS hardware. The server then sends these new coordinates through the socket to the GUI. The GUI performs this operation at 10 Hz, continuously updating the output seen on the GUI. Here is an example screenshot:
Nucleus Web Interface
Nucleus Web Interface is a web-based PHP app that connects to a Nucleus XML-RPC server and provides a user-friendly interface for listing nodes, selecting attributes, submitting queries, setting values, and visualizing query results.
Nucleus Command-Line Interface
Nucleus Command-Line is a Java app that connects to a SerialForwarder or the Nucleus XML-RPC Server and lets you get() and set() Nucleus attributes directly from the UNIX command line.
Deluge Command-Line Interface
Deluge is a command-line Java app that can inject new Deluge images, switch running images, erase images, and retrieve Deluge metadata and the Supplement file.
PC-side libraries
Python
Rpc
Rpc is a tool for calling arbitrary functions on the mote. The advantages of Rpc are:
- it is typed
- you can pass multiple arguments
- you do not have to create special nesC code. Just tag your function or interface with "@rpc()"
Rpc functions are automatically generated for all Registry attributes.
More information can be found at Rpc
RamSymbols
Ram Symbols is the python version of the nucleus ability to get or set arbitrary ram symbols. In python, ram symbols are typed. No changes must be made to the nesc code for this python tool to work.
More information can be found at Ram Symbols
Types, Enums, and Msgs
The Pytos environment automatically imports all types, typedefs, enums and msg definitions from the nesc application. More information can be found at Development Environment Demo
MoteCom
The Pytos environment can send/receive messages from multiple different motecom addresses simultaneously. Furthermore, when messages are received, they can be automatically parsed. More information can be found at Development Environment Demo
Drip/Drain
The PyTos environment allows one to create python objects that inherit methods and fields from Java classes. For example, the python Drip and Drain tools do everything that the java tools do, plus they have new python methods that translate between python TosMsg objects and java Mig objects. More info at Development Environment Demo
Straw
Java
- Java Setup
- add /opt/tinyos-1.x/contrib/nestfe/java to your CLASSPATH .
- Setup Nucleus, Drip, and Drain
- Follow the directions under tinyos-1.x/contrib/nucleus/docs/nucleus-manual.pdf
- Setup Deluge
- Follow the directions under tinyos-1.x/docs/deluge-manual.pdf
SerialForwarder
SerialForwarder sets up a virtual private network of binary mote packets over TCP connections, and can multiplex multiple packet streams into a single stream to support multiple-gateway applications.
Deluge Interface Component
Deluge includes several Java classes that provide functions for metadata retrieval, image injection, and node control, and communicate with the mote network on the other side.
Drip Interface Components
Drip is a Java class that injects Drip messages.
Drain Interface Components
Drain provides 2 Java classes, one to receive Drain messages and one to rebuild the Drain tree.
Nucleus Interface Component
NucleusInterface is a Java class that issues Nucleus queries over Drip and receives results over Drain.
Straw Interface Component
Straw is a Java class that provides a read() function that retrieves a bulk data object from a mote, using Bcast and Drain.
Clog Landmark Routing Server
Clog is a Java app receives packets destined for a named group and sent over Drain, and then re-sends them using Drip so that they can reach all group members.
Nucleus XML-RPC Server
Nucleus XML-RPC Server runs on a gateway node and exports the Nucleus get() and set() commands through an XML-RPC server, enabling queries and sets by many different clients.
Matlab
- Generic matlab setup instructions are in the tinyos CVS tree at tinyos-1.x/tools/matlab/doc/faq.html#setup
- Currently, there are some bugs in the instructions. The fix is at
http://www.eecs.berkeley.edu/~phoebusc/330NEST/welcome.html#matlab_setup
- On a linux computer, remember to run lmboot to start the license server on the local computer. lmboot should be under the matlab etc directory.
TestDetectionEvent and Multi-Target Tracking Matlab Tools
- Matlab Setup
- Compile java messages
- Compile java messages
cd /opt/tinyos-1.x/contrib/nestfe/java/net/tinyos/drain_msgs/DetectionEvent make
- Startup Matlab and add tinyos-1.x/contrib/nestfe/java to your classpath
- In Matlab R13, edit classpath.txt and put
- In Matlab R13, edit classpath.txt and put
- Startup Matlab and add tinyos-1.x/contrib/nestfe/java to your classpath
- FILE: classpath.txt
- Entries:
- o path_to_jarfile
- o [alpha,glnx86,sol2,unix,win32,mac]=path_to_jarfile
- o $matlabroot/path_to_jarfile
- o $jre_home/path_to_jarfile
. c:/cygwin/opt/tinyos-1.x/contrib/nestfe/java c:/cygwin/opt/tinyos-1.x/tools/java c:/jdk1.4.1_02/j2sdk1.4.1_02/jre/lib/ext/comm.jar $jre_home/lib/rt.jar $jre_home/lib/i18n.jar ...
- In Matlab R14 and beyond, you may be able to use the 'javapath' command
- Add tinyos-1.x/contrib/nestfe/matlab/apps/TestDetectionEvent/hmttsn_testbed to your matlab path
- Go to "File" → "Set Path.." in the matlab menu
- Add tinyos-1.x/contrib/nestfe/matlab/lib to your matlab path
- Add tinyos-1.x/contrib/nestfe/configurations to your matlab path if you wish to load configuration files without specifying the full path of the file
- Matlab Usage: See Detection_Demo#Tutorial and Multiple-target_Tracking_Demo#Tutorial
Generic NESTFE Environment Setup
- The setup instructions for separate tools are described above and will not be repeated here.
- It may be useful to add some directories in your path for commonly accessed scripts:
export PATH="$PATH:/opt/tinyos-1.x/contrib/nestfe/scripts" export PYTHONPATH="$PYTHONPATH:/opt/tinyos-1.x/contrib/nestfe/python"
- For instance, using this you can access a very useful file of python functions KrakenTools.py by running at the command prompt
>> from KrakenTools import * - it may be useful to import from KrakenTools during python startup. Search for documentation on PYTHONSTARTUP at www.python.org for how to do this.
- For instance, using this you can access a very useful file of python functions KrakenTools.py by running at the command prompt
- It may also be useful to alias some commonly used commands. See Kraken#Useful_Bash_functions for examples.
