Hi, i have a problem. I have to take datas from two different sensors on 
Tmote-Sky(Light and Temperature) and send on two differente radio channel to an 
other tmote-sky. After the transmission, radio turn off and then restart one 
second before the next ADC sampling (I hope!).
I wrote this code but the transmitter doesn't work well

configuration SenseToRfm {
// this module does not provide any interface
}       
implementation
{
  components Main, SenseToInt, IntToRfm, IntToRfm_8, IntToLeds, TimerC, ADCC, 
HamamatsuC as Sensor, DemoSensorC as Sensor_1, SenseToInt_PP;

  Main.StdControl -> SenseToInt;
  Main.StdControl -> IntToRfm;

  Main.StdControl -> SenseToInt_PP;
  Main.StdControl -> IntToRfm_8;

  SenseToInt.Timer -> TimerC.Timer[unique("Timer")];
  SenseToInt.TimerControl -> TimerC;
  SenseToInt.ADC -> Sensor.PAR;
  SenseToInt.ADCControl -> Sensor;
  SenseToInt.IntOutput -> IntToRfm;

  IntToLeds <- SenseToInt.IntOutput;

  SenseToInt_PP.Timer -> TimerC.Timer[unique("Timer")];
  SenseToInt_PP.TimerControl -> TimerC;
  SenseToInt_PP.ADC -> Sensor_1;
  SenseToInt_PP.ADCControl -> Sensor_1;
  SenseToInt_PP.IntOutput -> IntToRfm_8;
}

SenseToInt and SenseToInt_PP are the same, the only change is the sensor.

The code of IntToRfm is:



includes IntMsg;

configuration IntToRfm
{
  provides {
    interface IntOutput;
    interface StdControl;
  }
}
implementation
{
  components IntToRfmM, TimerC, GenericComm as Comm

// HPLPowerManagement is only needed for AVR based platforms
#ifdef __AVR__
           , HPLPowerManagementM as PM
#endif
           ;
#ifdef __AVR__
  CountSleepRadioM.PowerManagement -> PM;
  CountSleepRadioM.Enable -> PM.Enable;
#endif


  IntOutput = IntToRfmM;
  StdControl = IntToRfmM;

  StdControl = TimerC;

  IntToRfmM.Send -> Comm.SendMsg[AM_INTMSG];
  IntToRfmM.SubControl -> Comm;

  IntToRfmM.Timer -> TimerC.Timer[unique("Timer")];

 }



and IntToRfmM is:



includes IntMsg;
includes Timer;

module IntToRfmM 
{
  uses {
    interface StdControl as SubControl;
    interface SendMsg as Send;
    interface Timer;
  }

 // these are only needed for Atmel AVR based platforms
#ifdef __AVR__
  uses interface PowerManagement;
  uses command result_t Enable();
#endif

  provides {
    interface IntOutput;
    interface StdControl;
  }
}
implementation
{
  bool pending;
  TOS_Msg data;

  command result_t StdControl.init() {
    pending = FALSE;
   #ifdef __AVR__
    call Enable();
    call PowerManagement.adjustPower();
   #endif
    call SubControl.init();
   return SUCCESS;
  }

  command result_t StdControl.start() 
  {
    call SubControl.start();
        return SUCCESS;
  }


    command result_t StdControl.stop() 
  {
    return SUCCESS;
  }

  command result_t IntOutput.output(uint16_t value)
  {
    IntMsg *message = (IntMsg *)data.data;
    
    if (!pending) 
      {
        pending = TRUE;


        message->val = value;
        atomic {
          message->src = TOS_LOCAL_ADDRESS;
        }
        if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data))
          return SUCCESS;

        pending = FALSE;
      }
    return FAIL;
  }

  event result_t Send.sendDone(TOS_MsgPtr msg, result_t success)
  {
    if (pending && msg == &data)
      {
        pending = FALSE;
        
        signal IntOutput.outputComplete(success);
      }
    call SubControl.stop();
    call Timer.start( TIMER_ONE_SHOT, 4000 );
    
    return SUCCESS;
  }

  event result_t Timer.fired()
 {
   call SubControl.start();
   return SUCCESS;

  }
}


The difference between IntToRfm and IntToRfm_8 is the value of AM_INTMSG (4 for 
IntToRfm, 8 for IntToRfm_8). I would like to know if the code is correct and 
whick are the bugs. Please help.

Thanks
Simone


------------------------------------------------------
Leggi GRATIS le tue mail con il telefonino i-modeĀ™ di Wind
http://i-mode.wind.it/



_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to