Examples of UsbDevice


Examples of javax.usb.UsbDevice

   * @author Jan Roberts
   *
   */
  private UsbDevice findDevice(UsbHub hub)
  {
    UsbDevice cm19a = null;

    Iterator iterator = hub.getUsbPorts().iterator();

    while (iterator.hasNext())
    {
      UsbPort port = (UsbPort) iterator.next();

      if (port.isUsbDeviceAttached())
      {
        UsbDevice device = port.getUsbDevice();

        /* Is this the device? If so, quit looking */
        if (device.isUsbHub())
        {
          cm19a = findDevice((UsbHub) device);

          if (isCM19ADevice(cm19a))
          {
View Full Code Here

Examples of javax.usb.UsbDevice

    {
      throw new CM19AException("No virtual root usb hub found");
    }

    /* Find the attached CM19a */
    UsbDevice cm19a = findDevice(virtualRootUsbHub);

    if (cm19a == null)
    {
      throw new CM19AException("No CM19a found; /dev/bus/usb permissions problem?");
    }

    if (logger.isDebugEnabled())
    {
      StringBuilder builder = new StringBuilder("Device found and  configured is ");
      if (!cm19a.isConfigured())
      {
        builder.append("not");
      }
      builder.append(" configured");
      logger.debug(builder.toString());
    }

    UsbConfiguration config = cm19a.getActiveUsbConfiguration();
    if (config == null)
    {
      throw new CM19AException("No active configuration found");
    }

    /* Get the first interface, there should only be one */
    UsbInterface usbInterface = (UsbInterface) config.getUsbInterfaces().get(0);

    logger.debug("Got device; Manufacturer is " + cm19a.getManufacturerString());
    logger.debug("Got interface; Active is " + usbInterface.isActive() + " Claimed is " + usbInterface.isClaimed());

    try
    {
      usbInterface.claim();
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

    }

    @Override
    protected void startDevice() throws DriverException {
        try {
            USBDevice usbDevice = (USBDevice) getDevice();
            USBConfiguration conf = usbDevice.getConfiguration(0);
            usbDevice.setConfiguration(conf);
            // Set usb mass storage informations.
            this.storageDeviceData = new USBStorageDeviceData(usbDevice);
            USBDataPipe pipe;
            pipe = (USBDataPipe) this.storageDeviceData.getBulkOutEndPoint().getPipe();
            pipe.addListener(this);
            pipe.open();

            pipe = (USBDataPipe) this.storageDeviceData.getBulkInEndPoint().getPipe();
            pipe.addListener(this);
            pipe.open();

            usbDevice.registerAPI(SCSIHostControllerAPI.class, this);
            final Bus hostBus = new USBStorageSCSIHostBus(getDevice());
            scsiDevice = new USBStorageSCSIDevice(hostBus, "_sg");

            // Execute INQUIRY
            try {
                scsiDevice.inquiry();
            } catch (SCSIException ex) {
                throw new DriverException("Cannot INQUIRY device", ex);
            } catch (TimeoutException ex) {
                throw new DriverException("Cannot INQUIRY device : timeout", ex);
            } catch (InterruptedException ex) {
                throw new DriverException("Interrupted while INQUIRY device", ex);
            }
            // Register the generic SCSI device.
            try {
                final DeviceManager dm = usbDevice.getManager();
                dm.rename(scsiDevice, "sg", true);
                dm.register(scsiDevice);
                dm.rename(usbDevice, SCSIHostControllerAPI.DEVICE_PREFIX, true);
            } catch (DeviceAlreadyRegisteredException ex) {
                throw new DriverException(ex);
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

     */
    public Driver findDriver(Device device) {
        if (!(device instanceof USBDevice)) {
            return null;
        }
        final USBDevice dev = (USBDevice) device;
        if (dev.getDescriptor().getDeviceClass() != USB_CLASS_PER_INTERFACE) {
            return null;
        }
        final USBConfiguration conf = dev.getConfiguration(0);
        final USBInterface intf = conf.getInterface(0);
        final InterfaceDescriptor descr = intf.getDescriptor();
        if (descr.getInterfaceClass() != USB_CLASS_MASS_STORAGE) {
            return null;
        }
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

    @Override
    protected void startDevice() throws DriverException {

        UsbBluetoothDevice UsbBtDevice = new UsbBluetoothDevice();

        final USBDevice dev = (USBDevice) getDevice();
        UsbBtDevice.setUsbDevice(dev);
        final USBConfiguration conf = dev.getConfiguration(0);
        final USBInterface intf = conf.getInterface(0);
        final InterfaceDescriptor iDesc = intf.getDescriptor();

        USBEndPoint bulkInEndpoint[] = new USBEndPoint[8];
        USBEndPoint bulkOutEndpoint[] = new USBEndPoint[8];
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

    public Driver findDriver(Device device) {

        if (!(device instanceof USBDevice)) {
            return null;
        }
        final USBDevice dev = (USBDevice) device;
        final USBConfiguration conf = dev.getConfiguration(0);
        final USBInterface intf = conf.getInterface(0);
        final InterfaceDescriptor descr = intf.getDescriptor();
        if (descr.getInterfaceClass() != USB_CLASS_WIRELESS) {
            return null;
        }
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

    /**
     * @see org.jnode.driver.DeviceToDriverMapper#findDriver(org.jnode.driver.Device)
     */
    public Driver findDriver(Device device) {
        if (device instanceof USBDevice) {
            final USBDevice dev = (USBDevice) device;
            if (dev.getDescriptor().getDeviceClass() == USB_CLASS_PER_INTERFACE) {

                final USBConfiguration conf = dev.getConfiguration(0);
                final USBInterface intf = conf.getInterface(0);
                final InterfaceDescriptor descr = intf.getDescriptor();

                if (descr.getInterfaceClass() == USB_CLASS_HID) {
                    if (descr.getInterfaceSubClass() == HID_SUBCLASS_BOOT_INTERFACE) {
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

     * @throws NameNotFoundException
     * @see org.jnode.driver.Driver#startDevice()
     */
    protected void startDevice() throws DriverException {
        try {
            final USBDevice dev = (USBDevice) getDevice();
            final USBConfiguration conf = dev.getConfiguration(0);
            // dev.setConfiguration(conf);
            final USBInterface intf = conf.getInterface(0);
            this.ep = null;
            for (int i = 0; i < intf.getDescriptor().getNumEndPoints(); i++) {
                ep = intf.getEndPoint(i);
                if (((ep.getDescriptor().getAttributes() & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) &&
                        ((ep.getDescriptor().getEndPointAddress() & USB_DIR_IN) == 0))
                    break;
            }
            if (this.ep == null)
                throw new DriverException(
                        "Found no interrupt endpoint, HID specs required at least one.");

            //
            log.debug("Interval " + ep.getDescriptor().getInterval());

            // Create the interrupt request
            old = new byte[8];
            intData = new USBPacket(ep.getDescriptor().getMaxPacketSize());
            intPipe = (USBDataPipe) ep.getPipe();
            intPipe.addListener(this);
            intPipe.open();
            final USBRequest req = intPipe.createRequest(intData);
            intPipe.asyncSubmit(req);

            // Configure the default keyboard layout and register the KeyboardAPI
            KeyboardLayoutManager mgr = InitialNaming.lookup(KeyboardLayoutManager.NAME);
            apiAdapter.setKbInterpreter(mgr.createDefaultKeyboardInterpreter());
            dev.registerAPI(KeyboardAPI.class, apiAdapter);

            // Start the key event thread
            keyEventThread =
                    new ByteQueueProcessorThread(dev.getId() + "-daemon", keyCodeQueue, this);
            keyEventThread.start();
        } catch (USBException ex) {
            throw new DriverException(ex);
        } catch (NameNotFoundException ex) {
            throw new DriverException("Cannot find keyboard layout manager", ex);
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

    /**
     * @see org.jnode.driver.Driver#startDevice()
     */
    protected void startDevice() throws DriverException {
        try {
            final USBDevice dev = (USBDevice) getDevice();

            // Get active configuration
            final USBConfiguration conf = dev.getConfiguration();
            final USBInterface intf = conf.getInterface(0);
            this.ep = null;
            for (int i = 0; i < intf.getDescriptor().getNumEndPoints(); i++) {
                ep = intf.getEndPoint(i);
                if (((ep.getDescriptor().getAttributes() & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) &&
                        ((ep.getDescriptor().getEndPointAddress() & USB_DIR_IN) == 0))
                    break;
            }
            if (this.ep == null)
                throw new DriverException(
                        "Found no interrupt endpoint, HID specs required at least one.");

            // Create the interrupt request
            intPipe = (USBDataPipe) ep.getPipe();
            intPipe.addListener(this);
            intPipe.open();
            intData = new USBPacket(ep.getDescriptor().getMaxPacketSize());
            final USBRequest req = intPipe.createRequest(intData);
            intPipe.asyncSubmit(req);

            // Register the PointerAPI
            dev.registerAPI(PointerAPI.class, apiAdapter);
        } catch (USBException ex) {
            throw new DriverException(ex);
        }
    }
View Full Code Here

Examples of org.jnode.driver.bus.usb.USBDevice

     * @see org.jnode.driver.Driver#stopDevice()
     */
    protected void stopDevice() throws DriverException {
        // First stop all devices connected to this HUB.
        for (int i = 0; i < nrPorts; i++) {
            final USBDevice dev = devices[i];
            if (dev != null) {
                try {
                    dev.getManager().stop(dev);
                } catch (DeviceNotFoundException ex) {
                    log.error("Device not found " + dev.getId(), ex);
                }
            }
            devices[i] = null;
        }
        if (monitor != null) {
            monitor.stopMonitor();
            monitor = null;
        }
        this.nrPorts = 0;
        this.devices = null;
        this.dev = null;
        // Now unregister the API
        final USBDevice dev = (USBDevice) getDevice();
        dev.unregisterAPI(USBHubAPI.class);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.