c# - SCardTrasmit return empty receive byte array -
i'm working on c# pc/sc implementation acs readers , nfc tags.
i have prototyped scardtransmit follows:
[dllimport("winscard.dll")] public static extern int scardtransmit (int32 hcard, ref scard_io_request piosendrequest, byte[] sendbuff, int32 sendbufflen, ref scard_io_request piorecvrequest, byte[] recvbuff, out int32 recvbufflen);
and have following code:
scard.scard_io_request iorequest = new scard.scard_io_request(); iorequest.dwprotocol = protocol; // going t=1 iorequest.cbpcilength = 8; byte[] cmdbytes = new byte[] { 0xff, 0xca, 0x00, 0x00, 0x00 }; byte[] rcvbytes = new byte[10]; int rcvlenght = 0; retcode = scard.scardtransmit(handle, ref iorequest, cmdbytes, cmdbytes.length, ref iorequest, rcvbytes, out rcvlenght); if (retcode != scard.scard_s_success) throw new exception("failed querying tag uid: " + retcode);
all (not shown) init'ing stuff seems works fine , can succesfully tag's atr.
now, running code success return code, receive consistent received bytes lenght value corrisponding byte array empty (zeroes).
anyone can advice on this?
thank you.
the prototype scardtransmit
problem. write as:
[dllimport("winscard.dll")] public static extern uint scardtransmit(int32 hcard, scard_io_request piosendpci, [in] byte[] pbsendbuffer, uint cbsendlength, scard_io_request piorecvpci, [in, out] byte[] pbrecvbuffer, ref uint pcbrecvlength);
the main difference second last parameter pbrecvbuffer
, declared attributes in
, out
.
Comments
Post a Comment