[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla PromiscuousListener.java, 1.1, 1.2

Chien-Liang Fok chien-liang at users.sourceforge.net
Sat Apr 8 09:43:43 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15914/edu/wustl/mobilab/agilla

Modified Files:
	PromiscuousListener.java 
Log Message:


Index: PromiscuousListener.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/agilla/PromiscuousListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PromiscuousListener.java	13 Oct 2005 17:12:19 -0000	1.1
--- PromiscuousListener.java	8 Apr 2006 16:43:38 -0000	1.2
***************
*** 63,67 ****
   * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
   * 94704.  Attention:  Intel License Inquiry.
!  */
  /* Authors: Chien-Liang Fok <liang at cse.wustl.edu>
   * Date:        May 2 2005
--- 63,67 ----
   * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
   * 94704.  Attention:  Intel License Inquiry.
!  */
  /* Authors: Chien-Liang Fok <liang at cse.wustl.edu>
   * Date:        May 2 2005
***************
*** 72,76 ****
  import net.tinyos.packet.*;
  import net.tinyos.util.*;
! import edu.wustl.mobilab.agilla.messages.*;
  /**
   * @author Chien-Liang Fok <liang at cse.wustl.edu>
--- 72,76 ----
  import net.tinyos.packet.*;
  import net.tinyos.util.*;
! 
  /**
   * @author Chien-Liang Fok <liang at cse.wustl.edu>
***************
*** 78,98 ****
  public class PromiscuousListener implements AgillaConstants {
  	private MoteIF moteIF = null;
- 	private String source;
  	private PhoenixSource psource;
  	private SNInterface sni;
  	
  	public PromiscuousListener(String source, boolean debug) throws Exception {
- 		this.source = source;
  		Debugger.debug = debug;
! 		connect();
! 	}
! 	
! 	/**
! 	 * Connects the AgentInjector to the MoteIF.
! 	 */
! 	public void connect() {
  		try {
! 			if (source.equals("tossim-serial"))
! 				moteIF = new MoteIF(PrintStreamMessenger.err);
  			else {
  				psource = BuildSource.makePhoenix(
--- 78,91 ----
  public class PromiscuousListener implements AgillaConstants {
  	private MoteIF moteIF = null;
  	private PhoenixSource psource;
  	private SNInterface sni;
  	
  	public PromiscuousListener(String source, boolean debug) throws Exception {
  		Debugger.debug = debug;
! 		Debugger.printAllMsgs = true;
! 		
  		try {
! 			if (source.startsWith("sf"))
! 				moteIF = new MoteIF(BuildSource.makePhoenix(source, PrintStreamMessenger.err));
  			else {
  				psource = BuildSource.makePhoenix(
***************
*** 103,130 ****
  		} catch (Exception e) {
  			e.printStackTrace();
  		}
  		sni = new SNInterface(true);
! 		sni.setMoteIF(moteIF);
! 	}
! 	
! 	/**
! 	 * Disconnects the AgentInjector from the MoteIF.
! 	 */
! 	public void disconnect() {
! 		psource.shutdown();
! 		sni.disconnect();
! 		moteIF = null;
! 	}
! 	
! 	public boolean isConnected() {
! 		return moteIF == null;
! 	}
! 
! 	public void registerListener(MessageJ msg, MessageListenerJ listener) {
! 		sni.registerListener(msg, listener);
! 	}
! 	
! 	public void deregisterListener(MessageJ msg, MessageListenerJ listener) {
! 		sni.deregisterListener(msg, listener);
  	}
  	
--- 96,103 ----
  		} catch (Exception e) {
  			e.printStackTrace();
+ 			System.exit(1);
  		}
  		sni = new SNInterface(true);
! 		sni.setMoteIF(moteIF);		
  	}
  	
***************
*** 154,163 ****
  			e.printStackTrace();
  		}
! 	}
  	private static void usage() {
! 		System.err.println("usage: PromiscuousListener[-h|--help|-comm <source>|-d]");
! 		System.err
! 			.println("\t-comm <source> where <source> is COMx:[platform] or tossim-serial or RMI:address, default COM4:mica2");
  		System.err.println("\t-d for debug mode");
  	}
! }
--- 127,137 ----
  			e.printStackTrace();
  		}
! 	}
  	private static void usage() {
! 		System.err.println("usage: PromiscuousListener[-h | -comm <source> | -d]");
! 		System.err.println("\t-h prints this help message");
! 		System.err.println("\t-comm <source> where <source> is COMx:[platform] or sf at localhost:[port]");
  		System.err.println("\t-d for debug mode");
+ 		System.err.println("\nExample usage:\njava edu.wustl.mobilab.agilla.PromiscuousListener -comm COM51:tmote 2>&1 | text.txt");
  	}
! }



More information about the Tinyos-contrib-commits mailing list