[Firebug-cvs] firebug/project/java/src/org/firebug GPSLogger.java,NONE,1.1 DBLogger.java,1.26,1.27 F
Brought to you by:
doolin
Update of /cvsroot/firebug/firebug/project/java/src/org/firebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30727/src/org/firebug Modified Files: DBLogger.java FireLogger.java FireMsg.java GGAMsg.java ListenFB.java RangeLogger.java RangeMsg.java Added Files: GPSLogger.java Log Message: Reconfigured the ListenFB to accept arbitrary message AM types as long as there is a single byte magic number occupying the first byte of the payload. --- NEW FILE: GPSLogger.java --- package org.firebug; import org.firebug.database.MysqlDBHandler; import java.io.*; import java.sql.*; import java.util.Random; import net.tinyos.message.*; public class GPSLogger implements ListenFB.PacketPrinter { private MysqlDBHandler dbh; // Move this into some test code later. private Random rand = new Random(); public GPSLogger (String dbname) { dbh = new MysqlDBHandler("localhost","3306","root","",dbname,true); } public void print(InputStream in) { } /** All of the private methods for extracting * data from packets are deterministic, that is, * these methods should work on any random packet. */ private int getMoteID (byte [] packet) { int baseID=packet[5]; return baseID; //id; } private int get_packet_type(byte [] packet) { return (int)packet[2]; } public void print_packet_raw(byte [] packet) { for (int i = 0; i < packet.length; i++) { System.out.print(packet[i] + " "); } System.out.println("\n"); } public void print(byte [] packet) { GGAMsg msg = new GGAMsg(packet,5); Connection conn = dbh.getConnection(); int mote_id = msg.get_mote_id(); int hours = msg.get_hours(); int minutes = msg.get_minutes(); float dec_sec = msg.get_dec_sec(); int Lat_deg = msg.get_Lat_deg(); float Lat_dec_min = msg.get_Lat_dec_min(); int Long_deg = msg.get_Long_deg(); float Long_dec_min = msg.get_Long_dec_min(); int NSEWind = msg.get_NSEWind(); int num_sats = msg.get_num_sats(); //print_packet_raw(packet); /** FIXME: Ugly flow control using exception logic to * to track down a bbad statement, needs to be cleaned up. */ try { ResultSet rs; Statement stmt = conn.createStatement(); String insertquery = "INSERT INTO location VALUES (" + mote_id + ", " + hours + ", " + minutes + ", " + dec_sec + ", " + Lat_deg + ", " + Lat_dec_min + ", " + Long_deg + ", " + Long_dec_min + ", " + NSEWind + "," + num_sats + ")"; try { rs = stmt.executeQuery(insertquery); } catch (SQLException sqle) { System.out.println("Problem with insert statement: " + insertquery); sqle.printStackTrace(); } stmt.close(); } catch (SQLException sqle) { System.out.println("Problem with statement"); sqle.printStackTrace(); } dbh.return_connection(conn); } private static void test() { String database_name = "test"; GPSLogger dbl = new GPSLogger(database_name); while (true) { TestGPSLogger.test(dbl); try { Thread.sleep(3000); } catch (Exception e) { System.out.println(e); } } } public static void main(String [] args) { test(); } } /** FIXME: This whole test class needs to be fixed, or deleted. */ class TestGPSLogger { /** "test" is the _only_public_method_ in this * class. */ public static boolean test(GPSLogger dbl) { byte mote_id = (byte)0xff; FireMsg fmsg = new FireMsg(); fmsg.set_mote_id(1); fmsg.set_cnt(15); fmsg.set_temp(11); fmsg.set_rel_hum(12); fmsg.set_baro_pres(13); fmsg.set_lux(14); byte [] packet = {0x7e, //header 0x0, //header 0x0a, //packet type 0x7d, //group id 0x1a, //payload length 0x01, //routing 0x01, //routing 0x01, //routing 0x02, //routing 0x03, //routing mote_id, 0x12,0x67, //temp 0x37,0x2d, //rel_hum 0x4a,0x22 //baro }; dbl.print(packet); dbl.print_packet_raw(fmsg.dataGet()); return false; } /** All of the following methods are private * for a reason: they are only to be used in this * class. */ private static int getRandomID(int baseID) { int id = baseID + Math.abs(rand.nextInt())%5; return id; } private static float getRandomTemp(float basetemp) { float temp = (float)(basetemp + (3*rand.nextGaussian())); return temp; } private static float getRandomRelHum(float baserelhum) { float relhum = (float)(baserelhum + (3*rand.nextGaussian())); return relhum; } private static float getRandomBaroPres(float basebaropres) { float baropres = (float)(basebaropres + (3*rand.nextGaussian())); return baropres; } private static Random rand = new Random(); } Index: FireLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/FireLogger.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FireLogger.java 19 Feb 2004 17:41:53 -0000 1.2 --- FireLogger.java 27 Mar 2004 00:04:47 -0000 1.3 *************** *** 64,68 **** System.out.println(fmsg.toString()); ! int mote_id = fmsg.get_addr(); int cnt = fmsg.get_cnt(); float temp = fmsg.get_temp(); --- 64,68 ---- System.out.println(fmsg.toString()); ! int mote_id = fmsg.get_mote_id(); int cnt = fmsg.get_cnt(); float temp = fmsg.get_temp(); *************** *** 148,155 **** - - - - dbh.return_connection(conn); --- 148,151 ---- *************** *** 208,212 **** FireMsg fmsg = new FireMsg(); ! fmsg.set_addr(getRandomID(1)); fmsg.set_cnt(15); fmsg.set_temp(getRandomTemp((float)27.0)); --- 204,208 ---- FireMsg fmsg = new FireMsg(); ! fmsg.set_mote_id(getRandomID(1)); fmsg.set_cnt(15); fmsg.set_temp(getRandomTemp((float)27.0)); Index: RangeLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/RangeLogger.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RangeLogger.java 11 Mar 2004 23:53:36 -0000 1.1 --- RangeLogger.java 27 Mar 2004 00:04:47 -0000 1.2 *************** *** 65,68 **** --- 65,72 ---- //SensorMsg msg = new SensorMsg(packet,5,19); + int am_type = (int)(packet[5]&0xFF); + + + RangeMsg msg = new RangeMsg(packet,5,RangeMsg.DEFAULT_MESSAGE_SIZE); Index: ListenFB.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/ListenFB.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ListenFB.java 11 Mar 2004 23:52:00 -0000 1.18 --- ListenFB.java 27 Mar 2004 00:04:47 -0000 1.19 *************** *** 55,60 **** --- 55,68 ---- private OutputStream out; + /** This is lame, but anything else gets real hard real fast. */ + private static int AM_FIREDATA_MSG = 128; + private static int AM_RANGEDATA_MSG = 129; + private static int AM_GGAMSG = 130; + private static FireLogger firelogger; + private static RangeLogger rangelogger; + private static GPSLogger gpslogger; + /** Use this interface when changing the output * of the packet printing. Note that the packet *************** *** 97,100 **** --- 105,119 ---- + private PacketPrinter GetPrinter(int am_type) { + + if (am_type == AM_FIREDATA_MSG) { + return firelogger; + } else if (am_type == AM_RANGEDATA_MSG) { + return rangelogger; + } else { + return null; + } + } + public void open() throws NoSuchPortException, PortInUseException, *************** *** 149,152 **** --- 168,174 ---- } + static int extract_am_type(byte [] packet) { + return (int)(packet[5]&0xFF); + } /** FIXME: Need some changes here. First, change the *************** *** 158,167 **** * msg printer. */ ! public void read(Vector printers) throws IOException { ! //public void read(PacketPrinter printer) throws IOException { - //int i; - //int count = 0; - //byte[] packet = new byte[MAX_MSG_SIZE]; PacketSource reader = BuildSource.makePacketSource(); if (reader == null) { --- 180,186 ---- * msg printer. */ ! //public void read(Vector printers) throws IOException { ! public void read() throws IOException { PacketSource reader = BuildSource.makePacketSource(); if (reader == null) { *************** *** 173,184 **** reader.open(PrintStreamMessenger.err); for (;;) { byte[] packet = reader.readPacket(); ! Enumeration enum = printers.elements(); ! while (enum.hasMoreElements()) { ! PacketPrinter printer = (PacketPrinter)enum.nextElement(); ! printer.print(packet); ! } ! ! System.out.println(); } } --- 192,205 ---- reader.open(PrintStreamMessenger.err); for (;;) { + byte[] packet = reader.readPacket(); ! ! /** Right here we need to extract a magic number from the ! * payload to determine which kind of payload it is. ! */ ! int am_type = extract_am_type(packet); ! System.out.println("AM type number: " + am_type); ! PacketPrinter printer = GetPrinter(am_type); ! printer.print(packet); } } *************** *** 187,227 **** } - /* - // Note that i is an integer, in.read() - // is returning 4 bytes at a time. - while ((i = in.read()) != -1) { - - String val = Integer.toHexString( i & 0xff); - if (val.length() == 1) { - val = "0" + val; - } - - if(i == 0x7e || count != 0){ - - // We have to cast i from int to byte... - packet[count] = (byte)i; - System.out.print(val + " "); // Packet data - count++; - if (count >= MAX_MSG_SIZE) { - System.out.println(); - count = 0; - packetLength = MAX_MSG_SIZE; - // Might be faster to index the Vector. - Enumeration enum = printers.elements(); - while (enum.hasMoreElements()) { - PacketPrinter printer = (PacketPrinter)enum.nextElement(); - printer.print(packet); - } - } - } - else{ - System.out.println("extra byte: " + val); - } - } - */ - } --- 208,215 ---- } + } *************** *** 260,294 **** handle_args(args); - - Vector printers = new Vector(5); - String port = args[args.length - 1]; ListenFB reader = new ListenFB(port); - //SensorPacket print = new SensorPacket(); - //DBLogger dblogger = new DBLogger(dbname); - - //RawPacket rawpacket = new RawPacket(); - //FireLogger firelogger = new FireLogger(dbname); - RangeLogger rangelogger = new RangeLogger(dbname); - - //RawPacket rawpacket = new RawPacket(); - //FireLogger firelogger = new FireLogger(dbname); - //GPSLogger gpslogger = new GPSLogger(dbname); - - - //printers.add(print); - //printers.add(dblogger); - - //printers.add(firelogger); - printers.add(rangelogger); - - - //printers.add(firelogger); - //printers.add(gpslogger); try { ! //reader.open(); ! reader.read(printers); } catch (Exception e) { e.printStackTrace(); --- 248,260 ---- handle_args(args); String port = args[args.length - 1]; ListenFB reader = new ListenFB(port); + firelogger = new FireLogger(dbname); + rangelogger = new RangeLogger(dbname); + gpslogger = new GPSLogger(dbname); try { ! reader.read(); } catch (Exception e) { e.printStackTrace(); Index: DBLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/DBLogger.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** DBLogger.java 11 Mar 2004 23:52:00 -0000 1.26 --- DBLogger.java 27 Mar 2004 00:04:47 -0000 1.27 *************** *** 212,216 **** */ ! fmsg.set_addr(1); fmsg.set_cnt(15); fmsg.set_temp(11); --- 212,216 ---- */ ! fmsg.set_mote_id(1); fmsg.set_cnt(15); fmsg.set_temp(11); Index: FireMsg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/FireMsg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FireMsg.java 11 Mar 2004 23:52:00 -0000 1.2 --- FireMsg.java 27 Mar 2004 00:04:47 -0000 1.3 *************** *** 10,19 **** /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 20; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 128; ! /** Create a new FireMsg of size 20. */ public FireMsg() { super(DEFAULT_MESSAGE_SIZE); --- 10,19 ---- /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 21; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 128; ! /** Create a new FireMsg of size 21. */ public FireMsg() { super(DEFAULT_MESSAGE_SIZE); *************** *** 88,91 **** --- 88,94 ---- String s = "Message <FireMsg> \n"; try { + s += " [magic=0x"+Long.toHexString(get_magic())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { s += " [mote_id=0x"+Long.toHexString(get_mote_id())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } *************** *** 111,117 **** ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int ! // Offset (bits): 0 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 114,183 ---- ///////////////////////////////////////////////////////// + // Accessor methods for field: magic + // Field type: short + // Offset (bits): 0 + // Size (bits): 8 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'magic' is signed (true). + */ + public static boolean isSigned_magic() { + return true; + } + + /** + * Return whether the field 'magic' is an array (false). + */ + public static boolean isArray_magic() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'magic' + */ + public static int offset_magic() { + return (0 / 8); + } + + /** + * Return the offset (in bits) of the field 'magic' + */ + public static int offsetBits_magic() { + return 0; + } + + /** + * Return the value (as a short) of the field 'magic' + */ + public short get_magic() { + return (short)getUIntElement(offsetBits_magic(), 8); + } + + /** + * Set the value of the field 'magic' + */ + public void set_magic(short value) { + setUIntElement(offsetBits_magic(), 8, value); + } + + /** + * Return the size, in bytes, of the field 'magic' + */ + public static int size_magic() { + return (8 / 8); + } + + /** + * Return the size, in bits, of the field 'magic' + */ + public static int sizeBits_magic() { + return 8; + } + + ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int ! // Offset (bits): 8 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 135,139 **** */ public static int offset_mote_id() { ! return (0 / 8); } --- 201,205 ---- */ public static int offset_mote_id() { ! return (8 / 8); } *************** *** 142,146 **** */ public static int offsetBits_mote_id() { ! return 0; } --- 208,212 ---- */ public static int offsetBits_mote_id() { ! return 8; } *************** *** 176,180 **** // Accessor methods for field: cnt // Field type: int ! // Offset (bits): 16 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 242,246 ---- // Accessor methods for field: cnt // Field type: int ! // Offset (bits): 24 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 198,202 **** */ public static int offset_cnt() { ! return (16 / 8); } --- 264,268 ---- */ public static int offset_cnt() { ! return (24 / 8); } *************** *** 205,209 **** */ public static int offsetBits_cnt() { ! return 16; } --- 271,275 ---- */ public static int offsetBits_cnt() { ! return 24; } *************** *** 239,243 **** // Accessor methods for field: temp // Field type: float ! // Offset (bits): 32 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 305,309 ---- // Accessor methods for field: temp // Field type: float ! // Offset (bits): 40 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 261,265 **** */ public static int offset_temp() { ! return (32 / 8); } --- 327,331 ---- */ public static int offset_temp() { ! return (40 / 8); } *************** *** 268,272 **** */ public static int offsetBits_temp() { ! return 32; } --- 334,338 ---- */ public static int offsetBits_temp() { ! return 40; } *************** *** 302,306 **** // Accessor methods for field: rel_hum // Field type: float ! // Offset (bits): 64 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 368,372 ---- // Accessor methods for field: rel_hum // Field type: float ! // Offset (bits): 72 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 324,328 **** */ public static int offset_rel_hum() { ! return (64 / 8); } --- 390,394 ---- */ public static int offset_rel_hum() { ! return (72 / 8); } *************** *** 331,335 **** */ public static int offsetBits_rel_hum() { ! return 64; } --- 397,401 ---- */ public static int offsetBits_rel_hum() { ! return 72; } *************** *** 365,369 **** // Accessor methods for field: baro_pres // Field type: float ! // Offset (bits): 96 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 431,435 ---- // Accessor methods for field: baro_pres // Field type: float ! // Offset (bits): 104 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 387,391 **** */ public static int offset_baro_pres() { ! return (96 / 8); } --- 453,457 ---- */ public static int offset_baro_pres() { ! return (104 / 8); } *************** *** 394,398 **** */ public static int offsetBits_baro_pres() { ! return 96; } --- 460,464 ---- */ public static int offsetBits_baro_pres() { ! return 104; } *************** *** 428,432 **** // Accessor methods for field: lux // Field type: float ! // Offset (bits): 128 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 494,498 ---- // Accessor methods for field: lux // Field type: float ! // Offset (bits): 136 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 450,454 **** */ public static int offset_lux() { ! return (128 / 8); } --- 516,520 ---- */ public static int offset_lux() { ! return (136 / 8); } *************** *** 457,461 **** */ public static int offsetBits_lux() { ! return 128; } --- 523,527 ---- */ public static int offsetBits_lux() { ! return 136; } Index: RangeMsg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/RangeMsg.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RangeMsg.java 11 Mar 2004 23:53:36 -0000 1.1 --- RangeMsg.java 27 Mar 2004 00:04:47 -0000 1.2 *************** *** 10,19 **** /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 8; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 129; ! /** Create a new RangeMsg of size 8. */ public RangeMsg() { super(DEFAULT_MESSAGE_SIZE); --- 10,19 ---- /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 9; /** The Active Message type associated with this message. */ public static final int AM_TYPE = 129; ! /** Create a new RangeMsg of size 9. */ public RangeMsg() { super(DEFAULT_MESSAGE_SIZE); *************** *** 88,91 **** --- 88,94 ---- String s = "Message <RangeMsg> \n"; try { + s += " [magic=0x"+Long.toHexString(get_magic())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { s += " [mote_id=0x"+Long.toHexString(get_mote_id())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } *************** *** 105,111 **** ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int, unsigned ! // Offset (bits): 0 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 108,177 ---- ///////////////////////////////////////////////////////// + // Accessor methods for field: magic + // Field type: short, unsigned + // Offset (bits): 0 + // Size (bits): 8 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'magic' is signed (false). + */ + public static boolean isSigned_magic() { + return false; + } + + /** + * Return whether the field 'magic' is an array (false). + */ + public static boolean isArray_magic() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'magic' + */ + public static int offset_magic() { + return (0 / 8); + } + + /** + * Return the offset (in bits) of the field 'magic' + */ + public static int offsetBits_magic() { + return 0; + } + + /** + * Return the value (as a short) of the field 'magic' + */ + public short get_magic() { + return (short)getUIntElement(offsetBits_magic(), 8); + } + + /** + * Set the value of the field 'magic' + */ + public void set_magic(short value) { + setUIntElement(offsetBits_magic(), 8, value); + } + + /** + * Return the size, in bytes, of the field 'magic' + */ + public static int size_magic() { + return (8 / 8); + } + + /** + * Return the size, in bits, of the field 'magic' + */ + public static int sizeBits_magic() { + return 8; + } + + ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int, unsigned ! // Offset (bits): 8 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 129,133 **** */ public static int offset_mote_id() { ! return (0 / 8); } --- 195,199 ---- */ public static int offset_mote_id() { ! return (8 / 8); } *************** *** 136,140 **** */ public static int offsetBits_mote_id() { ! return 0; } --- 202,206 ---- */ public static int offsetBits_mote_id() { ! return 8; } *************** *** 170,174 **** // Accessor methods for field: count // Field type: int, unsigned ! // Offset (bits): 16 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 236,240 ---- // Accessor methods for field: count // Field type: int, unsigned ! // Offset (bits): 24 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 192,196 **** */ public static int offset_count() { ! return (16 / 8); } --- 258,262 ---- */ public static int offset_count() { ! return (24 / 8); } *************** *** 199,203 **** */ public static int offsetBits_count() { ! return 16; } --- 265,269 ---- */ public static int offsetBits_count() { ! return 24; } *************** *** 233,237 **** // Accessor methods for field: rssi // Field type: int, unsigned ! // Offset (bits): 32 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 299,303 ---- // Accessor methods for field: rssi // Field type: int, unsigned ! // Offset (bits): 40 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 255,259 **** */ public static int offset_rssi() { ! return (32 / 8); } --- 321,325 ---- */ public static int offset_rssi() { ! return (40 / 8); } *************** *** 262,266 **** */ public static int offsetBits_rssi() { ! return 32; } --- 328,332 ---- */ public static int offsetBits_rssi() { ! return 40; } *************** *** 296,300 **** // Accessor methods for field: voltage // Field type: int, unsigned ! // Offset (bits): 48 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 362,366 ---- // Accessor methods for field: voltage // Field type: int, unsigned ! // Offset (bits): 56 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 318,322 **** */ public static int offset_voltage() { ! return (48 / 8); } --- 384,388 ---- */ public static int offset_voltage() { ! return (56 / 8); } *************** *** 325,329 **** */ public static int offsetBits_voltage() { ! return 48; } --- 391,395 ---- */ public static int offsetBits_voltage() { ! return 56; } Index: GGAMsg.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/GGAMsg.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GGAMsg.java 11 Mar 2004 23:52:00 -0000 1.3 --- GGAMsg.java 27 Mar 2004 00:04:47 -0000 1.4 *************** *** 10,19 **** /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 20; /** The Active Message type associated with this message. */ ! public static final int AM_TYPE = 129; ! /** Create a new GGAMsg of size 20. */ public GGAMsg() { super(DEFAULT_MESSAGE_SIZE); --- 10,19 ---- /** The default size of this message type in bytes. */ ! public static final int DEFAULT_MESSAGE_SIZE = 21; /** The Active Message type associated with this message. */ ! public static final int AM_TYPE = 130; ! /** Create a new GGAMsg of size 21. */ public GGAMsg() { super(DEFAULT_MESSAGE_SIZE); *************** *** 88,91 **** --- 88,94 ---- String s = "Message <GGAMsg> \n"; try { + s += " [magic=0x"+Long.toHexString(get_magic())+"]\n"; + } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } + try { s += " [mote_id=0x"+Long.toHexString(get_mote_id())+"]\n"; } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ } *************** *** 123,129 **** ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int, unsigned ! // Offset (bits): 0 // Size (bits): 16 ///////////////////////////////////////////////////////// --- 126,195 ---- ///////////////////////////////////////////////////////// + // Accessor methods for field: magic + // Field type: short, unsigned + // Offset (bits): 0 + // Size (bits): 8 + ///////////////////////////////////////////////////////// + + /** + * Return whether the field 'magic' is signed (false). + */ + public static boolean isSigned_magic() { + return false; + } + + /** + * Return whether the field 'magic' is an array (false). + */ + public static boolean isArray_magic() { + return false; + } + + /** + * Return the offset (in bytes) of the field 'magic' + */ + public static int offset_magic() { + return (0 / 8); + } + + /** + * Return the offset (in bits) of the field 'magic' + */ + public static int offsetBits_magic() { + return 0; + } + + /** + * Return the value (as a short) of the field 'magic' + */ + public short get_magic() { + return (short)getUIntElement(offsetBits_magic(), 8); + } + + /** + * Set the value of the field 'magic' + */ + public void set_magic(short value) { + setUIntElement(offsetBits_magic(), 8, value); + } + + /** + * Return the size, in bytes, of the field 'magic' + */ + public static int size_magic() { + return (8 / 8); + } + + /** + * Return the size, in bits, of the field 'magic' + */ + public static int sizeBits_magic() { + return 8; + } + + ///////////////////////////////////////////////////////// // Accessor methods for field: mote_id // Field type: int, unsigned ! // Offset (bits): 8 // Size (bits): 16 ///////////////////////////////////////////////////////// *************** *** 147,151 **** */ public static int offset_mote_id() { ! return (0 / 8); } --- 213,217 ---- */ public static int offset_mote_id() { ! return (8 / 8); } *************** *** 154,158 **** */ public static int offsetBits_mote_id() { ! return 0; } --- 220,224 ---- */ public static int offsetBits_mote_id() { ! return 8; } *************** *** 188,192 **** // Accessor methods for field: hours // Field type: short, unsigned ! // Offset (bits): 16 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 254,258 ---- // Accessor methods for field: hours // Field type: short, unsigned ! // Offset (bits): 24 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 210,214 **** */ public static int offset_hours() { ! return (16 / 8); } --- 276,280 ---- */ public static int offset_hours() { ! return (24 / 8); } *************** *** 217,221 **** */ public static int offsetBits_hours() { ! return 16; } --- 283,287 ---- */ public static int offsetBits_hours() { ! return 24; } *************** *** 251,255 **** // Accessor methods for field: minutes // Field type: short, unsigned ! // Offset (bits): 24 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 317,321 ---- // Accessor methods for field: minutes // Field type: short, unsigned ! // Offset (bits): 32 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 273,277 **** */ public static int offset_minutes() { ! return (24 / 8); } --- 339,343 ---- */ public static int offset_minutes() { ! return (32 / 8); } *************** *** 280,284 **** */ public static int offsetBits_minutes() { ! return 24; } --- 346,350 ---- */ public static int offsetBits_minutes() { ! return 32; } *************** *** 314,318 **** // Accessor methods for field: dec_sec // Field type: float, unsigned ! // Offset (bits): 32 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 380,384 ---- // Accessor methods for field: dec_sec // Field type: float, unsigned ! // Offset (bits): 40 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 336,340 **** */ public static int offset_dec_sec() { ! return (32 / 8); } --- 402,406 ---- */ public static int offset_dec_sec() { ! return (40 / 8); } *************** *** 343,347 **** */ public static int offsetBits_dec_sec() { ! return 32; } --- 409,413 ---- */ public static int offsetBits_dec_sec() { ! return 40; } *************** *** 377,381 **** // Accessor methods for field: Lat_deg // Field type: short, unsigned ! // Offset (bits): 64 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 443,447 ---- // Accessor methods for field: Lat_deg // Field type: short, unsigned ! // Offset (bits): 72 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 399,403 **** */ public static int offset_Lat_deg() { ! return (64 / 8); } --- 465,469 ---- */ public static int offset_Lat_deg() { ! return (72 / 8); } *************** *** 406,410 **** */ public static int offsetBits_Lat_deg() { ! return 64; } --- 472,476 ---- */ public static int offsetBits_Lat_deg() { ! return 72; } *************** *** 440,444 **** // Accessor methods for field: Lat_dec_min // Field type: float, unsigned ! // Offset (bits): 72 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 506,510 ---- // Accessor methods for field: Lat_dec_min // Field type: float, unsigned ! // Offset (bits): 80 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 462,466 **** */ public static int offset_Lat_dec_min() { ! return (72 / 8); } --- 528,532 ---- */ public static int offset_Lat_dec_min() { ! return (80 / 8); } *************** *** 469,473 **** */ public static int offsetBits_Lat_dec_min() { ! return 72; } --- 535,539 ---- */ public static int offsetBits_Lat_dec_min() { ! return 80; } *************** *** 503,507 **** // Accessor methods for field: Long_deg // Field type: short, unsigned ! // Offset (bits): 104 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 569,573 ---- // Accessor methods for field: Long_deg // Field type: short, unsigned ! // Offset (bits): 112 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 525,529 **** */ public static int offset_Long_deg() { ! return (104 / 8); } --- 591,595 ---- */ public static int offset_Long_deg() { ! return (112 / 8); } *************** *** 532,536 **** */ public static int offsetBits_Long_deg() { ! return 104; } --- 598,602 ---- */ public static int offsetBits_Long_deg() { ! return 112; } *************** *** 566,570 **** // Accessor methods for field: Long_dec_min // Field type: float, unsigned ! // Offset (bits): 112 // Size (bits): 32 ///////////////////////////////////////////////////////// --- 632,636 ---- // Accessor methods for field: Long_dec_min // Field type: float, unsigned ! // Offset (bits): 120 // Size (bits): 32 ///////////////////////////////////////////////////////// *************** *** 588,592 **** */ public static int offset_Long_dec_min() { ! return (112 / 8); } --- 654,658 ---- */ public static int offset_Long_dec_min() { ! return (120 / 8); } *************** *** 595,599 **** */ public static int offsetBits_Long_dec_min() { ! return 112; } --- 661,665 ---- */ public static int offsetBits_Long_dec_min() { ! return 120; } *************** *** 629,633 **** // Accessor methods for field: NSEWind // Field type: short, unsigned ! // Offset (bits): 144 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 695,699 ---- // Accessor methods for field: NSEWind // Field type: short, unsigned ! // Offset (bits): 152 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 651,655 **** */ public static int offset_NSEWind() { ! return (144 / 8); } --- 717,721 ---- */ public static int offset_NSEWind() { ! return (152 / 8); } *************** *** 658,662 **** */ public static int offsetBits_NSEWind() { ! return 144; } --- 724,728 ---- */ public static int offsetBits_NSEWind() { ! return 152; } *************** *** 692,696 **** // Accessor methods for field: num_sats // Field type: short, unsigned ! // Offset (bits): 152 // Size (bits): 8 ///////////////////////////////////////////////////////// --- 758,762 ---- // Accessor methods for field: num_sats // Field type: short, unsigned ! // Offset (bits): 160 // Size (bits): 8 ///////////////////////////////////////////////////////// *************** *** 714,718 **** */ public static int offset_num_sats() { ! return (152 / 8); } --- 780,784 ---- */ public static int offset_num_sats() { ! return (160 / 8); } *************** *** 721,725 **** */ public static int offsetBits_num_sats() { ! return 152; } --- 787,791 ---- */ public static int offsetBits_num_sats() { ! return 160; } |