Re: [Tinyos-help] understanding if statements in tinyos

2013-10-31 Thread Philip Levis
Are you allocating the packet variable in your send function on the stack or in 
the component? On the stack won't work.

Phil

---
Philip Levis
Associate Professor
Computer Science and Electrical Engineering
Stanford University
http://csl.stanford.edu/~pal

On Oct 30, 2013, at 12:23 PM, Alaios  wrote:

> Hi all,
> I will need some help to further understand the tinyos fundamentals. I have 
> written some code (after finishing the mote to radio tutorial on the official 
> web site)
> Part of this tutorial was to create a structure for the information I would 
> like to send.
> 
> typedef nx_struct WirelessStruct{
> nx_uint16_t id;
> nx_uint16_t LedsBits;
> }WirelessPkt_t;
> 
> 
> What I send s
> 
> WirelessPkt_t* msg = (WirelessPkt_t*)(call 
> Packet.getPayload(&packet,sizeof(WirelessPkt_t)));
>  msg->id = 2;
>   msg->LedsBits = 2;
>   if (call AMSend.send(AM_BROADCAST_ADDR,& packet, 
> sizeof(WirelessPkt_t))==SUCCESS)
>  {
>isBusy==TRUE;
>  }
> 
> my send is succesful as the receiver part, as the leds turn on on the 
> receiver mote
> WirelessPkt_t* incoming=(WirelessPkt_t*)payload; // cast payload to our data 
> type
>  uint16_t data= incoming->id;
>  uint16_t dataTwo =incoming->LedsBits;
> 
> if (data==2 ){
> printf("I RECEIVED PACKAGE AND I AM: !%d!\n",TOS_NODE_ID);
> printf("data is: !%d!\n",data);
> }
> 
> if though I change the data==2 to the dataTwo==2 nothing happens on the 
> receiver part. Can someone try to see what might be the problem here?
> 
> I would like to thank you for your help
> 
> Regards
> Alex
> ___
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] understanding if statements in tinyos

2013-10-30 Thread Srikanth Nori
On Wed, Oct 30, 2013 at 1:57 PM, Eric Decker  wrote:

> So the way this works is nesc knows about the byte order of nx structs in
> the packet and it handles conversion to a native format as well as byte
> alignment issues.  So the code…


Ah. I was not aware of that. I vaguely recall having had issues with that
in the past, but I must be mistaken. My bad.

-Srikanth
___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Re: [Tinyos-help] understanding if statements in tinyos

2013-10-30 Thread Eric Decker
On Wed, Oct 30, 2013 at 12:29 PM, Srikanth Nori wrote:

> I suspect your issue is because you're mixing nx_uint16_t and uint16_t.
> The former is packed.
>

That's a red herring.

First I don't know what machine this is executing on, is it big or little
endian?   Is it a telosb?   If so it is little endian.   The original
poster didn't specify and that is an oversight and a critical piece of
information.

So the way this works is nesc knows about the byte order of nx structs in
the packet and it handles conversion to a native format as well as byte
alignment issues.  So the code…

uint16_t data = incoming->id

 and

uint16_t dataTwo = incoming->LedsBits

both should set data and dataTwo to the value 0x0002.   And it will be in
native order at this point.


So his code should have worked.   To actual see what is broken one needs to
either look at the machine code generated or look at the mcu as it is
actually executing the code.

It should have worked.

eric



> -Srikanth 
>
> On Wed, Oct 30, 2013 at 12:23 PM, Alaios  wrote:
>
>> Hi all,
>> I will need some help to further understand the tinyos fundamentals. I
>> have written some code (after finishing the mote to radio tutorial on the
>> official web site)
>> Part of this tutorial was to create a structure for the information I
>> would like to send.
>>
>> typedef nx_struct WirelessStruct{
>> nx_uint16_t id;
>> nx_uint16_t LedsBits;
>> }WirelessPkt_t;
>>
>>
>> What I send s
>>
>> WirelessPkt_t* msg = (WirelessPkt_t*)(call
>> Packet.getPayload(&packet,sizeof(WirelessPkt_t)));
>>  msg->id = 2;
>>   msg->LedsBits = 2;
>>   if (call AMSend.send(AM_BROADCAST_ADDR,& packet,
>> sizeof(WirelessPkt_t))==SUCCESS)
>>  {
>>isBusy==TRUE;
>>  }
>>
>> my send is succesful as the receiver part, as the leds turn on on the
>> receiver mote
>> WirelessPkt_t* incoming=(WirelessPkt_t*)payload; // cast payload to our
>> data type
>>  uint16_t data= incoming->id;
>>  uint16_t dataTwo =incoming->LedsBits;
>>
>> if (data==2 ){
>> printf("I RECEIVED PACKAGE AND I AM: !%d!\n",TOS_NODE_ID);
>> printf("data is: !%d!\n",data);
>> }
>>
>> if though I change the data==2 to the dataTwo==2 nothing happens on the
>> receiver part. Can someone try to see what might be the problem here?
>>
>> I would like to thank you for your help
>>
>> Regards
>> Alex
>>
>> ___
>> Tinyos-help mailing list
>> Tinyos-help@millennium.berkeley.edu
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>
>
> ___
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>



