Exemple #1
0
  public static void main(String[] args) throws Exception {
    String source = null;
    if (args.length == 2) {
      if (!args[0].equals("-comm")) {
        usage();
        System.exit(1);
      }
      source = args[1];
    } else if (args.length != 0) {
      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);
    TestSerial serial = new TestSerial(mif);
    serial.sendPackets();
  }
Exemple #2
0
 static void help() {
   System.out.println("");
   System.out.println("Usage: java RawLogger [options] ");
   System.out.println("  [options] are:");
   System.out.println("  -h, --help                  Display this message.");
   System.out.println("  --logging                   Enable Logging.");
   System.out.println("                              Required options (source). ");
   System.out.println("                              And (url, user, pass, tablename). ");
   System.out.println("  --display                   Display Packets.");
   System.out.println("                              Required options (source). ");
   System.out.println("  --createtable               Create a table.");
   System.out.println(
       "                              Required options (url, user, pass, tablename).");
   System.out.println("  --droptable                 Drop a table.");
   System.out.println(
       "                              Required options (url, user, pass, tablename).");
   System.out.println("  --cleartable                Clear a table.");
   System.out.println(
       "                              Required options (url, user, pass, tablename).");
   System.out.println("  --duration                  Summary of Experiement Duration.");
   System.out.println(
       "                              Required options (url, user, pass, tablename).");
   System.out.println("  --reset                     Reseting EPRB and the attached mote ");
   System.out.println("                              Required options (source). ");
   System.out.println("  --tablename=<name>          Specify sql tablename ");
   System.out.println("  --url=<ip/dbname>           JDBC URL. eg: localhost/rsc.");
   System.out.println("  --user=<user>               User of the database.");
   System.out.println("  --pass=<password>           Password of the database.");
   System.out.println("  --source=<type>             Standard TinyOS Source");
   System.out.println("                              serial@COM1:platform");
   System.out.println("                              network@HOSTNAME:PORTNUMBER");
   System.out.println("                              sf@HOSTNAME:PORTNUMBER");
   System.out.println("");
   System.exit(-1);
 }
Exemple #3
0
  public static void duration() {
    connectDb();
    String sql = "select min(time), max(time), count(*) from " + tablename + ";";
    try {
      ResultSet rs = query.executeQuery(sql);
      rs.next();
      int numCols = rs.getMetaData().getColumnCount();
      String minTime = rs.getString(1);
      String maxTime = rs.getString(2);
      String numPackets = rs.getString(3);
      System.out.println(
          "Experiment "
              + tablename
              + "\n\tfrom: "
              + minTime
              + "\n\tto: "
              + maxTime
              + "\n\tpackets: "
              + numPackets);

    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e);
      System.exit(1);
    }
  }
