Exemple #1
0
  private static void printDiamondDetails(int indent, DeviceDescriptor info) {
    Device dev = info.getDevice();

    if (info.getProductId() != 0x0001) {
      indentLine(indent, "That's not a Rio 500 ...");
      return;
    }
    Rio500 rio = null;

    try {
      indentLine(indent, "Rio 500 Status: ");
      indent += 2;

      rio = new Rio500(dev);
      rio.start();

      // basic memory statistics
      showStorage(indent, rio, false);
      if (rio.hasExternalMemory()) showStorage(indent, rio, true);

    } catch (Exception e) {
      e.printStackTrace(System.out);
      return;
    } finally {
      if (rio != null) rio.finish();
    }
  }
Exemple #2
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();
    }
  }
Exemple #3
0
  private static void showStorage(int indent, Rio500 rio, boolean external) throws IOException {
    Rio500.MemoryStatus mem;
    int temp;

    indentLine(indent, external ? "SmartMedia" : "Built-in Memory");
    indent += 2;

    temp = rio.getFreeMemory(external);
    indentLine(
        indent,
        "Available Memory in bytes:  "
            + (temp / (1024 * 1024))
            + "."
            + ((10 * (temp % (1024 * 1024))) / (1024 * 1024))
            + " MB, ");
    mem = rio.getMemoryStatus(external);
    temp = mem.getBlockCount();
    if (temp != 0) temp = ((temp - mem.getNumUnusedBlocks()) * 100) / temp;
    else temp = 1000;

    indentLine(
        indent,
        "Memory status: "
            + mem.getBlockCount()
            + " Blocks, "
            + mem.getBlockSize()
            + " bytes each, "
            + mem.getNumUnusedBlocks()
            + " blocks unused "
            + temp
            + "% full ");
    indentLine(indent, "First free block at 0x" + Integer.toHexString(mem.getFirstFreeBlock()));

    // dump folders and their contents
    Rio500.FolderEntry folders[] = rio.getFolders(external);

    for (int i = 0; i < folders.length; i++) {
      Rio500.FolderEntry f = folders[i];

      indentLine(
          indent,
          "Folder # "
              + i
              + ", offset = 0x"
              + Integer.toHexString(f.getOffset())
              + ", name1 = "
              + f.getName1()
              // + ", name2 = "
              // + f.getName2 ()
              + ", entries = "
              + f.getSongCount());
      indent += 2;
      try {
        Rio500.SongEntry songs[] = f.getSongs();

        for (int j = 0; j < songs.length; j++) {
          Rio500.SongEntry s = songs[j];
          indentLine(
              indent,
              "Song # "
                  + j
                  + ", offset = 0x"
                  + Integer.toHexString(s.getOffset())
                  + ", kbytes = "
                  + (s.getLength() / 1024));
          indentLine(
              indent + 4, "name1 = " + s.getName1()
              // + ", name2 = "
              // + s.getName2 ()
              );
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      indent -= 2;
    }
  }
Exemple #4
0
  private static void printKodakDetails(int indent, DeviceDescriptor info) {
    String type;

    switch (info.getProductId()) {
        //
        // "Taka" serial/usb protocol, dating back to DC-50
        //
      case 0x0120:
        type = "dc240";
        break;
      case 0x0130:
        type = "dc280";
        break;
      case 0x0131:
        type = "dc5000";
        break;
      case 0x0132:
        type = "dc3400";
        break;

        //
        // DigitaOS serial/usb protocol isn't Kodak-proprietary.
        // Also used by HP PhotoSmart C500
        //
      case 0x0100: // dc220
      case 0x0110: // dc260
      case 0x0111: // dc265
      case 0x0112: // dc290
        indentLine(indent, "http://ods.sourceforge.net/");
        return;

        //
        // There are many other old serial protocols that have been
        // brought forward into USB.  One hopes that vendor-neutral
        // standards will start to really catch on.
        //

        //
        // PTP protocol -- based on an ISO draft, intended to
        // be neutral with respect to vendor and protocol.  New.
        //
        // Doesn't have serial line legacy features.
        //
      case 0x0121: // dc240 with PTP prototype firmware
      case 0x0160: // dc4800
        indentLine(indent, "http://jphoto.sourceforge.net/");

        // FIXME:  if jPhoto is available it should
        // be able to plug itself in ...

        return;

      default:
        indentLine(indent, "I don't know about this product.");
        return;
    }
    indentLine(indent, "I can talk to a " + type + " ...");

    try {
      Kodak camera = new Kodak(info.getDevice());

      indentLine(indent, "Current camera status: ");
      camera.printSomeStatus(indent);

    } catch (IOException e) {
      indentLine(indent, "... but I can't do it just now.");
      indentLine(indent, e.getMessage());

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