M
Marc David PG
Guest
Hi,
I Copy a C# project from Universal Windows (I set there Windows 10, version 1903) To NET.Framework 4.8 And it take all the code fine less than:
the Windows.Storage.Streams AsBuffer()
public static AtrInfo Parse(byte[] atrBytes)
{
AtrInfo atrInfo = new AtrInfo();
byte initialChar = 0, formatByte = 0;
int supportedProtocols = 0;
using (DataReader reader = DataReader.FromBuffer(atrBytes.AsBuffer()))
{
initialChar = reader.ReadByte();
if (initialChar != (byte)AtrHeader.InitialHeader)
{
return null;
}
formatByte = reader.ReadByte();
var interfacePresence = (byte)(formatByte.HiNibble() << 4);
for (int i = 0; i < AtrInfo.MAXIMUM_ATR_CODES; i++)
{
if ((interfacePresence & 0x10) != 0)
atrInfo.ProtocolInterfaceA = reader.ReadByte();
if ((interfacePresence & 0x20) != 0)
atrInfo.ProtocolInterfaceB = reader.ReadByte();
if ((interfacePresence & 0x40) != 0)
atrInfo.ProtocolInterfaceC = reader.ReadByte();
if ((interfacePresence & 0x80) != 0)
atrInfo.ProtocolInterfaceD = reader.ReadByte();
else
break;
interfacePresence = atrInfo.ProtocolInterfaceD;
supportedProtocols |= (1 << interfacePresence.LowNibble());
}
atrInfo.HistoricalBytes = reader.ReadBuffer(formatByte.LowNibble());
if ((supportedProtocols & ~1) != 0)
{
atrInfo.TckValid = ValidateTCK(atrBytes);
}
return atrInfo;
}
}
How can I write it?
Thanks for help!
David
David
Continue reading...
I Copy a C# project from Universal Windows (I set there Windows 10, version 1903) To NET.Framework 4.8 And it take all the code fine less than:
the Windows.Storage.Streams AsBuffer()
public static AtrInfo Parse(byte[] atrBytes)
{
AtrInfo atrInfo = new AtrInfo();
byte initialChar = 0, formatByte = 0;
int supportedProtocols = 0;
using (DataReader reader = DataReader.FromBuffer(atrBytes.AsBuffer()))
{
initialChar = reader.ReadByte();
if (initialChar != (byte)AtrHeader.InitialHeader)
{
return null;
}
formatByte = reader.ReadByte();
var interfacePresence = (byte)(formatByte.HiNibble() << 4);
for (int i = 0; i < AtrInfo.MAXIMUM_ATR_CODES; i++)
{
if ((interfacePresence & 0x10) != 0)
atrInfo.ProtocolInterfaceA = reader.ReadByte();
if ((interfacePresence & 0x20) != 0)
atrInfo.ProtocolInterfaceB = reader.ReadByte();
if ((interfacePresence & 0x40) != 0)
atrInfo.ProtocolInterfaceC = reader.ReadByte();
if ((interfacePresence & 0x80) != 0)
atrInfo.ProtocolInterfaceD = reader.ReadByte();
else
break;
interfacePresence = atrInfo.ProtocolInterfaceD;
supportedProtocols |= (1 << interfacePresence.LowNibble());
}
atrInfo.HistoricalBytes = reader.ReadBuffer(formatByte.LowNibble());
if ((supportedProtocols & ~1) != 0)
{
atrInfo.TckValid = ValidateTCK(atrBytes);
}
return atrInfo;
}
}
How can I write it?
Thanks for help!
David
David
Continue reading...