Hi Sara,

 

Sorry for replying late but I was busy setting up a 25 node Sensor
network after the Easter break.

 

The code seems to be alright, it seems to be more the Serial side
problem. Search the list about baudrates and keywords such as "bad
packet", "packet too long" and I am sure you will be able to find the
solution. From my experience, try to adjust the baudrate to 57600bps.
You need to make changes at two places. 

 

/platform/hardware.h

 

and

 

/support/sdk/java/net/tinyos/packet/Baudrate.java    and then recompile
the tinyos.jar by doing a make in this location /support/sdk/java/

 

 

 

Hope it helps,

 

Varun

 

 

From: sara so [mailto:[email protected]] 
Sent: Friday, 10 April 2009 6:34 PM
To: Varun Jain
Subject: Re: generate data tinyos

 

Hi Varun,
I have posted this to the mailing list, but could you please help. I
have a little problem in the attached code, what I am trying to do is
just read the light sensor periodically and send it with some other data
to the Basestation but whenever I run Listen application then it display
"bad packet", "packet too long",  resynchronising!!!
Could you please take a quick look to my small code, maybe I miss
something.
Thanks for any help and happy Easter 
        Sara


include <Timer.h>
#include "BlinkToRadio.h"

module BlinkToRadioC {
  uses interface Boot;
  uses interface Leds;
  uses interface Timer<TMilli> as Timer0;
  uses interface Packet;
  uses interface AMPacket;
  uses interface AMSend;
  uses interface Read<uint16_t> as ReadLight; 
  uses interface SplitControl as AMControl;
}
implementation {
  uint16_t counter;
  message_t pkt;
  bool busy = FALSE;
  uint16_t  light;

  event void Boot.booted() {
      call AMControl.start();
  }

  event void AMControl.startDone(error_t err) {
    if (err == SUCCESS) {
      call Timer0.startPeriodic(TIMER_

PERIOD_MILLI);
    }
    else {  
      call AMControl.start();
    }
  }

  event void AMControl.stopDone(error_t err) {
  }



\\ may be here is the problem 
  event void Timer0.fired() {
   call ReadLight.read();
   
 if (!busy) {
  
BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call
Packet.getPayload(&pkt, sizeof(BlinkToRadioMsg) ));
btrpkt->nodeid = TOS_NODE_ID;
      btrpkt->counter = counter++;
      btrpkt->photo =light;
    if (call AMSend.send(0, &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) {
        busy = TRUE;
      }
    }
  }

  event void AMSend.sendDone(message_t* msg, error_t err) {
    if (&pkt == msg) {
  busy = FALSE;
    }
  }

  event void ReadLight.readDone(error_t result, uint16_t data)

  {

    if (result == SUCCESS){

     light = data;

  } }}

for wireing :
implementation {
  components MainC;
  components BlinkToRadioC as App;
  components new TimerMilliC() as Timer0;
  components ActiveMessageC;
  components new AMSenderC(AM_BLINKTORADIO);
  components new HamamatsuS10871TsrC() as SensorLght;

 

On Wed, Apr 8, 2009 at 3:39 AM, sara so <[email protected]> wrote:

Hi Varun,
Just to say thank you very much for your help. I will go through that
and see. 
Happy Easter
 Sara 

 

On Wed, Apr 8, 2009 at 2:38 AM, Varun Jain <[email protected]>
wrote:

Hi Sara,

 

There is a test application given in tinyos-2.x:

 

 /apps/tests/TestNetwork 

 

This application does both the network protocols possible with
TINYOS-2.x i.e. Collection (send data from all the nodes to a SINK node)
and also Dissemination (Sending small data items to all the nodes from
the Root Node) and I would say that you should play with this
application

 

There is another interesting application /apps/Antitheft  which does
similar to above but it provides you a GUI interface as well to
disseminate the items in the network.

 

If you are a beginner, then you can probably take the concept from these
applications and change it a little bit to get periodic data for your
testing purposes. Say you just have three timers firing at different
interval, sending the data to the SINK every time a timer fires and the
skeleton code will look something like this:

{

uses interface Timer<TMilli> as Timer1;

uses interface Timer<TMilli> as Timer2;

uses interface Timer<TMilli> as Timer3;

}

 

{

Call Timer1. startPeriodic (256);

Call Timer2. startPeriodic (512);

Call Timer3. startPeriodic (1024);

Uint16_t counter1 = 0;

 

Event void Timer1.fired () {

                counter1++;

                atomic {

                                if (!sendBusy) 

                                                post sendMessage();


                }

}

 

void sendMessage() {

    TestNetworkMsg* msg = (TestNetworkMsg*)call Send.getPayload(&packet,
sizeof(TestNetworkMsg));

    uint16_t metric;

    am_addr_t parent;

 

    call CtpInfo.getParent(&parent);

    call CtpInfo.getEtx(&metric);

 

    msg->source = TOS_NODE_ID;

    msg->seqno = seqno;

    msg->data = counter1;

    msg->parent = parent;

    msg->hopcount = 0;

    msg->metric = metric;

 

    if (call Send.send(&packet, sizeof(TestNetworkMsg)) != SUCCESS) {

            call Leds.led0On();

      dbg("TestNetworkC", "%s: Transmission failed.\n", __FUNCTION__);

    }

    else {

      sendBusy = TRUE;

      seqno++; 

      dbg("TestNetworkC", "%s: Transmission succeeded.\n",
__FUNCTION__);

    }

  }

 

 

 

Similarly you can send data when other timers fire.

 

 

Hope this helps. Let me know if you need any more help.

 

 

Regards,

Varun

 

P.S: I am more than happy to help as much as I can so send me as many
queries as you want but also CC your queries to "tinyos-help mailing
list" as there are so many other people in the community who can give
answers from different perspective. This also helps to people who are
looking for your kind of problem/query.

 

 

From: sara so [mailto:[email protected]] 
Sent: Tuesday, 7 April 2009 6:41 PM
To: Varun Jain
Subject: generate data tinyos

 

Hi Varun,
I am Sara from Berlin. I found your email while I was searching in
Google and hope that you can help me with the following question!
I want to be able to to generate data periodically from tmote sky node
and send it to the sink. Do you know how can  I generate any kind of
data and send it. Is there any application that do that. 
thank you for any help
 Sara 
  

 

 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to