更新记录

1.0.0(2024-08-18)

初始化发布


平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.6.8,Android:4.4,iOS:不支持 × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

概述

XF-serialPort封装了安卓串口通信的能力,支持多串口操作

插件接口

getAllDevices

获取所有串口信息

uni-app项目中(nvue)调用示例:

import { getAllDevices } from "@/uni_modules/XF-serialPort"

let res = getAllDevices(0);
console.log(res)

uni-app x项目(uvue)中调用示例:

import { getAllDevices } from "@/uni_modules/XF-serialPort";

let res = getAllDevices(0);
console.log(res)

可用性

Android系统

可提供的1.0.0及更高版本

getAllDeicesPath

查询串口设备地址列表

uni-app项目中(nvue)调用示例:

import { getAllDeicesPath } from "@/uni_modules/XF-serialPort"

let res = getAllDeicesPath(0);
console.log(res)

uni-app x项目(uvue)中调用示例:

import { getAllDeicesPath } from "@/uni_modules/XF-serialPort";

let res = getAllDeicesPath(0);
console.log(res)

可用性

Android系统

可提供的1.0.0及更高版本

addEventListener

串口接收数据监听

uni-app项目中(nvue)调用示例:

import { addEventListener } from "@/uni_modules/XF-serialPort"

addEventListener({
  index: 0,
  revType: 'text',
  complete: (res) => {
        console.log(res)
  }
});

uni-app x项目(uvue)中调用示例:

import { addEventListener } from "@/uni_modules/XF-serialPort";
import { EventListenerOptions } from "@/uni_modules/XF-serialPort/utssdk/interface.uts";

let options = {
  index: 0,
  revType: 'text',
  complete: (res : any) => {
    console.log(res)
  }
} as EventListenerOptions;
addEventListener(options);

可用性

Android系统

可提供的1.0.0及更高版本

open

打开串口

uni-app项目中(nvue)调用示例:

import { open } from "@/uni_modules/XF-serialPort"

open({
  index: 0,
  port: '/dev/ttyS2',
  baudRate: 115200,
  stopBits: 2,
  dataBits: 8,
  parity: 0,
  flowCon: 0,
  complete: (res) => {
        console.log(res)
  }
});

uni-app x项目(uvue)中调用示例:

import { open } from "@/uni_modules/XF-serialPort";
import { OpenOptions } from "@/uni_modules/XF-serialPort/utssdk/interface.uts";

let options = {
  index: 0,
  port: '/dev/ttyS2',
  baudRate: 115200,
  stopBits: 2,
  dataBits: 8,
  parity: 0,
  flowCon: 0,
  complete: (res : any) => {
    console.log(res)
  }
} as OpenOptions;
open(options);

可用性

Android系统

可提供的1.0.0及更高版本

send

发送数据

uni-app项目中(nvue)调用示例:

import { send } from "@/uni_modules/XF-serialPort"

send(0,'12344',text);

uni-app x项目(uvue)中调用示例:

import { send } from "@/uni_modules/XF-serialPort";

send(0,'12344',text);

可用性

Android系统

可提供的1.0.0及更高版本

close

关闭串口

uni-app项目中(nvue)调用示例:

import { close } from "@/uni_modules/XF-serialPort"

close(0);

uni-app x项目(uvue)中调用示例:

import { close } from "@/uni_modules/XF-serialPort";

close(0);

可用性

Android系统

可提供的1.0.0及更高版本

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问