public UsbDeviceAssert hasProductId(int id) { isNotNull(); int actualId = actual.getProductId(); assertThat(actualId) // .overridingErrorMessage("Expected product ID <%s> but was <%s>.", id, actualId) // .isEqualTo(id); return this; }
public CommunicationHandler(UsbManager usbManager) { this.mUsbManager = usbManager; mUsbDevice = null; for (final UsbDevice device : mUsbManager.getDeviceList().values()) { Log.d(TAG, "VID : " + device.getVendorId() + "PID : " + device.getProductId()); if (device.getVendorId() == PSLAB_VENDOR_ID && device.getProductId() == PSLAB_PRODUCT_ID) { Log.d(TAG, "Found PSLAB Device"); mUsbDevice = device; device_found = true; break; } } mReadBuffer = new byte[DEFAULT_READ_BUFFER_SIZE]; mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE]; }
public int getPid(){ return device.getProductId(); }
@Override protected boolean isCompatibleUsbDevice(UsbDevice usbDevice) { // Allow any Teensy, but not in HalfKay bootloader mode // Teensy PID depends on mode (e.g: Serail + MIDI) and also changed in TeensyDuino 1.31 return ((usbDevice.getProductId() != HALFKAY_PID) && (usbDevice.getVendorId() == TEENSY_VID)); }
@Override protected boolean isCompatibleUsbDevice(UsbDevice usbDevice) { return ((usbDevice.getProductId() == HALFKAY_PID) && (usbDevice.getVendorId() == HALFKAY_VID)); }
public static boolean isUsbDevice(UsbDevice usbDevice, int vid, int pid) { return usbDevice.getVendorId() == vid && usbDevice.getProductId() == pid; }
private void requestUserPermission() { Log.d(TAG, String.format("requestUserPermission(%X:%X)", device.getVendorId(), device.getProductId() ) ); PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); usbManager.requestPermission(device, mPendingIntent); }
private void requestUserPermission() { Log.d(TAG, String.format("requestUserPermission(%X:%X)", device.getVendorId(), device.getProductId() ) ); PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); usbManager.requestPermission(device, mPendingIntent); }
private void requestUserPermission() { Log.d(TAG, String.format("requestUserPermission(%X:%X)", device.getVendorId(), device.getProductId() ) ); PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); usbManager.requestPermission(device, mPendingIntent); }
public static List<UsbDevice> findUsbDevices(UsbManager usbManager, int vendorId, int productId) { List<UsbDevice> usbDeviceList = new ArrayList<UsbDevice>(); if (usbManager != null) { HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList(); // Iterate over USB devices for (Entry<String, UsbDevice> e : deviceList.entrySet()) { Log.i(LOG_TAG, "String: " + e.getKey() + " " + e.getValue().getVendorId() + " " + e.getValue().getProductId()); UsbDevice device = e.getValue(); if (device.getVendorId() == vendorId && device.getProductId() == productId) { usbDeviceList.add(device); } } } return usbDeviceList; }
public UsbDeviceAssert hasProductId(int id) { isNotNull(); int actualId = actual.getProductId(); assertThat(actualId) // .overridingErrorMessage("Expected product ID <%s> but was <%s>.", id, actualId) // .isEqualTo(id); return this; }
private UsbDevice findDevice(UsbManager manager, int vendorId, int productId) throws DataSourceResourceException { Log.d(TAG, "Looking for USB device with vendor ID " + vendorId + " and product ID " + productId); for(UsbDevice candidateDevice : manager.getDeviceList().values()) { if(candidateDevice.getVendorId() == vendorId && candidateDevice.getProductId() == productId) { Log.d(TAG, "Found USB device " + candidateDevice); return candidateDevice; } } throw new DataSourceResourceException("USB device with vendor " + "ID " + vendorId + " and product ID " + productId + " not found"); }
/** * Delete HVC-P Device. * @param device device */ public void removeUSBDevice(final UsbDevice device) { HVCCameraInfo camera = mServices.remove("" + device.getDeviceId() + "_" + device.getProductId() + "_" + device.getVendorId()); if (camera != null) { // デバイスとの接続切断を通知. notifyOnDisconnected(camera); } }
public static UsbDevice getUsbDevice(final int vendorId, final int productId, final String search) { final UsbManager manager = (UsbManager) xdrip.getAppContext().getSystemService(Context.USB_SERVICE); if (manager == null) return null; final HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); for (Map.Entry<String, UsbDevice> entry : deviceList.entrySet()) { final UsbDevice device = entry.getValue(); if (device.getVendorId() == vendorId && device.getProductId() == productId && device.toString().contains(search)) { Log.d(TAG, "Found device: " + entry.getKey() + " " + device.toString()); return device; } } return null; }
public static UsbDevice getUsbDevice(final int vendorId, final int productId, final String search) { final UsbManager manager = (UsbManager) xdrip.getAppContext().getSystemService(Context.USB_SERVICE); if (manager == null) return null; final HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); for (Map.Entry<String, UsbDevice> entry : deviceList.entrySet()) { final UsbDevice device = entry.getValue(); if (device.getVendorId() == vendorId && device.getProductId() == productId && device.toString().contains(search)) { Log.d(TAG, "Found device: " + entry.getKey() + " " + device.toString()); return device; } } return null; }
public static UsbSpiDevice createUsbSerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface) { int vid = device.getVendorId(); int pid = device.getProductId(); if(CP2130Ids.isDeviceSupported(vid, pid)) return new CP2130SpiDevice(device, connection, iface); else return null; }
public static boolean QueryAdapter() { HashMap<String, UsbDevice> devices = manager.getDeviceList(); for (Map.Entry<String, UsbDevice> pair : devices.entrySet()) { UsbDevice dev = pair.getValue(); if (dev.getProductId() == 0x0337 && dev.getVendorId() == 0x057e) { if (manager.hasPermission(dev)) return true; else RequestPermission(); } } return false; }
public static boolean QueryAdapter() { HashMap<String, UsbDevice> devices = manager.getDeviceList(); for (Map.Entry<String, UsbDevice> pair : devices.entrySet()) { UsbDevice dev = pair.getValue(); if (dev.getProductId() == NINTENDO_WIIMOTE_PRODUCT_ID && dev.getVendorId() == NINTENDO_VENDOR_ID) { if (manager.hasPermission(dev)) return true; else RequestPermission(); } } return false; }
/** * Constructor for default instances of DeviceInfo, populated with numerical IDs rather than * human-readable names. */ public DeviceInfo(UsbDevice device) { this(asFourDigitHex(device.getVendorId()), asFourDigitHex(device.getProductId())); }
public static boolean isSupported(UsbDevice device) { int vid = device.getVendorId(); int pid = device.getProductId(); if(FTDISioIds.isDeviceSupported(vid, pid)) return true; else if(CP210xIds.isDeviceSupported(vid, pid)) return true; else if(PL2303Ids.isDeviceSupported(vid, pid)) return true; else if(CH34xIds.isDeviceSupported(vid, pid)) return true; else if(isCdcDevice(device)) return true; else return false; }