openPort method

  1. @override
Future<String?> openPort({
  1. required DataFormat dataFormat,
  2. required String serialPort,
  3. required int baudRate,
})
override

Call the delegate openPort native method to start the communication with available port on the device the native method have three required arguments:

  1. Format of the data
  2. Name of port which you get from the getAvailablePorts method
  3. And baud Rate Once the the port is opened the TX and RX is started

Implementation

@override
Future<String?> openPort(
    {required DataFormat dataFormat,
    required String serialPort,
    required int baudRate}) async {
  final argument = {
    "dataFormat": dataFormat == DataFormat.ASCII ? "true" : "false",
    "serialPort": serialPort,
    "baudRate": baudRate.toString(),
  };
  final version = await methodChannel.invokeMethod<String>(
      'embeddedSerial/open', argument);
  return version;
}