CardReader status event should return the ATR

- Of the inserted card.
- Refactoring of the code that creates a Buffer instance into a
  separate function.
- Update the example and README
- It fixes bug #2
This commit is contained in:
Santiago Gimeno
2013-07-04 22:50:18 +02:00
parent c98f7bc2de
commit 3f2a1b5e4e
5 changed files with 42 additions and 18 deletions

View File

@@ -12,11 +12,11 @@ pcsc.on('reader', function(reader) {
reader.on('status', function(status) {
console.log('Status(', this.name, '):', status);
/* check what has changed */
var changes = this.status ^ status;
var changes = this.state ^ status.state;
if (changes) {
if ((changes & this.SCARD_STATE_EMPTY) && (status & this.SCARD_STATE_EMPTY)) {
if ((changes & this.SCARD_STATE_EMPTY) && (status.state & this.SCARD_STATE_EMPTY)) {
console.log("card removed");/* card removed */
} else if ((changes & this.SCARD_STATE_PRESENT) && (status & this.SCARD_STATE_PRESENT)) {
} else if ((changes & this.SCARD_STATE_PRESENT) && (status.state & this.SCARD_STATE_PRESENT)) {
console.log("card inserted");/* card inserted */
}
}