Constructor
new RfReader(plug, rfIdx)
构造Rf读卡器对象
Name | Type | Default | Description |
---|---|---|---|
plug | RktPlug | 插件通信对象 | |
rfIdx | number | 0 | Rf读卡器对象索引 |
- Source
Members
(static, readonly) DevType :number
设备类型
- number
Name | Type | Description |
---|---|---|
AUTO | number | 自动匹配 优先顺序HID>USB>SERIAL(YZ>HC>MU>CU) |
HC_HID | number | |
CU_SERIAL | number | |
YZ_CH9326 | number | |
MU_HID | number | |
YZ_SERIAL | number | |
CU_CH340 | number | |
AE_API | number | AE-API第三方读卡器接口 |
- Source
(static, readonly) RfType :number
射频协议类型
- number
Name | Type | Description |
---|---|---|
None | number | |
Iso14443A | number | |
Iso14443B | number | |
Iso15693 | number |
- Source
Methods
(async) beep(ms) → {Promise}
蜂鸣器
Name | Type | Default | Description |
---|---|---|---|
ms | number | 15 | 持续毫秒 |
- Source
err/msg + retval
- Type:
- Promise
(async) close() → {Promise}
主动关闭设备连接占用
- Source
err/msg
- Type:
- Promise
(async) findId() → {Promise}
查找初始状态的ID 如需重复查找非初始状态ID需rfReset重置状态
- Source
err/msg + retval(数组对象各协议最大示例值如下) { "retval": [ { "rf_type": 1, "uid": "FFFFFFFFFFFFFFFFFFFF", "atqa": 65535, "sak": 255 }, { "rf_type": 2, "uid": "FFFFFFFF", "application": "FFFFFFFF", "protocol": "FFFFFF" }, { "rf_type": 4, "dsfid": 255, "uid": "FFFFFFFFFFFFFFFF" } ] }
- Type:
- Promise
(async) getDevType() → {Promise}
获取当前设备类型
- Source
err/msg + retval
- Type:
- Promise
getRfIdx() → {number}
获取当前Rf读卡器对象索引
- Source
- Type:
- number
(async) getRfType() → {Promise}
获取当前RF协议类型 参考RfReader.RfType 如果为0则代表设备暂未切换具体的协议模式
- Source
err/msg + retval
- Type:
- Promise
(async) getVer() → {Promise}
获取读卡器固件版本信息描述字符串
- Source
err/msg + retval/ver
- Type:
- Promise
(async) hasRfType(rfType, forceSwitch) → {Promise}
设备当前是否具备指定的RF协议能力 需要当前读卡器已连接
Name | Type | Default | Description |
---|---|---|---|
rfType | RfType | 协议类型参考RfReader.RfType 如果设备不支持且无法切换协议模式返回false | |
forceSwitch | boolean | false | 默认false仅当前初始为0暂未切换时允许切换,true则为强制切换但会影响感应区RFID状态 |
- Source
err/msg + retval
- Type:
- Promise
(async) init(devType) → {Promise}
申请初始化读卡器对象
Name | Type | Description |
---|---|---|
devType | DevType | 设备类型 |
- Source
err/msg
- Type:
- Promise
(async) led(Y, G) → {Promise}
控制LED灯 仅支持带灯读卡器
Name | Type | Description |
---|---|---|
Y | number | 黄灯 -1=忽略 0=熄灭 1=点亮 |
G | number | 绿灯 -1=忽略 0=熄灭 1=点亮 |
- Source
err/msg + retval
- Type:
- Promise
(async) loopContinue() → {Promise}
继续loopFindId自动暂停中的循环处理任务
- Source
err/msg
- Type:
- Promise
(async) loopFindId(callback, ms, pause, fixIdle) → {Promise}
自动无限循环寻卡 注意重复调用将取消上次绑定的回调,同时之后调用其他某些读卡器方法也会自动停止
Name | Type | Default | Description |
---|---|---|---|
callback | callback | 事件回调evt参数对象包含retval(数组对象参考findId) | |
ms | number | 100 | 循环间隔毫秒 |
pause | boolean | false | 是否找到Id后自动暂停等待loopContinue继续 注意loop必须在暂停或停止状态才能执行其他读卡器操作 |
fixIdle | boolean | false | 是否启用对比Id更改变化修复芯片或设备不兼容Idle寻卡导致的重复寻到相同芯片现象 |
- Source
err/msg
- Type:
- Promise
(async) loopStop() → {Promise}
主动停止Loop循环处理任务
- Source
err/msg
- Type:
- Promise
(async) ping(open) → {Promise}
检查设备连接是否正常
Name | Type | Default | Description |
---|---|---|---|
open | boolean | true | 是否自动打开设备 |
- Source
err/msg + retval(-1=已被占用/1=已连接/0=连接失败)
- Type:
- Promise
(async) rfReset() → {Promise}
射频感应天线复位重启 重置所有RFID状态
- Source
err/msg + retval
- Type:
- Promise
(async) serialCfg(devType, addr) → {Promise}
串口设备配置 在使用串口类读卡器前必须最优先调用1次
Name | Type | Description |
---|---|---|
devType | DevType | 设备类型参考RfReader.DevType 仅支持SERIAL类读卡器 |
addr | string | 端口地址 例如 "/dev/ttyS3" |
- Source
err/msg + retval
- Type:
- Promise
(async) serialOnly(only) → {Promise}
配置是否占用串口通信唯一连接 非串口设备无意义
Name | Type | Default | Description |
---|---|---|---|
only | boolean | true | 默认true=保持通信,false=仅在操作时占用串口通信 |
- Source
err/msg
- Type:
- Promise
(async) setDevType(devType) → {Promise}
切换设备类型
Name | Type | Description |
---|---|---|
devType | DevType | 设备类型 |
- Source
err/msg + retval
- Type:
- Promise
(async) setIso14443A(enable, limit) → {Promise}
设置Iso14443A协议寻卡
Name | Type | Default | Description |
---|---|---|---|
enable | boolean | 是否启用 默认为禁用状态 | |
limit | number | 0 | 限制最大查找ID数量 默认0代表不限制 |
- Source
err/msg
- Type:
- Promise
(async) setIso14443B(enable, limit, afi, slotsNum) → {Promise}
设置Iso14443B协议寻卡
Name | Type | Default | Description |
---|---|---|---|
enable | boolean | 是否启用 默认为禁用状态 | |
limit | number | 0 | 限制最大查找ID数量 默认0代表不限制 |
afi | number | 0 | 过滤AFI |
slotsNum | number | 0 | 时隙槽数0~4分别代表Slots1/2/4/8/16 |
- Source
err/msg
- Type:
- Promise
(async) setIso15693(enable, limit, afi, nb16Slots) → {Promise}
设置Iso15693协议寻卡
Name | Type | Default | Description |
---|---|---|---|
enable | boolean | 是否启用 默认为禁用状态 | |
limit | number | 0 | 限制最大查找ID数量 默认0代表不限制 |
afi | number | 256 | 如果AFI>0xFF则忽略AFI过滤 |
nb16Slots | boolean | false | 时隙槽数false=1:slot,true=16:slots |
- Source
err/msg
- Type:
- Promise
setRfIdx(rfIdx)
设置切换Rf读卡器对象索引
Name | Type | Description |
---|---|---|
rfIdx | number | Rf读卡器对象索引 |
- Source
(async) waitFindId(ms) → {Promise}
自动等待循环寻卡 注意重复调用将自动停止上一次,同时之后调用其他某些读卡器方法也会自动停止
Name | Type | Default | Description |
---|---|---|---|
ms | number | 100 | 循环间隔毫秒 |
- Source
err/msg + retval(数组对象参考findId)
- Type:
- Promise
(static) guessAtqaType(atqa)
猜测ATQA芯片类型字符串描述
Name | Type | Description |
---|---|---|
atqa | number | ISO14443A响应的ATQA |
- Source
(static) uidToCardNo(uid)
UID前4字节转换为十进制小端序10位的兼容卡号
Name | Type | Description |
---|---|---|
uid | string | 不低于4字节的UID字符串 |
- Source