From 7265244b327b22b11ea7daf8252e1a7886bfb07a Mon Sep 17 00:00:00 2001 From: pipeng Date: Wed, 14 Mar 2007 03:22:37 +0000 Subject: [PATCH] Change to use driver which follow TEP 109 . --- apps/tests/mica2/mts300/TestMts300C.nc | 48 +------------ apps/tests/mica2/mts300/TestMts300P.nc | 99 ++++++++------------------ 2 files changed, 32 insertions(+), 115 deletions(-) diff --git a/apps/tests/mica2/mts300/TestMts300C.nc b/apps/tests/mica2/mts300/TestMts300C.nc index c08f06f9..f7da8d79 100644 --- a/apps/tests/mica2/mts300/TestMts300C.nc +++ b/apps/tests/mica2/mts300/TestMts300C.nc @@ -1,41 +1,3 @@ -// $Id$ - -/* - * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - * downloading, copying, installing or using the software you agree to - * this license. If you do not agree to this license, do not download, - * install, copy or use the software. - * - * Copyright (c) 2004-2006 Crossbow Technology, Inc. - * 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 (updated) modification history and the author appear in - * all copies of this source code. - * - * Permission is also granted to distribute this software under the - * standard BSD license as contained in the TinyOS distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * TinyOS 1.x to TinyOS 2.x translation layer. - * - * @author Alif - */ #include "XMTS300.h" #include "mts300.h" @@ -53,12 +15,11 @@ implementation // sensorboard devices components new SensorMts300C(); - components SounderC; TestMts300P -> MainC.Boot; TestMts300P.MTS300Timer -> MTS300Timer; - TestMts300P.Leds -> NoLedsC; + TestMts300P.Leds -> LedsC; // communication TestMts300P.RadioControl -> Radio; @@ -70,9 +31,9 @@ implementation TestMts300P.UartPacket -> Serial; // sensor components - MainC.SoftwareInit -> SensorMts300C; - TestMts300P.MTS300Control -> SensorMts300C.StdControl; TestMts300P.Vref -> SensorMts300C.Vref; + TestMts300P.Sounder -> SensorMts300C.Sounder; + TestMts300P.Light -> SensorMts300C.Light; TestMts300P.Temp -> SensorMts300C.Temp; TestMts300P.Microphone -> SensorMts300C.Microphone; @@ -80,7 +41,4 @@ implementation TestMts300P.AccelY -> SensorMts300C.AccelY; TestMts300P.MagX -> SensorMts300C.MagX; TestMts300P.MagY -> SensorMts300C.MagY; - - MainC.SoftwareInit -> SounderC; - TestMts300P.Sounder -> SounderC; } diff --git a/apps/tests/mica2/mts300/TestMts300P.nc b/apps/tests/mica2/mts300/TestMts300P.nc index 2f46d90e..334c032f 100644 --- a/apps/tests/mica2/mts300/TestMts300P.nc +++ b/apps/tests/mica2/mts300/TestMts300P.nc @@ -1,42 +1,3 @@ -// $Id$ - -/* - * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. - * downloading, copying, installing or using the software you agree to - * this license. If you do not agree to this license, do not download, - * install, copy or use the software. - * - * Copyright (c) 2004-2006 Crossbow Technology, Inc. - * 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 (updated) modification history and the author appear in - * all copies of this source code. - * - * Permission is also granted to distribute this software under the - * standard BSD license as contained in the TinyOS distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * TinyOS 1.x to TinyOS 2.x translation layer. - * - * @author Alif - */ - #include "Timer.h" #include "XMTS300.h" #include "mts300.h" @@ -57,8 +18,7 @@ module TestMts300P interface Packet as UartPacket; interface AMSend as UartSend; // sensor components - interface StdControl as MTS300Control; - interface StdControl as Sounder; + interface Mts300Sounder as Sounder; interface Read as Vref; //!< voltage interface Read as Light; interface Read as Temp; @@ -105,6 +65,29 @@ implementation norace uint16_t accel_ave_x, accel_ave_y; norace uint8_t accel_ave_points; + +////////////////////////////////////////////////////////////////////////////// +// +// packet sending +// +////////////////////////////////////////////////////////////////////////////// + task void send_msg() + { + atomic packet_ready = FALSE; + // check length of the allocated buffer to see if it is enough for our packet + if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg)) + { + return ; + } + // OK, the buffer is large enough + //pMsg->vref = counter; + if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS) + { + sending_packet = TRUE; + call Leds.led2On(); + } + } + ////////////////////////////////////////////////////////////////////////////// // // basic control routines @@ -143,9 +126,8 @@ implementation { if (err == SUCCESS) { - call MTS300Control.start(); - call Sounder.start(); - call MTS300Timer.startPeriodic( 300 ); + call Sounder.beep(1000); + call MTS300Timer.startPeriodic( 1000 ); } else { @@ -182,12 +164,6 @@ implementation } call Leds.led1Toggle(); - counter++; - - if(counter==1) - { - call Sounder.stop(); - } if (sending_packet) return ; @@ -197,23 +173,6 @@ implementation call Vref.read(); return ; } - - if (packet_ready) - { - atomic packet_ready = FALSE; - // check length of the allocated buffer to see if it is enough for our packet - if (call RadioPacket.maxPayloadLength() < sizeof(Mts300Msg)) - { - return ; - } - // OK, the buffer is large enough - //pMsg->vref = counter; - if (call UartSend.send(AM_BROADCAST_ADDR, &packet, sizeof(Mts300Msg)) == SUCCESS) - { - sending_packet = TRUE; - call Leds.led2On(); - } - } } /** @@ -230,7 +189,6 @@ implementation { pMsg->vref = 0; } -// atomic packet_ready = TRUE; atomic state = STATE_LIGHT_START; call Light.read(); } @@ -251,9 +209,10 @@ implementation } atomic state = STATE_TEMP_START; call Temp.read(); +// atomic state = STATE_MIC_START; +// call Microphone.read(); } - /** * Temperature data read * @@ -345,7 +304,6 @@ implementation { pMsg->accelY = 0; } -// atomic packet_ready = TRUE; atomic state = STATE_MAGX_START; call MagX.read(); } @@ -383,6 +341,7 @@ implementation pMsg->magY = 0; } atomic packet_ready = TRUE; + post send_msg(); } /** -- 2.39.2