[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestRadioPM/apps/TestSerialDebug Makefile, NONE, 1.1.2.1 PrintSerialDebugMsgs.java, NONE, 1.1.2.1 TestSerialDebugAppC.nc, NONE, 1.1.2.1 TestSerialDebugC.nc, NONE, 1.1.2.1

Kevin Klues klueska at users.sourceforge.net
Mon May 15 12:36:09 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestRadioPM/apps/TestSerialDebug
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9561/apps/tests/TestRadioPM/apps/TestSerialDebug

Added Files:
      Tag: tos-2-resource-pm-eval-cand
	Makefile PrintSerialDebugMsgs.java TestSerialDebugAppC.nc 
	TestSerialDebugC.nc 
Log Message:
Radio Power Management protocol architecture

--- NEW FILE: Makefile ---
BASE_DIR = $(TOSROOT)/apps/tests/TestRadioPM/lib/

COMPONENT=TestSerialDebugAppC

CFLAGS += -I$(BASE_DIR)/serialDebug
BUILD_EXTRA_DEPS += SerialDebugMsg.class PrintSerialDebugMsgs.class

%.class: %.java
	javac $<

SerialDebugMsg.java: $(BASE_DIR)/serialDebug/SerialDebugMsg.h
	mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=SerialDebugMsg $(BASE_DIR)/serialDebug/SerialDebugMsg.h SerialDebugMsg -o $@

include $(MAKERULES)


--- NEW FILE: PrintSerialDebugMsgs.java ---
/*									tab:4
 * "Copyright (c) 2005 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."
 *
 */

/**
 * Java-side application for testing serial port communication.
 * Modified to just receive packets of type NumSenderMsgs and
 * print them out
 * 
 *
 * @author Phil Levis <pal at cs.berkeley.edu>
 * @author Kevin Klues <klueska at cs.wustl.edu>
 * @date August 12 2005
 */

import java.io.IOException;

import net.tinyos.message.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;

public class PrintSerialDebugMsgs implements MessageListener {

  private MoteIF moteIF;
  
  public PrintSerialDebugMsgs(MoteIF moteIF) {
    this.moteIF = moteIF;
    this.moteIF.registerListener(new SerialDebugMsg(), this);
  }

  public void messageReceived(int to, Message message) {
    SerialDebugMsg msg = (SerialDebugMsg)message;
    for(int i=0; i<msg.get_num_vars(); i++) {
      int numChars =0;
      char nextChar = (char)(msg.getElement_vars(i, numChars++));
      System.out.print(nextChar);
      while(nextChar != 0 && numChars<8) {
        nextChar = (char)(msg.getElement_vars(i, numChars++));
        System.out.print(nextChar);
      }
      System.out.print(": " + msg.getElement_vals(i) + "\n");
    }
  }
  
  private static void usage() {
    System.err.println("usage: PrintSerialDebugMsgs [-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);
    }
    MoteIF mif = new MoteIF(phoenix);
    PrintSerialDebugMsgs serial = new PrintSerialDebugMsgs(mif);
  }


}

--- NEW FILE: TestSerialDebugAppC.nc ---
/*
 * "Copyright (c) 2005 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.2.1 $
 * @date $Date: 2006/05/15 19:36:07 $
 */

#include "SerialDebugMsg.h"

configuration TestSerialDebugAppC {}
implementation {
  components LedsC;
  components TestSerialDebugC as App;
  components SerialDebugC;

  App.Boot -> SerialDebugC;
  App.Leds -> LedsC;
  App.SerialDebug -> SerialDebugC;
}


--- NEW FILE: TestSerialDebugC.nc ---
/*
 * "Copyright (c) 2005 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.2.1 $
 * @date $Date: 2006/05/15 19:36:07 $ 
 */

module TestSerialDebugC {
  uses {
    interface Boot;
    interface Leds;
    interface SerialDebug;
  }
}
implementation {

  event void Boot.booted() {
    call SerialDebug.print("0123456789", 20);
    call SerialDebug.print("1234567890", 25);
    call SerialDebug.print("2345678901", 30);
    call SerialDebug.print("3456789012", 35);
    call SerialDebug.print("3456789012", 65539);

    call SerialDebug.flush();
  }

  event void SerialDebug.flushDone(error_t error) {
    call SerialDebug.print("0123456789", 20);
    call SerialDebug.print("1234567890", 25);
    call SerialDebug.print("2345678901", 30);
    call SerialDebug.print("3456789012", 35);
    call SerialDebug.print("3456789012", 65539);

    call SerialDebug.flush();    
  }
}



More information about the Tinyos-2-commits mailing list