[Firebug-cvs] firebug/project/src/gps LogMsg.class,NONE,1.1 LogMsg.java,NONE,1.1 gpsBcast.class,NONE
Brought to you by:
doolin
From: <cs...@us...> - 2003-05-22 22:29:50
|
Update of /cvsroot/firebug/firebug/project/src/gps In directory sc8-pr-cvs1:/tmp/cvs-serv32544 Modified Files: gps.nc gpsM.nc Added Files: LogMsg.class LogMsg.java gpsBcast.class gpsBcast.java gpsCmd.nc gpsCmdM.nc gpsCmdMsg.class gpsCmdMsg.h gpsCmdMsg.java gpsRetrieve.nc Removed Files: Makefile Log Message: gps only runs on mica2 --- NEW FILE: LogMsg.class --- (This appears to be a binary file; contents omitted.) --- NEW FILE: LogMsg.java --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This class implements a Java interface to the 'LogMsg' * message type. */ package net.tinyos.gps_mig; public class LogMsg extends net.tinyos.message.Message { /** The default size of this message type in bytes. */ public static final int DEFAULT_MESSAGE_SIZE = 18; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 9; /** Create a new LogMsg of size 18. */ public LogMsg() { super(DEFAULT_MESSAGE_SIZE); amTypeSet(AM_TYPE); } /** Create a new LogMsg of the given data_length. */ public LogMsg(int data_length) { super(data_length); amTypeSet(AM_TYPE); } /** * Create a new LogMsg with the given data_length * and base offset. */ public LogMsg(int data_length, int base_offset) { super(data_length, base_offset); amTypeSet(AM_TYPE); } /** * Create a new LogMsg using the given byte array * as backing store. */ public LogMsg(byte[] data) { super(data); amTypeSet(AM_TYPE); } /** * Create a new LogMsg using the given byte array * as backing store, with the given base offset. */ public LogMsg(byte[] data, int base_offset) { super(data, base_offset); amTypeSet(AM_TYPE); } /** * Create a new LogMsg using the given byte array * as backing store, with the given base offset and data length. */ public LogMsg(byte[] data, int base_offset, int data_length) { super(data, base_offset, data_length); amTypeSet(AM_TYPE); } /** * Create a new LogMsg embedded in the given message * at the given base offset. */ public LogMsg(net.tinyos.message.Message msg, int base_offset) { super(msg, base_offset, DEFAULT_MESSAGE_SIZE); amTypeSet(AM_TYPE); } /** * Create a new LogMsg embedded in the given message * at the given base offset and length. */ public LogMsg(net.tinyos.message.Message msg, int base_offset, int data_length) { super(msg, base_offset, data_length); amTypeSet(AM_TYPE); } /** /* Return a String representation of this message. Includes the * message type name and the non-indexed field values. */ public String toString() { String s = "Message <LogMsg> \n"; try { s += " [sourceaddr=0x"+Long.toHexString(get_sourceaddr())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [log="; for (int i = 0; i < 16; i++) { s += "0x"+Long.toHexString(getElement_log(i) & 0xff)+" "; } s += "]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } return s; } // Message-type-specific access methods appear below. ///////////////////////////////////////////////////////// // Accessor methods for field: sourceaddr // Field type: int, unsigned // Offset (bits): 0 // Size (bits): 16 ///////////////////////////////////////////////////////// /** * Return whether the field 'sourceaddr' is signed (false). */ public static boolean isSigned_sourceaddr() { return false; } /** * Return whether the field 'sourceaddr' is an array (false). */ public static boolean isArray_sourceaddr() { return false; } /** * Return the offset (in bytes) of the field 'sourceaddr' */ public static int offset_sourceaddr() { return (0 / 8); } /** * Return the offset (in bits) of the field 'sourceaddr' */ public static int offsetBits_sourceaddr() { return 0; } /** * Return the value (as a int) of the field 'sourceaddr' */ public int get_sourceaddr() { return (int)getUIntElement(offsetBits_sourceaddr(), 16); } /** * Set the value of the field 'sourceaddr' */ public void set_sourceaddr(int value) { setUIntElement(offsetBits_sourceaddr(), 16, value); } /** * Return the size, in bytes, of the field 'sourceaddr' */ public static int size_sourceaddr() { return (16 / 8); } /** * Return the size, in bits, of the field 'sourceaddr' */ public static int sizeBits_sourceaddr() { return 16; } ///////////////////////////////////////////////////////// // Accessor methods for field: log // Field type: short[], unsigned // Offset (bits): 16 // Size of each element (bits): 8 ///////////////////////////////////////////////////////// /** * Return whether the field 'log' is signed (false). */ public static boolean isSigned_log() { return false; } /** * Return whether the field 'log' is an array (true). */ public static boolean isArray_log() { return true; } /** * Return the offset (in bytes) of the field 'log' */ public static int offset_log(int index1) { int offset = 16; if (index1 < 0 || index1 >= 16) throw new ArrayIndexOutOfBoundsException(); offset += 0 + index1 * 8; return (offset / 8); } /** * Return the offset (in bits) of the field 'log' */ public static int offsetBits_log(int index1) { int offset = 16; if (index1 < 0 || index1 >= 16) throw new ArrayIndexOutOfBoundsException(); offset += 0 + index1 * 8; return offset; } /** * Return the entire array 'log' as a short[] */ public short[] get_log() { short[] tmp = new short[16]; for (int index0 = 0; index0 < numElements_log(0); index0++) { tmp[index0] = getElement_log(index0); } return tmp; } /** * Set the contents of the array 'log' from the given short[] */ public void set_log(short[] value) { for (int index0 = 0; index0 < value.length; index0++) { setElement_log(index0, value[index0]); } } /** * Return an element (as a short) of the array 'log' */ public short getElement_log(int index1) { return (short)getUIntElement(offsetBits_log(index1), 8); } /** * Set an element of the array 'log' */ public void setElement_log(int index1, short value) { setUIntElement(offsetBits_log(index1), 8, value); } /** * Return the total size, in bytes, of the array 'log' */ public static int totalSize_log() { return (128 / 8); } /** * Return the total size, in bits, of the array 'log' */ public static int totalSizeBits_log() { return 128; } /** * Return the size, in bytes, of each element of the array 'log' */ public static int elementSize_log() { return (8 / 8); } /** * Return the size, in bits, of each element of the array 'log' */ public static int elementSizeBits_log() { return 8; } /** * Return the number of dimensions in the array 'log' */ public static int numDimensions_log() { return 1; } /** * Return the number of elements in the array 'log' */ public static int numElements_log() { return 16; } /** * Return the number of elements in the array 'log' * for the given dimension. */ public static int numElements_log(int dimension) { int array_dims[] = { 16, }; if (dimension < 0 || dimension >= 1) throw new ArrayIndexOutOfBoundsException(); if (array_dims[dimension] == 0) throw new IllegalArgumentException("Array dimension "+dimension+" has unknown size"); return array_dims[dimension]; } /** * Fill in the array 'log' with a String */ public void setString_log(String s) { int len = s.length(); int i; for (i = 0; i < len; i++) { setElement_log(i, (short)s.charAt(i)); } setElement_log(i, (short)0); //null terminate } /** * Read the array 'log' as a String */ public String getString_log() { char carr[] = new char[Math.min(net.tinyos.message.Message.MAX_CONVERTED_STRING_LENGTH,16)]; int i; for (i = 0; i < carr.length; i++) { if ((char)getElement_log(i) == (char)0) break; carr[i] = (char)getElement_log(i); } return new String(carr,0,i); } } --- NEW FILE: gpsBcast.class --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gpsBcast.java --- package net.tinyos.gps_mig; import net.tinyos.util.*; import java.io.*; import java.util.Properties; import net.tinyos.message.*; public class gpsBcast implements MessageListener { static Properties p = new Properties(); public static final byte UTC = 1; public static final byte LONGITUDE = 2; public static final byte NS_INDICATOR = 3; public static final byte LATITUDE = 4; public static final byte EW_INDICATOR = 5; public boolean read_log_done = false; public static final short TOS_BCAST_ADDR = (short) 0xffff; public static void usage() { System.err.println("Usage: java net.tinyos.tools.gpsBcast"+ " <group_id> <command> [arguments]"); System.err.println("\twhere <command> and [arguments] can be one of the following:"); System.err.println("\t\tUTC [dest_address]"); System.err.println("\t\tLONGITUDE [dest_address]"); System.err.println("\t\tNS_INDICATOR [dest_address]"); System.err.println("\t\tLATITUDE [dest_address]"); System.err.println("\t\tEW_INDICATOR [dest_address]"); } public static byte restoreSequenceNo() { try { FileInputStream fis = new FileInputStream("bcast.properties"); p.load(fis); byte i = (byte)Integer.parseInt(p.getProperty("sequenceNo", "1")); fis.close(); return i; } catch (IOException e) { p.setProperty("sequenceNo", "1"); return 1; } } public static void saveSequenceNo(int i) { try { FileOutputStream fos = new FileOutputStream("bcast.properties"); p.setProperty("sequenceNo", Integer.toString(i)); p.store(fos, "#Properties for gpsBcast\n"); } catch (IOException e) { System.err.println("Exception while saving sequence number" + e); e.printStackTrace(); } } public static void main(String[] argv) throws IOException{ String cmd; byte group_id = 0; byte sequenceNo = 0; if (argv.length < 2) { usage(); System.exit(-1); } try { group_id = (byte)(Integer.parseInt(argv[0]) & 0xff); } catch (NumberFormatException nfe) { usage(); System.exit(-1); } cmd = argv[1]; gpsCmdMsg packet = new gpsCmdMsg(); sequenceNo = restoreSequenceNo(); packet.set_seqno(sequenceNo); packet.set_hop_count((short)0); packet.set_source(0); if (cmd.equals("UTC")) { packet.set_action(UTC); short address = (short)Integer.parseInt(argv[2]); packet.set_args_rl_args_destaddr(address); } else if (cmd.equals("LONGITUDE")) { packet.set_action(LONGITUDE); short address = (short)Integer.parseInt(argv[2]); packet.set_args_rl_args_destaddr(address); } else if (cmd.equals("NS_INDICATOR")) { packet.set_action(NS_INDICATOR); short address = (short)Integer.parseInt(argv[2]); packet.set_args_rl_args_destaddr(address); } else if (cmd.equals("LATITUDE")) { packet.set_action(LATITUDE); short address = (short)Integer.parseInt(argv[2]); packet.set_args_rl_args_destaddr(address); } else if (cmd.equals("EW_INDICATOR")) { packet.set_action(EW_INDICATOR); short address = (short)Integer.parseInt(argv[2]); packet.set_args_rl_args_destaddr(address); } else { usage(); System.exit(-1); } try { System.err.print("Sending payload: "); for (int i = 0; i < packet.dataLength(); i++) { System.err.print(Integer.toHexString(packet.dataGet()[i] & 0xff)+ " "); } System.err.println(); MoteIF mote = new MoteIF("127.0.0.1", 9000, group_id); gpsBcast bc = null; bc = new gpsBcast(); mote.registerListener(new LogMsg(), bc); mote.start(); mote.send(TOS_BCAST_ADDR, packet); synchronized (bc) { if (bc.read_log_done == false) { System.err.println("Waiting for response to read_log..."); bc.wait(10000); } if (bc.read_log_done == false) { System.err.println("Warning: Timed out waiting for response to read_log command!"); } } saveSequenceNo(sequenceNo+1); System.exit(0); } catch(Exception e) { e.printStackTrace(); } } public void messageReceived(int dest_addr, Message m) { LogMsg lm = (LogMsg) m; System.err.println("Received log message: "+lm); System.err.print("Log values: "); for (int i = 0; i < lm.numElements_log(); i++) { short val = lm.getElement_log(i); System.err.print(Integer.toHexString((int)val)+" "); } System.err.println(""); synchronized (this) { read_log_done = true; this.notifyAll(); } } } --- NEW FILE: gpsCmd.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* tab:4 * Copyright (c) 2000-2002 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." * */ /* * This file is part of the FireBug project. * * FireBug is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * FireBug is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * You should have received a copy of the GNU Lesser General Public License * along with Geotechnica; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ includes gpsCmdMsg; configuration gpsCmd { provides interface gpsRetrieve; } implementation { components Main, gpsCmdM, gps, Logger, GenericComm as Comm, PotC, LedsC; Main.StdControl -> gpsCmdM; SimpleCmdM.Leds -> LedsC; gpsRetrive = gpsCmdM.gpsRetrieve; gpsCmdM.CommControl -> Comm; gpsCmdM.ReceiveCmdMsg -> Comm.ReceiveMsg[AM_GPSCMDMSG]; gpsCmdM.SendLogMsg -> Comm.SendMsg[AM_LOGMSG]; gpsCmdM.LoggerRead -> Logger; gpsCmdM.Pot -> PotC; } --- NEW FILE: gpsCmdM.nc --- /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ /* tab:4 * Copyright (c) 2000-2002 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." * */ /* * This file is part of the FireBug project. * * FireBug is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * FireBug is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * You should have received a copy of the GNU Lesser General Public License * along with Geotechnica; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ includes gpsCmdMsg; module gpsCmdM { provides { interface StdControl; interface gpsRetrieve; } uses { interface Leds; interface Pot; interface ReceiveMsg as ReceiveCmdMsg; interface StdControl as CommControl; interface LoggerRead; interface SendMsg as SendLogMsg; } } implementation { // declare module static variables here TOS_MsgPtr cur_msg; // The current command message TOS_Msg log_msg; // The current log message bool send_pending; // TRUE if a message send is pending bool eeprom_read_pending; // TRUE if an EEPROM read is pending TOS_Msg buf; // Free buffer for message reception task void cmdInterpret() { struct gpsCmdMsg *cmd = (struct gpsCmdMsg *)cur_msg->data; result_t status = SUCCESS; // do local packet modifications: update the hop count and packet source cmd->hop_count++; cmd->source = TOS_LOCAL_ADDRESS; // Execute the command if ((cmd->args.rl_args.destaddr == TOS_LOCAL_ADDRESS) && (eeprom_read_pending == FALSE)) { if (call LoggerRead.read(24+(cmd->action),((struct LogMsg *)log_msg.data)->log)) { eeprom_read_pending = TRUE; } } signal ProcessCmd.done(cur_msg, status); } command result_t StdControl.init() { cur_msg = &buf; send_pending = FALSE; eeprom_read_pending = FALSE; return rcombine(call CommControl.init(), call Leds.init()); } command result_t StdControl.start(){ return SUCCESS; } command result_t StdControl.stop(){ return SUCCESS; } event result_t LoggerRead.readDone(uint8_t * packet, result_t success) { struct LogMsg *lm; if (success && eeprom_read_pending && !send_pending) { lm = (struct LogMsg *)(log_msg.data); lm->sourceaddr = TOS_LOCAL_ADDRESS; if (call SendLogMsg.send(TOS_BCAST_ADDR, sizeof(struct LogMsg), &log_msg)) { call Leds.redOn(); send_pending = TRUE; } } eeprom_read_pending = FALSE; call Leds.yellowOff(); return SUCCESS; } command result_t gpsRetrieve.execute(TOS_MsgPtr pmsg) { cur_msg = pmsg; post cmdInterpret(); return SUCCESS; } event TOS_MsgPtr ReceiveCmdMsg.receive(TOS_MsgPtr pmsg){ result_t retval; TOS_MsgPtr ret = cur_msg; call Leds.greenToggle(); retval = call gpsRetrieve.execute(pmsg); if (retval==SUCCESS) { return ret; } else { return pmsg; } } default event result_t gpsRetrieve.done(TOS_MsgPtr pmsg, result_t status) { return status; } event result_t SendLogMsg.sendDone(TOS_MsgPtr pmsg, result_t status) { call Leds.redOff(); send_pending = FALSE; return status; } } // end of implementation --- NEW FILE: gpsCmdMsg.class --- (This appears to be a binary file; contents omitted.) --- NEW FILE: gpsCmdMsg.h --- enum { AM_GPSCMDMSG = 8, AM_LOGMSG=9 }; enum { UTC = 1, LONGITUDE = 2, NS_INDICATOR = 3, LATITUDE = 4, EW_INDICATOR = 5, }; typedef struct { int nsamples; uint32_t interval; } start_sense_args; typedef struct { uint16_t destaddr; } read_log_args; typedef struct gpsCmdMsg { int8_t seqno; int8_t action; uint16_t source; uint8_t hop_count; union { start_sense_args ss_args; read_log_args rl_args; uint8_t untyped_args[0]; } args; } gpsCmdMsg; // Log message structure typedef struct LogMsg { uint16_t sourceaddr; uint8_t log[16]; } LogMsg; --- NEW FILE: gpsCmdMsg.java --- /** * This class is automatically generated by mig. DO NOT EDIT THIS FILE. * This class implements a Java interface to the 'gpsCmdMsg' * message type. */ package net.tinyos.gps_mig; public class gpsCmdMsg extends net.tinyos.message.Message { /** The default size of this message type in bytes. */ public static final int DEFAULT_MESSAGE_SIZE = 11; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 8; /** Create a new gpsCmdMsg of size 11. */ public gpsCmdMsg() { super(DEFAULT_MESSAGE_SIZE); amTypeSet(AM_TYPE); } /** Create a new gpsCmdMsg of the given data_length. */ public gpsCmdMsg(int data_length) { super(data_length); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg with the given data_length * and base offset. */ public gpsCmdMsg(int data_length, int base_offset) { super(data_length, base_offset); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg using the given byte array * as backing store. */ public gpsCmdMsg(byte[] data) { super(data); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg using the given byte array * as backing store, with the given base offset. */ public gpsCmdMsg(byte[] data, int base_offset) { super(data, base_offset); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg using the given byte array * as backing store, with the given base offset and data length. */ public gpsCmdMsg(byte[] data, int base_offset, int data_length) { super(data, base_offset, data_length); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg embedded in the given message * at the given base offset. */ public gpsCmdMsg(net.tinyos.message.Message msg, int base_offset) { super(msg, base_offset, DEFAULT_MESSAGE_SIZE); amTypeSet(AM_TYPE); } /** * Create a new gpsCmdMsg embedded in the given message * at the given base offset and length. */ public gpsCmdMsg(net.tinyos.message.Message msg, int base_offset, int data_length) { super(msg, base_offset, data_length); amTypeSet(AM_TYPE); } /** /* Return a String representation of this message. Includes the * message type name and the non-indexed field values. */ public String toString() { String s = "Message <gpsCmdMsg> \n"; try { s += " [seqno=0x"+Long.toHexString(get_seqno())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [action=0x"+Long.toHexString(get_action())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [source=0x"+Long.toHexString(get_source())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [hop_count=0x"+Long.toHexString(get_hop_count())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [args.ss_args.nsamples=0x"+Long.toHexString(get_args_ss_args_nsamples())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [args.ss_args.interval=0x"+Long.toHexString(get_args_ss_args_interval())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { s += " [args.rl_args.destaddr=0x"+Long.toHexString(get_args_rl_args_destaddr())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } try { } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } return s; } // Message-type-specific access methods appear below. ///////////////////////////////////////////////////////// // Accessor methods for field: seqno // Field type: byte // Offset (bits): 0 // Size (bits): 8 ///////////////////////////////////////////////////////// /** * Return whether the field 'seqno' is signed (false). */ public static boolean isSigned_seqno() { return false; } /** * Return whether the field 'seqno' is an array (false). */ public static boolean isArray_seqno() { return false; } /** * Return the offset (in bytes) of the field 'seqno' */ public static int offset_seqno() { return (0 / 8); } /** * Return the offset (in bits) of the field 'seqno' */ public static int offsetBits_seqno() { return 0; } /** * Return the value (as a byte) of the field 'seqno' */ public byte get_seqno() { return (byte)getSIntElement(offsetBits_seqno(), 8); } /** * Set the value of the field 'seqno' */ public void set_seqno(byte value) { setSIntElement(offsetBits_seqno(), 8, value); } /** * Return the size, in bytes, of the field 'seqno' */ public static int size_seqno() { return (8 / 8); } /** * Return the size, in bits, of the field 'seqno' */ public static int sizeBits_seqno() { return 8; } ///////////////////////////////////////////////////////// // Accessor methods for field: action // Field type: byte // Offset (bits): 8 // Size (bits): 8 ///////////////////////////////////////////////////////// /** * Return whether the field 'action' is signed (false). */ public static boolean isSigned_action() { return false; } /** * Return whether the field 'action' is an array (false). */ public static boolean isArray_action() { return false; } /** * Return the offset (in bytes) of the field 'action' */ public static int offset_action() { return (8 / 8); } /** * Return the offset (in bits) of the field 'action' */ public static int offsetBits_action() { return 8; } /** * Return the value (as a byte) of the field 'action' */ public byte get_action() { return (byte)getSIntElement(offsetBits_action(), 8); } /** * Set the value of the field 'action' */ public void set_action(byte value) { setSIntElement(offsetBits_action(), 8, value); } /** * Return the size, in bytes, of the field 'action' */ public static int size_action() { return (8 / 8); } /** * Return the size, in bits, of the field 'action' */ public static int sizeBits_action() { return 8; } ///////////////////////////////////////////////////////// // Accessor methods for field: source // Field type: int // Offset (bits): 16 // Size (bits): 16 ///////////////////////////////////////////////////////// /** * Return whether the field 'source' is signed (false). */ public static boolean isSigned_source() { return false; } /** * Return whether the field 'source' is an array (false). */ public static boolean isArray_source() { return false; } /** * Return the offset (in bytes) of the field 'source' */ public static int offset_source() { return (16 / 8); } /** * Return the offset (in bits) of the field 'source' */ public static int offsetBits_source() { return 16; } /** * Return the value (as a int) of the field 'source' */ public int get_source() { return (int)getUIntElement(offsetBits_source(), 16); } /** * Set the value of the field 'source' */ public void set_source(int value) { setUIntElement(offsetBits_source(), 16, value); } /** * Return the size, in bytes, of the field 'source' */ public static int size_source() { return (16 / 8); } /** * Return the size, in bits, of the field 'source' */ public static int sizeBits_source() { return 16; } ///////////////////////////////////////////////////////// // Accessor methods for field: hop_count // Field type: short // Offset (bits): 32 // Size (bits): 8 ///////////////////////////////////////////////////////// /** * Return whether the field 'hop_count' is signed (false). */ public static boolean isSigned_hop_count() { return false; } /** * Return whether the field 'hop_count' is an array (false). */ public static boolean isArray_hop_count() { return false; } /** * Return the offset (in bytes) of the field 'hop_count' */ public static int offset_hop_count() { return (32 / 8); } /** * Return the offset (in bits) of the field 'hop_count' */ public static int offsetBits_hop_count() { return 32; } /** * Return the value (as a short) of the field 'hop_count' */ public short get_hop_count() { return (short)getUIntElement(offsetBits_hop_count(), 8); } /** * Set the value of the field 'hop_count' */ public void set_hop_count(short value) { setUIntElement(offsetBits_hop_count(), 8, value); } /** * Return the size, in bytes, of the field 'hop_count' */ public static int size_hop_count() { return (8 / 8); } /** * Return the size, in bits, of the field 'hop_count' */ public static int sizeBits_hop_count() { return 8; } ///////////////////////////////////////////////////////// // Accessor methods for field: args.ss_args.nsamples // Field type: short // Offset (bits): 40 // Size (bits): 16 ///////////////////////////////////////////////////////// /** * Return whether the field 'args.ss_args.nsamples' is signed (false). */ public static boolean isSigned_args_ss_args_nsamples() { return false; } /** * Return whether the field 'args.ss_args.nsamples' is an array (false). */ public static boolean isArray_args_ss_args_nsamples() { return false; } /** * Return the offset (in bytes) of the field 'args.ss_args.nsamples' */ public static int offset_args_ss_args_nsamples() { return (40 / 8); } /** * Return the offset (in bits) of the field 'args.ss_args.nsamples' */ public static int offsetBits_args_ss_args_nsamples() { return 40; } /** * Return the value (as a short) of the field 'args.ss_args.nsamples' */ public short get_args_ss_args_nsamples() { return (short)getSIntElement(offsetBits_args_ss_args_nsamples(), 16); } /** * Set the value of the field 'args.ss_args.nsamples' */ public void set_args_ss_args_nsamples(short value) { setSIntElement(offsetBits_args_ss_args_nsamples(), 16, value); } /** * Return the size, in bytes, of the field 'args.ss_args.nsamples' */ public static int size_args_ss_args_nsamples() { return (16 / 8); } /** * Return the size, in bits, of the field 'args.ss_args.nsamples' */ public static int sizeBits_args_ss_args_nsamples() { return 16; } ///////////////////////////////////////////////////////// // Accessor methods for field: args.ss_args.interval // Field type: long // Offset (bits): 56 // Size (bits): 32 ///////////////////////////////////////////////////////// /** * Return whether the field 'args.ss_args.interval' is signed (false). */ public static boolean isSigned_args_ss_args_interval() { return false; } /** * Return whether the field 'args.ss_args.interval' is an array (false). */ public static boolean isArray_args_ss_args_interval() { return false; } /** * Return the offset (in bytes) of the field 'args.ss_args.interval' */ public static int offset_args_ss_args_interval() { return (56 / 8); } /** * Return the offset (in bits) of the field 'args.ss_args.interval' */ public static int offsetBits_args_ss_args_interval() { return 56; } /** * Return the value (as a long) of the field 'args.ss_args.interval' */ public long get_args_ss_args_interval() { return (long)getUIntElement(offsetBits_args_ss_args_interval(), 32); } /** * Set the value of the field 'args.ss_args.interval' */ public void set_args_ss_args_interval(long value) { setUIntElement(offsetBits_args_ss_args_interval(), 32, value); } /** * Return the size, in bytes, of the field 'args.ss_args.interval' */ public static int size_args_ss_args_interval() { return (32 / 8); } /** * Return the size, in bits, of the field 'args.ss_args.interval' */ public static int sizeBits_args_ss_args_interval() { return 32; } ///////////////////////////////////////////////////////// // Accessor methods for field: args.rl_args.destaddr // Field type: int // Offset (bits): 40 // Size (bits): 16 ///////////////////////////////////////////////////////// /** * Return whether the field 'args.rl_args.destaddr' is signed (false). */ public static boolean isSigned_args_rl_args_destaddr() { return false; } /** * Return whether the field 'args.rl_args.destaddr' is an array (false). */ public static boolean isArray_args_rl_args_destaddr() { return false; } /** * Return the offset (in bytes) of the field 'args.rl_args.destaddr' */ public static int offset_args_rl_args_destaddr() { return (40 / 8); } /** * Return the offset (in bits) of the field 'args.rl_args.destaddr' */ public static int offsetBits_args_rl_args_destaddr() { return 40; } /** * Return the value (as a int) of the field 'args.rl_args.destaddr' */ public int get_args_rl_args_destaddr() { return (int)getUIntElement(offsetBits_args_rl_args_destaddr(), 16); } /** * Set the value of the field 'args.rl_args.destaddr' */ public void set_args_rl_args_destaddr(int value) { setUIntElement(offsetBits_args_rl_args_destaddr(), 16, value); } /** * Return the size, in bytes, of the field 'args.rl_args.destaddr' */ public static int size_args_rl_args_destaddr() { return (16 / 8); } /** * Return the size, in bits, of the field 'args.rl_args.destaddr' */ public static int sizeBits_args_rl_args_destaddr() { return 16; } ///////////////////////////////////////////////////////// // Accessor methods for field: args.untyped_args // Field type: short[] // Offset (bits): 40 // Size of each element (bits): 8 ///////////////////////////////////////////////////////// /** * Return whether the field 'args.untyped_args' is signed (false). */ public static boolean isSigned_args_untyped_args() { return false; } /** * Return whether the field 'args.untyped_args' is an array (true). */ public static boolean isArray_args_untyped_args() { return true; } /** * Return the offset (in bytes) of the field 'args.untyped_args' */ public static int offset_args_untyped_args(int index1) { int offset = 40; if (index1 < 0) throw new ArrayIndexOutOfBoundsException(); offset += 0 + index1 * 8; return (offset / 8); } /** * Return the offset (in bits) of the field 'args.untyped_args' */ public static int offsetBits_args_untyped_args(int index1) { int offset = 40; if (index1 < 0) throw new ArrayIndexOutOfBoundsException(); offset += 0 + index1 * 8; return offset; } /** * Return the entire array 'args.untyped_args' as a short[] */ public short[] get_args_untyped_args() { throw new IllegalArgumentException("Cannot get field as array - unknown size"); } /** * Set the contents of the array 'args.untyped_args' from the given short[] */ public void set_args_untyped_args(short[] value) { for (int index0 = 0; index0 < value.length; index0++) { setElement_args_untyped_args(index0, value[index0]); } } /** * Return an element (as a short) of the array 'args.untyped_args' */ public short getElement_args_untyped_args(int index1) { return (short)getUIntElement(offsetBits_args_untyped_args(index1), 8); } /** * Set an element of the array 'args.untyped_args' */ public void setElement_args_untyped_args(int index1, short value) { setUIntElement(offsetBits_args_untyped_args(index1), 8, value); } /** * Return the size, in bytes, of each element of the array 'args.untyped_args' */ public static int elementSize_args_untyped_args() { return (8 / 8); } /** * Return the size, in bits, of each element of the array 'args.untyped_args' */ public static int elementSizeBits_args_untyped_args() { return 8; } /** * Return the number of dimensions in the array 'args.untyped_args' */ public static int numDimensions_args_untyped_args() { return 1; } /** * Return the number of elements in the array 'args.untyped_args' * for the given dimension. */ public static int numElements_args_untyped_args(int dimension) { int array_dims[] = { 0, }; if (dimension < 0 || dimension >= 1) throw new ArrayIndexOutOfBoundsException(); if (array_dims[dimension] == 0) throw new IllegalArgumentException("Array dimension "+dimension+" has unknown size"); return array_dims[dimension]; } /** * Fill in the array 'args.untyped_args' with a String */ public void setString_args_untyped_args(String s) { int len = s.length(); int i; for (i = 0; i < len; i++) { setElement_args_untyped_args(i, (short)s.charAt(i)); } setElement_args_untyped_args(i, (short)0); //null terminate } /** * Read the array 'args.untyped_args' as a String */ public String getString_args_untyped_args() { char carr[] = new char[net.tinyos.message.Message.MAX_CONVERTED_STRING_LENGTH]; int i; for (i = 0; i < carr.length; i++) { if ((char)getElement_args_untyped_args(i) == (char)0) break; carr[i] = (char)getElement_args_untyped_args(i); } return new String(carr,0,i); } } --- NEW FILE: gpsRetrieve.nc --- includes AM; interface gpsRetrieve { command result_t execute(TOS_MsgPtr pmsg); event result_t done(TOS_MsgPtr pmsg, result_t status); } Index: gps.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gps.nc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** gps.nc 14 Apr 2003 18:24:56 -0000 1.12 --- gps.nc 22 May 2003 22:29:47 -0000 1.13 *************** *** 1,87 **** ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! ! /* tab:4 ! * Copyright (c) 2000-2002 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." ! * ! */ ! ! /* ! * This file is part of the FireBug project. ! * ! * FireBug is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2, or (at your option) any ! * later version. ! * ! * FireBug is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! ! * You should have received a copy of the GNU Lesser General Public License ! * along with Geotechnica; see the file COPYING. If not, write to the Free ! * Software Foundation, 59 Temple Place - Suite 330, Boston, ! * MA 02111-1307, USA. ! */ ! ! /* ! * @authors C Majidi ! * @date $Date$ ! * ! */ ! ! /* ! * Logs GPS data into mote's EEPROM ! */ ! ! ! includes AM; ! ! configuration gps { ! } ! ! ! implementation { ! ! components Main, ! LedsC, ! ClockC, ! SimpleCmd, ! gpsM, ! //gps_uartM, ! gps_packet; ! ! components GenericComm as Comm; ! ! Main.StdControl -> gpsM; ! ! gpsM.Leds -> LedsC; ! ! gpsM.Clock -> ClockC; ! ! //gpsM.gps_uart -> gps_uartM; ! ! gpsM.SubControl -> Comm; ! ! gpsM.Packet -> gps_packet.Packet; ! ! } ! --- 1,80 ---- ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! ! /* tab:4 ! * Copyright (c) 2000-2002 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." ! * ! */ ! ! /* ! * This file is part of the FireBug project. ! * ! * FireBug is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2, or (at your option) any ! * later version. ! * ! * FireBug is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! ! * You should have received a copy of the GNU Lesser General Public License ! * along with Geotechnica; see the file COPYING. If not, write to the Free ! * Software Foundation, 59 Temple Place - Suite 330, Boston, ! * MA 02111-1307, USA. ! */ ! ! /* ! * @authors C Majidi ! * @date $Date$ ! * ! */ ! ! /* ! * Logs GPS data into mote's EEPROM ! * Only runs on the mica2 platform ! */ ! ! ! includes AM; ! ! configuration gps { ! } ! ! ! implementation { ! ! components Main, ! LedsC, ! gpsM; ! ! components GenericComm as Comm, Logger; ! ! Main.StdControl -> gpsM; ! ! gpsM.Leds -> LedsC; ! gpsM.LoggerWrite -> Logger.LoggerWrite; ! gpsM.LoggerRead -> Logger; ! ! gpsM.SubControl -> Comm; ! gpsM.SubControl -> Logger; ! } ! Index: gpsM.nc =================================================================== RCS file: /cvsroot/firebug/firebug/project/src/gps/gpsM.nc,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** gpsM.nc 18 Apr 2003 20:47:55 -0000 1.25 --- gpsM.nc 22 May 2003 22:29:47 -0000 1.26 *************** *** 1,270 **** ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! /* tab:4 ! * Copyright (c) 2000-2002 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." ! * ! */ ! ! /* ! * This file is part of the FireBug project. ! * ! * FireBug is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2, or (at your option) any ! * later version. ! * ! * FireBug is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! ! * You should have received a copy of the GNU Lesser General Public License ! * along with Geotechnica; see the file COPYING. If not, write to the Free ! * Software Foundation, 59 Temple Place - Suite 330, Boston, ! * MA 02111-1307, USA. ! */ ! /* ! * @authors C Majidi ! * @date $Date$ ! * ! */ ! ! /* Collects location data from a GPS receiver ! * stores it into a mote's EEPROM ! */ ! ! /* Set-up: ! * 1. mount receiver board onto mote ! * 2. power on mote ! * 3. mote collects GPS data and logs it in EEPROM ! * ! * 4. to retrieve data, perform the following: ! * a. load a second mote w/ genericbase ! * b. leave genericbase mote on programming board ! * c. open serial forward on PC: ! * java net.tinyos.sf.SerialForward ! * d. broadcast retrieve command over the radio: ! * java net.tinyos.tools.BcastInject ... ! * <group ID> read_log <gps mote ID> ! * e. packet is sent to the base station via radio ! */ ! ! /* Implementation: ! * 1. Initialize UART at 4800 baud ! * 2. Powerup GPS ! * 3. Set GPS to 9600 and NMEA data format ! * 4. Switch UART to 9600 baud ! * 5. NMEA message received on UART RX (interrupt handler) ! * via gps_packet module ! * 6. Filter for GGA Message and Parse ! * 7. If data valid, store in EEPROM ! * 8. Poweroff GPS ! */ ! ! /* Debugging: ! * Green Light Toggle - GPS receiver initialization ! * Red Light Toggle - UART RX Event ! * Yellow Light Toggle - GPSMsg stored in EEPROM ! */ ! ! includes gps; ! ! //GPS States ! #define GPS_IDLE 0 ! #define GPS_POWERON 1 ! #define GPS_WAKEUP 2 ! #define GPS_INIT 3 //GPS initialization state ! #define GPS_SENDMSG 4 //Send GGA query, not in original code ! #define GPS_LOCATE 5 //GPS searching ! #define GPS_POWEROFF 6 ! ! #define TOS_CLK_DIV 32 ! #define TICS_PER_100MSEC 12 ! ! #define GPS_BAUD4800 50 //GPS NMEA default (does 50 correspond to 4800?) ! #define GPS_BAUD9600 25 //4MHz System Clock rate ! ! ! module gpsM { ! ! provides { ! ! interface StdControl; ! ! // following not needed if gps_uart used ! command result_t SetBaud(char rate); ! } ! ! uses { ! ! interface StdControl as SubControl; ! interface Leds; ! interface Packet; ! interface Clock; ! //interface gps_uart; ! } ! } ! ! ! implementation { ! ! /* ! ****************** ! *Define Variables* ! ****************** ! */ ! ! char cGPSState; ! char NextGPSState; ! char Ticksper100mSec; ! char ClockTickDivider; ! ! /* ! ******************* ! *Initialize Client* ! ******************* ! */ ! ! command result_t StdControl.init() { ! TOSH_SET_PW1_PIN(); // poweroff GPS ! //call gps_uart.init2(GPS_BAUD4800); //init UART at 4800 baud ! call SetBaud(GPS_BAUD4800); //init UART at 4800 baud ! return rcombine(call SubControl.init(), call Leds.init()); ! } ! ! /* ! ******************* ! *Start/Stop Client* ! ******************* ! */ ! ! command result_t StdControl.start() { ! ClockTickDivider = 0; ! Ticksper100mSec = TICS_PER_100MSEC; ! cGPSState = GPS_POWERON; ! call Clock.setRate(TOS_CLK_DIV,2); ! return call SubControl.start(); ! } ! ! command result_t StdControl.stop() { ! cGPSState = GPS_POWEROFF; ! return call SubControl.stop(); ! } ! ! /* ! ******************* ! *Event: Clock Tick* ! ******************* ! */ ! ! event result_t Clock.fire() { ! ! if (cGPSState == GPS_IDLE) { ! return SUCCESS; ! } ! ! //Handler for high rate user clocks ! ClockTickDivider++; ! if (ClockTickDivider < Ticksper100mSec){ ! return SUCCESS; ! } ! ClockTickDivider = 0; ! ! ! /* Most of the switch statement exists to ! * allow a delay between processing successive ! * commands issued to the GPS hardware. ! * Everything between POWERON and POWEROFF ! * could probably be replaced with a function ! * using time delays between calls. ! */ ! switch (cGPSState) { ! ! case GPS_POWERON: ! TOSH_CLR_PW1_PIN(); // Poweron GPS ! //call gps_uart.init2(GPS_BAUD4800); ! //call SetBaud(GPS_BAUD4800); ! NextGPSState = GPS_WAKEUP; ! break; ! ! case GPS_WAKEUP: ! //call Packet.gpsSet(); // set GPS to 9600 baud, NMEA format ! NextGPSState = GPS_INIT; ! break; ! ! case GPS_INIT: ! //call gps_uart.init2(GPS_BAUD9600); ! call SetBaud(GPS_BAUD9600); ! call Leds.greenOn(); // DEBUG: GPS Initialized ! //NextGPSState = GPS_LOCATE; ! NextGPSState = GPS_SENDMSG; ! break; ! ! // NOTE: GPS_SENDMSG not part of original code ! case GPS_SENDMSG: ! call Packet.gpsGGA(); ! NextGPSState = GPS_LOCATE; ! break; ! ! case GPS_LOCATE: ! if (call Packet.nmeaReady()) { ! call Packet.gpsLog(); ! NextGPSState = GPS_POWEROFF; ! } ! break; ! ! case GPS_POWEROFF: ! TOSH_SET_PW1_PIN(); // Poweroff GPS ! NextGPSState = GPS_IDLE; ! break; ! } ! ! cGPSState = NextGPSState; ! return SUCCESS; ! } ! ! /* ! ************************* ! *Set Baud on Client UART* ! ************************* ! * ! *NOTE: not required if gps_uart is used ! * instead, call gps_uart.init2(rate) ! */ ! ! command result_t SetBaud(char rate) { ! //FIXME: Document ! outp(rate, UBRR); //what does this do? ! inp(UDR); //what does this do? ! outp(0xd8, UCR); //what does this do? ! sei(); //what does this do? ! return SUCCESS; ! } ! ! event result_t Packet.rxByteReady(uint8_t data) { ! return SUCCESS; ! } ! ! event result_t Packet.txByteReady(char success) { ! return SUCCESS; ! } ! ! } ! --- 1,407 ---- ! /* -*- Mode: C; c-basic-indent: 3; indent-tabs-mode: nil -*- */ ! ! /* tab:4 ! * Copyright (c) 2000-2002 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." ! * ! */ ! ! /* ! * This file is part of the FireBug project. ! * ! * FireBug is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2, or (at your option) any ! * later version. ! * ! * FireBug is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! ! * You should have received a copy of the GNU Lesser General Public License ! * along with Geotechnica; see the file COPYING. If not, write to the Free ! * Software Foundation, 59 Temple Place - Suite 330, Boston, ! * MA 02111-1307, USA. ! */ ! /* ! * @authors C Majidi ! * @date $Date$ ! * ! */ ! ! /* Collects location data from a GPS receiver ! * stores it into a mote's EEPROM. ! * Only runs on the mica2 platform. ! */ ! ! /* Set-up: ! * 1. mount receiver board onto mote ! * 2. power on mote ! * 3. mote collects GPS data and logs it in EEPROM ! * ! * 4. to retrieve data, perform the following: ! * a. load a second mote w/ genericbase ! * b. leave genericbase mote on programming board ! * c. open serial forward on PC: ! * java net.tinyos.sf.SerialForward ! * d. broadcast retrieve command over the radio: ! * java net.tinyos.tools.BcastInject ... ! * <group ID> read_log <gps mote ID> ! * e. packet is sent to the base station via radio ! */ ! ! /* Implementation: ! * 1. Powerup GPS ! * 2. Set UART1 to 4800 baud ! * 3. Command GPS to output GGA message once per second ! * 4. When # of satellites used > 3, store message ! * a) store each field in a separate line of EEPROM ! * b) data stored in lines 25 to 38 (i.e. 14 fields) ! * 5. Poweroff GPS ! */ ! ! includes gps; ! ! #define MSG_LENGTH 100 ! #define DELIMITER ',' ! ! // MICA 2 UART baud rates ! #define GPS_BAUD_MICA2_57600 15 ! #define GPS_BAUD_MICA2_19200 47 ! #define GPS_BAUD_MICA2_9600 95 ! #define GPS_BAUD_MICA2_4800 191 ! ! ! module gpsM { ! ! provides { ! interface StdControl; ! command result_t getGPS(); ! command result_t waitGPS(); ! command result_t logGPS(uint8_t NMEAstr[MSG_LENGTH]); ! command result_t clearGPS(); ! } ! ! uses { ! interface StdControl as SubControl; ! interface Leds; ! interface LoggerWrite; ! interface LoggerRead; ! } ! } ! ! ! implementation { ! ! uint16_t j; ! uint8_t cmd_msg[MSG_LENGTH]; ! ! /* ! ******************* ! *Initialize Client* ! ******************* ! */ ! ! command result_t StdControl.init() { ! TOSH_MAKE_PW0_OUTPUT(); //make PW1 an output ! //TOSH_SET_PW0_PIN(); //turn on GPS power ! TOSH_CLR_PW0_PIN(); //turn on GPS power ! ! //uart1 also connected to serial flash,.. disable it ! TOSH_MAKE_FLASH_SELECT_OUTPUT(); //make flash memory enable an output ! TOSH_SET_FLASH_SELECT_PIN(); //disable serial flash ! ! // configure uart1 for 4800 baud ! outp(0,UBRR1H); ! outp(GPS_BAUD_MICA2_4800, UBRR1L); ! outp((1<<U2X),UCSR1A); // Set UART double speed ! outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR1C); // Set frame format: 8 data-bits, 1 stop-bit ! // Enable reciever and transmitter, disabletheir interrupts ! inp(UDR1); ! outp(((0 << RXCIE) | (0 << TXCIE) | (1 << RXEN) | (1 << TXEN)) ,UCSR1B); ! ! // configure uart0 for 4800 baud (still runs at 57,6 !!) ! outp(0,UBRR0H); ! outp(GPS_BAUD_MICA2_4800, UBRR0L); ! outp((1<<U2X),UCSR0A); // Set UART double speed ! outp(((1 << UCSZ1) | (1 << UCSZ0)) , UCSR0C); // Set frame format: 8 data-bits, 1 stop-bit ! inp(UDR0); ! // Enable reciever and transmitter, disabletheir interrupts ! outp(((0 << RXCIE) | (0 << TXCIE) | (1 << RXE... [truncated message content] |