基本跑通
This commit is contained in:
@@ -371,6 +371,15 @@ public class Ch934xSerialPlugin implements FlutterPlugin, MethodCallHandler, Act
|
||||
// 注意:不注册 IDataCallback — SDK 在有回调注册时会通过回调
|
||||
// 投递数据并释放内部缓冲区,导致 readData() 返回空。
|
||||
// 通过 dataStream 轮询 readData() 拉取数据。
|
||||
|
||||
// 配置串口参数:115200, 8数据位, 1停止位, 无校验, 关闭流控
|
||||
try {
|
||||
CH934XManager.getInstance().setSerialParameter(
|
||||
activeDevice, activeSerialNumber, 115200, 8, 1, 0, false);
|
||||
} catch (Exception ignored) {
|
||||
// 设置失败不影响串口使用(使用芯片默认值)
|
||||
}
|
||||
|
||||
ensureModemCallback();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class _MockCh934xSerialPlatform extends Ch934xSerialPlatform
|
||||
Future<bool> requestUsbPermission(int deviceId) async => true;
|
||||
|
||||
@override
|
||||
Future<Uint8List> read(int length) async => readBytes ?? Uint8List(0);
|
||||
Future<Uint8List> read(int length, {int? serialPortIndex}) async => readBytes ?? Uint8List(0);
|
||||
|
||||
@override
|
||||
Future<int> write(Uint8List data) async => writeResult;
|
||||
|
||||
Reference in New Issue
Block a user