更新记录
1.0.2(2024-11-27)
改
1.0.1(2024-11-27)
串口打开/接收/发送
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
1打开串口通信 openSerialPort() 示例 openSerialPort() //调用
2.1原生插件发送消息 device_message_send(message) 参数 类型 说明 message string 发送的十六进制消息 示例
device_send("1AA1")//发送1AA1
2.2原生监听串口数据 device_message_read(message) 参数 类型 说明 message function 回调函数
message(rec) 参数 类型 说明 rec string 收到的数据
示例: device_message_read(message); function message(ref) { console.log("接收到的消息: " + ref); }
3.1封装后发送消息 device_output(io_num,io_state) 参数 类型 说明 io_num INT 设备输出端口号 io_state bool 设备输出状态
示例 device_output(1,true) //端口号:1,端口状态;true
3.2封装后的监听串口数据 device_input(message) 参数 类型 说明 message function 回调函数
message(io_num,io_bool) 参数 类型 说明 io_num INT 设备输入端口号 io_bool bool 设备输出状态
示例 device_input(message); message(io_num, io_bool) { console.log("IO Number: " + io_num); // 结果:1 console.log("IO State: " + io_bool); //结果:true }