Exemple #4
0
  public void run() {

    // setup advertisement message
    advMsg.set_sourceAddr(TOS_UART_ADDR);

    if (reboot) {
      advMsg.set_summary_vNum(0x0);
      advMsg.set_runningVNum(0xffff);
    } else {
      advMsg.set_summary_vNum(0xffff);
      advMsg.set_runningVNum(0x0);
    }
    advMsg.set_summary_numPgsComplete((byte) numPgs);

    while (true) {
      try {
        // send an advertisement message every second
        if (printAllMsgs) System.out.print(advMsg);
        send(advMsg);
        Thread.currentThread().sleep(1000);
        if (reboot) {
          System.exit(0);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemple #5
0
  Download(String[] args) {

    boolean done = false;
    boolean dumpSrec2 = false;
    String infile = "";
    vNum = -1;

    for (int i = 0; i < args.length; i++) {
      if (done) usage();

      if (args[i].equals("--srecfile")) {
        infile = args[++i];
      } else if (args[i].equals("--printmsgs")) {
        printAllMsgs = true;
      } else if (args[i].equals("--dumpsrec")) {
        dumpSrec2 = true;
      } else if (args[i].equals("--reboot")) {
        reboot = true;
      } else if (args[i].equals("-h") || args[i].equals("--help")) usage();
      else usage();
    }
    if (!reboot) {
      if (infile.equals("")) {
        usage();
      } else {
        readSrecCode(infile);
      }
    }

    if (dumpSrec2) {
      dumpSrec();
      System.exit(0);
    }

    try {
      intf = new MoteIF((Messenger) null);
      intf.registerListener(new DelugeAdvMsg(), this);
      intf.registerListener(new DelugeReqUpdMetadataMsg(), this);
      intf.registerListener(new DelugeReqMsg(), this);
    } catch (Exception e) {
      System.out.println("ERROR: Couldn't contact serial forwarder.");
      System.exit(1);
    }

    intf.start();
  }
Exemple #6
0
 private static void usage() {
   System.err.println("usage: java net.tinyos.drain.Drip <opts>");
   System.err.println("  -d <data value>");
   System.err.println("  -c <channel id>");
   System.err.println("  -w : send message with wakeup bit set");
   System.err.println("  -h, --help : this information");
   System.exit(1);
 }
Exemple #7
0
  public synchronized void messageReceived(int to, Message m) {

    switch (m.amType()) {
      case DelugeAdvMsg.AM_TYPE:
        DelugeAdvMsg rxAdvMsg = (DelugeAdvMsg) m;

        if (vNum == rxAdvMsg.get_summary_vNum()
            && numPgs == rxAdvMsg.get_summary_numPgsComplete()) {
          // ALL DONE, QUIT!
          System.out.println("DOWNLOAD COMPLETE!");
          System.out.println("--------------------------------------------------");
          System.exit(0);
        }

        break;

      case DelugeReqUpdMetadataMsg.AM_TYPE:
        DelugeReqUpdMetadataMsg reqUpd = (DelugeReqUpdMetadataMsg) m;

        if (printAllMsgs) System.out.print(reqUpd);
        vNum = (short) (reqUpd.get_vNum() + 1);
        advMsg.set_summary_vNum(vNum);

        System.out.print("Upgrading from version [" + reqUpd.get_vNum() + "]");
        System.out.println(" to version [" + vNum + "]");

        transmitMetadataUpd();

        break;

      case DelugeReqMsg.AM_TYPE:
        DelugeReqMsg req = (DelugeReqMsg) m;

        if (printAllMsgs) System.out.print(req);

        if (vNum != req.get_vNum()) {
          System.out.println("ERROR: Node requesting wrong version");
          System.exit(1);
        }

        transmitPage(req.get_pgNum());

        break;
    }
  }
Exemple #8
0
 private void usage() {
   System.err.println("usage: java net.tinyos.deluge.Download [options]");
   System.err.println("[options] are:");
   System.err.println("  --srecfile <srec> : srec file to download");
   System.err.println("  --reboot          : send reboot command to network");
   System.err.println("  --dumpsrec        : dumps hex of srec image");
   System.err.println("  --printmsgs       : print all sent/received msgs");
   System.exit(1);
 }
Exemple #9
0
 public synchronized void send(Message m) {
   try {
     intf.send(MoteIF.TOS_BCAST_ADDR, m);
   } catch (IOException e) {
     e.printStackTrace();
     System.out.println("ERROR: Can't send message");
     System.exit(1);
   }
 }
Exemple #10
0
 private void send(Message m) {
   try {
     moteIF.send(MoteIF.TOS_BCAST_ADDR, m);
   } catch (IOException e) {
     e.printStackTrace();
     System.out.println("ERROR: Can't send message");
     System.exit(1);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public AntiTheftGui() {
   try {
     guiInit();
     /* Setup communication with the mote and request a messageReceived
     callback when an AlertMsg is received */
     mote = new MoteIF(this);
     mote.registerListener(new AlertMsg(), this);
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(2);
   }
 }
Exemple #12
0
 static void connectDb() {
   // before: localhost/rsc
   sqlURL = "jdbc:postgresql://" + sqlURL;
   // after: "jdbc:postgresql://localhost/rsc";
   // "jdbc:postgresql://webbie.berkeley.intel-research.net/rsc"
   try {
     Class.forName("org.postgresql.Driver");
   } catch (ClassNotFoundException cnfe) {
     System.out.println("Couldn't find the driver!");
     System.out.println("Let's print a stack trace, and exit.");
     System.exit(1);
   }
   Connection connection = null;
   try {
     connection = DriverManager.getConnection(sqlURL, sqlUser, sqlPassword);
     query = connection.createStatement();
   } catch (SQLException se) {
     System.out.println("Couldn't connect: " + se);
     System.exit(1);
   }
 }
Exemple #13
0
  public static void clearTable() {
    connectDb();
    String sql = "delete from " + tablename + ";";
    try {
      query.executeUpdate(sql);

    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e);
      System.exit(1);
    }
    System.out.println("Table Cleared Successfully");
  }
Exemple #14
0
  public Drip(int id) {

    log.info("Started id=" + id);
    try {
      moteIF = new MoteIF();
      moteIF.registerListener(new DripMsg(), this);
    } catch (Exception e) {
      System.out.println("ERROR: Couldn't contact serial forwarder.");
      System.exit(1);
    }

    this.id = id;
  }
Exemple #15
0
  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);
  }
  public TestTtsp() {
    try {
      mote = new MoteIF(PrintStreamMessenger.err);
      mote.registerListener(new TestTtspMsg(), this);
      System.out.println("Connecting to basestation...OK");
    } catch (Exception e) {
      System.out.println("Connecting to basestation...FAILED");
      e.printStackTrace();
      System.exit(2);
    }

    System.out.println(
        "[Reception Time (ms)] [Node] [Beacon] [GlobalTime (ms)] [LocalTime (ms)] [Offset (ms)] [Root] [Period]");
  }
Exemple #17
0
  public static void main(String[] args) {

    parseArgs(args);

    Drip drip = new Drip(channel);
    TestDripMsg msg = new TestDripMsg();
    msg.set_data((short) data);

    if (wakeup) {
      drip.sendWakeup(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
    } else {
      drip.send(msg, TestDripMsg.DEFAULT_MESSAGE_SIZE);
    }
    System.exit(0);
  }
Exemple #18
0
  public static void reset() {
    // network@ip:10002
    String address = source.substring(8, source.length() - 6);

    try {
      Socket server = new Socket(address, 9999);
      DataOutputStream out = new DataOutputStream(server.getOutputStream());
      out.writeBytes("\r\n");
      out.flush();
      out.writeBytes("9\r\n");
      out.flush();
    } catch (Exception e) {
      System.out.println("Sorry I can't reset the device fro some reason: " + e);
      System.exit(1);
    }
    System.out.println("Issued reset command to " + address);
  }
  public static void main(String[] args) {
    String motePort = null;
    String outputFile = null;
    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-comm")) {
        motePort = args[++i];
        System.out.println("Using mote port: " + motePort);
      } else if (args[i].equals("-file")) {
        outputFile = args[++i];
        System.out.println("Saving data to: " + outputFile);
      } else {
        usage();
        System.exit(1);
      }
    }

    RadioSignalMeter meter = new RadioSignalMeter(motePort, outputFile);
  }
Exemple #20
0
  public static void createTable() {
    connectDb();
    String dataField = "";
    for (int i = 0; i < AM_HEADER_LENGTH + TOSH_DATA_LENGTH + CRC_LENGTH; i++) {
      dataField = dataField + ", " + "b" + Integer.toString(i) + " smallint";
    }
    String sql =
        "create table "
            + tablename
            + " (time timestamp without time zone, packetid serial"
            + dataField;
    sql += ", primary key (packetid) );";
    try {
      query.executeUpdate(sql);

    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e);
      System.exit(1);
    }
    System.out.println("Initialise Table Successfully");
  }
Exemple #21
0
  public static void main(String[] args) throws Exception {
    String source = null;
    Vector v = new Vector();
    if (args.length > 0) {
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("-comm")) {
          source = args[++i];
        } else {
          String className = args[i];
          try {
            Class c = Class.forName(className);
            Object packet = c.newInstance();
            Message msg = (Message) packet;
            if (msg.amType() < 0) {
              System.err.println(className + " does not have an AM type - ignored");
            } else {
              v.addElement(msg);
            }
          } catch (Exception e) {
            System.err.println(e);
          }
        }
      }
    } else if (args.length != 0) {
      usage();
      System.exit(1);
    }

    MsgReader mr = new MsgReader(source);
    Enumeration msgs = v.elements();
    while (msgs.hasMoreElements()) {
      Message m = (Message) msgs.nextElement();
      mr.addMsgType(m);
    }
    mr.start();
  }
Exemple #22
0
 public static void usage() {
   System.err.println("java net.tinyos.wakeup.Wakeup {both,bat,cap} <timeout in seconds>");
   System.exit(1);
 }