Recent Changes - Search:

Tracking

Hardware

Software

Mega Plan

Etc.

HowToUseMotes

How to use the Motes

Loading the Motes

  1. Ensure the USB connector on the mote is connected with the free USB port on the Raspberry Pi
  2. Navigate to the mote_tool helper program directory
    Absolute Path: /home/pi/flockbot/wsn/Mote_Tool
    Relative Path: ~/flockbot/wsn/Mote_Tool
  3. Launch the mote_tool program
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ pwd
    /home/pi/flockbot/wsn/Mote_Tool
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ ./mote_tool
    Enter your option:
    0 - Quit the Program
    1 - Burn Node ID
    2 - Load the RSSI Program
    3 - Load the Beacons Program
    4 - Load the Diagnostic Program
    > 
    
  4. Select option 1 to set the ID for the mote. Valid IDs range from 1-127. This is your beacon number.
    Note: This may take a minute or two to execute.
     > 1
    Enter the mote ID: 
     > 3
    using saved target 'sky'
    rm -f *~ *core core *.srec \
    ...
    ...
    Reset device ...
    Done
    make[2]: Leaving directory `/home/pi/flockbot/wsn/BurnNodeID'
    make[1]: Leaving directory `/home/pi/flockbot/wsn/BurnNodeID'
    rm burn-nodeid.ihex
    Enter your option:
    
  5. At this time, follow the instructions in the next section to verify the mote load and verify the program run.
    Note: When doing a future check, the key line is on line 3:
    ... Node id is set to 3.
    The verification following this load should look like the following. If the Restored ID is not your Burned ID, then the mote is bad.
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ sh connect.sh 
    connecting to /dev/ttyUSB0 (115200) [OK]
    ?!??#??3????*?1Rime started with address 0.18.116.0.16.203.133.3
    MAC 00:12:74:00:10:cb:85:03 Contiki 2.6 started. Node id is set to 3.
    CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26
    Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7400:10cb:8503
    Starting 'Burn node id'
    Burning node id 3
    Restored node id 3
    
    
  6. Now use mote_tool to load the program of choice on to the mote. The following is an example of loading the Beacon code.
    This will take a long time the first time this is compiled on each flockbot.
    Note: Occasionally this will also end in a segfault. This is due to the flashing program and is normal if it occurs after Reset Device...
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ ./mote_tool 
    Enter your option:
    0 - Quit the Program
    1 - Burn Node ID
    2 - Load the RSSI Program
    3 - Load the Beacons Program
    4 - Load the Diagnostic Program
     > 3
    Select your mode: 
    1 - Robot
    2 - Beacon
     > 2
    Specify Beacon Send Timer (seconds): 10
    Specify Beacon Decay Timer (seconds): 2
    Specify Beacon Decay Percentage (per timer tick): 5
    using saved target 'sky'
    ...
    ...
    Reset device ...
    Done
    make[2]: Leaving directory `/home/pi/flockbot/wsn/Beacons'
    make[1]: Leaving directory `/home/pi/flockbot/wsn/Beacons'
    rm beacon.co beacon.ihex obj_sky/contiki-sky-main.o
    Segmentation fault
    
    
  7. Run the verification connect tool and verify normal operations, as applicable. At this point your mote is programmed and ready for operation.
    The following is a sample of verifying a Beacon mote. The Robot program will not give any output.
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ sh connect.sh 
    connecting to /dev/ttyUSB0 (115200) [OK]
    ?+?W?????#??[  3],TX,  3, 97, 97, 97, 97, 97, 97
    [  3],TX,  3, 95, 95, 95, 95, 95, 95
    [  3],TX,  3, 91, 91, 91, 91, 91, 91
    [  3],TX,  3, 89, 89, 89, 89, 89, 89
    [  3],TX,  3, 86, 86, 86, 86, 86, 86
    

