Re: [Tinyos-help] why both AMPacket and Packet interfaces are used in tinyos-2.x/apps/tutorials/BlinkToRadio/BlinkToRadioC.nc

2006-06-30 Thread Philip Levis

On Jun 29, 2006, at 10:43 PM, Liu Haibin wrote:


Hi,

The following is tinyos-2.x/apps/tutorials/BlinkToRadio/ 
BlinkToRadioC.nc from tinyos-2_0_devel-BRANCH. I found that it  
declares to use both AMPacket and Packet interfaces and actually it  
uses only Packet in the implementation. So is AMPacket redundant  
there?





Yes. It's like having a #include for a header that you don't actually  
use. It's probably the result of a few iterations on the component.


Phil
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


[Tinyos-help] why both AMPacket and Packet interfaces are used in tinyos-2.x/apps/tutorials/BlinkToRadio/BlinkToRadioC.nc

2006-06-29 Thread Liu Haibin
Hi,The following is tinyos-2.x/apps/tutorials/BlinkToRadio/BlinkToRadioC.nc from tinyos-2_0_devel-BRANCH. I found that it declares to use both AMPacket and Packet interfaces and actually it uses only Packet in the implementation. So is AMPacket redundant there?
Regards,Haibin// $Id: BlinkToRadioC.nc,v 1.1.2.2 2006/02/09 17:17:48 idgay Exp $/** Copyright (c) 2000-2006 The Regents of the University of California. 
* All rights reserved.** Permission to use, copy, modify, and distribute this software and its* documentation for any purpose, without fee, and without written agreement is* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.* * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS* ON AN AS IS BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.**//*** Implementation of the BlinkToRadio application. A counter is* incremented and a radio message is sent whenever a timer fires.
* Whenever a radio message is received, the three least significant* bits of the counter in the message payload are displayed on the* LEDs. Program two motes with this application. As long as they* are both within range of each other, the LEDs on both will keep
* changing. If the LEDs on one (or both) of the nodes stops changing* and hold steady, then that node is no longer receiving any messages* from the other node.** @author Prabal Dutta* @date Feb 1, 2006
*/#include Timer.h#include BlinkToRadio.hmodule BlinkToRadioC { uses interface Boot; uses interface Leds; uses interface TimerTMilli as Timer0; uses interface Packet;
 uses interface AMPacket; uses interface AMSend; uses interface Receive; uses interface SplitControl as AMControl;}implementation { uint16_t counter; message_t pkt; bool busy = FALSE;
 void setLeds(uint16_t val) { if (val  0x01) call Leds.led0On(); else  call Leds.led0Off(); if (val  0x02) call Leds.led1On(); else call Leds.led1Off
(); if (val  0x04) call Leds.led2On(); else call Leds.led2Off(); } event void Boot.booted() { call AMControl.start(); } event void AMControl.startDone
(error_t err) { if (err == SUCCESS) { call Timer0.startPeriodic(TIMER_PERIOD_MILLI); } else { call AMControl.start(); } } event void AMControl.stopDone(error_t err) {
 } event void Timer0.fired() { counter++; if (!busy) { BlinkToRadioMsg* btrpkt =  (BlinkToRadioMsg*)(call Packet.getPayload(pkt, NULL)); btrpkt-nodeid = TOS_NODE_ID;
 btrpkt-counter = counter; if (call AMSend.send(AM_BROADCAST_ADDR,  pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) { busy = TRUE; } } } event void 
AMSend.sendDone(message_t* msg, error_t err) { if (pkt == msg) { busy = FALSE; } } event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len){ if (len == sizeof(BlinkToRadioMsg)) {
 BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload; setLeds(btrpkt-counter); } return msg; }}
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help