I am working on improving battery lifetime in MICAz platform. Now, I am
writting a simple code in T2 that it must provide info about the number of
transmissions in a window of time. It is based in a Round-Robin schedule.

I have tried to compile in UbunTOS, but it returns this compilation problem:

//////////////////////////////////////////////////////////////////////////////////////////

*mkdir -p build/micaz
    compiling TestP to a micaz binary
ncc -o build/micaz/main.exe -Os -finline-limit=100000 -Wall -Wshadow
-Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb
-DIDENT_PROGRAM_NAME=\"TestP\" -DIDENT_USER_ID=\"ubuntu\"
-DIDENT_HOSTNAME=\"ubuntu\" -DIDENT_USER_HASH=0xf67b89f7L
-DIDENT_UNIX_TIME=0x4831d016L -DIDENT_UID_HASH=0xbeee9eedL
-fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())'
-fnesc-dump='referenced(interfacedefs, components)'
-fnesc-dumpfile=build/micaz/wiring-check.xml TestP.nc -lm
/usr/lib/gcc/avr/3.4.3/../../../../avr/lib/avr5/crtm128.o(.init9+0x0): In
function `__bad_interrupt':
../../../crt1/gcrt1.S:104: undefined reference to `main'
make: *** [exe0] Error 1

*/////////////////////////////////////////////////////////////////////////////////////////

The program code is:

////////////////////////////////////////
---- TestP.nc
//////////////////////////////////////
*#include "Config.h"

module TestP {
  uses {
    interface Boot;
    interface SplitControl;
    interface AMSend;
    interface Receive;
    //interface Leds;
    interface PacketAcknowledgements;
    interface Timer<TMilli> as Timer0;
    interface Timer<TMilli> as Timer1;
    interface McuSleep;
  }
}

implementation {

  /** Message to transmit */
  message_t pkt;
  bool sync = FALSE;
  bool acked = FALSE;
  uint8_t counterTemp = 0;

  /***************** Prototypes ****************/
  task void send();
  task void synchro();

  /***************** Boot Events ****************/
  event void Boot.booted() {
    call SplitControl.start();
  }

  /***************** SplitControl Events ****************/
  event void SplitControl.startDone(error_t error) {
    post synchro();
  }

  event void SplitControl.stopDone(error_t error) {
  }

  /***************** Receive Events ****************/
  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t
len) {

    if (!sync && (len == 0)) {
      testMsg* testpkt = (testMsg*)payload;
      // Hay que poner bien esto
      //uwait_h(MOTE_ID*T_RR_CYCLE*2);
      call Timer0.startPeriodic(T_RR_CYCLE);
      sync = TRUE;
      return msg;
    } else {}
    return msg;
  }

  /***************** AMSend Events ****************/
  event void AMSend.sendDone(message_t *msg, error_t error) {
    acked = (call PacketAcknowledgements.wasAcked(msg));
    if (!acked && !sync)  {
      post synchro();
      return;

    }
    else if(acked && !sync) {
      //uwait(MOTE_ID*T_RR_CYCLE*2);
      //call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
      //sync= TRUE;
      // Esperar hasta que los demás envien lo suyo y la
      // estación base envie la trama de sync
      return;
    }
    else if(!acked && sync) {
      post send();
      return;
    }
    else {
      counterTemp = 0;
    }
    return;
  }


  /***************** Timer Events ****************/
  event void Timer0.fired() {
    post send();
    call Timer1.startOneShot(T_RR_WINDOW);
    return;
  }

  event void Timer1.fired() {
    // Falta apagar la radio!
    call McuSleep.sleep();
    return;
  }

  /***************** Tasks ****************/
  task void send() {
    //counterTemp++;// = (counterTemp + 1);
    testMsg* testpkt = (testMsg*)(call AMSend.getPayload(&pkt));
    testpkt->counter = counterTemp;
    call PacketAcknowledgements.requestAck(&pkt);

    if(call AMSend.send(0, &pkt, sizeof(testMsg)) != SUCCESS) {
      post send();
    }
  }

  task void synchro() {
      call PacketAcknowledgements.requestAck(&pkt);
    if(call AMSend.send(0, &pkt, 0) != SUCCESS) {
      post synchro();
    }

  }

}*
/////////////////////////////////////////////////////////////////////////

