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
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help