首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从node.js访问ACS芯片读取器

从node.js访问ACS芯片读取器
EN

Stack Overflow用户
提问于 2018-10-10 10:20:52
回答 1查看 920关注 0票数 0

我试图使用节点-usb库从ACR1252访问ACS芯片读取器( node.js ).但是,由于没有文档,这个库似乎确实是一个使用上的麻烦。到目前为止,我已经识别了设备并连接到接口(就在mac上,linux仍然不能工作)。当识别芯片时,当芯片被移除时,设备发出<Buffer 50 03><Buffer 50 02>

然而,当发送命令获取芯片的序列号时,传输调用由于错误undefined而失败。

到目前为止,这是我的代码:

代码语言:javascript
复制
import usb, { InEndpoint, OutEndpoint } from 'usb';

usb.on('attach', device => {
   device.__open();
   device.__claimInterface(0);

   device.open();

   const ifc = device.interface(0);
   ifc.claim();

   const outEndpoint: OutEndpoint = <OutEndpoint>ifc.endpoints[0];
   const inEndpoint: InEndpoint = <InEndpoint>ifc.endpoints[2];

   inEndpoint.startPoll();
   inEndpoint.on('data', (buffer: Buffer) => {
      console.warn('-- Received data: ', buffer);

      if (buffer.toString('hex') === '5003') {
         console.warn('Chip recognized!');
         outEndpoint.transfer(Buffer.from('FF CA 00 00 00', 'hex'), error => {
            console.warn('transfer error', error);
         });
      }
   });
   inEndpoint.on('error', error => {
      console.warn('error', error);
   });
});

输出日志:

代码语言:javascript
复制
-- Received data:  <Buffer 50 03>
Chip recognized!
transfer error undefined
-- Received data:  <Buffer 50 02>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-12 10:07:51

您必须实现CCID协议才能与智能卡读取器通信(这并不像将APDU发送到USB端点那样简单)。

考虑使用节点-pcsclite,它提供了PC/SC API,这是与智能卡读取器通信的一种标准方式--您的代码将与安装的驱动程序支持的任何智能卡读取器一起工作,您将不必实现PC/SC

有关示例,请参见卢梭的博客

祝你的项目好运!

EDIT>

有一个javascript 这里的演示CCID实现。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52737996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档