[Tinyos-help] typos or defined elsewhere?
Chad Metcalf
metcalfc at gmail.com
Thu Jan 4 21:26:19 PST 2007
This is all covered in the 3rd tutorial, including where to find these
files (tos/interfaces or tos/system). Also if you are new to TinyOS I
strongly recommend you read Dr Levis' TinyOS Programming "book".
http://csl.stanford.edu/~pal/pubs/tinyos-programming.pdf
You can also use the find command (it should be around in Cygwin or Linux).
For example:
metcalfc at metcalfc2:/opt/tinyos-2.x$ find . -name AMSend.nc
./tos/interfaces/AMSend.nc
So this tells us that AMSend is an interface that is in the
tos/interface directory.
Grep is also your friend.
For example:
metcalfc at metcalfc2:/opt/tinyos-2.x$ grep -R 'send' tos/interfaces/AMSend.nc
/** The basic active message message sending interface. Also see
* Packet interface of the component providing AMSend. If send
* returns SUCCESS, then the component will signal the sendDone
* event in the future; if send returns an error, it will not
* signal the event. Note that a component may accept a send
* will signal sendDone with error code.
* @param addr address to which to send the packet
* @return SUCCESS if the request to send succeeded and a
* sendDone will be signaled later, EBUSY if the
* abstraction cannot send now but will be able to
* in a state that can send (e.g., off).
* @see sendDone
command error_t send(am_addr_t addr, message_t* msg, uint8_t len);
* if the send was successfully canceled, if the radio is
* sendFailed event, and never a sendSucceeded event.
* @see sendDone
* Signaled in response to an accepted send request. <tt>msg</tt> is
* the send was successful.
* @param msg the packet which was submitted as a send request
* @see send
event void sendDone(message_t* msg, error_t error);
Its all there. Just poke around a bit.
Cheers
Chad
On 1/4/07, Mohamed Ahmed <mohamed7ahmed at yahoo.com> wrote:
> Hi Chad,
>
> Thank you very much for your helpful email and clarifications!
>
> I didn't mean the tutorials are not correct but was unable to
> figure out where these variables come from as I'm new to TinyOS.
>
> ----
> implementation {
>
> uint16_t counter;
> message_t pkt;
> bool busy = FALSE;
> ----
>
> I can't find where "pkt" is initialized. Could you please show me where
> this initialization takes place?
>
> Also, where is the declaration (or definition) of AMSend.Send?
> Could you show me the definition of the command "Send" of the
> interface "AMSend"?
>
> Besides, "Receive.receive" was never called.
>
> Thank you very much for making these clear.
>
> Mohamed
>
> Chad Metcalf <metcalfc at gmail.com> wrote:
>
> On 1/4/07, Mohamed Ahmed wrote:
> > Hi,
> >
> > Could someone tell me the following code is complete/correct?
> > Where is pkt defined?
>
> According the version in my
> $TOSROOT/apps/tutorials/BlinkToRadio/BlinkToRadioC.nc pkt
> is defined
> on line 55. Just search for it.
>
> ----
> implementation {
>
> uint16_t counter;
> message_t pkt;
> bool busy = FALSE;
> ----
>
> > Also btrpkt is not used after initializing its fields "nodeid" and
> > "counter".
>
> You are correct. The btrpkt pointer is used to used access to the
> nodeid and counter fields. Once they are updated you don't need to use
> the pointer anymore. That's what this:
>
> BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call Packet.getPayload(&pkt,
> NULL))
>
> is doing for you. The pkt is the packet you are sending. The payload
> is where the BlinkToRadioMsg structure lives (for this message type).
> By getting a pointer to the payload and casting it to a pointer to the
> BlinkToRadioMsg struct you get a nice convenient way of modifying the
> values of nodeid and counter.
>
> Now in this line:
>
> if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(BlinkToRadioMsg))
> == SUCCESS) {
>
> you send the pkt. The nodeid and counter values have been changed. So
> you don't need the btrptk because it isn't the whole packet, just the
> payload.
>
> Generally, the tutorials are correct.
>
> Cheers,
> Chad
>
>
> --
> Chad @ Home
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
--
Chad @ Home
More information about the Tinyos-help
mailing list