[Pcsclite-cvs-commit] r7039 - trunk/Drivers/ccid/src

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Sun Nov 9 20:32:32 UTC 2014


Author: rousseau
Date: 2014-11-09 20:32:32 +0000 (Sun, 09 Nov 2014)
New Revision: 7039

Modified:
   trunk/Drivers/ccid/src/commands.c
   trunk/Drivers/ccid/src/commands.h
Log:
Add CmdEscapeCheck()

CmdEscapeCheck() is CmdEscape() with an extra "mayfail" parameter.

If mayfail is TRUE then the error is logged as PCSC_LOG_INFO instead of
PCSC_LOG_ERROR.

This is usefull in cases we know the command may fail. So the error is
expected and not really an error.

See Alioth bug [#314871] "commands.c:979:CmdEscape error on byte 10"           
message
https://alioth.debian.org/tracker/index.php?func=detail&aid=314871&group_id=3010+++5&atid=410086


Modified: trunk/Drivers/ccid/src/commands.c
===================================================================
--- trunk/Drivers/ccid/src/commands.c	2014-11-09 20:27:05 UTC (rev 7038)
+++ trunk/Drivers/ccid/src/commands.c	2014-11-09 20:32:32 UTC (rev 7039)
@@ -48,6 +48,7 @@
 #include "defs.h"
 #include "ccid_ifdhandler.h"
 #include "debug.h"
+#include "utils.h"
 
 /* All the pinpad readers I used are more or less bogus
  * I use code to change the user command and make the firmware happy */
@@ -884,6 +885,21 @@
 	const unsigned char TxBuffer[], unsigned int TxLength,
 	unsigned char RxBuffer[], unsigned int *RxLength, unsigned int timeout)
 {
+	return CmdEscapeCheck(reader_index, TxBuffer, TxLength, RxBuffer, RxLength,
+		timeout, FALSE);
+} /* CmdEscape */
+
+
+/*****************************************************************************
+ *
+ *					Escape (with check of gravity)
+ *
+ ****************************************************************************/
+RESPONSECODE CmdEscapeCheck(unsigned int reader_index,
+	const unsigned char TxBuffer[], unsigned int TxLength,
+	unsigned char RxBuffer[], unsigned int *RxLength, unsigned int timeout,
+	int mayfail)
+{
 	unsigned char *cmd_in, *cmd_out;
 	status_t res;
 	unsigned int length_in, length_out;
@@ -976,7 +992,9 @@
 
 	if (cmd_out[STATUS_OFFSET] & CCID_COMMAND_FAILED)
 	{
-		ccid_error(PCSC_LOG_ERROR, cmd_out[ERROR_OFFSET], __FILE__, __LINE__, __FUNCTION__);    /* bError */
+		/* mayfail: the error may be expected and not fatal */
+		ccid_error(mayfail ? PCSC_LOG_INFO : PCSC_LOG_ERROR,
+			cmd_out[ERROR_OFFSET], __FILE__, __LINE__, __FUNCTION__);    /* bError */
 		return_value = IFD_COMMUNICATION_ERROR;
 	}
 
@@ -994,7 +1012,7 @@
 		ccid_descriptor -> readTimeout = old_read_timeout;
 
 	return return_value;
-} /* Escape */
+} /* EscapeCheck */
 
 
 /*****************************************************************************

Modified: trunk/Drivers/ccid/src/commands.h
===================================================================
--- trunk/Drivers/ccid/src/commands.h	2014-11-09 20:27:05 UTC (rev 7038)
+++ trunk/Drivers/ccid/src/commands.h	2014-11-09 20:32:32 UTC (rev 7039)
@@ -41,6 +41,11 @@
 	const unsigned char TxBuffer[], unsigned int TxLength,
 	unsigned char RxBuffer[], unsigned int *RxLength, unsigned int timeout);
 
+RESPONSECODE CmdEscapeCheck(unsigned int reader_index,
+	const unsigned char TxBuffer[], unsigned int TxLength,
+	unsigned char RxBuffer[], unsigned int *RxLength, unsigned int timeout,
+	int mayfail);
+
 RESPONSECODE CmdPowerOff(unsigned int reader_index);
 
 RESPONSECODE CmdGetSlotStatus(unsigned int reader_index,




More information about the Pcsclite-cvs-commit mailing list