<< Chapter < Page | Chapter >> Page > |
source_code/iar_v4.11/lab_ezwsn.eww
with IAR. The project corresponding to this section is called
txrx_noise
. , and program a single board; close IAR.txrx_noise.py
in some directory on your computer
Alternatively, this file is already present in the downloadable
source code , in the directory
source_code/c_files/
. .Xlaunch
you have installed on your computer.Cygwin
and go into the folder containing
./txrx_noise.py
using command
cd
path to your folder
In cygwin, your Windows drive C:\ is called
/cygdrive/c
. Also, use forward slashes. If your folder is located at
C:\Users\Thomas\Desktop\source_code
, in Cygwin, type
cd /c/cygdrive/Users/Thomas/Desktop/source_code
. .export DISPLAY=127.0.0.1:0.0
cat /dev/com
x
. You should see the same content appearing as when using PuTTY. If not, read the COM
x port with PuTTY and try again.cat /dev/com
x | ./txrx_noise.py
A window appears which looks like the one depicted below.#include "mrfi.h"
#include "radios/family1/mrfi_spi.h"void print_rssi(int8_t rssi)
{char output[] = {" 000 "};if (rssi<0) {output[0]='-';rssi=-rssi;}output[1] = '0'+((rssi/100)%10);output[2] = '0'+((rssi/10)%10);output[3] = '0'+ (rssi%10);TXString(output, (sizeof output)-1);
}int main(void)
{int8_t rssi;
uint8_t channel;BSP_Init();
MRFI_Init();P3SEL |= 0x30;
UCA0CTL1 = UCSSEL_2;UCA0BR0 = 0x41;
UCA0BR1 = 0x3;UCA0MCTL = UCBRS_2;
UCA0CTL1&= ~UCSWRST;
MRFI_WakeUp();__bis_SR_register(GIE);
while(1) {for (channel=0;channel<200;channel++) {
MRFI_RxIdle();mrfiSpiWriteReg(CHANNR,channel);
MRFI_RxOn();rssi=MRFI_Rssi();
print_rssi(rssi);}
TXString("\n",1);}
}void MRFI_RxCompleteISR()
{}
C code
#!/usr/bin/env python
import re, Gnuplot, sysif __name__ == '__main__':
print 'display started...'g = Gnuplot.Gnuplot(debug=1)
g('set term x11 title "eZWSN sprectum analyzer"')g('set yrange [-110:0]')g('set data style linespoints')
g.xlabel('frequency (MHz)')g.ylabel('RSSI (dBm)')
char = ''line = ''
while 1:char = sys.stdin.read(1)
if char == '\n':sline = line.split()
data = []for i in range(len(sline)):
try:sline[i] = int(sline[i])
except:sline[i] = 0frequency = 2433.0+(0.2*i)
data.append([frequency,sline[i]])
g.plot(data)line = ''
else:line = line + char
Python code
Some keys for understanding the code running on the mote:
print_rssi()
is a function which prints the RSSI value read from
the CC2500 onto the serial port which is initialized between lines 18 and 25.
TXString()
is a function provided in
bsp_board.c
.TXString()
function. These lines can then be read using
PuTTY.MRFI_Rssi()
is a function declared in the
drivers.The python script continuously feeds the GNUplot environment with data received from the standard interface. Note that the content of the right COMx port if pipedto this python script.
BSP_Init();
, add line
P2DIR |= 0x08;
TXString("\n",1);
, add line
P2DIR ^= 0x08;
. This toggles extension port
P6
every time the screen gets refreshed.P6
the refresh rate of the frequency
analyzer. Make sure to refresh rate is around 1.1s.P2DIR ^= 0x08;
right after line
print_rssi(rssi);
. You now measure the time it takes for
the mote to sample the noise level on one channel, and move to the other.Notification Switch
Would you like to follow the 'Ezwsn: experimenting with wireless sensor networks using the ez430-rf2500' conversation and receive update notifications?