Package com.grephq.ot
Class Jusb
- java.lang.Object
-
- com.grephq.ot.Jusb
-
public class Jusb extends java.lang.ObjectJava wrapper for libusb- Since:
- 12-2022
-
-
Constructor Summary
Constructors Constructor Description Jusb(int vendorID, int productID)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose()Close a device handlestatic voidexit()Deinitialize libusbstatic voidfreeDeviceList(int unref_devices)Frees a list of devices previously discoveredstatic intgetBusNumber()Get the number of the bus the device is connected tostatic intgetConfiguration(int configuration)Determine the bConfigurationValue of the currently active configurationstatic intgetDescriptor(int desc_type, int desc_index, char data, int length)Retrieve a descriptor from a devicestatic intgetDeviceAddress()Get the address of the device on the bus it is connected tostatic intgetDeviceList()Returns the number of USB devices currently attached to the systemstatic intgetDeviceSpeed()Get the negotiated connection speed for a devicestatic intgetPortNumber()Get the number of the port that a device is connected tostatic intinit()Initialize libusbstatic intopen(int vendorID, int productID)Creates a device handle for devicestatic intresetDevice()Attempt to restore previous configurationsstatic intsetConfiguration(int configuration)Set the active configuration for a devicestatic voidsetDebug(int level)Log message levels
-
-
-
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 foproductID- 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 typedesc_index- the index of the descriptor to retrievedata- output buffer for descriptorlength- 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
-
-