Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setBuzzerOutput is not a function. Includes debug & suggested fix #64

Open
JohnMcLear opened this issue Jan 14, 2019 · 0 comments
Open
Assignees

Comments

@JohnMcLear
Copy link
Contributor

JohnMcLear commented Jan 14, 2019

Installed using npm install nfc-pcsc --save I get:

$ node test.js
unable to direct comms TypeError: reader.setBuzzerOutput is not a function
    at NFC.nfc.on (/home/pi/test.js:56:24)
const { NFC, TAG_ISO_14443_3, TAG_ISO_14443_4, KEY_TYPE_A, KEY_TYPE_B, CONNECT_MODE_DIRECT } = require('nfc-pcsc');

nfc.on('reader', async reader => {
        try{
          await reader.connect(CONNECT_MODE_DIRECT);
          await reader.setBuzzerOutput(false);
          await reader.disconnect();
        }catch(e){
          console.log("unable to direct comms", e);
        }
...

Any idea what I'm doing wrong? I have it working on another instance fine.. It's as if it';s using the nfc-pcsc but I removed all other copies and only have one copy on this box -_-

I can see the function in the source code..

pi@LOCK2:~/node_modules/nfc-pcsc $ grep -rni setBuzzerOutput .
./examples/led.js:30:           await reader.setBuzzerOutput(false);
./dist/ACR122Reader.js:110:  async setBuzzerOutput(enabled = true) {
./src/ACR122Reader.js:157:      async setBuzzerOutput(enabled = true) {
pi@LOCK2:~/node_modules/nfc-pcsc $ 

Doing npm install in the node_modules/nfc-pcsc folder then npm run example-led

Returns:

> [email protected] example-led /home/pi/node_modules/nfc-pcsc
> node -r @babel/register examples/led.js

2:25:40 PM – debug: new reader detected 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00'
2:25:40 PM – info: device attached { reader: 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00' }
2:25:40 PM – debug: trying to connect [ 'CONNECT_MODE_DIRECT', 3 ]
2:25:40 PM – debug: new reader detected 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader SAM] 01 00'
2:25:40 PM – info: device attached { reader: 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader SAM] 01 00' }
2:25:40 PM – debug: trying to connect [ 'CONNECT_MODE_DIRECT', 3 ]
2:25:40 PM – debug: connected { type: 3, protocol: 0 }
TypeError: reader.setBuzzerOutput is not a function
    at NFC.setBuzzerOutput (/home/pi/node_modules/nfc-pcsc/examples/led.js:30:16)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
2:25:40 PM – debug: connected { type: 3, protocol: 0 }
TypeError: reader.setBuzzerOutput is not a function
    at NFC.setBuzzerOutput (/home/pi/node_modules/nfc-pcsc/examples/led.js:30:16)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
2:25:40 PM – debug: status { state: 18, atr: <Buffer > }
2:25:40 PM – debug: changes 18
2:25:40 PM – debug: card removed
2:25:40 PM – debug: trying to disconnect { type: 3, protocol: 0 }
2:25:40 PM – debug: status { state: 18, atr: <Buffer > }
2:25:40 PM – debug: changes 18
2:25:40 PM – debug: card removed
2:25:40 PM – debug: trying to disconnect { type: 3, protocol: 0 }
2:25:40 PM – debug: disconnected
2:25:40 PM – debug: disconnected

So yeah.. confused!

Turns out it might be a hardware thing

ACR122Reader {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  reader:
   CardReader {
     name: 'ACS ACR122U PICC Interface 00 00',
     connected: false,
     _events:
      [Object: null prototype] {
        _end: [Function],
        error: [Function],
        status: [AsyncFunction],
        end: [Function] },
     _eventsCount: 4 },
  logger:
   { log: [Function: log],
     debug: [Function: log],
     info: [Function: log],
     warn: [Function: log],
     error: [Function: log] },
  connection: null,
  card: null,
  autoProcessing: true,
  _aid: null,
  keyStorage: { '0': null, '1': null },
  pendingLoadAuthenticationKey: {} }
<Buffer ff 00 52 00 00>

Works..

Reader {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  reader:
   CardReader {
     name: 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00',
     connected: false,
     _events:
      [Object: null prototype] {
        _end: [Function],
        error: [Function],
        status: [Function],
        end: [Function] },
     _eventsCount: 4 },
  logger:
   { log: [Function: log],
     debug: [Function: log],
     info: [Function: log],
     warn: [Function: log],
     error: [Function: log] },
  connection: null,
  card: null,
  autoProcessing: true,
  _aid: null,
  _parsedAid: null,
  keyStorage: { '0': null, '1': null },
  pendingLoadAuthenticationKey: {} }
Reader {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  reader:
   CardReader {
     name: 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader SAM] 01 00',
     connected: false,
     _events:
      [Object: null prototype] {
        _end: [Function],
        error: [Function],
        status: [Function],
        end: [Function] },
     _eventsCount: 4 },
  logger:
   { log: [Function: log],
     debug: [Function: log],
     info: [Function: log],
     warn: [Function: log],
     error: [Function: log] },
  connection: null,
  card: null,
  autoProcessing: true,
  _aid: null,
  _parsedAid: null,
  keyStorage: { '0': null, '1': null },
  pendingLoadAuthenticationKey: {} }

Doesn't..

Note the name: 'ACS ACR1252 Dual Reader [ACR1252 Dual Reader SAM] 01 00',

https://github.com/pokusew/nfc-pcsc/blob/master/src/NFC.js#L42 is to blame..

I will leave you to fix how you like but basically my fix is just changing the line to

if (reader.name.toLowerCase().indexOf('acr12') !== -1) {

The whole ACR12x family uses pretty much the same API so it should be a safe bet.. Your call tho :)

Also when you try to use the .led method and it hasn't detected ACR122 or whatever then it should notify the developer to explain why it isn't working so they don't have to do all the leg work I had to today =)X x

Tnx!

@JohnMcLear JohnMcLear changed the title setBuzzerOutput is not a function? Wut?! setBuzzerOutput is not a function. Includes debug & suggested fix Jan 14, 2019
@pokusew pokusew self-assigned this Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants