public static string SendCommand(ISmartCardReader smartCardReader, string command) { return(smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command)); }
public static void ReadContactSlotConfiguration(string readerName) { var contactSlot = new Readers.AViatoR.Components.ContactSlotConfiguration(); ISmartCardReader smartCardReader = Connect(readerName); if (!smartCardReader.IsConnected) { return; } string command; string response; // Read contact slot enable command = contactSlot.ContactSlotEnable.GetApdu; response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); PrintData("Contact Slot", command, response, contactSlot.ContactSlotEnable.TranslateGetResponse(response)); // Read operating mode command = contactSlot.OperatingMode.GetApdu; response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); PrintData("Operating Mode", command, response, contactSlot.OperatingMode.TranslateGetResponse(response).ToString()); // Read contact slot enable command = contactSlot.VoltageSequence.GetApdu; response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); List <VoltageSequenceFlags> voltageSequenceList = contactSlot.VoltageSequence.TranslateGetResponse(response); if (voltageSequenceList.Count == 0) { PrintData("Voltage Sequence", command, response, "Device driver decides."); } else { PrintData("Voltage Sequence", command, response, voltageSequenceList.Select(item => item.ToString()).ToArray()); } // close connection smartCardReader.Disconnect(CardDisposition.Unpower); }
public static void SetOperatingMode(string readerName) { var contactSlot = new Readers.AViatoR.Components.ContactSlotConfiguration(); ISmartCardReader smartCardReader = Connect(readerName); if (!smartCardReader.IsConnected) { return; } string command; string response; // Set ISO7816 mode command = contactSlot.OperatingMode.SetApdu(OperatingModeFlags.Iso7816); response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); PrintData("Set Operating Mode", command, response, "ISO 7816 mode"); // Set EMVco mode // command = contactSlot.OperatingMode.SetApdu(OperatingModeFlags.EMVCo); // response = reader.ConnectionMode != ReaderSharingMode.Direct ? reader.Transmit(command) : reader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); // PrintData("Set Operating Mode", command, response, "EMVco mode"); smartCardReader.Disconnect(CardDisposition.Unpower); }
public static void SetVoltageSequence(string readerName) { var contactSlot = new Readers.AViatoR.Components.ContactSlotConfiguration(); ISmartCardReader smartCardReader = Connect(readerName); if (!smartCardReader.IsConnected) { return; } string command; string response; // Device Driver decides command = contactSlot.VoltageSequence.SetAutomaticSequenceApdu(); response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); PrintData("Set Voltage Sequence", command, response, "Device driver decides"); // High Mid Low // command = contactSlot.VoltageSequence.SetApdu(VoltageSequenceFlags.High, VoltageSequenceFlags.Mid, VoltageSequenceFlags.Low); // response = reader.ConnectionMode != ReaderSharingMode.Direct ? reader.Transmit(command) : reader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); // PrintData("Voltage Sequence", command, response, "High -> Mid -> Low"); // Low Mid High // command = contactSlot.VoltageSequence.SetApdu(VoltageSequenceFlags.Low, VoltageSequenceFlags.Mid, VoltageSequenceFlags.High); // response = reader.ConnectionMode != ReaderSharingMode.Direct ? reader.Transmit(command) : reader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); // PrintData("Voltage Sequence", command, response, "Low -> Mid -> High"); smartCardReader.Disconnect(CardDisposition.Unpower); }
public static void SetContactSlotEnable(string readerName) { var contactSlot = new Readers.AViatoR.Components.ContactSlotConfiguration(); ISmartCardReader smartCardReader = Connect(readerName); if (!smartCardReader.IsConnected) { return; } string command; string response; //enable command = contactSlot.ContactSlotEnable.SetApdu(true); response = smartCardReader.ConnectionMode != ReaderSharingMode.Direct ? smartCardReader.Transmit(command) : smartCardReader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); PrintData("Set Contact Slot", command, response, "Enable"); //disable // command = contactSlot.ContactSlotEnable.SetApdu(false); // response = reader.ConnectionMode != ReaderSharingMode.Direct ? reader.Transmit(command) : reader.Control(ReaderControlCode.IOCTL_CCID_ESCAPE, command); // PrintData("Set Contact Slot", command, response, "Disable"); smartCardReader.Disconnect(CardDisposition.Unpower); }