Commit 3658c9f7 authored by David Johnson's avatar David Johnson

Add support for dumping recv radio packet CRCs to uart; make build process

simpler.
parent 00a8694e
// $Id: ElabRadioDumpM.nc,v 1.1 2005-05-27 21:55:55 johnsond Exp $ // $Id: ElabRadioDumpM.nc,v 1.2 2005-06-23 16:46:32 johnsond Exp $
/* tab:4 /* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California. * "Copyright (c) 2000-2003 The Regents of the University of California.
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
*/ */
/* /*
* Author: Phil Buonadonna * Author: Phil Buonadonna
* Revision: $Id: ElabRadioDumpM.nc,v 1.1 2005-05-27 21:55:55 johnsond Exp $ * Revision: $Id: ElabRadioDumpM.nc,v 1.2 2005-06-23 16:46:32 johnsond Exp $
* *
* *
*/ */
...@@ -118,8 +118,10 @@ implementation ...@@ -118,8 +118,10 @@ implementation
pMsg->data[3] = pMsg->type; pMsg->data[3] = pMsg->type;
pMsg->data[4] = pMsg->addr; pMsg->data[4] = pMsg->addr;
pMsg->data[5] = pMsg->addr >> 8; pMsg->data[5] = pMsg->addr >> 8;
pMsg->data[6] = pMsg->crc;
pMsg->data[7] = pMsg->crc >> 8;
pMsg->length = (pMsg->length > 5)?pMsg->length:5; pMsg->length = (pMsg->length > 8)?pMsg->length:8;
Result = call UARTSend.send(TOS_UART_ADDR,pMsg->length,pMsg); Result = call UARTSend.send(TOS_UART_ADDR,pMsg->length,pMsg);
if (Result != SUCCESS) { if (Result != SUCCESS) {
...@@ -186,7 +188,7 @@ implementation ...@@ -186,7 +188,7 @@ implementation
ok2 = call RadioControl.start(); ok2 = call RadioControl.start();
call Leds.greenOn(); //call Leds.greenOn();
call Timer.start(TIMER_REPEAT,1024); call Timer.start(TIMER_REPEAT,1024);
return rcombine(ok1, ok2); return rcombine(ok1, ok2);
...@@ -207,26 +209,29 @@ implementation ...@@ -207,26 +209,29 @@ implementation
dbg(DBG_USR1, "ElabRadioDump received radio packet.\n"); dbg(DBG_USR1, "ElabRadioDump received radio packet.\n");
if (Msg->crc) { if (Msg->crc) {
atomic { /* turn off cause passed the crc */
call Leds.redOff();
}
else {
call Leds.redOn();
}
atomic {
pBuf = gRxBufPoolTbl[gRxHeadIndex]; pBuf = gRxBufPoolTbl[gRxHeadIndex];
if (pBuf->length == 0) { if (pBuf->length == 0) {
gRxBufPoolTbl[gRxHeadIndex] = Msg; gRxBufPoolTbl[gRxHeadIndex] = Msg;
gRxHeadIndex++; gRxHeadIndex %= QUEUE_SIZE; gRxHeadIndex++; gRxHeadIndex %= QUEUE_SIZE;
} }
else { else {
pBuf = NULL; pBuf = NULL;
} }
} }
if (pBuf) { if (pBuf) {
post RadioRcvdTask(); post RadioRcvdTask();
}
else {
pBuf = Msg;
}
} }
else { else {
pBuf = Msg; pBuf = Msg;
} }
return pBuf; return pBuf;
...@@ -313,7 +318,7 @@ implementation ...@@ -313,7 +318,7 @@ implementation
} }
event result_t Timer.fired() { event result_t Timer.fired() {
call Leds.redToggle(); call Leds.greenToggle();
return SUCCESS; return SUCCESS;
} }
......
COMPONENT=ElabRadioDump COMPONENT=ElabRadioDump
PFLAGS=-I%T/lib/HDLC PFLAGS=-I%T/lib/HDLC
include ../Makerules include ../Makerules
# stolen pretty much from tos
all: all-recursive
install: all install-recursive
clean: clean-recursive
all-recursive install-recursive clean-recursive:
target=`echo $@ | sed s/-recursive//`; \
(cd tools && $(MAKE) $$target)
README for RobTransparetBase README for ElabRadioDump
Modified from the standard TransparentBase by ricci@cs.utah.edu Modified from the standard TransparentBase by ricci@cs.utah.edu
...@@ -7,3 +7,9 @@ main modifications were: to use the GenericComm component for UART I/O ...@@ -7,3 +7,9 @@ main modifications were: to use the GenericComm component for UART I/O
rather then Framer, to make it easier for my own scripts to process the rather then Framer, to make it easier for my own scripts to process the
packets, and to stuff the received RSSI into packets that are resent on packets, and to stuff the received RSSI into packets that are resent on
the serial port. the serial port.
Actually, now it dumps sender, crc, AM type, and RSSI. Tools for listening can
be built by a 'gmake -f Makefile.tools' ... the resulting binaries in
tools/src should include a C serial forwarder, sf listener, and a raw serial
listener. Both listeners dump the same output.
# stolen pretty much from tos
all: all-recursive
install: all install-recursive
clean: clean-recursive
all-recursive install-recursive clean-recursive:
target=`echo $@ | sed s/-recursive//`; \
(cd src && $(MAKE) $$target)
PROGRAMS = serial_listen sf_listen
TOOLSDIR = ../../../../tools/src/sf
CFLAGS = -I../../../../tools/src/sf
all: $(PROGRAMS)
# this builds a copy of the c serial forwarder in this directory.
sf: $(TOOLSDIR)/sf.c $(TOOLSDIR)/serialsource.c $(TOOLSDIR)/sfsource.c \
$(TOOLSDIR)/platform.c $(TOOLSDIR)/platform.h \
$(TOOLSDIR)/serialsource.h $(TOOLSDIR)/sfsource.h
gcc -O1 -Wall -g -o $@ $(TOOLSDIR)/sf.c $(TOOLSDIR)/serialsource.c \
$(TOOLSDIR)/sfsource.c platform.c $(CFLAGS)
# this listens to a serial forwarder
sf_listen: sf_listen.c $(TOOLSDIR)/sfsource.c $(TOOLSDIR)/platform.c \
$(TOOLSDIR)/platform.h $(TOOLSDIR)/sfsource.h
gcc -O1 -Wall -g -o $@ sf_listen.c $(TOOLSDIR)/sfsource.c \
$(TOOLSDIR)/platform.c $(TOOLSDIR)/serialsource.c $(CFLAGS)
# this listens to a raw serial device
serial_listen: serial_listen.c $(TOOLSDIR)/sfsource.c $(TOOLSDIR)/platform.c \
$(TOOLSDIR)/platform.h $(TOOLSDIR)/sfsource.h
gcc -O1 -Wall -g -o $@ serial_listen.c $(TOOLSDIR)/serialsource.c \
$(TOOLSDIR)/platform.c $(CFLAGS)
clean:
rm -f $(PROGRAMS)
...@@ -42,30 +42,29 @@ int main(int argc, char **argv) ...@@ -42,30 +42,29 @@ int main(int argc, char **argv)
int len, i; int len, i;
const unsigned char *packet = read_serial_packet(src, &len); const unsigned char *packet = read_serial_packet(src, &len);
if (!packet)
exit(0);
int rssi_val; int rssi_val;
int am_type; int am_type;
int orig_sender; int orig_sender;
float real_rssi; float real_rssi;
float vdc = 3.0f; float vdc = 3.0f;
int crc;
if (!packet)
exit(0);
//for (i = 0; i < len; i++)
// printf("%02x ", packet[i]);
//printf("counter: %d RSSI: %d\n",packet[5],((packet[6] & 0xff) << 8) | (packet[7] & 0xff));
rssi_val = ((packet[7] & 0xff) << 8) | (packet[6] & 0xff); rssi_val = ((packet[7] & 0xff) << 8) | (packet[6] & 0xff);
am_type = packet[8]; am_type = packet[8];
orig_sender = ((packet[10] & 0xff) << 8) | (packet[9] & 0xff); orig_sender = ((packet[10] & 0xff) << 8) | (packet[9] & 0xff);
crc = ((packet[12] & 0xff) << 8) | (packet[11] & 0xff);
/* for mica 2, ALSO depends on the value of vdc; which for wall plugin /* for mica 2, ALSO depends on the value of vdc; which for wall plugin
* is 3 VDC; for 1.5V batts it's something else * is 3 VDC; for 1.5V batts it's something else
*/ */
real_rssi = -50.0f * (vdc * (rssi_val/1024.0f)) - 45.5f; real_rssi = -50.0f * (vdc * (rssi_val/1024.0f)) - 45.5f;
printf("original sender: %d; AM type: %d; RSSI: %f dBm\n", printf("original sender: %d; crc: %d; AM type: %d; RSSI: %f dBm\n",
orig_sender, orig_sender,
crc,
am_type, am_type,
real_rssi); real_rssi);
fflush(stdout); fflush(stdout);
......
#include <stdio.h>
#include <stdlib.h>
#include "serialsource.h"
static char *msgs[] = {
"unknown_packet_type",
"ack_timeout" ,
"sync" ,
"too_long" ,
"too_short" ,
"bad_sync" ,
"bad_crc" ,
"closed" ,
"no_memory" ,
"unix_error"
};
void stderr_msg(serial_source_msg problem)
{
fprintf(stderr, "Note: %s\n", msgs[problem]);
}
int main(int argc, char **argv)
{
serial_source src;
if (argc != 3)
{
fprintf(stderr, "Usage: %s <device> <rate> - dump packets from a serial port\n", argv[0]);
exit(2);
}
src = open_serial_source(argv[1], atoi(argv[2]), 0, stderr_msg);
if (!src)
{
fprintf(stderr, "Couldn't open serial port at %s:%s\n",
argv[1], argv[2]);
exit(1);
}
for (;;)
{
int len, i;
const unsigned char *packet = read_serial_packet(src, &len);
int rssi_val;
int am_type;
int orig_sender;
float real_rssi;
float vdc = 3.0f;
int crc;
if (!packet)
exit(0);
rssi_val = ((packet[7] & 0xff) << 8) | (packet[6] & 0xff);
am_type = packet[8];
orig_sender = ((packet[10] & 0xff) << 8) | (packet[9] & 0xff);
crc = ((packet[12] & 0xff) << 8) | (packet[11] & 0xff);
/* for mica 2, ALSO depends on the value of vdc; which for wall plugin
* is 3 VDC; for 1.5V batts it's something else
*/
real_rssi = -50.0f * (vdc * (rssi_val/1024.0f)) - 45.5f;
printf("original sender: %d; crc: %d; AM type: %d; RSSI: %f dBm\n",
orig_sender,
crc,
am_type,
real_rssi);
fflush(stdout);
//putchar('\n');
free((void *)packet);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment