Ejemplo n.º 1
0
  public static void main(String argv[]) {
    Bus busses[] = null;
    Host host;

    try {

      // FIXME:  option flag for rmi (iiop?) host:port spec.

      host = HostFactory.getHost();
      if (host == null) {
        System.err.println("USB is unavailable, can't run.");
        return;
      }

      System.out.println("<!-- " + host + " -->");

      busses = host.getBusses();
      indentLine(0, "<host busses='" + busses.length + "'>");
      for (int busno = 0; busno < busses.length; busno++) {
        indentLine(2, "<!-- Bus #" + (busno + 1) + " -->");
        // show tree from root hub
        if (busses[busno] != null) {
          try {
            printDevice(2, busses[busno].getRootHub());
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
      indentLine(0, "</host>");

    } catch (SecurityException e) {
      System.err.println("USB permissions problem:");
      System.err.println(e.getMessage());
      System.exit(1);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }