From 88b30dc1ada08f40bed2b6d25aca268fa30e83de Mon Sep 17 00:00:00 2001 From: klueska Date: Wed, 19 Sep 2007 04:39:16 +0000 Subject: [PATCH] Added PrintfClient as into net.tinyos.tools --- support/sdk/java/net/tinyos/tools/Makefile | 7 ++ .../java/net/tinyos/tools/PrintfClient.java | 85 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 support/sdk/java/net/tinyos/tools/PrintfClient.java diff --git a/support/sdk/java/net/tinyos/tools/Makefile b/support/sdk/java/net/tinyos/tools/Makefile index 1102a8a4..7caa0c86 100644 --- a/support/sdk/java/net/tinyos/tools/Makefile +++ b/support/sdk/java/net/tinyos/tools/Makefile @@ -5,6 +5,13 @@ # @author TinyOS Team # +INITIAL_TARGETS = PrintfMsg.class + ROOT = ../../.. include $(ROOT)/Makefile.include +PRINTF_H = $(TOSDIR)/lib/printf/printf.h + +PrintfMsg.java: $(PRINTF_H) + mig java $(CFLAGS) -java-classname=net.tinyos.tools.PrintfMsg $(PRINTF_H) printf_msg -o $@ + diff --git a/support/sdk/java/net/tinyos/tools/PrintfClient.java b/support/sdk/java/net/tinyos/tools/PrintfClient.java new file mode 100644 index 00000000..06dac45d --- /dev/null +++ b/support/sdk/java/net/tinyos/tools/PrintfClient.java @@ -0,0 +1,85 @@ +/* + * "Copyright (c) 2006 Washington University in St. Louis. + * 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 WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON + * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * WASHINGTON UNIVERSITY IN ST. LOUIS 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 WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS." + */ + +/** + * @author Kevin Klues (klueska@cs.wustl.edu) + * @version $Revision$ + * @date $Date$ + */ + +package net.tinyos.tools; + +import java.io.IOException; + +import net.tinyos.message.*; +import net.tinyos.tools.*; +import net.tinyos.packet.*; +import net.tinyos.util.*; + +public class PrintfClient implements MessageListener { + + private MoteIF moteIF; + + public PrintfClient(MoteIF moteIF) { + this.moteIF = moteIF; + this.moteIF.registerListener(new PrintfMsg(), this); + } + + public void messageReceived(int to, Message message) { + PrintfMsg msg = (PrintfMsg)message; + for(int i=0; i]"); + } + + public static void main(String[] args) throws Exception { + String source = ""; + if (args.length == 2) { + if (!args[0].equals("-comm")) { + usage(); + System.exit(1); + } + source = args[1]; + } + else { + usage(); + System.exit(1); + } + + PhoenixSource phoenix; + if (source == null) { + phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); + } + else { + phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); + } + System.out.print(phoenix); + MoteIF mif = new MoteIF(phoenix); + PrintfClient client = new PrintfClient(mif); + } +} -- 2.39.2