[Tinyos-help] tos.interfaces.Receive and triggering Receive.receive()

Arik Sapojnik sapojnik at gmail.com
Mon Apr 12 04:20:19 PDT 2010


   1. You haven't posted your wiring. Do you use the same AM type in Rx and
   Tx?
   2. You didn't initialize the "locked", perhaps you should.
   3. I don't see the size of your msg_t struct - perhaps it is smaller then
   the maxPayload.
   4. Add more printouts


Arik



On Mon, Apr 12, 2010 at 13:23, Christopher Mueller <
Christopher_Mueller at gmx.de> wrote:

> I recently started working with TinyOs and wrote a small application, which
> just sends a packet and signals if it received a packet.
> The signalling is done using the Receive interface and the
> Receive.receive() event message. Unfortunately this event is never
> triggered, although packets are send successfully and the nodes are in
> communication range.
> Any idea what could cause the problem?
> The code of the application is below:
>
> #include "Timer.h"
> #include "Tree.h"
> #include "printf.h"
>
>
> module TreeC {
>  uses {
>    interface Leds;
>    interface Boot;
>    interface Receive;
>    interface AMSend;
>    interface Timer<TMilli> as MilliTimer;
>    interface SplitControl as AMControl;
>    interface SplitControl as PrintfControl;
>    interface AMPacket;
>    interface ActiveMessageAddress;
>    interface PrintfFlush;
>   }
> }
> implementation {
>
>  message_t packet;
>
>  bool locked;
>  uint16_t counter = 0;
>  am_addr_t addr;
>
>  event void Boot.booted() {
>
>    call AMControl.start();
>    call PrintfControl.start();
>  }
>
>  event void AMControl.startDone(error_t err) {
>    if (err == SUCCESS) {
>     if (TOS_NODE_ID == 1) {}
>     else
>      if (TOS_NODE_ID == 2){
>       call MilliTimer.startPeriodic(250);
>       call Leds.led0On();
>       printf("hello world from Node 2"); call PrintfFlush.flush();
>      }
>      else {
>       call MilliTimer.startPeriodic(250);
>      }
>    }
>    else {
>      call AMControl.start();
>    }
>  }
>
>  event void AMControl.stopDone(error_t err) {
>    // do nothing
>  }
>
>  event void PrintfControl.startDone(error_t err) {
>    // do nothing
>  }
>  event void PrintfControl.stopDone(error_t err) {
>    // do nothing
>  }
>
>
>
>  event void MilliTimer.fired() {
>    if (locked) {
>      return;
>    }
>    else {
>      msg_t* rcm = (msg_t*)call AMSend.getPayload(&packet);
>      if (call AMSend.maxPayloadLength() < sizeof(msg_t))
>           return;
>     rcm->data = 0x5555;
>
>     if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(msg_t)) ==
> SUCCESS) {
>        locked = TRUE;
>        }
>    }
>  }
>
>  event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t
> len) {
>                printf("Received packet"); call PrintfFlush.flush();
>                call Leds.led1On();
>        return bufPtr;
>
>  }
>
>  event void AMSend.sendDone(message_t* bufPtr, error_t error) {
>    call Leds.led0Off();
>        call Leds.led2On();
>    if (&packet == bufPtr) {
>      locked = FALSE;
>    }
>  }
>        async event void ActiveMessageAddress.changed() {
>  }
>  event void PrintfFlush.flushDone(error_t error){}
> }
>
>
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>



-- 
Best Regards,
Arik Sapojnik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20100412/09057a88/attachment.htm 


More information about the Tinyos-help mailing list