*********************************************************
------     TestC.nc
*********************************************************
*#include "Config.h"

module TestP {
  uses {
    interface Boot;
    interface SplitControl;
    interface AMSend;
    interface Receive;
    //interface Leds;
    interface PacketAcknowledgements;
    interface Timer<TMilli> as Timer0;
    interface Timer<TMilli> as Timer1;
    interface McuSleep;
  }
}

implementation {

  /** Message to transmit */
  message_t pkt;
  bool sync = FALSE;
  bool acked = FALSE;
  uint8_t counterTemp = 0;

  /***************** Prototypes ****************/
  task void send();
  task void synchro();

  /***************** Boot Events ****************/
  event void Boot.booted() {
    call SplitControl.start();
  }

  /***************** SplitControl Events ****************/
  event void SplitControl.startDone(error_t error) {
    post synchro();
  }

  event void SplitControl.stopDone(error_t error) {
  }

  /***************** Receive Events ****************/
  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t
len) {

    if (!sync && (len == 0)) {
      testMsg* testpkt = (testMsg*)payload;
      // Hay que poner bien esto
      //uwait_h(MOTE_ID*T_RR_CYCLE*2);
      call Timer0.startPeriodic(T_RR_CYCLE);
      sync = TRUE;
      return msg;
    } else {}
    return msg;
  }

  /***************** AMSend Events ****************/
  event void AMSend.sendDone(message_t *msg, error_t error) {
    acked = (call PacketAcknowledgements.wasAcked(msg));
    if (!acked && !sync)  {
      post synchro();
      return;

    }
    else if(acked && !sync) {
      //uwait(MOTE_ID*T_RR_CYCLE*2);
      //call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
      //sync= TRUE;
      // Esperar hasta que los demás envien lo suyo y la
      // estación base envie la trama de sync
      return;
    }
    else if(!acked && sync) {
      post send();
      return;
    }
    else {
      counterTemp = 0;
    }
    return;
  }


  /***************** Timer Events ****************/
  event void Timer0.fired() {
    post send();
    call Timer1.startOneShot(T_RR_WINDOW);
    return;
  }

  event void Timer1.fired() {
    // Falta apagar la radio!
    call McuSleep.sleep();
    return;
  }

  /***************** Tasks ****************/
  task void send() {
    //counterTemp++;// = (counterTemp + 1);
    testMsg* testpkt = (testMsg*)(call AMSend.getPayload(&pkt));
    testpkt->counter = counterTemp;
    call PacketAcknowledgements.requestAck(&pkt);

    if(call AMSend.send(0, &pkt, sizeof(testMsg)) != SUCCESS) {
      post send();
    }
  }

  task void synchro() {
      call PacketAcknowledgements.requestAck(&pkt);
    if(call AMSend.send(0, &pkt, 0) != SUCCESS) {
      post synchro();
    }

  }

}*
****************************************************************************

______________________________________________________
-------       Config.h
______________________________________________________
*
#ifndef RR_CFG
#define RR_CFG

enum {
  T_RR_CYCLE = 1000,
  T_RR_WINDOW = 20,
  MOTE_ID = 1
};

#endif

#ifndef MSG_CFG
#define MSG_CFG

typedef nx_struct testMsg {
  //nx_bool nodeid;
  nx_uint16_t counter;
} testMsg;

#endif*
__________________________________________________


I am sorry for this huge post, but I think is easier to find where is the
problem with the whole code here.


Thanks in advance for your help,
Carlos
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to