Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
junmp-psam
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
ning
junmp-psam
Commits
543d49f6
Commit
543d49f6
authored
Jan 16, 2019
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PSAM卡接入
parent
eee3e689
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
24 行增加
和
6 行删除
+24
-6
Application.js
app/Application.js
+1
-0
Card.js
app/Card.js
+7
-0
Device.js
app/Device.js
+11
-3
Devices.js
app/Devices.js
+5
-3
没有找到文件。
app/Application.js
View file @
543d49f6
...
...
@@ -101,6 +101,7 @@ class Application extends EventEmitter {
}));
};
/**
* 获取母卡导出密钥
*/
...
...
app/Card.js
View file @
543d49f6
...
...
@@ -18,6 +18,13 @@ import ResApdu from './ResApdu';
class
Card
extends
EventEmitter
{
/**
* PSAM卡构造方法
*
* @param device 读写设备
* @param attr PSAM卡序号
* @param protocol 通讯协议
*/
constructor
(
device
,
attr
,
protocol
)
{
super
();
this
.
device
=
device
;
...
...
app/Device.js
View file @
543d49f6
...
...
@@ -3,7 +3,7 @@
* <pre>
*
*
* 描述:设备
接入类
* 描述:设备
对卡的操作
* 版本:1.0.0
* 日期:2019/01/16
* 作者:ningzp@junmp.com.cn
...
...
@@ -26,6 +26,10 @@ class Device extends EventEmitter {
/**
* 卡片是否已插入
*
* @param changes
* @param reader 读写设备
* @param status 设备状态值
*/
const
isCardInserted
=
(
changes
,
reader
,
status
)
=>
{
return
(
changes
&
reader
.
SCARD_STATE_PRESENT
)
&&
(
status
.
state
&
reader
.
SCARD_STATE_PRESENT
);
...
...
@@ -33,6 +37,10 @@ class Device extends EventEmitter {
/**
* 卡片是否已拔出
*
* @param changes
* @param reader 读写设备
* @param status 设备状态值
*/
const
isCardRemoved
=
(
changes
,
reader
,
status
)
=>
{
return
(
changes
&
reader
.
SCARD_STATE_EMPTY
)
&&
(
status
.
state
&
reader
.
SCARD_STATE_EMPTY
);
...
...
@@ -87,9 +95,9 @@ class Device extends EventEmitter {
/**
* 指令传输
*
* @param data
指令
* @param data
传输数据
* @param res_len 预期响应长度
* @param protocol 协议
* @param protocol
传输
协议
* @param cb 回调
*/
transmit
(
data
,
res_len
,
protocol
,
cb
)
{
...
...
app/Devices.js
View file @
543d49f6
...
...
@@ -4,7 +4,7 @@
* <pre>
*
*
* 描述:
* 描述:
读写器设备操作
* 版本:1.0.0
* 日期:2019/01/16
* 作者:ningzp@junmp.com.cn
...
...
@@ -14,8 +14,6 @@
* </pre>
*/
const
pcsclite
=
require
(
'@pokusew/pcsclite'
);
import
{
EventEmitter
}
from
'events'
;
import
Device
from
'./Device'
;
...
...
@@ -30,12 +28,16 @@ class Devices extends EventEmitter {
this
.
pcsc
.
on
(
'reader'
,
(
reader
)
=>
{
const
device
=
new
Device
(
reader
);
this
.
devices
[
reader
.
name
]
=
device
;
//设备保活事件
this
.
emit
(
'device-activated'
,
{
device
,
devices
:
this
.
listDevices
()});
//设备断开
reader
.
on
(
'end'
,
()
=>
{
delete
this
.
devices
[
reader
.
name
];
this
.
emit
(
'device-deactivated'
,
{
device
,
devices
:
this
.
listDevices
()});
});
//设备异常错误
reader
.
on
(
'error'
,
(
error
)
=>
{
this
.
emit
(
'error'
,
{
reader
,
error
});
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论