[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/RssiToSerial
Makefile, NONE, 1.1 RssiToSerial.h, NONE, 1.1 RssiToSerialC.nc,
NONE, 1.1 RssiToSerialP.nc, NONE, 1.1 SpecAnalyzer.java, NONE, 1.1
dmm
rincon at users.sourceforge.net
Thu Apr 12 10:14:10 PDT 2007
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tests/cc2420/LplUnicastPeriodicDelivery
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestPeriodic.h, NONE,
1.1 TestPeriodicC.nc, NONE, 1.1 TestPeriodicP.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TestAcks
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestAcksC.nc, NONE,
1.1 TestAcksP.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/cc2420/RssiToSerial
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20118/RssiToSerial
Added Files:
Makefile RssiToSerial.h RssiToSerialC.nc RssiToSerialP.nc
SpecAnalyzer.java
Log Message:
Supporting test suite for the newest CC2420 stack. Includes a low power version of RadioCountToLeds, TxThroughput analysis, TestAck, Unicast and Broadcast deliveries, RssiToSerial channel analyzer, and the PacketLink test app.
--- NEW FILE: Makefile ---
COMPONENT=RssiToSerialC
BUILD_EXTRA_DEPS = RssiSerialMsg.java SpecAnalyzer.class
RssiSerialMsg.java: RssiToSerial.h
mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=RssiSerialMsg RssiToSerial.h rssi_serial_msg -o $@
SpecAnalyzer.class: $(wildcard *.java) SpecAnalyzer.java
javac *.java
include $(MAKERULES)
--- NEW FILE: RssiToSerial.h ---
/*
* Copyright (c) 2005-2006 Rincon Research Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Rincon Research Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
* @author Jared Hill
*/
#ifndef RSSI_TO_SERIAL_H
#define RSSI_TO_SERIAL_H
typedef nx_struct rssi_serial_msg {
nx_uint16_t rssiAvgValue;
nx_uint16_t rssiLargestValue;
nx_uint8_t channel;
} rssi_serial_msg_t;
enum {
AM_RSSI_SERIAL_MSG = 6,
WAIT_TIME = 256,
//* Using log2 samples to avoid a divide. Sending a packet every 1 second will allow
//* allow about 5000 samples. A packet every half second allows for 2500 samples, and
//* a packet every quarter second allows for 1250 samples.
// When to send a packet is based upon how many samples have been taken, not a
// predetermined amount of time. Rough estimates of time can be found using the
// conversion stated above.
LOG2SAMPLES = 7,
};
#endif
--- NEW FILE: RssiToSerialC.nc ---
/*
* Copyright (c) 2005-2006 Rincon Research Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Rincon Research Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
* @author Jared Hill
*/
#include "RssiToSerial.h"
/**
*
*
* @author Jared Hill
* @date 23 March 2007
*/
configuration RssiToSerialC {}
implementation {
components MainC, RssiToSerialP as App, LedsC;
components new TimerMilliC();
components SerialActiveMessageC as AM;
components ActiveMessageC;
components CC2420ControlC;
App.Boot -> MainC.Boot;
App.SerialControl -> AM;
App.AMSend -> AM.AMSend[AM_RSSI_SERIAL_MSG];
App.AMControl -> ActiveMessageC;
App.Leds -> LedsC;
App.Packet -> AM;
App.ReadRssi -> CC2420ControlC.ReadRssi;
App.Config -> CC2420ControlC.CC2420Config;
}
--- NEW FILE: RssiToSerialP.nc ---
/*
* Copyright (c) 2005-2006 Rincon Research Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Rincon Research Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
* @author Jared Hill
*/
#include "Timer.h"
#include "RssiToSerial.h"
/**
*
*
* @author Jared Hill
* @date 23 March 2007
*/
module RssiToSerialP {
uses {
interface Leds;
interface Boot;
interface AMSend;
interface SplitControl as AMControl;
interface SplitControl as SerialControl;
interface Packet;
interface Read<uint16_t> as ReadRssi;
interface CC2420Config as Config;
}
}
implementation {
/******* Global Variables ****************/
message_t packet;
bool locked;
uint32_t total;
uint16_t largest;
uint16_t reads;
/******** Declare Tasks *******************/
task void readRssi();
task void sendSerialMsg();
/************ Boot Events *****************/
event void Boot.booted() {
call AMControl.start();
total = 0;
largest = 0;
reads = 0;
locked = FALSE;
}
/************ AMControl Events ******************/
event void AMControl.startDone(error_t err) {
if (err == SUCCESS) {
call SerialControl.start();
}
else {
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err) {
// do nothing
}
/***************SerialControl Events*****************/
event void SerialControl.startDone(error_t error){
if (error == SUCCESS) {
post readRssi();
}
else {
call AMControl.start();
}
}
event void SerialControl.stopDone(error_t error){
//do nothing
}
/***************** AMSend Events ****************************/
event void AMSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
//post readRssi();
}
/**************** ReadRssi Events *************************/
event void ReadRssi.readDone(error_t result, uint16_t val ){
if(result != SUCCESS){
post readRssi();
return;
}
atomic{
total += val;
reads ++;
if(largest < val){
largest = val;
}
}
if(reads == (1<<LOG2SAMPLES)){
post sendSerialMsg();
}
post readRssi();
}
/********************* Config Events *************************/
event void Config.syncDone(error_t error){
}
/***************** TASKS *****************************/
task void readRssi(){
if(call ReadRssi.read() != SUCCESS){
post readRssi();
}
}
task void sendSerialMsg(){
if(locked){
return;
}
else {
rssi_serial_msg_t* rsm = (rssi_serial_msg_t*)call Packet.getPayload(&packet, NULL);
if (call Packet.maxPayloadLength() < sizeof(rssi_serial_msg_t)) {
return;
}
atomic{
rsm->rssiAvgValue = (total >> (LOG2SAMPLES));
rsm->rssiLargestValue = largest;
total = 0;
largest = 0;
reads = 0;
}
rsm->channel = call Config.getChannel();
if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(rssi_serial_msg_t)) == SUCCESS) {
locked = TRUE;
}
}
}
}
--- NEW FILE: SpecAnalyzer.java ---
/*
* Copyright (c) 2005-2006 Rincon Research Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
* - Neither the name of the Rincon Research Corporation nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE
*/
/**
*
* @author Jared Hill
*/
import net.tinyos.message.Message;
import net.tinyos.message.MessageListener;
import net.tinyos.message.MoteIF;
import net.tinyos.message.SerialPacket;
import net.tinyos.packet.BuildSource;
import net.tinyos.packet.PhoenixSource;
import net.tinyos.util.PrintStreamMessenger;
public class SpecAnalyzer implements MessageListener {
/** Communication with the mote */
private MoteIF mote;
/** Broadcast Address */
public static final short TOS_BCAST_ADDR = (short) 0xffff;
/** The message from the mote */
private RssiSerialMsg rssiMsg;
/** The total number of characters written last time */
private int lastCharsWritten = 0;
/** The maximum size of the bar on the command line, in characters */
private static final int MAX_CHARACTERS = 50;
/**
* Constructor
*
* @param argv
*/
public SpecAnalyzer(MoteIF mif) {
try {
System.out.println("Connecting to serial forwarder...");
mote = mif;
mote.registerListener(new RssiSerialMsg(), this);
} catch (Exception e) {
System.err.println("Couldn't contact serial forwarder");
}
}
/**
* Received a message from the mote
*/
synchronized public void messageReceived(int dest,
Message m) {
rssiMsg = (RssiSerialMsg) m;
updateSpectrum(rssiMsg.get_rssiLargestValue(), rssiMsg.get_rssiAvgValue());
}
/**
* Overwrites the current command line prompt with blank space
*
*/
void clearSpectrum() {
for(int i = 0; i < lastCharsWritten; i++) {
System.out.print('\b');
}
}
/**
* Prints the magnitude of the spectrum to stdout. Specifically, it prints
* (largest - average) "+" signs to stdout.
*
* @param largest
* the largest rssi value taken during the sample period
* @param avg
* the average rssi value taken during the sample period
*/
void updateSpectrum(int largest, int avg) {
clearSpectrum();
String bar = "[";
int size = (int) ((float) largest * (float) ((float) MAX_CHARACTERS / (float) (255)));
for(int i = 0; i < size && i < MAX_CHARACTERS; i++) {
bar += "+";
}
for(int i = 0; i < (MAX_CHARACTERS - size); i++) {
bar += " ";
}
bar += "]";
lastCharsWritten = bar.length();
System.out.print(bar);
}
private static void usage() {
System.err.println("usage: SpecAnalyzer [-comm <source>]");
}
/**
* Main Method
*
* @param argv
*/
public static void main(String[] args) {
String source = null;
if (args.length == 2) {
if (!args[0].equals("-comm")) {
usage();
System.exit(1);
}
source = args[1];
} else if (args.length != 0) {
usage();
System.exit(1);
}
PhoenixSource phoenix;
if (source == null) {
phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err);
} else {
phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err);
}
MoteIF mif = new MoteIF(phoenix);
new SpecAnalyzer(mif);
}
}
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/apps/tests/cc2420/LplUnicastPeriodicDelivery
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestPeriodic.h, NONE,
1.1 TestPeriodicC.nc, NONE, 1.1 TestPeriodicP.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/cc2420/TestAcks
Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestAcksC.nc, NONE,
1.1 TestAcksP.nc, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list