[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/apps/PhyTestSender Makefile, NONE, 1.1 PhyTestSender.nc, NONE, 1.1 PhyTestSenderM.nc, NONE, 1.1 README, NONE, 1.1 config.h, NONE, 1.1 testMsg.h, NONE, 1.1
Wei Ye
weiyeisi at users.sourceforge.net
Tue May 6 10:30:59 PDT 2008
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/apps/PhyTestReceiver Makefile, NONE, 1.1 PhyTestReceiver.nc, NONE, 1.1 PhyTestReceiverM.nc, NONE, 1.1 README, NONE, 1.1 config.h, NONE, 1.1 testMsg.h, NONE, 1.1
- Next message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/apps/SCPBase Makefile, NONE, 1.1 README, NONE, 1.1 SCPBase.nc, NONE, 1.1 SCPBaseM.nc, NONE, 1.1 SCPBaseMsg.h, NONE, 1.1 config.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/scp-mac/apps/PhyTestSender
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9805/scp-mac/apps/PhyTestSender
Added Files:
Makefile PhyTestSender.nc PhyTestSenderM.nc README config.h
testMsg.h
Log Message:
scp-mac implementation from USC/ISI
--- NEW FILE: Makefile ---
COMPONENT=PhyTestSender
ifdef SLPLDIR
include $(SLPLDIR)/../apps/Makeapps
else
# assume SLPLDIR is ../../tos
include ../Makeapps
endif
--- NEW FILE: PhyTestSender.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* Sender part for testing the physical layer
*/
includes config; // include config.h first
includes testMsg;
configuration PhyTestSender { }
implementation
{
components Main, PhyTestSenderM, PhyRadio, RandomLFSR, LedsC,
TimerC, LocalTimeC;
Main.StdControl -> PhyTestSenderM;
PhyTestSenderM.PhyControl -> PhyRadio;
PhyTestSenderM.PhyPkt -> PhyRadio;
PhyTestSenderM.RadioTxPower -> PhyRadio;
PhyTestSenderM.Random -> RandomLFSR;
PhyTestSenderM.Leds -> LedsC;
PhyTestSenderM.TxTimer -> TimerC.Timer[unique("Timer")];
PhyTestSenderM.LocalTime ->LocalTimeC;
}
--- NEW FILE: PhyTestSenderM.nc ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* Sender part for testing the physical layer
*/
module PhyTestSenderM
{
provides interface StdControl;
uses {
interface StdControl as PhyControl;
interface PhyPkt;
interface GetSetU8 as RadioTxPower;
interface Random;
interface Leds;
interface Timer as TxTimer;
interface GetSetU32 as LocalTime;
}
}
implementation
{
#include "PhyConst.h"
#if (PHY_MAX_PKT_LEN < TST_MIN_PKT_LEN)
#error PHY_MAX_PKT_LEN must be larger or equal to TST_MIN_PKT_LEN
#endif
typedef enum {
FIX_LEN_INTVL,
VAR_LEN_INTVL,
FIX_LEN_NO_INTVL,
VAR_LEN_NO_INTVL,
STOP
} TxMode;
TxMode txMode;
uint8_t numTx; // number of transmitted pkts
uint32_t txStartTime; // timestamp when tx starts
uint16_t txDuration; // number of ticks used in last tx
uint8_t pktLen;
AppPkt dataPkt; // packet to be sent
task void sendPkt();
command result_t StdControl.init()
{
call Leds.init();
call PhyControl.init(); // initialize physical layer
call Random.init(); // initialize random number generator
#ifdef RADIO_TX_POWER
call RadioTxPower.set(RADIO_TX_POWER);
#endif
numTx = 0;
return SUCCESS;
}
command result_t StdControl.start()
{
call PhyControl.start();
// post task to send first packet
call TxTimer.start(TIMER_ONE_SHOT, TST_PKT_SETUP_TIME);
// post sendPkt();
return SUCCESS;
}
command result_t StdControl.stop()
{
call PhyControl.stop();
return SUCCESS;
}
task void sendPkt()
{
// construct and send a new message
uint16_t addPreamble;
dataPkt.hdr.seqNo = numTx; // record sequence number
dataPkt.data[0] = (uint8_t)(txDuration>>8); // time used in tx last pkt
dataPkt.data[1] = (uint8_t)(txDuration);
// select a packet length
#ifdef TST_RANDOM_PKT_LEN
#if (PHY_MAX_PKT_LEN <= TST_MIN_PKT_LEN)
#error PHY_MAX_PKT_LEN must be larger than TST_MIN_PKT_LEN for random pkt length
#endif
pktLen = (uint8_t)(call Random.rand() %
(PHY_MAX_PKT_LEN - TST_MIN_PKT_LEN)) + TST_MIN_PKT_LEN;
#else
pktLen = (uint8_t)PHY_MAX_PKT_LEN;
#endif
// add preamble to base preamble
#ifdef TST_ADD_FIXED_PREAMBLE
addPreamble = (uint16_t)(TST_ADD_FIXED_PREAMBLE);
#else
addPreamble = call Random.rand() & 0xff; // add random preamble
#endif
txStartTime = call LocalTime.get();
call PhyPkt.send(&dataPkt, pktLen, addPreamble);
}
event result_t TxTimer.fired()
{
post sendPkt();
return SUCCESS;
}
event result_t PhyPkt.sendDone(void* msg)
{
call Leds.redToggle();
numTx++;
txDuration = (uint16_t)(call LocalTime.get() - txStartTime);
if (numTx < TST_NUM_PKTS) {
#if (TST_PKT_INTERVAL == 0)
post sendPkt();
#else
// start timer to schedule next tx
call TxTimer.start(TIMER_ONE_SHOT, TST_PKT_INTERVAL);
#endif
} else { // send all packets
// turn on LEDs to show final results
call Leds.redOn();
call Leds.greenOn();
call Leds.yellowOff();
}
return SUCCESS;
}
event void* PhyPkt.receiveDone(void* data, uint8_t error)
{
return data;
}
} // end of implementation
--- NEW FILE: README ---
1. INTRODUCTION
This application tests the Physical Layer (PHY) developed at USC/ISI.
The primary component of the physical layer that provides the interface
to upper layer is PHY_RADIO. The mote programmed by this application is a
transmitter that sends packets with different options.
2. FUNCTIONALITY
A sender will send a group of packets with different configurations,
including packet length (fixed or random), packet interval, and additional
preamble length (fixed or random).
In the transmitted packets, there is sequence number of the Tx duration
of the previous transmitted packet.
Red led toggles when a packet is send. After all packets are sent, all
LEDs are turned on.
3. HOW TO USE
To use all the default parameters, simply type 'make mica2' and/or 'make
install mica2'.
To specify different options, look at config.h file for details.
4. NOTES
1) This application is to be used with a receiver part, which is at
apps/PhyTestReceiver/.
2) You can use a snooper (at apps/Snooper/) to see the contents of each packet.
Please note that the sender does NOT clean the memory for each packet. So when
sending variable length packets, a long packet following a short packet will
contain all the payload of the short packet. Don't simply think that packet is
corrupted because of the non-zero payload.
--- NEW FILE: config.h ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* This file configures parameters of all components used by the application.
* It is supposed to be included before any other files in an
* application's configuration (wiring) file, such as Test.nc, so that these
* macro definations will override default definations in other files.
* These macros are in the global name space, so use a prefix to indicate
* which layers they belong to.
*
*/
#ifndef CONFIG
#define CONFIG
#define TST_MIN_PKT_LEN 10 // don't change this
// Configure Physical layer. Definitions here override default values
// Default values are defined in PhyMsg.h
// --------------------------------------------------------------
//#define PHY_MAX_PKT_LEN 250 // min: TST_MIN_PKT_LEN, max: 250, default: 100
// configure radio transmission power (0x01--0xff)
// Following sample values are for 433MHz mica2: 0x0f=0dBm (TinyOS default)
// 0x0B = -3dBm, 0x08 = -6dBm, 0x05 = -9dBm, 0x03 = -14dBm 0x01 = -20dBm
// 0x0f = 0dBm, 0x50 = 3dBm, 0x80 = 6dBm, 0xe0 = 9dBm, 0xff = 10dBm
//#define RADIO_TX_POWER 0x03
// tell PHY to measure radio energy usage, only for performace analysis
//#define RADIO_MEASURE_ENERGY
// if the following constant is defined, each packet will add the fixed
// length preamble with the specified time (miliseconds).
// min value: 0, max value: 27327 (ms)
// if the following constant is not defined, a random length preamble (0--255
// bytes) will be added for each packet
//#define ADD_FIXED_PREAMBLE 1000
// Configure the test application
// -------------------------------
// num of pkts to be sent, max value is 255
#define TST_NUM_PKTS 100
// pkt interval (binary ms). when it is 0, pkts are send back-to-back
#define TST_PKT_INTERVAL 10
// if defined, will send packets with random length between 10--250
//#define TST_RANDOM_PKT_LEN
// the following constant specifies the length of preamble (bytes)
// to be added to the base preamble
// if it is not defined, a random length preamble (0--255 bytes) will
// be added for each packet
#define TST_ADD_FIXED_PREAMBLE 0
// Debugging with UART
//#define PHY_UART_DEBUG_BYTE
#endif // CONFIG
--- NEW FILE: testMsg.h ---
/*
* Copyright (C) 2003-2005 the University of Southern California.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition to releasing this program under the LGPL, the authors are
* willing to dual-license it under other terms. You may contact the authors
* of this project by writing to Wei Ye, USC/ISI, 4676 Admirality Way, Suite
* 1001, Marina del Rey, CA 90292, USA.
*/
/*
* Authors: Wei Ye
*
* Message format for testing the physical layer -- PhyRadio
*/
#ifndef TEST_MSG
#define TEST_MSG
// include physical layer header defination
#include "PhyRadioMsg.h"
typedef struct {
PhyHeader hdr; // include lower-layer header first
unsigned char seqNo;
} AppHeader;
#define PAYLOAD_LEN (PHY_MAX_PKT_LEN - sizeof(AppHeader) - 2)
typedef struct {
AppHeader hdr;
char data[PAYLOAD_LEN];
short crc; // crc must be the last field -- required by PhyRadio
} AppPkt;
#endif
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/apps/PhyTestReceiver Makefile, NONE, 1.1 PhyTestReceiver.nc, NONE, 1.1 PhyTestReceiverM.nc, NONE, 1.1 README, NONE, 1.1 config.h, NONE, 1.1 testMsg.h, NONE, 1.1
- Next message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/scp-mac/apps/SCPBase Makefile, NONE, 1.1 README, NONE, 1.1 SCPBase.nc, NONE, 1.1 SCPBaseM.nc, NONE, 1.1 SCPBaseMsg.h, NONE, 1.1 config.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list