4 * "Copyright (c) 2000-2005 The Regents of the University of California.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation for any purpose, without fee, and without written agreement is
9 * hereby granted, provided that the above copyright notice, the following
10 * two paragraphs and the author appear in all copies of this software.
12 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
14 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
15 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
20 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
21 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23 * Copyright (c) 2002-2003 Intel Corporation
24 * All rights reserved.
26 * This file is distributed under the terms in the attached INTEL-LICENSE
27 * file. If you do not find these files, copies can be found by writing to
28 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
29 * 94704. Attention: Intel License Inquiry.
33 * Application to test that the TinyOS java toolchain can communicate
34 * with motes over the serial port.
36 * @author Gilman Tolle
37 * @author Philip Levis
44 #include "TestSerial.h"
48 interface SplitControl as Control;
53 interface Timer<TMilli> as MilliTimer;
64 event void Boot.booted() {
68 event void MilliTimer.fired() {
74 test_serial_msg_t* rcm = (test_serial_msg_t*)call Packet.getPayload(&packet, sizeof(test_serial_msg_t));
75 if (rcm == NULL) {return;}
76 if (call Packet.maxPayloadLength() < sizeof(test_serial_msg_t)) {
80 rcm->counter = counter * 3.2;
81 if (call AMSend.send(AM_BROADCAST_ADDR, &packet, sizeof(test_serial_msg_t)) == SUCCESS) {
87 event message_t* Receive.receive(message_t* bufPtr,
88 void* payload, uint8_t len) {
89 if (len != sizeof(test_serial_msg_t)) {return bufPtr;}
91 test_serial_msg_t* rcm = (test_serial_msg_t*)payload;
92 if ((int)rcm->counter & 0x1) {
98 if ((int)rcm->counter & 0x2) {
104 if ((int)rcm->counter & 0x4) {
114 event void AMSend.sendDone(message_t* bufPtr, error_t error) {
115 if (&packet == bufPtr) {
120 event void Control.startDone(error_t err) {
121 if (err == SUCCESS) {
122 call MilliTimer.startPeriodic(1000);
125 event void Control.stopDone(error_t err) {}