Hi,

 

The code written by Sara seems to be alright. (See the “Oscilloscope” 
application).

 

Sara, the scenario in the code that you are using the data will be sent to all 
the nodes in the network, not to a particular SINK node. But still if you can 
want to access this packet, you can do it using “BaseStation” application. 
“BaseStation” application basically sends out any packet coming on the radio to 
the serial and vice-versa. An  application already does constant readings for 
sensors, called  “Oscilloscope”, see tinyos tutorial 
(http://docs.tinyos.net/index.php/Sensing) . If you program one node with 
Oscilloscope application (after programming the node with a particular node id 
and change ) and another mote with  BaseStation, you should be able to do what 
you are doing now with a tested application.

 

But to really test what Sara wants to do, such that a constant message is sent 
from a node to a Sink (Root) Node, you really need to use COLLECTION and 
Dissemination, and try to apply applications like “TestNetwork”. In this 
application, there is a section where you send the message…. Here instead of 
“0xCAFE”, you can send a counter value incremented every time the message is 
sent..

 

   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 = 0xCAFE;

    msg->parent = parent;

    msg->hopcount = 0;

    msg->metric = metric;

 

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

      failedSend();

      call Leds.led0On();

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

    }

    else {

      sendBusy = TRUE;

      seqno++; 

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

    }

  }

 

ALSO note, you need to program one node with node id 500 which will act as the 
SINK node and all other node id’s will act as the sensor nodes sending the 
data. Hope it helps, let the community know if you could solve your problem or 
not or you need any more help.

 

 

-varun

 

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Mohamed H. 
Seddik
Sent: Thursday, 16 April 2009 1:25 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [Tinyos-help] generate data tinyos

 

Hi Sara

 

as what I understand in tinyos because I am new in it that 

the command call ReadLight.read();

after read process done the seconde will be 

event void ReadLight.readDone(error_t result, uint16_t data)
so your program may be will not go through sending process.

 

try to change the order of your commands, and sorry if I am wrong.

Thanks  & Have a Nice Day

 

Mohamed



--- On Thu, 4/16/09, Varun Jain <[email protected]> wrote:


From: Varun Jain <[email protected]>
Subject: Re: [Tinyos-help] generate data tinyos
To: "sara so" <[email protected]>
Cc: [email protected]
Date: Thursday, April 16, 2009, 2:10 AM

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] 
<http://us.mc329.mail.yahoo.com/mc/[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 

 

_______________________________________________
Tinyos-help mailing list
[email protected] 
<http://us.mc329.mail.yahoo.com/mc/[email protected]>
 
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help 
<https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help> 

 

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

Reply via email to