-- 
Eric B. Decker
Senior (over 50 :-) Researcher
___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Re: [Tinyos-help] understanding if statements in tinyos

2013-10-30 Thread Srikanth Nori
I suspect your issue is because you're mixing nx_uint16_t and uint16_t. The
former is packed.

-Srikanth 

On Wed, Oct 30, 2013 at 12:23 PM, Alaios  wrote:

> Hi all,
> I will need some help to further understand the tinyos fundamentals. I
> have written some code (after finishing the mote to radio tutorial on the
> official web site)
> Part of this tutorial was to create a structure for the information I
> would like to send.
>
> typedef nx_struct WirelessStruct{
> nx_uint16_t id;
> nx_uint16_t LedsBits;
> }WirelessPkt_t;
>
>
> What I send s
>
> WirelessPkt_t* msg = (WirelessPkt_t*)(call
> Packet.getPayload(&packet,sizeof(WirelessPkt_t)));
>  msg->id = 2;
>   msg->LedsBits = 2;
>   if (call AMSend.send(AM_BROADCAST_ADDR,& packet,
> sizeof(WirelessPkt_t))==SUCCESS)
>  {
>isBusy==TRUE;
>  }
>
> my send is succesful as the receiver part, as the leds turn on on the
> receiver mote
> WirelessPkt_t* incoming=(WirelessPkt_t*)payload; // cast payload to our
> data type
>  uint16_t data= incoming->id;
>  uint16_t dataTwo =incoming->LedsBits;
>
> if (data==2 ){
> printf("I RECEIVED PACKAGE AND I AM: !%d!\n",TOS_NODE_ID);
> printf("data is: !%d!\n",data);
> }
>
> if though I change the data==2 to the dataTwo==2 nothing happens on the
> receiver part. Can someone try to see what might be the problem here?
>
> I would like to thank you for your help
>
> Regards
> Alex
>
> ___
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

[Tinyos-help] understanding if statements in tinyos

2013-10-30 Thread Alaios
Hi all,
I will need some help to further understand the tinyos fundamentals. I have 
written some code (after finishing the mote to radio tutorial on the official 
web site)

Part of this tutorial was to create a structure for the information I would 
like to send.

    typedef nx_struct WirelessStruct{
            nx_uint16_t id;
            nx_uint16_t LedsBits;
    }WirelessPkt_t;
        


What I send s

WirelessPkt_t* msg = (WirelessPkt_t*)(call 
Packet.getPayload(&packet,sizeof(WirelessPkt_t)));
 msg->id = 2;
  msg->LedsBits = 2;
  if (call AMSend.send(AM_BROADCAST_ADDR,& packet, 
sizeof(WirelessPkt_t))==SUCCESS    )
 {
               isBusy==TRUE;
 }


my send is succesful as the receiver part, as the leds turn on on the receiver 
mote

WirelessPkt_t* incoming=(WirelessPkt_t*)payload; // cast payload to our data 
type
 uint16_t data= incoming->id;
 uint16_t dataTwo =incoming->LedsBits;
            
            if (data==2 ){
                printf("I RECEIVED PACKAGE AND I AM: !%d!\n",TOS_NODE_ID);
                printf("data is: !%d!\n",data);
            }

if though I change the data==2 to the dataTwo==2 nothing happens on the 
receiver part. Can someone try to see what might be the problem here?

I would like to thank you for your help

Regards
Alex
___
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help