C# Mifare Desfire/Mifare plus can';t使用ACS ACR1252读取
嗨,我是RFID阅读的新手。所以首先我从github下载了pcsc sharp存储库。然后我尝试从普通的rfid标签中读取二进制文件,它工作得很好,但下一步是从我认为是模拟的rfid标签中读取数据。RFID标签控制器为pn71501。从这个标签使用pcsc夏普,我无法读取任何数据,除了ATR和uid。我试着用我的iPhone读取这个标签,它读取了。那我做错了什么 我也尝试使用已经完成的软件,但它也无法读取 以下是我使用NFC工具得到的信息: 我使用的PS智能卡读卡器是ACS ACR1252 这是我的密码:C# Mifare Desfire/Mifare plus can';t使用ACS ACR1252读取,c#,rfid,smartcard-reader,pcsc,acr1252,C#,Rfid,Smartcard Reader,Pcsc,Acr1252,嗨,我是RFID阅读的新手。所以首先我从github下载了pcsc sharp存储库。然后我尝试从普通的rfid标签中读取二进制文件,它工作得很好,但下一步是从我认为是模拟的rfid标签中读取数据。RFID标签控制器为pn71501。从这个标签使用pcsc夏普,我无法读取任何数据,除了ATR和uid。我试着用我的iPhone读取这个标签,它读取了。那我做错了什么 我也尝试使用已经完成的软件,但它也无法读取 以下是我使用NFC工具得到的信息: 我使用的PS智能卡读卡器是ACS ACR1252
using System;
using System.Text;
using System.Collections.Generic;
using PCSC;
using PCSC.Iso7816;
namespace Transmit {
public class Program {
public static void Main() {
using (var context = ContextFactory.Instance.Establish(SCardScope.System)) {
var readerNames = context.GetReaders();
if (NoReaderFound(readerNames)) {
Console.WriteLine("You need at least one reader in order to run this example.");
Console.ReadKey();
return;
}
var readerName = ChooseRfidReader(readerNames);
if (readerName == null) {
return;
}
String response = "";
using (var rfidReader = context.ConnectReader(readerName, SCardShareMode.Shared, SCardProtocol.Any)) {
// for (byte i = 0x00; i < 0x47; i++) {
var apdu = new CommandApdu(IsoCase.Case3Extended, rfidReader.Protocol) {
CLA = 0xFF,
Instruction = (InstructionCode)0xB0,
P1 = 0x00,
P2 = 0x00,
Le = 0x10
};
using (rfidReader.Transaction(SCardReaderDisposition.Leave)) {
//Console.WriteLine("Retrieving the UID .... ");
var sendPci = SCardPCI.GetPci(rfidReader.Protocol);
var receivePci = new SCardPCI(); // IO returned protocol control information.
var receiveBuffer = new byte[256];
var command = apdu.ToArray();
var bytesReceived = rfidReader.Transmit(
sendPci, // Protocol Control Information (T0, T1 or Raw)
command, // command APDU
command.Length,
receivePci, // returning Protocol Control Information
receiveBuffer,
receiveBuffer.Length); // data buffer
var responseApdu =
new ResponseApdu(receiveBuffer, bytesReceived, IsoCase.Case3Extended, rfidReader.Protocol);
Console.WriteLine(String.Format("SW1: {0:X2} SW2: {1:X2}", responseApdu.SW1, responseApdu.SW2));
//if(responseApdu.DataSize > 0) {
//response += BitConverter.ToString(responseApdu.GetData()).Replace('-', ' ');
response += responseApdu.DataSize;
// }
}
// }
}
/*String[] devidedResponse = response.Split(' ');
String stillResponse = "";
bool notStarted = true;
int skipBytes = 7;
int onByte = 0;
for(int i = 0; i < devidedResponse.Length; i++) {
if (devidedResponse[i] != "D1" && notStarted) {
continue;
} else if (onByte < skipBytes) {
notStarted = false;
onByte += 1;
continue;
} else if (devidedResponse[i] == "FE") {
break;
}
stillResponse += devidedResponse[i] + " ";
}
String res = stillResponse.Trim();
string asciiCharString = "";
var splitResult = res.Split(' ');
foreach (string hexChar in splitResult) {
var byteChar = int.Parse(hexChar, System.Globalization.NumberStyles.HexNumber);
asciiCharString += (char)byteChar;
}*/
Console.WriteLine(response);
}
Console.WriteLine("\nPress any key to exit.");
Console.ReadKey();
}
private static string ChooseRfidReader(IList<string> readerNames) {
// Show available readers.
Console.WriteLine("Available readers: ");
for (var i = 0; i < readerNames.Count; i++) {
Console.WriteLine($"[{i}] {readerNames[i]}");
}
// Ask the user which one to choose.
Console.Write("Which reader is an RFID reader? ");
var line = Console.ReadLine();
if (int.TryParse(line, out var choice) && choice >= 0 && (choice <= readerNames.Count)) {
return readerNames[choice];
}
Console.WriteLine("An invalid number has been entered.");
Console.ReadKey();
return null;
}
private static bool NoReaderFound(ICollection<string> readerNames) =>
readerNames == null || readerNames.Count < 1;
}
}
使用系统;
使用系统文本;
使用System.Collections.Generic;
使用PCSC;
采用PCSC.Iso7816;
名称空间传输{
公共课程{
公共静态void Main(){
使用(var context=ContextFactory.Instance.build(SCardScope.System)){
var readerNames=context.GetReaders();
if(NoReaderFound(读卡器名称)){
WriteLine(“您至少需要一个读卡器才能运行此示例。”);
Console.ReadKey();
返回;
}
var readerName=选择FIDReader(readerName);
if(readerName==null){
返回;
}
字符串响应=”;
使用(var rfidReader=context.ConnectReader(readerName、SCardShareMode.Shared、SCardProtocol.Any)){
//用于(字节i=0x00;i<0x47;i++){
var apdu=新命令apdu(IsoCase.Case3Extended,rfidReader.Protocol){
CLA=0xFF,
指令=(指令代码)0xB0,
P1=0x00,
P2=0x00,
Le=0x10
};
使用(rfidReader.Transaction(scarderDisposition.Leave)){
//Console.WriteLine(“检索UID…”);
var sendPci=SCardPCI.GetPci(rfidReader.Protocol);
var receivePci=new SCardPCI();//IO返回协议控制信息。
var receiveBuffer=新字节[256];
var命令=apdu.ToArray();
var bytesReceived=rfidReader.Transmit(
sendPci,//协议控制信息(T0、T1或原始)
命令,//命令APDU
命令长度,
receivePci,//返回协议控制信息
接收缓冲区,
receiveBuffer.Length);//数据缓冲区
var响应EAPDU=
新响应ADU(接收缓冲区、接收字节、IsoCase.CASE3扩展、rfidReader.Protocol);
WriteLine(String.Format(“SW1:{0:X2}SW2:{1:X2}”,responseApdu.SW1,responseApdu.SW2));
//如果(responseADU.DataSize>0){
//response+=BitConverter.ToString(responseADU.GetData()).Replace('-','');
response+=responseADU.DataSize;
// }
}
// }
}
/*字符串[]devidedResponse=response.Split(“”);
字符串stillResponse=“”;
bool notstart=true;
int skipBytes=7;
int onByte=0;
for(int i=0;i=0&&choice
readerNames==null | | readerNames.Count<1;
}
}
我知道。我以前查过。你能用文件管理器读取卡片吗
像UART这样的硬件设备可以在三个不同的级别读取