2using System.Collections.Generic;
30 PData = pData ??
throw new ArgumentNullException(nameof(pData));
62 return data.ToArray();
74 byte mode = data.Length > 0 ? data[0] : (byte)0;
75 byte pCommand = data.Length > 1 ? data[1] : (byte)0;
76 byte[] pData = data.Length > 2 ? data.Slice(2).ToArray() : [];
91 new(0, 2, [0, (byte)(enabled ? 1 : 0)]);
107 if (command ==
null)
throw new ArgumentNullException(nameof(command));
109 var data =
new byte[command.Length + 1];
110 data[0] = readerNumber;
111 Array.Copy(command, 0, data, 1, command.Length);
120 new(1, 2, [readerNumber]);
127 new(1, 4, [readerNumber]);
132 var sb =
new StringBuilder();
133 sb.AppendLine($
" Mode: {Mode}");
134 sb.AppendLine($
"PCommand: {PCommand}");
135 sb.AppendLine($
" PData: {BitConverter.ToString(PData)}");
136 return sb.ToString();
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload of a PD command message.
byte[] PData
Gets the command-specific data.
byte PCommand
Gets the mode-specific command code.
override string ToString()
override CommandType CommandType
static ExtendedWrite ModeZeroConfiguration(bool enabled)
Configures Mode 0 (enable or disable transparent mode).
override ReadOnlySpan< byte > SecurityControlBlock()
byte Mode
Gets the extended READ/WRITE mode.
static ExtendedWrite ModeOneConfiguration()
Switches the PD to Mode 1 (transparent APDU).
static ExtendedWrite ModeOneTerminateSmartCardConnection(byte readerNumber)
Instructs the PD to terminate the smart card session on the specified reader.
static ExtendedWrite ReadModeSetting()
Queries the PD for its current extended mode setting.
static ExtendedWrite ModeOnePassAPDUCommand(byte readerNumber, byte[] command)
Passes a raw APDU to the smart card through the specified reader.
static ExtendedWrite ModeOneSmartCardScan(byte readerNumber)
Instructs the PD to scan for a smart card on the specified reader.
static ExtendedWrite ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
ExtendedWrite(byte mode, byte pCommand, byte[] pData)
Initializes a new instance of the ExtendedWrite class.
override byte[] BuildData()