Allow keep trying if SCard service is unavailable
This commit is contained in:
@@ -10,6 +10,8 @@ inherits(CardReader, EventEmitter);
|
||||
|
||||
function parseReadersString(buffer) {
|
||||
|
||||
try {
|
||||
|
||||
const string = buffer.toString().slice(0, -1);
|
||||
|
||||
// it looks like
|
||||
@@ -22,6 +24,11 @@ function parseReadersString(buffer) {
|
||||
|
||||
return string.split('\u0000').slice(0, -1);
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -287,6 +287,11 @@ LONG PCSCLite::get_card_readers(PCSCLite* pcsclite, AsyncResult* async_result) {
|
||||
result = get_card_readers(pcsclite, async_result);
|
||||
}
|
||||
#endif
|
||||
if (result == SCARD_E_NO_SERVICE || result == SCARD_E_SERVICE_STOPPED) {
|
||||
SCardReleaseContext(pcsclite->m_card_context);
|
||||
SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &pcsclite->m_card_context);
|
||||
result = get_card_readers(pcsclite, async_result);
|
||||
}
|
||||
} else {
|
||||
/* Store the readers_name in the baton */
|
||||
async_result->readers_name = readers_name;
|
||||
|
||||
Reference in New Issue
Block a user