I"ve been working through the T2 tutorial 3, and use AMsend instead of Packet just to self teach, and hit a cryptic C part I want to ask for alternative ways to write. It comes up using the Packet or AMSend interfaces. If you use Packet.getPayLoad(&pkt, NULL) or AMSend.getPayLoad(&pkt) to find out the address of the next packet, you can use a line from the tutorial and it compiles, but is so opaque to me I want to find other ways to write it.

BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*) (call AMSend.getPayload(&pkt));
     //cast result of .getPayload to pointer of nx_struct BlinkToRadioMsg*
     btrpkt->nodeid = TOS_NODEID;    // stuff data in struct member
     btrpkt->counter = counter;            // stuff data in struct member

where the header file includes this struct definition:

    typedef nx_struct BlinkToRadioMsg {
      nx_uint16_t nodeid;
      nx_uint16_t counter;
    } BlinkToRadioMsg;

Is there any way to write the top line more like:

BlinkToRadioMsg* btrpkt ;   // declare type of btrpkt is address of struct
btrpkt = (call AMSend.getPayload(&pkt));

or maybe just:
BlinkToRadioMsg* btrpkt ;   // declare type of btrpkt variable
call AMSend.getPayload(&btrpkt)




What is the meaning of
(BlinkToRadioMsg*)  (call AMSend.getPayload(&pkt));
in the top line?  Is this the syntax for coercing to type BlinkToRadioMsg*?
Where in the docs is this syntax defined?
It's not like K&R C...where
you would declare *btrpkt to get a pointer you could use as btrpkt->nodeid


John Griessen

Ecosensory


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

Reply via email to