2013-05-21 2 views
0

나는 ACS 판독기 및 NFC 태그를 사용하여 C# PC/SC 구현을하고 있습니다. 다음과 같이SCardTrasmit 반환 빈 수신 바이트 배열

은 내가 SCardTransmit 프로토 타입을했다 :

[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); 

을 그리고 나는 다음과 같은 코드가 있습니다

 SCard.SCARD_IO_REQUEST ioRequest = new SCard.SCARD_IO_REQUEST(); 
     ioRequest.dwProtocol = Protocol; // Is going to be 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); 

을 모든 (도시하지 않음)에 물건을 init'ing하기에 잘 작동하고 내가 할 수있는 것 태그의 ATR을 성공적으로 가져옵니다.

이제이 코드를 실행하면 성공 반환 코드가 수신되며 일치하는 바이트 길이 값이 수신되지만 해당 바이트 배열은 비어 있습니다 (0).

누구나 이것에 대한 조언을 할 수 있습니까?

감사합니다.

답변

1

SCardTransmit의 프로토 타입이 가장 문제 일 수 있습니다.

[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); 

가장 큰 차이점은 속성 InOut로 선언 된 마지막 매개 변수 pbRecvBuffer, 두 번째입니다 : 나는 그것을 작성합니다.