Verify the Mote Load

  1. Ensure the USB connector on the mote is connected with the free USB port on the Raspberry Pi
  2. Navigate to the mote_tool helper program directory
    Absolute Path: /home/pi/flockbot/wsn/Mote_Tool
    Relative Path: ~/flockbot/wsn/Mote_Tool
  3. Launch the connect program. You will see junk on the line. Once connected, either wait until the junk clears or press the RESET button on the mote.
    Note that this is a direct serial interface. The only way to quit this program is to issue a CTRL-C
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ sh connect.sh 
    connecting to /dev/ttyUSB0 (115200) [OK]
    ?+?W?????#??[  3],TX,  3, 97, 97, 97, 97, 97, 97
    [  3],TX,  3, 95, 95, 95, 95, 95, 95
    [  3],TX,  3, 91, 91, 91, 91, 91, 91
    [  3],TX,  3, 89, 89, 89, 89, 89, 89
    [  3],TX,  3, 86, 86, 86, 86, 86, 86
    

Troubleshooting

  • If the connect.sh tool gives you this error:
    pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ sh connect.sh 
    connect.sh: 2: connect.sh: ../contiki/tools/sky/serialdump-linux: not found
    
Then, follow these steps
pi@raspberrypi ~/flockbot/wsn/Mote_Tool $ cd ../contiki/tools/sky/
pi@raspberrypi ~/flockbot/wsn/contiki/tools/sky $ make
cc -o serialdump-linux serialdump.c
serialdump.c: In function ‘main’:
serialdump.c:280:4: warning: incompatible implicit declaration of built-in function ‘strftime’ [enabled by default]
serialdump.c:280:4: warning: passing argument 4 of ‘strftime’ makes pointer from integer without a cast [enabled by default]
serialdump.c:280:4: note: expected ‘const void *’ but argument is of type ‘int’
The warnings are normal. After this completes, the connect tool will run normally.
  • Getting the following error:
    /dev/ttyUSB0: No such file or directory
    This means the mote is not connected to the Pi via USB. Unplug and reattach the USB cable and try again.

Programming the Motes (On-Board API)

In your behavior file:

  • Include the appropriate headers:
    #include <pthread.h>
    #include "../../pi/rpi_wsn.h" 
    
  • Use the following code to initialize and connect to the mote
    pthread_t mote_listener_thread; // Create the mote listener thread
    //make mote connection
    if(pthread_create(&mote_listener_thread, NULL, mote_start, NULL) != 0)
      fprintf(stderr, "Error in creating listener thread for mote communications. Exiting\n");
    ...
    mote_close(); // Shuts the mote down
    pthread_join(mote_listener_thread, NULL);  // Waits for the mote thread to gracefully exit
    
  • The commands to interact with the mote are:
    Note: Sending an array to the mote can be done on the stack. This command does not free the array.
    // Gets the received data from the mote.  One \n terminated string at a time.
    char *buf = get_mote_data(1000); //timeout in miniseconds for wait on data
    
    ...
    // Send a message to the mote (Format here is SETimabcdef\n)
    // Where i is the mote ID (or -1 for all motes)
    // Where m is the mode (1 for Set Levels and 2 for Set Decay Mode)
    // Where a-f are the values for each pheromone
    char ary[11];
    sprintf(ary, "SET________\n"); // Must be \n terminated for the mote serial comms.
    ary[3] = -1; // Beacon ID or -1 for all beacons.
    ary[4] = 1; // 1 - Set Pheromone Levels, 2 - Set Decay Mode.
    // For Pheromone Levels, valid values are 0 to 127.
    // For Decay Mode, 0 - Decay, 1 - No Decay
    for(i = 5; i < 11; i++)
       ary[i] = 100;
    ary[11] ='\n';
    mote_send_message(ary, 11);
    

Programming the Motes (Socket) As no-one appears to be doing this, the instructions will be deferred until the next version of the Flockbot goes online.

Edit - History - Print - Recent Changes - Search
Page last modified on May 06, 2014, at 06:01 PM