I am using PCSC-sharp library for reading from felica card(NFC). By using the pcsc-sharp sample codes now able to show the card id only. I would like to write new details to the card(say employee code or name) and read the same using ht.Is there any possible way to do this. https://github.com/danm-de/pcsc-sharp/
private static string getData()
{
var context = _contextFactory.Establish(SCardScope.System);
using (var rfidReader = new SCardReader(context))
{
var sc = rfidReader.Connect(readerName, SCardShareMode.Shared, SCardProtocol.Any);
if (sc != SCardError.Success)
{
Console.WriteLine("Card removed", readerName);
writeFile("Card removed");
return "";
}
var apdu = new CommandApdu(IsoCase.Case2Short, rfidReader.ActiveProtocol)
{
CLA = 0xFF,
Instruction = InstructionCode.GetData,
P1 = 0x00,
P2 = 0x00,
Le = 0 // We don't know the ID tag size
};
sc = rfidReader.BeginTransaction();
if (sc != SCardError.Success)
{
Console.WriteLine("Could not begin transaction.");
Console.ReadKey();
return "";
}
Console.WriteLine("Retrieving the UID .... ");
var receivePci = new SCardPCI(); // IO returned protocol control information.
var sendPci = SCardPCI.GetPci(rfidReader.ActiveProtocol);
var receiveBuffer = new byte[256];
var command = apdu.ToArray();
sc = rfidReader.Transmit(
sendPci, // Protocol Control Information (T0, T1 or Raw)
command, // command APDU
receivePci, // returning Protocol Control Information
ref receiveBuffer); // data buffer
if (sc != SCardError.Success)
{
Console.WriteLine("Error: " + SCardHelper.StringifyError(sc));
}
var responseApdu = new ResponseApdu(receiveBuffer, IsoCase.Case2Short, rfidReader.ActiveProtocol);
Console.WriteLine("Uid: {0}", responseApdu.HasData ? BitConverter.ToString(responseApdu.GetData()) : "No uid received");
Console.WriteLine("Uid: {0}", responseApdu.HasData ? responseApdu.GetData().ToString() : "No uid received");
writeFile(BitConverter.ToString(responseApdu.GetData()));
rfidReader.EndTransaction(SCardReaderDisposition.Leave);
rfidReader.Disconnect(SCardReaderDisposition.Reset);
return BitConverter.ToString(responseApdu.GetData());
}
}