Package ch.ntb.inf.libusbJava

Examples of ch.ntb.inf.libusbJava.Device


    System.out.println();
  }

  public static void main(String[] args) {
    // get a device instance with vendor id and product id
    Device dev = USB.getDevice((short) 0x8235, (short) 0x0100);
    try {
      // data to write to the device
      byte[] data = new byte[] { 0, 1, 2, 3 };
      // data read from the device
      byte[] readData = new byte[data.length];

      // open the device with configuration 1, interface 0 and without
      // altinterface
      // this will initialise Libusb for you
      dev.open(1, 0, -1);
      // write some data to the device
      // 0x03 is the endpoint address of the OUT endpoint 3 (from PC to
      // device)
      dev.writeInterrupt(0x02, data, data.length, 2000, false);
      // read some data from the device
      // 0x84 is the endpoint address of the IN endpoint 4 (from PC to
      // device)
      // bit 7 (0x80) is set in case of an IN endpoint
      dev.readInterrupt(0x86, readData, readData.length, 2000, false);
      // log the data from the device
      logData(readData);
      // close the device
      dev.close();
    } catch (USBException e) {
      // if an exception occures during connect or read/write an exception
      // is thrown
      e.printStackTrace();
    }
View Full Code Here


    String oldFilename = dev.getDevice().getFilename();
    String oldBusName = dev.getDevice().getBus().getDirname();
    assertNotNull(oldFilename);
    assertNotNull(oldBusName);
    log.info("filename: " + oldFilename + ", busName: " + oldBusName);
    Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
        .getIdProduct());
    doClose();
    assertEquals(dev, dev2);
  }
View Full Code Here

    String oldFilename = dev.getDevice().getFilename();
    String oldBusName = dev.getDevice().getBus().getDirname();
    assertNotNull(oldFilename);
    assertNotNull(oldBusName);
    log.info("filename: " + oldFilename + ", busName: " + oldBusName);
    Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
        .getIdProduct(), oldBusName, null);
    doClose();
    assertEquals(dev, dev2);
  }
View Full Code Here

    String oldFilename = dev.getDevice().getFilename();
    String oldBusName = dev.getDevice().getBus().getDirname();
    assertNotNull(oldFilename);
    assertNotNull(oldBusName);
    log.info("filename: " + oldFilename + ", busName: " + oldBusName);
    Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
        .getIdProduct(), null, oldFilename);
    doClose();
    assertEquals(dev, dev2);
  }
View Full Code Here

    String oldFilename = dev.getDevice().getFilename();
    String oldBusName = dev.getDevice().getBus().getDirname();
    assertNotNull(oldFilename);
    assertNotNull(oldBusName);
    log.info("filename: " + oldFilename + ", busName: " + oldBusName);
    Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
        .getIdProduct(), oldBusName, oldFilename);
    doClose();
    assertEquals(dev, dev2);
  }
View Full Code Here

TOP

Related Classes of ch.ntb.inf.libusbJava.Device

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.