-
Notifications
You must be signed in to change notification settings - Fork 127
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
Error writing to ATMEL AT88SC1616C CryptoMemory Card #62
Comments
Hi @madsbrydegaard, I have no experience with the ATMEL cards but according to the docs you posted, it seems you have to perform an ACK polling sequence after some commands (see page 32, Section 7.4 Acknowledge Polling, Table 7-2). Citation from Verify Password: $BA, 7.6.5.2, page 41:
Hope it helps. 🙂 |
@pokusew The page you are referring to are located in synchronous protocol - but I guess the lib are actually using the async protocol (T-0 / ISO 7816-3) starting at page 45 (However I am only guessing) In that section there is no mentioning of any polling cmd since (i guess) the host are a(sync)waiting the device to complete any writes. Can you confirm whether nfc-pcsc uses sync or async protocol? |
On further investigation I found one similar incident as mine which again led me to this stackpage It refers to the ISO 7816-3 standard and states that after sending the headers (instruction bytes) to the card - and before any data is transferred - a procedure byte is returned from the card. This byte can have a range of values - wherein 60 is a NULL byte that requires no further action. This is what was causing the same exception as mine, in that other project (mentioned at top) and I suspect it might be the case for me as well. The reason is, that the command which causes the exception is a set command that does not need to return anything. So I suspect that the card returns SW1=60 (in accordance with ISO 7816-3) and that is what causes the problem. Any further help is greatly appreciated! |
Hi @madsbrydegaard, nfc-pcsc is the wrapper around the PC/SC system API which is quite a high level API. The protocol is actually determined by the reader itself, in your case, the reader uTrust 2700 F supports ISO/IEC 7816 part 1-4, so the communication with your card is according to the ISO 7816-3 standard (which probably means async). I got an idea where the issue might come from. 💡 Could you please log the value of const { NFC } = require('nfc-pcsc');
const nfc = new NFC(); // optionally you can pass logger
nfc.on('reader', reader => {
console.log(`${reader.reader.name} device attached`);
reader.autoProcessing = false;
reader.on('card', async card => {
console.log(`${reader.reader.name} card detected`, card);
console.log('connection', reader.connection); // <- add this line and send me the output
});
// the rest of the handlers
});
nfc.on('error', err => {
console.log('an error occurred', err);
}); Explanation: When a card is detected, nfc-pcsc connects to it (see here) with unspecified protocol and in SCARD_SHARE_SHARED mode (see here). So when we log the Hope it helps. 🙂 |
connection { type: 2, protocol: 1 } |
Good news - Being confirmed that protocol was 1 = sync I looked again and by pure coincidence I read in the documentation that set commands should consist of 4 bytes and not 5 - as in async. I have previously followed some code from a earlier project where they used 5 bytes for set cmds so I assumed that 5 was the magic number. It wasnt... And It did the trick - I can now set and read. Next I will try to write as well ;) You can go ahead and close this. |
@madsbrydegaard Great you made it work! 👍Good job! Just to make it clear: You removed the first byte ( BTW: I think that You can verify it by printing: console.log('constants', {
raw: reader.reader.SCARD_PROTOCOL_RAW, // 4
t0: reader.reader.SCARD_PROTOCOL_T0, // 1
t1: reader.reader.SCARD_PROTOCOL_T1, // 2
or: reader.reader.SCARD_PROTOCOL_T0 | reader.reader.SCARD_PROTOCOL_T1, // 3
}); And according to to card's docs, section 6.2 (page 27):
However, it doesn't matter! The important thing is that it works! 😄 |
Actually I removed the last byte, so that my set user zone cmd looks like this:
Which is strange since its only valid in sync mode. I can also confirm that writing is successful without the need to wait and make ACK calls. BTW Here is the output from your log cmd which confirms the use of T=0 protocol Thnx again for your time. |
@madsbrydegaard You're welcome! The behavior is really weird but I am happy it works. 🙂 |
Hi,
It might be far-fetched but I am having an issue writing to a ATMEL AT88SC1616C CryptoMemory Card using Identive CLOUD 2700 F Smart Card Reader
I am following the instructions from this manual:
http:https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-5211-CryptoMem-Full-Specification-Datasheet.pdf
using reader.transmit method of nfc-pcsc
However I keep getting a transmission error from nfc-pcsc when setting the zone byte (write operation)
Does anyone have hint to what the problem is?
NFC-PCSC 0.7.0, Node.js 10.11.0, Chromium 69.0.3497.106, and Electron 4.0.0
The text was updated successfully, but these errors were encountered: