open method
Opens a Web Serial port selected via the browser's port-picker dialog.
path should be web:request (as returned by availablePorts).
The browser picker is shown and the returned Future resolves once the
user confirms the selection and the port is opened.
Returns true on success, false if the user cancels or the port
cannot be opened.
Implementation
Future<bool> open(String path, SerialConfig config) async {
_stopSession();
final ok = await openWebPort(
path,
baudRate: config.baudRate,
dataBits: config.dataBits,
stopBits: config.stopBits,
parity: config.parity,
flowControl: config.flowControl,
);
if (!ok) return false;
_webPath = path;
_webDataSub = webDataStream(path)?.listen((bytes) {
_eventController.add(SerialEvent(SerialEventType.data, bytes));
});
_eventController.add(SerialEvent(SerialEventType.connected, null));
return true;
}