当前位置: 首页>>代码示例>>Java>>正文


Java USBException类代码示例

本文整理汇总了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;
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:20,代码来源:DigisparkDiscoveryUtil.java

示例2: getDevices

import ch.ntb.usb.USBException; //导入依赖的package包/类
private Map<String, Usb_Device> getDevices() {
	try {
		return DigisparkDiscoveryUtil.getDevices();
	} catch (USBException e) {
		throw propagate(e);
	}
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:8,代码来源:DigisparkConnection.java

示例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();
	}
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:15,代码来源:DigisparkConnection.java

示例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);
	}
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:9,代码来源:DigisparkLinkConfig.java

示例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();
		}
	}
}
 
开发者ID:EsotericSoftware,项目名称:powermate,代码行数:14,代码来源:PowerMate.java

示例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;
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:41,代码来源:DigisparkUSBConnection.java


注:本文中的ch.ntb.usb.USBException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。