feat(ch934x_serial): 添加多端口并发轮询流功能
- 新增多端口并发轮询流 portDataStream 方法,支持每周期轮询 8 个端口 - 修改 read 方法增加 serialPortIndex 参数,支持指定端口读取数据 - 更新 Android 原生实现,支持通过 serialPortIndex 参数指定读取端口 - 移除 IDataCallback 注册逻辑,改用轮询方式拉取数据避免缓冲区冲突 - 添加主线程切换机制,确保异常推送在主线程执行 - 更新 pubspec.yaml 添加 ch934x_serial 本地插件依赖 - 更新项目路线图,标记 Phase 42 完成,进度更新至 50%
This commit is contained in:
@@ -124,14 +124,15 @@ class MethodChannelCh934xSerial extends Ch934xSerialPlatform {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List> read(int length) async {
|
||||
Future<Uint8List> read(int length, {int? serialPortIndex}) async {
|
||||
if (length <= 0) {
|
||||
return Uint8List(0);
|
||||
}
|
||||
final raw = await methodChannel.invokeMethod<Uint8List>(
|
||||
'read',
|
||||
<String, Object>{'length': length},
|
||||
);
|
||||
final args = <String, Object>{'length': length};
|
||||
if (serialPortIndex != null) {
|
||||
args['serialPortIndex'] = serialPortIndex;
|
||||
}
|
||||
final raw = await methodChannel.invokeMethod<Uint8List>('read', args);
|
||||
return raw ?? Uint8List(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user