Open SamVerschueren opened 7 years ago
Hi @SamVerschueren,
firstly, could you please provide more details?
According to my quick search, it looks like a strange error connected to Windows OS.
Also I have found an interesting thread related to this problem.
I believe, we can find a solution together.
So, please answer my questions.
Hope it helps.
Hi @pokusew, thanks for the quick reply. I know, my initial post was very brief but didn't have much time to provide more details, so here we go.
Here is the code that shows the behaviour
'use strict';
const NFC = require('nfc-pcsc').default;
const nfc = new NFC();
nfc.on('reader', reader => {
reader.on('card', card => {
console.log(`Card detected (${card.type})`);
const data = Buffer.from([0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0]);
reader.write(6, data)
.then(result => {
console.log('done!');
console.log(result);
})
.catch(err => {
console.log('error');
console.error(err);
});
});
});
Save that file as index.js
and run it. Put a tag on the card reader and then it should fail with the error message that I gave in my initial post. If you kill the program, put the tag on the card reader and then start the program while the tag is already detected by the reader, it works perfectly fine. It just doesn't work if the reader detects the tag while my code is already running.
When I reduce the size of the data buffer to 8 bytes, it seems to work perfectly fine. So I tried to chop my data array in chunks of 4 bytes each and wrote them sequentially to the tag. The first 2 or 3 chunks work, but then I get the same error or another one indicating that the card is unpowered.
So maybe I'm doing something wrong here, but I need to write 64 bytes (or more) to the tag and am not sure how I can achieve that.
I often get a
WriteError
but can't really find a workaround for this. I also have no clue what the error message even means. Does someone have a clue how I can solve this?