capacitor-serial-port-android
v0.0.4
Published
serial port communication
Downloads
248
Readme
capacitor-serial-port-android
serial port communication
Install
npm install capacitor-serial-port-android
npx cap sync
API
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>
打印方法,没啥用
| Param | Type |
| ------------- | ------------------------------- |
| options
| { value: string; } |
Returns: Promise<{ value: string; }>
listen(...)
listen(option: PortCommunicationOption) => Promise<{ data: string; }>
监听对应的串口
| Param | Type |
| ------------ | --------------------------------------------------------------------------- |
| option
| PortCommunicationOption |
Returns: Promise<{ data: string; }>
sendTxt(...)
sendTxt(data: { message: string; }) => Promise<boolean>
发送文本
| Param | Type |
| ---------- | --------------------------------- |
| data
| { message: string; } |
Returns: Promise<boolean>
sendHex(...)
sendHex(data: { message: string; }) => Promise<boolean>
发送十六进制,请确保传入的是十六进制数据
| Param | Type |
| ---------- | --------------------------------- |
| data
| { message: string; } |
Returns: Promise<boolean>
getAllDevices()
getAllDevices() => Promise<string[]>
获取所有串口列表
Returns: Promise<string[]>
close()
close() => Promise<boolean>
关闭当前打开的串口
Returns: Promise<boolean>
Interfaces
PortCommunicationOption
| Prop | Type | Description |
| ----------------- | ------------------- | ----------- |
| port
| string | 端口 |
| baudRate
| number | 波特率 |
| stopBit
| number | 停止位 |
| dataBit
| number | 数据位 |
| parity
| number | 校验位 |
| flowControl
| number | 流控 |