Package com.grephq.ot

Class Jusb


  • public class Jusb
    extends java.lang.Object
    Java wrapper for libusb
    Since:
    12-2022
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int productID
      USB device product ID
      int vendorID
      USB device vendor ID
    • Constructor Summary

      Constructors 
      Constructor Description
      Jusb​(int vendorID, int productID)  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close()
      Close a device handle
      static void exit()
      Deinitialize libusb
      static void freeDeviceList​(int unref_devices)
      Frees a list of devices previously discovered
      static int getBusNumber()
      Get the number of the bus the device is connected to
      static int getConfiguration​(int configuration)
      Determine the bConfigurationValue of the currently active configuration
      static int getDescriptor​(int desc_type, int desc_index, char data, int length)
      Retrieve a descriptor from a device
      static int getDeviceAddress()
      Get the address of the device on the bus it is connected to
      static int getDeviceList()
      Returns the number of USB devices currently attached to the system
      static int getDeviceSpeed()
      Get the negotiated connection speed for a device
      static int getPortNumber()
      Get the number of the port that a device is connected to
      static int init()
      Initialize libusb
      static int open​(int vendorID, int productID)
      Creates a device handle for device
      static int resetDevice()
      Attempt to restore previous configurations
      static int setConfiguration​(int configuration)
      Set the active configuration for a device
      static void setDebug​(int level)
      Log message levels
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • vendorID

        public int vendorID
        USB device vendor ID
      • productID

        public int productID
        USB device product ID
    • Constructor Detail

      • Jusb

        public Jusb​(int vendorID,
                    int productID)
    • Method Detail

      • init

        public static int init()
        Initialize libusb
        Returns:
        int
        See Also:
        Documentation
      • open

        public static int open​(int vendorID,
                               int productID)
        Creates a device handle for device
        Parameters:
        vendorID - the idVendor value to search fo
        productID - the idProduct value to search for
        Returns:
        int
        See Also:
        Documentation
      • getDeviceAddress

        public static int getDeviceAddress()
        Get the address of the device on the bus it is connected to
        Returns:
        int
        See Also:
        Documentation
      • getDeviceList

        public static int getDeviceList()
        Returns the number of USB devices currently attached to the system
        Returns:
        int
        See Also:
        Documentation
      • getDeviceSpeed

        public static int getDeviceSpeed()
        Get the negotiated connection speed for a device
        Returns:
        int
        See Also:
        Documentation
      • getPortNumber

        public static int getPortNumber()
        Get the number of the port that a device is connected to
        Returns:
        int
        See Also:
        Documentation
      • getConfiguration

        public static int getConfiguration​(int configuration)
        Determine the bConfigurationValue of the currently active configuration
        Parameters:
        configuration - output location for the bConfigurationValue of the active configuration (only valid for return code 0)
        Returns:
        int
        See Also:
        Documentation
      • getDescriptor

        public static int getDescriptor​(int desc_type,
                                        int desc_index,
                                        char data,
                                        int length)
        Retrieve a descriptor from a device
        Parameters:
        desc_type - the descriptor type
        desc_index - the index of the descriptor to retrieve
        data - output buffer for descriptor
        length - size of data buffer
        Returns:
        int
        See Also:
        Documentation
      • getBusNumber

        public static int getBusNumber()
        Get the number of the bus the device is connected to
        Returns:
        int
        See Also:
        Documentation
      • freeDeviceList

        public static void freeDeviceList​(int unref_devices)
        Frees a list of devices previously discovered
        Parameters:
        unref_devices - whether to unref the devices in the list
        See Also:
        Documentation
      • setConfiguration

        public static int setConfiguration​(int configuration)
        Set the active configuration for a device
        Parameters:
        configuration - the bConfigurationValue of the configuration you wish to activate, or -1 if you wish to put the device in an unconfigured state
        Returns:
        int
        See Also:
        Documentation
      • setDebug

        public static void setDebug​(int level)
        Log message levels
        Parameters:
        level - debug level
        See Also:
        Documentation
      • resetDevice

        public static int resetDevice()
        Attempt to restore previous configurations
        Returns:
        int
        See Also:
        Documentation
      • close

        public static void close()
        Close a device handle
        See Also:
        Documentation
      • exit

        public static void exit()
        Deinitialize libusb
        See Also:
        Documentation