本文整理汇总了Java中ch.ntb.usb.USBException类的典型用法代码示例。如果您正苦于以下问题:Java USBException类的具体用法?Java USBException怎么用?Java USBException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
USBException类属于ch.ntb.usb包,在下文中一共展示了USBException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDevices
import ch.ntb.usb.USBException; //导入依赖的package包/类
public static Map<String, Usb_Device> getDevices() throws USBException {
Map<String, Usb_Device> deviceMap = new LinkedHashMap<String, Usb_Device>();
USB.init();
Usb_Bus bus = USB.getBus();
int idx = 0;
while (bus != null) {
Usb_Device device = bus.getDevices();
while (device != null) {
Usb_Device_Descriptor devDesc = device.getDescriptor();
if (devDesc.getIdVendor() == 0x16C0
&& devDesc.getIdProduct() == 0x05DF) {
deviceMap.put(usbDeviceName(++idx), device);
}
device = device.getNext();
}
bus = bus.getNext();
}
return deviceMap;
}
示例2: getDevices
import ch.ntb.usb.USBException; //导入依赖的package包/类
private Map<String, Usb_Device> getDevices() {
try {
return DigisparkDiscoveryUtil.getDevices();
} catch (USBException e) {
throw propagate(e);
}
}
示例3: tryARecover
import ch.ntb.usb.USBException; //导入依赖的package包/类
private void tryARecover() throws USBException {
try {
MILLISECONDS.sleep(10);
Map<String, Usb_Device> deviceMap = getDevices();
usbDevice = deviceMap.get(deviceName);
checkState(usbDevice != null, "No device with portName %s found",
deviceName);
MILLISECONDS.sleep(10);
connect();
MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
示例4: listdeviceNames
import ch.ntb.usb.USBException; //导入依赖的package包/类
@ChoiceFor("deviceName")
public Set<String> listdeviceNames() {
try {
return DigisparkDiscoveryUtil.getDevices().keySet();
} catch (USBException e) {
throw propagate(e);
}
}
示例5: setBrightness
import ch.ntb.usb.USBException; //导入依赖的package包/类
public void setBrightness (float brightness) {
if (dev == null) return;
this.brightness = brightness;
brightnessDelay = fadeDelay;
try {
dev.writeInterrupt(2, new byte[] {(byte)(0xff * brightness)}, 1, brightnessTimeout, false);
} catch (USBException ex) {
if (debug) {
System.out.println("Error setting brightness:");
ex.printStackTrace();
}
}
}
示例6: getPortList
import ch.ntb.usb.USBException; //导入依赖的package包/类
@Override
public List<String> getPortList() {
List<String> retvalue = new ArrayList<String>();
deviceMap.clear();
try {
USB.init();
Usb_Bus bus = USB.getBus();
Usb_Device device = null;
int internal_index = 0;
while(bus != null) {
device = bus.getDevices();
while (device != null) {
Usb_Device_Descriptor devDesc = device.getDescriptor();
if(devDesc.getIdVendor() == 0x16C0 && devDesc.getIdProduct() == 0x05DF) {
internal_index++;
String deviceName = getUsbDeviceName(internal_index);
retvalue.add(deviceName);
deviceMap.put(deviceName, device);
}
device = device.getNext();
}
bus = bus.getNext();
}
}
catch(USBException e) {
e.printStackTrace();
deviceMap.clear();
retvalue.clear();
throw new RuntimeException(e);
}
if(contact != null) {
contact.writeLog(id, "found the following ports:");
for (String string : retvalue) {
contact.writeLog(id, " " + string);
}
}
return retvalue;
}