hey all
this is my program:
#include "Timer.h"
#include "RadioSenseToLeds.h"
uint16_t global_i=0;
uint16_t global_a[6];
module TestC
{
uses {
interface Boot;
interface Timer<TMilli> as Timer0;
interface Timer<TMilli> as Timer1;
interface Read<uint16_t>;
interface Leds;
interface SplitControl as RadioControl;
interface AMSend;
interface Packet;
interface Receive;
}
}
implementation
{
message_t packet;
radio_sense_msg_t* rsm;
bool locked = FALSE;
event void Boot.booted() {
call RadioControl.start();
}
event void RadioControl.startDone(error_t err)
{
if (err==SUCCESS)
{
call Timer0.startPeriodic( 5000);
call Timer1.startPeriodic( 15000);
}
}
event void RadioControl.stopDone(error_t err) {}
event void Timer0.fired()
{
call Read.read();
}
event void Read.readDone(error_t result, uint16_t data)
{
uint16_t data_Temp=0;
data_Temp= (data/4096*1.5 - 0.986)/0.00355;
global_a[global_i] = data_Temp;
global_i++;
}
event void Timer1.fired()
{
uint16_t mean=0;
uint16_t con=22;
for (global_i=0;global_i<=2;global_i++)
mean+=global_a[global_i];
mean=mean/3;
if (con>mean)
{
mean++;
call Leds.led0On();
}
else
{
mean--;
call Leds.led1On();
}
call Leds.led0Off();
call Leds.led1Off();
rsm = (radio_sense_msg_t*)call Packet.getPayload(&packet,
sizeof(radio_sense_msg_t));
if (rsm == NULL) {
return;
}
rsm->data = mean;
if (call AMSend.send(0x0000, &packet, sizeof(radio_sense_msg_t)) ==
SUCCESS) {
locked = TRUE;
}
mean=0;
for (global_i=0;global_i<=2;global_i++)
global_a[global_i]=0;
global_i=0;
}
event message_t* Receive.receive(message_t* bufPtr, void* payload,
uint8_t len)
{
call Leds.led1Toggle();
if (len != sizeof(radio_sense_msg_t)) {return bufPtr;}
else {
radio_sense_msg_t* rsm = (radio_sense_msg_t*)payload;
uint16_t val = rsm->data;
if (val & 0x0004)
call Leds.led2On();
else
call Leds.led2Off();
if (val & 0x0002)
call Leds.led1On();
else
call Leds.led1Off();
if (val & 0x0001)
call Leds.led0On();
else
call Leds.led0Off();
return bufPtr;
}
}
event void AMSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
}
}
can anyone tell me what the problem with this program is. there arent any
errors while compiling, but it does not read the values we
want to input using a .dat file. we used the listen application to check the
transmitted msg, and these are the outputs we got after
45 secs..
x...@ubuntu:~$ java net.tinyos.tools.Listen
00 00 00 00 01 02 00 07 54 9B
00 00 00 00 01 02 00 07 54 3F
00 00 00 00 01 02 00 07 54 3F
even when we tried to check whether it is reading our input values
correctly, we got the wrong output.. simulator being used is avrora..
HELP!!
thanks!
abhishek
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help