VanGo
High-Rate Data Acquisition System
»Home
»Download
»Install
»Brief Intro
System Overview

Running AuricleDemo

EmStar

Make sure to have your id set in the /etc directory. The atcual id number does not matter, so set it to anything. Also make sure to have root privileges when you do this.

# echo "72" > /etc/id

To get EmStar running have the kfusd module installed in your kernel and make sure fusdd is running. Root privileges are needed.

# cd ${EMSTAR_ROOT}
# insmod obj.i686-linux/fusd/kfusd.ko
# ./obj.i686-linux/fusd/fusdd

You should get some warnings when starting fusdd, avoid them. If you run into trouble getting EmStar to run, consult the EmStar installation guide.

The Motes

To run VanGo you will need to install two application on two different motes. First, install EmstarBase; this will be the base-station mote responsible for relaying data from all other motes to EmStar. This mote must have a mote ID of 1. Change /dev/ttyUSB0 to the right physical mote location.

$ cd ${EMSTAR_ROOT}/tos-contrib/nic/apps/EmstarBase/
$ make install,1 telosb bsl,/dev/ttyUSB0 baud,115200

Then install the AuricleDemo application on the other mote.

$ cd ${EMSTAR_ROOT}/tos-contrib/vango/apps/AuricleDemo/
$ make install,2 telosb bsl,/dev/ttyUSB1

The Backend

VanGo is composed of code running on the motes and on a backend PC-class device. The PC-class device acts as a mote network client that controls the mote network and relays mote data to the end user.

To run the PC code, first modify the configuration file to set the physical location of the mote and the mote's serial communication speed.

Example: emstar/tos-contrib/vango/emstar/AuricleDemoClient.run
include mote/mote.run

&mote_tosnic(port=/dev/ttyUSB0,mote=telos,args="--baud 115200");

process AuricleUser {
   type = once;
   waitfor = mote0;
   loglevel = LOG_DEBUG_3;
   cmd = "tos-contrib/vango/emstar/AuricleDemoClient --appname
          auricleU --log class=usr1,usr2,boot,error:elog=LOG_WARNING";
   emview = "module=EmTOS/Leds:dev=mpclient:leds";
}

Next, start the client:

$ cd ${EMSTAR_ROOT}/obj.i686-linux
$ ./emrun/emrun ../tos-contrib/vango/emstar/AuricleDemoClient.run

AuricleDemo is now up and running. There are two ways to interact with AuricleDemo:

  • Through the Java Demo application

  • Manually via sockets

Java Demo

To run the Java demo, we first need to compile it:

$ cd ${EMSTAR_ROOT}/tos-contrib/vango/java
$ javac auricle/Auricle.java

Make sure that ArucleDemoCleint is running and run the java application:

$ cd ${EMSTAR_ROOT}/tos-contrib/vango/java
$ java auricle.Auricle

There are two connect buttons; the one on the right deals with the data generated by the motes, the one on the left deals with the command interface.

Sockets

There are two main sockets that AuricleDemoCleint provides: command and data. The command port is used to send commands to the mote network. The commands are simple ASCII strings sent to port 8003. Port 8000 is the data port that replicates all data sent by the mote network back to the base-station.

Sending Commands

Commands come

Example: vango/tos/platform/emstar/ControlSocketM.nc
...
/*
  msg format :
  destination <colon> command-1 <semi-colon> command-2  ...
  command format (whitespace delimited):
  command [<space>|<tab>]+ value
  value format (a value containing more than one field is comma delimited):
  value [,next_value]*

  recognized non-numeric destinations: local, broadcast
  recognized non-numeric values: true, false

  values are 16-bit unsigned

  e.g.:
  'broadcast: fir-set-vector 4,12,1,0,3; gate-enable true\n'
*/
...

Receiving Data

The data that is sent over port 8000 is enclosed in a packet header that describes the data set.

Example: vango/tos/lib/MotephoneTypes.h
...
typedef struct sample_set_hdr_s {
  uint16_t send_mask; // which fields get transmitted
  addr_t src;
  uint8_t modality;
  uint8_t channels;
  uint8_t version;
  uint8_t format;
  uint16_t rate;
  uint16_t mean;
  uint16_t md;
  uint16_t duty_cycle;
  timestamp_t timestamp;
  uint32_t sample_number; // first sample number in set
  length_t sample_count;  // number of samples in set
  uint16_t flags;
  gate_info_t gate_info;
  zerocrossing_info_t zerocrossing_info;
  uint8_t data[0];
} __attribute__ ((packed)) sample_set_hdr_t;
...

Here is a sample program to get data out of the socket; first get the header, then find out how much data the header is describing before getting more data out of the stream.

...
  // first get the header
  while((buf_len = recv(data_socket, buf, sizeof(sample_set_hdr_t), 0)) > 0)
  {
    int count;
    packet = (sample_set_hdr_t*) buf;

    // now we need to get the data
    switch(packet->format){
      case SAMPLE_4_BIT_ALIGNED:
        bits = 4;
        count = packet->sample_count;
        break;
      case SAMPLE_8_BIT_ALIGNED:
      case SAMPLE_8_BIT_PACKED:
        bits = 8;
        count = packet->sample_count;
            break;
      case SAMPLE_12_BIT_PACKED:
        bits = 8;
        count = (packet->sample_count * 4) / 3;
        break;
      case ADPCM_4_BIT:
      case SAMPLE_4_BIT_PACKED:
        bits = 4;
        count = packet->sample_count / 2;
        printf("packet data format is ADPCM; is this going to be a problem?\n");
        break;
      case SAMPLE_12_BIT_ALIGNED:
        bits = 12;
        count = packet->sample_count * 2;
        break;
      case SAMPLE_16_BIT:
        bits = 16;
        count = packet->sample_count * 2;
        break;
      case UNKNOWN_FORMAT:
      default:
        bits = 0;
        printf("packet data format not known, exiting\n");
        exit(1);
    }

    buf_len += recv(data_socket, buf + buf_len, count, 0);
    ...
  }
...