public static UsbSerialDevice CreateUsbSerialDevice(UsbDevice device, UsbDeviceConnection connection, int iface) { /* * It checks given vid and pid and will return a custom driver or a CDC serial driver. * When CDC is returned open() method is even more important, its response will inform about if it can be really * opened as a serial device with a generic CDC serial driver */ int vid = device.VendorId; int pid = device.ProductId; if (FTDISioIds.IsDeviceSupported(vid, pid)) { return(new FTDISerialDevice(device, connection, iface)); } else if (CP210xIds.IsDeviceSupported(vid, pid)) { return(new CP2102SerialDevice(device, connection, iface)); } else if (PL2303Ids.IsDeviceSupported(vid, pid)) { return(new PL2303SerialDevice(device, connection, iface)); } else if (CH34xIds.IsDeviceSupported(vid, pid)) { return(new CH34xSerialDevice(device, connection, iface)); } else if (IsCdcDevice(device)) { return(new CDCSerialDevice(device, connection, iface)); } else { return(null); } }
public static bool IsSupported(UsbDevice device) { int vid = device.VendorId; int pid = device.ProductId; 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); } }