All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 89031812 authored by David Johnson's avatar David Johnson

A version of the ElabRadioDumper that frequency hops from 902-928MHz.

parent 73418e5a
// $Id: ElabRadioDumpFH.nc,v 1.1 2005-06-27 17:49:21 johnsond Exp $
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/* Author: Phil Buonadonna
* Revision: $Id: ElabRadioDumpFH.nc,v 1.1 2005-06-27 17:49:21 johnsond Exp $
*/
/**
* @author Phil Buonadonna
*/
configuration ElabRadioDumpFH {
}
implementation {
components Main, ElabRadioDumpFHM, RadioCRCPacket as Comm,
//UARTNoCRCPacket as UART,
GenericComm as UART,
LedsC,
TimerC;
// CC1000ControlM;
//FramerM, UART
Main.StdControl -> ElabRadioDumpFHM;
ElabRadioDumpFHM.Timer -> TimerC.Timer[unique("Timer")];
ElabRadioDumpFHM.TimerFH -> TimerC.Timer[unique("Timer")];
//ElabRadioDumpFHM.UARTControl -> FramerM;
//ElabRadioDumpFHM.UARTSend -> FramerM;
//ElabRadioDumpFHM.UARTReceive -> FramerM;
//ElabRadioDumpFHM.UARTTokenReceive -> FramerM;
ElabRadioDumpFHM.UARTControl -> UART;
//ElabRadioDumpFHM.UARTSend -> UART;
//ElabRadioDumpFHM.UARTReceive -> UART;
ElabRadioDumpFHM.UARTSend -> UART.SendMsg[4];
ElabRadioDumpFHM.UARTReceive -> UART.ReceiveMsg[4];
ElabRadioDumpFHM.RadioControl -> Comm;
ElabRadioDumpFHM.RadioSend -> Comm;
ElabRadioDumpFHM.RadioReceive -> Comm;
ElabRadioDumpFHM.Leds -> LedsC;
ElabRadioDumpFHM.CC1000Control -> Comm;
//FramerM.ByteControl -> UART;
//FramerM.ByteComm -> UART;
}
This diff is collapsed.
COMPONENT=ElabRadioDumpFH
PFLAGS=-I%T/lib/HDLC
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)
# 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)
#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);
if (!packet)
exit(0);
int rssi_val;
int am_type;
int orig_sender;
float real_rssi;
float vdc = 3.0f;
int crc;
unsigned int freq = 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);
freq = ((packet[16] & 0xff) << 24) | ((packet[15] & 0xff) << 16) |
((packet[14] & 0xff) << 8) | (packet[13] & 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("origin: %d; crc: %d; AM type: %d; RSSI: %f dBm; freq: %d\n",
orig_sender,
crc,
am_type,
real_rssi,
freq);
fflush(stdout);
//putchar('\n');
free((void *)packet);
}
}
#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