[英]C++ SmartCard communication
我正在使用Windows.Devices.SmartCards命名空間與智能卡進行通信。 我找到了讀者,還有卡片。 我還可以向卡發送APDU命令。 但是問題在於,在幾個ADPU之后,我收到的響應為0x63 00而不是0x9000。在大多數情況下,它停止接收第二個或第三個APDU之后的命令,此后響應始終為0x63 00,直到我卸下卡並重新連接。
這是我的傳輸代碼:
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;
}
該connection
是有效的SmartCardConnection^
對象。
create_task
函數來自concurrency
名稱空間。
您需要捕獲異常以了解實際情況。
例如,在獲得緩沖區時嘗試以下操作:
try
{
IBuffer^ responseBuffer = task.get();
}
catch (COMException ^ex)
{
std::cout << "Transmit APDU failed with exception:" + ex->ToString() << std::endl;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.