Serial serialPortA = await FlutterSerialPort.createSerialPort( Device("deviceNameA", "/your/device/path"), 9600);
Serial serialPortB = await FlutterSerialPort.createSerialPort( Device("deviceNameB", "/your/device/path"), 115200);
bool openResultA = await serialPortA.open();
print(serialPortA.isConnected) // true
bool openResultB = await serialPortB.open();
print(serialPortB.isConnected) // false
serialPortA.receiveStream.listen((recv) {
print("Receive: $recv");
});
serialPortB.receiveStream.listen((recv) {
print("Receive: $recv");
});
你可以参照:
https://github.com/Marcello168/react-native-multi-serial-port