本文整理汇总了Java中org.usb4java.DeviceDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java DeviceDescriptor类的具体用法?Java DeviceDescriptor怎么用?Java DeviceDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceDescriptor类属于org.usb4java包,在下文中一共展示了DeviceDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FCDTunerController
import org.usb4java.DeviceDescriptor; //导入依赖的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);
}
}
示例2: initAirspyTuner
import org.usb4java.DeviceDescriptor; //导入依赖的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");
}
}
示例3: initHackRFTuner
import org.usb4java.DeviceDescriptor; //导入依赖的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");
}
}
示例4: RTL2832TunerController
import org.usb4java.DeviceDescriptor; //导入依赖的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;
}
示例5: initAirspyTuner
import org.usb4java.DeviceDescriptor; //导入依赖的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;
}
}
示例6: findDevice
import org.usb4java.DeviceDescriptor; //导入依赖的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;
}
示例7: SimpleUsbDeviceDescriptor
import org.usb4java.DeviceDescriptor; //导入依赖的package包/类
/**
* Construct from a libusb4java device descriptor.
*
* @param descriptor
* The descriptor from which to copy the data.
*/
public SimpleUsbDeviceDescriptor(final DeviceDescriptor descriptor)
{
this(descriptor.bLength(),
descriptor.bDescriptorType(),
descriptor.bcdUSB(),
descriptor.bDeviceClass(),
descriptor.bDeviceSubClass(),
descriptor.bDeviceProtocol(),
descriptor.bMaxPacketSize0(),
descriptor.idVendor(),
descriptor.idProduct(),
descriptor.bcdDevice(),
descriptor.iManufacturer(),
descriptor.iProduct(),
descriptor.iSerialNumber(),
descriptor.bNumConfigurations());
}
示例8: createId
import org.usb4java.DeviceDescriptor; //导入依赖的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.DeviceDescriptor; //导入依赖的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.DeviceDescriptor; //导入依赖的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.DeviceDescriptor; //导入依赖的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.DeviceDescriptor; //导入依赖的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: getDevices
import org.usb4java.DeviceDescriptor; //导入依赖的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()]);
}
示例14: buildCompatibleDevicesList
import org.usb4java.DeviceDescriptor; //导入依赖的package包/类
private List<Device> buildCompatibleDevicesList() {
final List<Device> compatibleDevicesListLocal = new ArrayList<>();
final DeviceList devList = new DeviceList();
LibUsb.getDeviceList(null, devList);
final DeviceDescriptor devDesc = new DeviceDescriptor();
for (final Device dev : devList) {
LibUsb.getDeviceDescriptor(dev, devDesc);
final ImmutablePair<Short, Short> vidPid = new ImmutablePair<>(devDesc.idVendor(), devDesc.idProduct());
// Check that the device is not already bound to any other driver.
final DeviceHandle devHandle = new DeviceHandle();
int status = LibUsb.open(dev, devHandle);
if (status != LibUsb.SUCCESS) {
continue; // Skip device.
}
status = LibUsb.kernelDriverActive(devHandle, 0);
LibUsb.close(devHandle);
if (((status == LibUsb.ERROR_NOT_SUPPORTED) || (status == LibUsb.SUCCESS))
&& vidPidToClassMap.containsKey(vidPid)) {
// This is a VID/PID combination we support, so let's add the
// device to the compatible
// devices list and increase its reference count.
compatibleDevicesListLocal.add(LibUsb.refDevice(dev));
}
}
LibUsb.freeDeviceList(devList, true);
return compatibleDevicesListLocal;
}
示例15: buildCompatibleDevicesList
import org.usb4java.DeviceDescriptor; //导入依赖的package包/类
private List<Device> buildCompatibleDevicesList() {
final List<Device> compatibleDevicesListLocal = new ArrayList<>();
final DeviceList devList = new DeviceList();
LibUsb.getDeviceList(null, devList);
final DeviceDescriptor devDesc = new DeviceDescriptor();
for (final Device dev : devList) {
LibUsb.getDeviceDescriptor(dev, devDesc);
final ImmutablePair<Short, Short> vidPid = new ImmutablePair<>(devDesc.idVendor(), devDesc.idProduct());
// Check that the device is not already bound to any other driver.
final DeviceHandle devHandle = new DeviceHandle();
int status = LibUsb.open(dev, devHandle);
if (status != LibUsb.SUCCESS) {
continue; // Skip device.
}
status = LibUsb.kernelDriverActive(devHandle, 0);
LibUsb.close(devHandle);
if (((status == LibUsb.ERROR_NOT_SUPPORTED) || (status == LibUsb.SUCCESS)) && vidPidToClassMap.containsKey(vidPid)) {
// This is a VID/PID combination we support, so let's add the
// device to the compatible
// devices list and increase its reference count.
compatibleDevicesListLocal.add(LibUsb.refDevice(dev));
}
}
LibUsb.freeDeviceList(devList, true);
return compatibleDevicesListLocal;
}