Examples of Usb_Bus


Examples of ch.ntb.inf.libusbJava.Usb_Bus

              // open bus
              LibusbJava.usb_init();
              LibusbJava.usb_find_busses();
              LibusbJava.usb_find_devices();

              Usb_Bus bus = LibusbJava.usb_get_busses();
              if (bus != null) {
                treeModel.fireTreeStructureChanged(bus);
                expandAll(usbTree);
              }
            }
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

      // open bus
      LibusbJava.usb_init();
      LibusbJava.usb_find_busses();
      LibusbJava.usb_find_devices();

      Usb_Bus bus = LibusbJava.usb_get_busses();

      treeModel = new UsbTreeModel(bus, jPropertiesArea);
      usbTree = new JTree(treeModel);
      expandAll(usbTree);
      usbTree.addTreeSelectionListener(treeModel);
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

   */
  public Object getChild(Object parent, int index) {

    if (parent instanceof String
        && ((String) parent).compareTo(USB_ROOT) == 0) {
      Usb_Bus curBus = rootBus;

      for (int i = 0; curBus != null; curBus = curBus.getNext(), i++) {
        if (i == index)
          return curBus;
      }
    }

View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

  public int getChildCount(Object parent) {
    if (parent instanceof String
        && ((String) parent).compareTo(USB_ROOT) == 0) {
      int count = 0;

      Usb_Bus curBus = rootBus;

      for (; curBus != null; curBus = curBus.getNext()) {
        count++;
      }

      return count;
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

  public void valueChanged(TreeSelectionEvent e) {
    JTree tree = (JTree) e.getSource();
    Object component = tree.getLastSelectedPathComponent();
    if (component instanceof Usb_Bus) {
      Usb_Bus bus = (Usb_Bus) component;
      StringBuffer sb = new StringBuffer("Usb_Bus\n");
      sb.append("\tdirname: " + bus.getDirname() + "\n");
      sb.append("\tlocation: 0x" + Long.toHexString(bus.getLocation())
          + "\n");
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Device) {
      Usb_Device device = (Usb_Device) component;
      StringBuffer sb = new StringBuffer("Usb_Device\n");
      sb.append("\tfilename: " + device.getFilename() + "\n");
      sb.append("\tdevnum: " + device.getDevnum() + "\n");
      sb.append("\tnum_children: " + device.getNumChildren() + "\n");
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Device_Descriptor) {
      Usb_Device_Descriptor devDesc = (Usb_Device_Descriptor) component;
      StringBuffer sb = new StringBuffer("Usb_Device_Descriptor\n");
      sb.append("\tblenght: 0x"
          + Integer.toHexString(devDesc.getBLength() & 0xFF) + "\n");
      sb.append("\tbDescriptorType: 0x"
          + Integer.toHexString(devDesc.getBDescriptorType() & 0xFF)
          + "\n");
      sb.append("\tbcdUSB: 0x"
          + Integer.toHexString(devDesc.getBcdUSB() & 0xFFFF) + "\n");
      sb.append("\tbDeviceClass: 0x"
          + Integer.toHexString(devDesc.getBDeviceClass() & 0xFF)
          + "\n");
      sb.append("\tbDeviceSubClass: 0x"
          + Integer.toHexString(devDesc.getBDeviceSubClass() & 0xFF)
          + "\n");
      sb.append("\tbDeviceProtocol: 0x"
          + Integer.toHexString(devDesc.getBDeviceProtocol() & 0xFF)
          + "\n");
      sb.append("\tbMaxPacketSize0: 0x"
          + Integer.toHexString(devDesc.getBMaxPacketSize0() & 0xFF)
          + " (" + devDesc.getBMaxPacketSize0() + ")\n");
      sb.append("\tidVendor: 0x"
          + Integer.toHexString(devDesc.getIdVendor() & 0xFFFF)
          + "\n");
      sb.append("\tidProduct: 0x"
          + Integer.toHexString(devDesc.getIdProduct() & 0xFFFF)
          + "\n");
      sb.append("\tbcdDevice: 0x"
          + Integer.toHexString(devDesc.getBcdDevice() & 0xFF) + "\n");
      sb.append("\tiManufacturer: 0x"
          + Integer.toHexString(devDesc.getIManufacturer() & 0xFF)
          + "\n");
      sb.append("\tiProduct: 0x"
          + Integer.toHexString(devDesc.getIProduct()) + "\n");
      sb.append("\tiSerialNumber: 0x"
          + Integer.toHexString(devDesc.getISerialNumber() & 0xFF)
          + "\n");
      sb.append("\tbNumConfigurations: 0x"
          + Integer.toHexString(devDesc.getBNumConfigurations() & 0xFF)
          + "\n");
      // get device handle to retrieve string descriptors
      Usb_Bus bus = rootBus;
      while (bus != null) {
        Usb_Device dev = bus.getDevices();
        while (dev != null) {
          Usb_Device_Descriptor tmpDevDesc = dev.getDescriptor();
          if ((dev.getDescriptor() != null)
              && ((dev.getDescriptor().getIManufacturer() > 0)
                  || (dev.getDescriptor().getIProduct() > 0) || (dev
                  .getDescriptor().getISerialNumber() > 0))) {
            if (tmpDevDesc.equals(devDesc)) {
              try {
                sb.append("\nString descriptors\n");
                long handle = LibusbJava1.libusb_open(dev);

                try {
                  if (dev.getDescriptor().getIManufacturer() > 0) {
                    String manufacturer = LibusbJava1
                        .libusb_get_string_descriptor_ascii(
                            handle,
                            devDesc.getIManufacturer(),
                            255);
                    if (manufacturer == null)
                      manufacturer = "unable to fetch manufacturer string";
                    sb.append("\tiManufacturer: "
                        + manufacturer + "\n");
                  }
                  if (dev.getDescriptor().getIProduct() > 0) {
                    String product = LibusbJava1
                        .libusb_get_string_descriptor_ascii(
                            handle,
                            devDesc.getIProduct(),
                            255);
                    if (product == null)
                      product = "unable to fetch product string";
                    sb.append("\tiProduct: " + product
                        + "\n");
                  }
                  if (dev.getDescriptor().getISerialNumber() > 0) {
                    String serialNumber = LibusbJava1
                        .libusb_get_string_descriptor_ascii(
                            handle,
                            devDesc.getISerialNumber(),
                            255);
                    if (serialNumber == null)
                      serialNumber = "unable to fetch serial number string";
                    sb.append("\tiSerialNumber: "
                        + serialNumber + "\n");
                  }
                } catch (LibusbError ex) {
                  sb.append("\terror getting descriptors: "
                      + ex.getErrorString() + "\n");
                } finally {
                  LibusbJava1.libusb_close(handle);
                }
              } catch (LibusbError ex) {
                sb.append("\terror opening the device"
                    + ex.getErrorString() + "\n");
              }
            }
          }
          dev = dev.getNext();
        }
        bus = bus.getNext();
      }
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Config_Descriptor) {
      Usb_Config_Descriptor confDesc = (Usb_Config_Descriptor) component;
      StringBuffer sb = new StringBuffer("Usb_Config_Descriptor\n");
      sb.append("\tblenght: 0x"
          + Integer.toHexString(confDesc.getBLength()) + "\n");
      sb.append("\tbDescriptorType: 0x"
          + Integer.toHexString(confDesc.getBDescriptorType() & 0xFF)
          + "\n");
      sb.append("\tbNumInterfaces: 0x"
          + Integer.toHexString(confDesc.getBNumInterfaces() & 0xFF)
          + "\n");
      sb.append("\tbConfigurationValue: 0x"
          + Integer.toHexString(confDesc.getBConfigurationValue() & 0xFF)
          + "\n");
      sb.append("\tiConfiguration: 0x"
          + Integer.toHexString(confDesc.getIConfiguration() & 0xFF)
          + "\n");
      sb.append("\tbmAttributes: 0x"
          + Integer.toHexString(confDesc.getBmAttributes() & 0xFF)
          + "\n");
      sb.append("\tMaxPower [mA]: 0x"
          + Integer.toHexString(confDesc.getMaxPower() & 0xFF) + " ("
          + confDesc.getMaxPower() + ")\n");
      sb.append("\textralen: 0x"
          + Integer.toHexString(confDesc.getExtralen()) + "\n");
      sb.append("\textra: "
          + extraDescriptorToString(confDesc.getExtra()) + "\n");
      // get device handle to retrieve string descriptors
      Usb_Bus bus = rootBus;
      while (bus != null) {
        Usb_Device dev = bus.getDevices();
        while (dev != null) {
          Usb_Config_Descriptor[] tmpConfDesc = dev.getConfig();
          for (int i = 0; i < tmpConfDesc.length; i++) {
            if ((tmpConfDesc.equals(confDesc))
                && (confDesc.getIConfiguration() > 0)) {
              try {
                sb.append("\nString descriptors\n");
                long handle = LibusbJava1.libusb_open(dev);

                try {
                  String configuration = LibusbJava1
                      .libusb_get_string_descriptor_ascii(
                          handle,
                          confDesc.getIConfiguration(),
                          255);
                  if (configuration == null)
                    configuration = "unable to fetch configuration string";
                  sb.append("\tiConfiguration: "
                      + configuration + "\n");
                } catch (LibusbError e1) {
                  sb.append("\terror getting config descriptor: "
                      + e1.getErrorString() + "\n");
                } finally {
                  LibusbJava1.libusb_close(handle);
                }
              } catch (LibusbError e1) {
                sb.append("\terror opening the device: "
                    + e1.getErrorString() + "\n");
              } finally {
              }
            }
          }
          dev = dev.getNext();
        }
        bus = bus.getNext();
      }
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Interface) {
      Usb_Interface int_ = (Usb_Interface) component;
      StringBuffer sb = new StringBuffer("Usb_Interface\n");
      sb.append("\tnum_altsetting: 0x"
          + Integer.toHexString(int_.getNumAltsetting()) + "\n");
      sb.append("\taltsetting: " + int_.getAltsetting() + "\n");
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Interface_Descriptor) {
      Usb_Interface_Descriptor intDesc = (Usb_Interface_Descriptor) component;
      StringBuffer sb = new StringBuffer("Usb_Interface_Descriptor\n");
      sb.append("\tblenght: 0x"
          + Integer.toHexString(intDesc.getBLength() & 0xFF) + "\n");
      sb.append("\tbDescriptorType: 0x"
          + Integer.toHexString(intDesc.getBDescriptorType() & 0xFF)
          + "\n");
      sb.append("\tbInterfaceNumber: 0x"
          + Integer.toHexString(intDesc.getBInterfaceNumber() & 0xFF)
          + "\n");
      sb.append("\tbAlternateSetting: 0x"
          + Integer.toHexString(intDesc.getBAlternateSetting() & 0xFF)
          + "\n");
      sb.append("\tbNumEndpoints: 0x"
          + Integer.toHexString(intDesc.getBNumEndpoints() & 0xFF)
          + "\n");
      sb.append("\tbInterfaceClass: 0x"
          + Integer.toHexString(intDesc.getBInterfaceClass() & 0xFF)
          + "\n");
      sb.append("\tbInterfaceSubClass: 0x"
          + Integer.toHexString(intDesc.getBInterfaceSubClass() & 0xFF)
          + "\n");
      sb.append("\tbInterfaceProtocol: 0x"
          + Integer.toHexString(intDesc.getBInterfaceProtocol() & 0xFF)
          + "\n");
      sb.append("\tiInterface: 0x"
          + Integer.toHexString(intDesc.getIInterface()) + "\n");
      sb.append("\textralen: 0x"
          + Integer.toHexString(intDesc.getExtralen()) + "\n");
      sb.append("\textra: " + extraDescriptorToString(intDesc.getExtra())
          + "\n");
      // get device handle to retrieve string descriptors
      Usb_Bus bus = rootBus;
      while (bus != null) {
        Usb_Device dev = bus.getDevices();
        while (dev != null) {
          try {
            long handle = LibusbJava1.libusb_open(dev);

            Usb_Config_Descriptor[] confDescs = dev.getConfig();
            for (int i = 0; i < confDescs.length; i++) {
              Usb_Interface[] ints = confDescs[i].getInterface();
             
              for (int j = 0; j < ints.length; j++) {
                Usb_Interface_Descriptor[] tmpIntDescs = ints[j]
                    .getAltsetting();
               
                for (int k = 0; k < ints.length; k++) {
                  if (i < tmpIntDescs.length
                      && tmpIntDescs[i].equals(intDesc)
                      && (intDesc.getIInterface() > 0)) {
                    sb.append("\nString descriptors\n");
                    try {
                      String interface_ = LibusbJava1
                          .libusb_get_string_descriptor_ascii(
                              handle,
                              intDesc.getIInterface(),
                              255);
                      if (interface_ == null)
                        interface_ = "unable to fetch interface string";
                      sb.append("\tiInterface: "
                          + interface_ + "\n");
                    } catch (LibusbError e1) {
                      sb.append("\terror while reading descriptors: "
                          + e1.getErrorString()
                          + "\n");
                    }
                  }
                }
              }
            }

            LibusbJava1.libusb_close(handle);
          } catch (LibusbError e1) {
            sb.append("\terror opening the device: "
                + e1.getErrorString() + "\n");
          }

          dev = dev.getNext();
        }
        bus = bus.getNext();
      }
      textArea.setText(sb.toString());
    } else if (component instanceof Usb_Endpoint_Descriptor) {
      Usb_Endpoint_Descriptor epDesc = (Usb_Endpoint_Descriptor) component;
      StringBuffer sb = new StringBuffer("Usb_Endpoint_Descriptor\n");
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

    LibusbJava.usb_find_busses();
    LibusbJava.usb_find_devices();

    // retrieve a object tree representing the bus with its devices and
    // descriptors
    Usb_Bus bus = LibusbJava.usb_get_busses();

    // log the bus structure to standard out
    Utils.logBus(bus);
  }
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

    // print the devices
    LibusbJava.usb_init();
//    LibusbJava.usb_set_debug(255);
    LibusbJava.usb_find_busses();
    LibusbJava.usb_find_devices();
    Usb_Bus bus = LibusbJava.usb_get_busses();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    Utils.logBus(bus, ps);
    log.info(baos.toString());
  }
View Full Code Here

Examples of ch.ntb.inf.libusbJava.Usb_Bus

    // print the devices
    LibusbJava.usb_init();
//    LibusbJava.usb_find_busses();
    LibusbJava.usb_find_devices();
    Usb_Bus bus = LibusbJava.usb_get_busses();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    Utils.logBus(bus, ps);
    log.info(baos.toString());
  }
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.