On Wed, Oct 30, 2013 at 12:29 PM, Srikanth Nori <[email protected]>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 <http://srikanthnv.net>
>
> On Wed, Oct 30, 2013 at 12:23 PM, Alaios <[email protected]> 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
>> [email protected]
>> 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
>



-- 
Eric B. Decker
Senior (over 50 :-) Researcher
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to