From 0678e778b105ceab7ff1b5ff744a50e90275fe04 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Wed, 3 Mar 2010 18:48:29 -0500 Subject: [PATCH] initial packet error rate test skeleton --- config.mk | 2 +- tests/Makefile | 4 ++- tests/per.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 tests/per.c diff --git a/config.mk b/config.mk index 43e232af1..e44d35fcf 100644 --- a/config.mk +++ b/config.mk @@ -32,7 +32,7 @@ CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ -fno-builtin -ffreestanding -isystem \ $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wcast-align -Wextra -Werror +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wcast-align -Wextra #-Werror AFLAGS_DEBUG := -Wa,-gstabs AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) diff --git a/tests/Makefile b/tests/Makefile index 3bb939f1c..3c7c8cd5b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -14,7 +14,9 @@ TARGETS := blink-red blink-green blink-blue blink-white blink-allio \ # these targets are built with space reserved for variables needed by ROM services # this space is initialized with a rom call to rom_data_init -TARGETS_WITH_ROM_VARS := nvm-read nvm-write romimg flasher rftest-rx rftest-tx +TARGETS_WITH_ROM_VARS := nvm-read nvm-write romimg flasher \ + rftest-rx rftest-tx \ + per include $(MC1322X)/Makefile.include diff --git a/tests/per.c b/tests/per.c new file mode 100644 index 000000000..aa0aa78a9 --- /dev/null +++ b/tests/per.c @@ -0,0 +1,82 @@ +#include +#include +#include + +#include "tests.h" +#include "config.h" + +/* This program communicates with itself and determines the packet */ +/* error rate (PER) under a variety of powers and packet sizes */ +/* Each test the packets are sent and received as fast as possible */ + +/* The program first scans on channel 11 and attempts to open a test */ +/* session with a node. After opening a session, the nodes begin the */ +/* test sequence */ + +#define DEBUG_MACA 1 + +typedef struct { + int type; +} packet_t; + +enum STATES { + SCANNING, + MAX_STATE +}; + +enum PACKET_TYPE { + PACKET_PERTEST, + MAX_PACKET_TYPE +}; + +int get_packet(packet_t *p) { return 0; } +void print_packet(packet_t p) { return; } + +void main(void) { + uint32_t state; + packet_t p; + + uart_init(INC,MOD); + + print_welcome("Packet error test"); + + /* standard radio initialization */ + reset_maca(); + radio_init(); + vreg_init(); + flyback_init(); + init_phy(); + + /* trim the reference osc. to 24MHz */ + pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS); + + set_power(0x0f); /* 0dbm */ + set_channel(0); /* channel 11 */ + + /* initial radio command */ + /* nop, promiscuous, no cca */ + *MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE); + + state = SCANNING; + while(1) { + + switch(state) { + case SCANNING: + if(get_packet(&p)) { + print_packet(p); + /* if we have a packet */ + /* check if it's a pertest beacon */ + if(p.type == PACKET_PERTEST) { + /* try to start a session */ + } + } + break; + default: + break; + } + + + } + +} +