You need to get deeply with the Kernigan and Ritchie 'C' Programming Manual.
If you are not familaiar with C you are basically Stuff Out of Luck with TOS.

In general:

   type* name;        // declares a pointer to a variable of type.
   type _name;        // another variable, the '_' may make it less visible
   name = &something; // sets the pointer to the address of "something"
   name = (type*)else; // casts (forces) "else" to be a type*

The TOS_Msg stucts are defined in tos/types/AM.h, unless of course
you are NOT using mica2 or the UART, in which case they may be defined
in a tos/platform/[platform]/AM.h file...And, no, that is not part
of the 'C' definition, but rather a consequence of 'C''s propensity
to encourage you to shoot yourself until you lose consciousness.

Pong message structs can probably be found in a *.h ('*' is not a
pointer in this case, thank the Unix gods...) file somewhere in
the vicinity of the pong app directory.

MS

Wu Nick wrote:
> Deal, all
> I am not very familiar with the nesC and C language. So I got some 
> problem with the source code. For example, in the PingPong application 
> which under the apps file. I know about how the PingPong app works, so I 
> can guess what the meaning for each event and command. But some parts of 
> the source code I don’t explicit understand, especially for the part 
> which is about packet transmission. I append apart of source code on the 
> back (I put a # mark in the front, and write my Q on the back). Have 
> anyone can kindly explain that for me? Please help me out of this
> Best regards,
> Wu
> 
> implementation {
> #    TOS_Msg m_msg;                   // using TOS_Msg structure from 
> AM.h, naming m_msg, right?
> #    TOS_MsgPtr p_msg;               // where is TOS_MsgPtr from? #    
> PongMsg_t* pongmsg;                                     // the * symbol 
> in here is a pointer?
>        command result_t StdControl.init() {
>        
> #                        pongmsg = (PongMsg_t*)m_msg.data;        // no 
> idea for this!!
> #                         p_msg = &m_msg;                      //what is 
> the & mean?
>        }
> 
>        event result_t Timer.fired() {
>     
> #       if (call SendMsg.send(TOS_BCAST_ADDR, sizeof(PongMsg_t), p_msg)) 
> { }  // this command will check for????
>            
>     }
> 
>     event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr msg ) {
> #        PongMsg_t* _pongmsg;      // what is the different between 
> pongmsg and _pongmsg???
>     
> #        _pongmsg = (PongMsg_t*)msg->data;        //where is the data 
> structure from???
>     
>                if( _pongmsg->src != TOS_LOCAL_ADDRESS ) {
>             pongmsg->src = _pongmsg->src;
>             pongmsg->src_rssi = rssival;
>             pongmsg->src_lqi = _pongmsg->src_lqi;
>             pongmsg->dest = TOS_LOCAL_ADDRESS;
>             pongmsg->dest_lqi = battval;
> #            call SendMsg.send(_pongmsg->src, sizeof(PongMsg_t), 
> p_msg);  // what does the parameter p_msg define for???         } else {
>             // send to UART
>             call Leds.yellowToggle();
>             pongmsg->src = _pongmsg->src;
>             pongmsg->src_rssi = _pongmsg->src_rssi;
>             pongmsg->src_lqi = _pongmsg->src_lqi;
>             pongmsg->dest = _pongmsg->dest;
>             pongmsg->dest_rssi = rssival;
>             pongmsg->dest_lqi = _pongmsg->dest_lqi;
>             call SendMsg.send(TOS_UART_ADDR, sizeof(PongMsg_t), p_msg);
>         }
> #        return msg;             // the return value msg is for what?
>     }
> 
> _________________________________________________________________
> 信箱不夠大?MSN Hotmail Plus:讓你的 Hotmail 信箱容量增加 1000 倍 
> http://join.msn.com/?pgmarket=zh-tw
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to