create method

Future<UsbPort> create (int vid, int pid, [ String type = "", int interface = -1 ])

Creates a UsbPort from vid, pid and optionally type and interface. throws an error on failure. This function will pop up a permission request if needed.

vid = Vendor Id pid = Product Id type = One of UserSerial.CDC, UsbSerial.CH34x, UsbSerial.CP210x, UsbSerial.FTDI, UsbSerial.PL2303 or empty for auto detect. interface = Interface of the Usb Interface, -1 for auto detect.

Example for a fake device with VID 0x1000 and PID 0x2000

UsbPort port = await UsbSerial.create(0x1000, 0x2000);

Implementation

static Future<UsbPort> create(int vid, int pid,
    [String type = "", int interface = -1]) async {
  String methodChannelName = await _channel.invokeMethod("create", {
    "type": type,
    "vid": vid,
    "pid": pid,
    "deviceId": -1,
    "interface": interface
  });

  if (methodChannelName == null) {
    return null;
  }

  return new UsbPort(methodChannelName);
}