openPort method
Future<String?>
openPort({
- required DataFormat dataFormat,
- required String serialPort,
- 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:
- Format of the data
- Name of port which you get from the getAvailablePorts method
- 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;
}