I'm trying to send APDU commands to the card reader itself instead of the Smart Card. The test command I'm using turns the RF field on and off.
This commands sends over SCardTransmit if I first connected to a smart card. But as soon as the RF field is off, the card disconnects and I cant send another APDU to turn the field on.
Basically is there any way to send APDU's over pc/sc without a card present. I want to configure certain parts of the reader before reading a card.
Thanks in advance.
-----Edit-----
As FPGA Warrior mentioned I need to use SCardControl to send APDU commands to the card reader.
The steps I've gotten so far:
Connect to 'card' with SCardConnect with SCARD_SHARE_DIRECT and SCARD_PROTOCOL_UNDEFINED. This will return as success and give you the card handle.
_lastError = SCardConnect(_hContext, _cardReaderName, dwShareMode, dwPreferredProtocols, ref phCard, ref _activeProtocol);
Returns: 0 and what looks like a valid _hCard handle.
I then call SCardControl
_lastError = SCardControl(phCard, CTL_code(3500), txBytes, (uint)txByte.Length, out rxBytes, (uint)rxAttr.Length, out rxLen);
I now get the error ERROR_INVALID_HANDLE (0x6). So it seems that my SCardConnect does not return a valid handle, even thou it does not return an error.
As a side note to use PC_to_RDR_Escape mode on the device you might need to edit the registry to turn it on if the drivers you installed does not allow it. https://msdn.microsoft.com/en-us/library/windows/hardware/dn653571%28v=vs.85%29.aspx