[Tinyos-2-commits] CVS: tinyos-2.x/support/sdk/java/net/tinyos/tools PrintfClient.java, NONE, 1.1 Makefile, 1.4, 1.5

Kevin Klues klueska at users.sourceforge.net
Tue Sep 18 21:39:18 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/support/sdk/java/net/tinyos/tools
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23540

Modified Files:
	Makefile 
Added Files:
	PrintfClient.java 
Log Message:
Added PrintfClient as into net.tinyos.tools

--- NEW FILE: PrintfClient.java ---
/*
 * "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 at cs.wustl.edu)
 * @version $Revision: 1.1 $
 * @date $Date: 2007/09/19 04:39:16 $
 */

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<msg.totalSize_buffer(); i++) {
      char nextChar = (char)(msg.getElement_buffer(i));
      if(nextChar != 0)
        System.out.print(nextChar);
    }
  }
  
  private static void usage() {
    System.err.println("usage: PrintfClient [-comm <source>]");
  }
  
  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);
  }
}

Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/support/sdk/java/net/tinyos/tools/Makefile,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile	12 Dec 2006 18:23:00 -0000	1.4
--- Makefile	19 Sep 2007 04:39:16 -0000	1.5
***************
*** 6,10 ****
--- 6,17 ----
  #
  
+ 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 $@
+ 



More information about the Tinyos-2-commits mailing list