I'm using Windows.Devices.SmartCards namespace for communicating with a smart card. I found the reader, and also the card. I can also send APDU commands to the card. But the problem is that after couple of ADPU's I receive response 0x63 00 instead of 0x90 00. Most of the time it stops receiving commands after the second or third APDU and after this the response is always 0x63 00 until I remove the card and reconnect.
Here is my code for transmitting:
String^ NFC::transmit(Array<unsigned char>^ outgoing)
{
String^ response = "";
IBuffer^ out = CryptographicBuffer::CreateFromByteArray(outgoing);
auto task = create_task(connection->TransmitAsync(out)).then([](IBuffer^ buffer) {
return buffer;
});
IBuffer^ responseBuffer = task.get();
response = CryptographicBuffer::EncodeToHexString(responseBuffer);
return response;
}
The connection
is a valid SmartCardConnection^
object.
The create_task
function is from the concurrency
namespace.
You need to catch the exceptions to see whats is really happens.
For example, try something like this when you get the buffer:
try
{
IBuffer^ responseBuffer = task.get();
}
catch (COMException ^ex)
{
std::cout << "Transmit APDU failed with exception:" + ex->ToString() << std::endl;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.