예제 #1
0
  /** Wraps access to the specified camera. */
  public Kodak(Device dev) throws IOException {
    try {
      // can we use usbdevfs?
      socket = new USBSocket(dev);
      in = socket.getInputStream();
      out = socket.getOutputStream();

    } catch (IOException e) {

      if ("Linux".equals(System.getProperty("os.name"))) {
        // assume this is the LOCAL implementation
        // semantics are like a half duplex packet stream socket

        // assume just one camera (kernel handles up to 16)
        // single open, per the driver's exclusion policy
        random = new RandomAccessFile("/dev/usb/dc2xx0", "rw");
        in = new InputHack(random);
        out = new OutputHack(random);
      } else {
        throw e;
      }

      // NOTE:  GCJ 2.96 bug on this path ... putting this
      // call here evidently prevented the constructor from
      // returning a null object.  Strange.
      System.err.print("");
    }
    getCameraStatus();
    getCameraType(); // ensures it's a supported camera type
  }
예제 #2
0
  public void close() throws IOException {
    in = null;
    out = null;

    if (random != null) {
      random.close();
      random = null;
    } else if (socket != null) {
      socket.close();
      socket = null;
    }
  }