本文整理汇总了Java中org.usb4java.Device类的典型用法代码示例。如果您正苦于以下问题:Java Device类的具体用法?Java Device怎么用?Java Device使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Device类属于org.usb4java包,在下文中一共展示了Device类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshCompatibleDevicesList
import org.usb4java.Device; //导入依赖的package包/类
private void refreshCompatibleDevicesList() {
// Temporary storage to allow modification.
final List<Device> tmpDrain = new ArrayList<>(buildCompatibleDevicesList());
// Replace with new data in a non-destructive way, by not touching
// values that were already present.
final List<Device> removals = new ArrayList<>();
for (final Device element : compatibleDevicesList) {
if (tmpDrain.contains(element)) {
tmpDrain.remove(element);
}
else {
removals.add(element);
LibUsb.unrefDevice(element);
}
}
// Remove all items that need to be deleted and add all the new ones in
// only one call each.
compatibleDevicesList.removeAll(removals);
compatibleDevicesList.addAll(tmpDrain);
// Consume newContent fully.
tmpDrain.clear();
}
示例2: FCDTunerController
import org.usb4java.Device; //导入依赖的package包/类
/**
* Generic FCD tuner controller - contains functionality common across both
* funcube dongle tuners
*
* @param device
* @param descriptor
* @param minTunableFrequency
* @param maxTunableFrequency
*/
public FCDTunerController(Device device,
DeviceDescriptor descriptor,
int sampleRate,
int minTunableFrequency,
int maxTunableFrequency)
{
super(minTunableFrequency, maxTunableFrequency, DC_SPIKE_AVOID_BUFFER, USABLE_BANDWIDTH_PERCENT);
mDevice = device;
mDeviceDescriptor = descriptor;
try
{
mFrequencyController.setSampleRate(sampleRate);
}
catch(SourceException se)
{
mLog.error("Error setting sample rate to [" + sampleRate + "]", se);
}
}
示例3: initAirspyTuner
import org.usb4java.Device; //导入依赖的package包/类
private TunerInitStatus initAirspyTuner(Device device,
DeviceDescriptor descriptor)
{
try
{
AirspyTunerController airspyController = new AirspyTunerController(device);
airspyController.init();
AirspyTuner tuner = new AirspyTuner(airspyController);
return new TunerInitStatus(tuner, "LOADED");
}
catch(SourceException se)
{
mLog.error("couldn't construct Airspy controller/tuner", se);
return new TunerInitStatus(null,
"error constructing Airspy tuner controller");
}
}
示例4: initHackRFTuner
import org.usb4java.Device; //导入依赖的package包/类
private TunerInitStatus initHackRFTuner(Device device,
DeviceDescriptor descriptor)
{
try
{
HackRFTunerController hackRFController = new HackRFTunerController(device, descriptor);
hackRFController.init();
HackRFTuner tuner = new HackRFTuner(hackRFController);
return new TunerInitStatus(tuner, "LOADED");
}
catch(SourceException se)
{
mLog.error("couldn't construct HackRF controller/tuner", se);
return new TunerInitStatus(null,
"error constructing HackRF tuner controller");
}
}
示例5: RTL2832TunerController
import org.usb4java.Device; //导入依赖的package包/类
/**
* Abstract tuner controller device. Use the static getTunerClass() method
* to determine the tuner type, and construct the corresponding child
* tuner controller class for that tuner type.
*/
public RTL2832TunerController( Device device,
DeviceDescriptor deviceDescriptor,
ThreadPoolManager threadPoolManager,
long minTunableFrequency,
long maxTunableFrequency,
int centerUnusableBandwidth,
double usableBandwidthPercentage ) throws DeviceException
{
//super( minTunableFrequency,
// maxTunableFrequency,
// centerUnusableBandwidth,
// usableBandwidthPercentage );
mThreadPoolManager = threadPoolManager;
mDevice = device;
mDeviceDescriptor = deviceDescriptor;
}
示例6: initAirspyTuner
import org.usb4java.Device; //导入依赖的package包/类
private static AirspyDevice initAirspyTuner( Device device,
DeviceDescriptor descriptor ) throws UsbException
{
try
{
ThreadPoolManager mThreadPoolManager = new ThreadPoolManager();
AirspyDevice airspyController =
new AirspyDevice( device, mThreadPoolManager );
airspyController.init();
//AirspyTuner tuner = new AirspyTuner( airspyController );
return airspyController;
}
catch( DeviceException se ) {
Log.errorDialog("couldn't construct Airspy controller/tuner", se.getMessage() );
return null;
}
}
示例7: findDevice
import org.usb4java.Device; //导入依赖的package包/类
public Device findDevice(short vendorId, short productId) {
// Read the USB device list
DeviceList list = new DeviceList();
int result = LibUsb.getDeviceList(null, list);
if (result < 0) throw new LibUsbException("Unable to get device list", result);
try {
// Iterate over all devices and scan for the right one
for (Device device: list) {
DeviceDescriptor descriptor = new DeviceDescriptor();
result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to read device descriptor", result);
if (descriptor.idVendor() == vendorId && descriptor.idProduct() == productId) return device;
}
} finally {
// Ensure the allocated device list is freed
LibUsb.freeDeviceList(list, true);
}
// Device not found
return null;
}
示例8: createId
import org.usb4java.Device; //导入依赖的package包/类
/**
* Creates a device ID from the specified device.
*
* @param device
* The libusb device. Must not be null.
* @return The device id.
* @throws UsbPlatformException
* When device descriptor could not be read from the specified
* device.
*/
private DeviceId createId(final Device device) throws UsbPlatformException
{
if (device == null)
throw new IllegalArgumentException("device must be set");
final int busNumber = LibUsb.getBusNumber(device);
final int addressNumber = LibUsb.getDeviceAddress(device);
final int portNumber = LibUsb.getPortNumber(device);
final DeviceDescriptor deviceDescriptor = new DeviceDescriptor();
final int result = LibUsb.getDeviceDescriptor(device, deviceDescriptor);
if (result < 0)
{
throw ExceptionUtils.createPlatformException(
"Unable to get device descriptor for device " + addressNumber
+ " at bus " + busNumber, result);
}
return new DeviceId(busNumber, addressNumber, portNumber,
new SimpleUsbDeviceDescriptor(deviceDescriptor));
}
示例9: findAllDevices
import org.usb4java.Device; //导入依赖的package包/类
/**
* List all Devices on the Computer with a specific vid and pid value
*
* @param vid short
* @param pid short
* @return Vector<Device>
* @author yassir
*/
private Vector<Device> findAllDevices(short vid, short pid) {
Vector<Device> v_dev = new Vector<Device>();
try {
// Iterate over all devices and scan for the right one
for (Device device : allDevices) {
DeviceDescriptor descriptor = new DeviceDescriptor();
int result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result != LibUsb.SUCCESS)
throw new LibUsbException(
"Unable to read device descriptor", result);
if (descriptor.idVendor() == vid
&& descriptor.idProduct() == pid)
v_dev.add(device); // return device;
}
} catch (Exception e) {
e.printStackTrace();
}
return v_dev;
}
示例10: dumpDaplugWinUSB
import org.usb4java.Device; //导入依赖的package包/类
/**
* Get All informations and print it to screen form a specific Device
* @param device Device
* @return String
* @author yassir
*/
public static String dumpDaplugWinUSB(Device device) {
DeviceDescriptor des = new DeviceDescriptor();
LibUsb.getDeviceDescriptor(device, des);
String res = " vid : " + des.idVendor()
+ "\n pid : " + des.idProduct()
+ "\n Manufacturer : " + des.iManufacturer()
+ "\n bcdevice : " + des.bcdDevice()
+ "\n bcdUSB : " + des.bcdUSB()
+ "\n serial : " + des.iSerialNumber()
+ "\n bDescriptorType : " + des.bDescriptorType()
+ "\n bDeviceClass : " + des.bDeviceClass()
+ "\n bDeviceProtocol : " + des.bDeviceProtocol()
+ "\n bDeviceSubClass : " + des.bDeviceSubClass()
+ "\n bLength : " + des.bLength()
+ "\n bMaxPacketSize0 : " + des.bMaxPacketSize0()
+ "\n bNumConfigurations : " + des.bNumConfigurations()
+ "\n getBuffer : " + des.getBuffer()
+ "\n getPointer : " + device.getPointer()
+ "\n hashCode : " + des.hashCode();
return res;
}
示例11: getPath
import org.usb4java.Device; //导入依赖的package包/类
/**
* Create List all Device with their path. It's an other way to list devices by their path.
* Please Notice that this path is something created specifically for this case.
*
* @return Vector<String> List of all device path
* @author yassir
*/
public Vector<String> getPath() {
Vector<String> v_res = new Vector<String>();
for(Device device : allDevices) {
DeviceDescriptor des = new DeviceDescriptor();
LibUsb.getDeviceDescriptor(device, des);
int i = 0;
if (PRODUCT_ID == des.idProduct() && VENDOR_ID == des.idVendor()) {
StringBuilder sb = new StringBuilder();
sb.append("Dongle ").append(i).append(",WINUSB").append(",").append(device.getPointer()).append(",").append("Plug-up");
v_res.addElement(sb.toString());
i++;
}
}
return v_res;
}
示例12: openDaplugWinusb
import org.usb4java.Device; //导入依赖的package包/类
/**
* Open DaplugDongle with a specific vendor_id and product_id
* @param vid short the product vendor_id
* @param pid short the product product_id
* @return Vector<String> open Daplug Dongle
* @author yassir
*/
private Vector<Device> openDaplugWinusb(short vid, short pid) {
Vector<Device> v_dev = new Vector<Device>();
for (Device device : allDevices) {
DeviceDescriptor descriptor = new DeviceDescriptor();
int result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result != LibUsb.SUCCESS)
throw new LibUsbException(
"Unable to read device descriptor", result);
if (descriptor.idVendor() == vid
&& descriptor.idProduct() == pid) {
v_dev.add(device);
}
}
return v_dev;
}
示例13: dumpConfigurationDescriptors
import org.usb4java.Device; //导入依赖的package包/类
/**
* Dumps all configuration descriptors of the specified device. Because
* libusb descriptors are connected to each other (Configuration descriptor
* references interface descriptors which reference endpoint descriptors)
* dumping a configuration descriptor also dumps all interface and endpoint
* descriptors in this configuration.
*
* @param device
* The USB device.
* @param numConfigurations
* The number of configurations to dump (Read from the device
* descriptor)
*/
public static void dumpConfigurationDescriptors(final Device device,
final int numConfigurations)
{
for (byte i = 0; i < numConfigurations; i += 1)
{
final ConfigDescriptor descriptor = new ConfigDescriptor();
final int result = LibUsb.getConfigDescriptor(device, i, descriptor);
if (result < 0)
{
throw new LibUsbException("Unable to read config descriptor",
result);
}
try
{
System.out.println(descriptor.dump().replaceAll("(?m)^",
" "));
}
finally
{
// Ensure that the config descriptor is freed
LibUsb.freeConfigDescriptor(descriptor);
}
}
}
示例14: find_ep
import org.usb4java.Device; //导入依赖的package包/类
static protected byte find_ep(Device device) {
byte ep_addr = 0;
ConfigDescriptor config = new ConfigDescriptor();
int rval = LibUsb.getActiveConfigDescriptor(device, config);
if (rval != 0) {
throw new LibUsbException("error LibUsb.getActiveConfigDescriptor", rval);
}
InterfaceDescriptor altsetting = null;
for (int i = 0; i < config.bNumInterfaces(); i++) {
Interface[] iface = config.iface();
altsetting = iface[i].altsetting()[0];
if (altsetting.bInterfaceNumber() == 0) {
break;
}
}
EndpointDescriptor ep;
for (int i = 0; i < altsetting.bNumEndpoints(); i++) {
ep = altsetting.endpoint()[i];
if ((ep.bmAttributes() & LibUsb.TRANSFER_TYPE_MASK) == LibUsb.TRANSFER_TYPE_BULK && ep.wMaxPacketSize() != 0) {
ep_addr = ep.bEndpointAddress();
break;
}
}
LibUsb.freeConfigDescriptor(config);
return ep_addr;
}
示例15: getDevices
import org.usb4java.Device; //导入依赖的package包/类
public Device[] getDevices(int vendor_id, int product_id){
DeviceList usb_device_list = new DeviceList();
int result = LibUsb.getDeviceList(context, usb_device_list);
if (result < 0){
throw new LibUsbException("Unable to get device list", result);
}
ArrayList<Device> ps3_device_list = new ArrayList<Device>();
try {
for (Device usb_device : usb_device_list) {
DeviceDescriptor descriptor = new DeviceDescriptor();
result = LibUsb.getDeviceDescriptor(usb_device, descriptor);
if (result != LibUsb.SUCCESS){
throw new LibUsbException("Unable to read device descriptor", result);
}
if(descriptor.idVendor() == vendor_id && descriptor.idProduct() == product_id){
DeviceHandle handle = new DeviceHandle();
result = LibUsb.open(usb_device, handle);
if (result != LibUsb.SUCCESS){
throw new LibUsbException("Unable to open USB device", result);
}
LibUsb.close(handle);
LibUsb.refDevice(usb_device);
ps3_device_list.add(usb_device);
}
}
} finally {
LibUsb.freeDeviceList(usb_device_list, true);
}
return ps3_device_list.toArray(new Device[ps3_device_list.size()]);
}