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

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Tue Jan 28 14:50:43 UTC 2014


Author: rousseau
Date: 2014-01-28 14:50:43 +0000 (Tue, 28 Jan 2014)
New Revision: 6832

Modified:
   trunk/Drivers/ccid/src/ccid.h
   trunk/Drivers/ccid/src/ccid_serial.c
   trunk/Drivers/ccid/src/reader.conf.in
Log:
Add support of Gemalto CR30 reader in serial communication

The Gemalto CR30 reader is a dual slot reader. The reader can be
connected with a USB cable (normal CCID protocol) or using a serial
cable.

The serial configuration is made using a special name in
/etc/reader.conf DEVICENAME field like:
DEVICENAME        /dev/ttyS0:GemCoreSIMPro2


Modified: trunk/Drivers/ccid/src/ccid.h
===================================================================
--- trunk/Drivers/ccid/src/ccid.h	2014-01-28 13:15:22 UTC (rev 6831)
+++ trunk/Drivers/ccid/src/ccid.h	2014-01-28 14:50:43 UTC (rev 6832)
@@ -185,6 +185,7 @@
 #define GEMPCTWIN	0x08E63437
 #define GEMPCPINPAD 0x08E63478
 #define GEMCORESIMPRO 0x08E63480
+#define GEMCORESIMPRO2 0x08E60000 /* Does NOT match a real VID/PID as new firmware release exposes same VID/PID */
 #define GEMCOREPOSPRO 0x08E63479
 #define GEMALTOPROXDU 0x08E65503
 #define GEMALTOPROXSU 0x08E65504
@@ -267,6 +268,19 @@
 /* data rates supported by the secondary slots on the GemCore Pos Pro & SIM Pro */
 #define GEMPLUS_CUSTOM_DATA_RATES 10753, 21505, 43011, 125000
 
+/* data rates for GemCore SIM Pro 2 */
+#define SIMPRO2_ISO_DATA_RATES 8709, 10322, 12403, 12500, \
+		12903, 17204, 18750, 20645, 24806, \
+		25000, 25806, 28125, 30967, 34408, \
+		37500, 41290, 46875, 49612, 50000, \
+		51612, 56250, 62500, 64516, 68817, \
+		74418, 75000, 82580, 86021, 93750, \
+		99224, 100000, 103225, 112500, 124031, \
+		125000, 137634, 150000, 154838, 165161, \
+		172043, 187500, 198449, 200000, 206451, \
+		258064, 275268, 300000, 396899, 400000, \
+		412903, 550537, 600000, 825806
+
 /* Structure returned by Gemalto readers for the CCID Escape command 0x6A */
 struct GEMALTO_FIRMWARE_FEATURES
 {

Modified: trunk/Drivers/ccid/src/ccid_serial.c
===================================================================
--- trunk/Drivers/ccid/src/ccid_serial.c	2014-01-28 13:15:22 UTC (rev 6831)
+++ trunk/Drivers/ccid/src/ccid_serial.c	2014-01-28 14:50:43 UTC (rev 6832)
@@ -154,6 +154,9 @@
 /* data rates supported by the secondary slots on the GemCore Pos Pro & SIM Pro */
 unsigned int SerialCustomDataRates[] = { GEMPLUS_CUSTOM_DATA_RATES, 0 };
 
+/* data rates supported by the GemCore SIM Pro 2 */
+unsigned int SIMPro2DataRates[] = { SIMPRO2_ISO_DATA_RATES, 0  };
+
 /* no need to initialize to 0 since it is static */
 static _serialDevice serialDevice[CCID_DRIVER_MAX_READERS];
 
@@ -522,6 +525,8 @@
 		readerID = GEMCOREPOSPRO;
 	else if (0 == strcasecmp(reader_name,"GemCoreSIMPro"))
 		readerID = GEMCORESIMPRO;
+	else if (0 == strcasecmp(reader_name,"GemCoreSIMPro2"))
+		readerID = GEMCORESIMPRO2;
 	else if (0 == strcasecmp(reader_name,"GemPCPinPad"))
 		readerID = GEMPCPINPAD;
 
@@ -622,6 +627,14 @@
 			serialDevice[reader_index].ccid.dwMaxDataRate = 500000;
 			break;
 
+		case GEMCORESIMPRO2:
+			serialDevice[reader_index].ccid.dwDefaultClock = 4800;
+			serialDevice[reader_index].ccid.bMaxSlotIndex = 1; /* 2 slots */
+			serialDevice[reader_index].ccid.arrayOfSupportedDataRates = SIMPro2DataRates;
+			serialDevice[reader_index].echo = FALSE;
+			serialDevice[reader_index].ccid.dwMaxDataRate = 825806;
+			break;
+
 		case GEMPCPINPAD:
 			serialDevice[reader_index].ccid.bPINSupport = 0x03;
 			serialDevice[reader_index].ccid.arrayOfSupportedDataRates = SerialExtendedDataRates;
@@ -740,6 +753,58 @@
 	 * will echo characters for you.  Don't generate signals. */
 	current_termios.c_lflag = 0;
 
+	if (0 == strcasecmp(reader_name,"GemCoreSIMPro2"))
+	{
+		unsigned char pcbuffer[SIZE_GET_SLOT_STATUS];
+		unsigned int old_timeout;
+		RESPONSECODE r;
+
+		/* Unless we resume from a stand-by condition, GemCoreSIMPro2
+		 * starts at 9600 bauds, so let's first try this speed */
+		/* set serial port speed to 9600 bauds */
+		(void)cfsetspeed(&current_termios, B9600);
+		DEBUG_INFO("Set serial port baudrate to 9600 and correct configuration");
+		if (tcsetattr(serialDevice[reader_index].fd, TCSANOW, &current_termios) == -1)
+		{
+			(void)close(serialDevice[reader_index].fd);
+			serialDevice[reader_index].fd = -1;
+			DEBUG_CRITICAL2("tcsetattr error: %s", strerror(errno));
+
+			return STATUS_UNSUCCESSFUL;
+		}
+
+		/* Test current speed issuing a CmdGetSlotStatus with a very
+		 * short time out of 1 seconds */
+		old_timeout = serialDevice[reader_index].ccid.readTimeout;
+
+		serialDevice[reader_index].ccid.readTimeout = 1*1000;
+		r = CmdGetSlotStatus(reader_index, pcbuffer);
+
+		/* Restore default time out value */
+		serialDevice[reader_index].ccid.readTimeout = old_timeout;
+
+		if (IFD_SUCCESS == r)
+		{
+			/* We are at 9600 bauds, let's move to 115200 */
+			unsigned char tx_buffer[] = { 0x01, 0x10, 0x20 };
+			unsigned char rx_buffer[50];
+			unsigned int rx_length = sizeof(rx_buffer);
+
+			if (IFD_SUCCESS == CmdEscape(reader_index, tx_buffer,
+				sizeof(tx_buffer), rx_buffer, &rx_length, 0))
+			{
+				/* Let the reader setup its new communication speed */
+				(void)usleep(250*1000);
+			}
+			else
+			{
+				DEBUG_INFO("CmdEscape to configure 115200 bauds failed");
+			}
+		}
+		/* In case of a failure, reader is probably already at 115200
+		 * bauds as code below assumes */
+	}
+
 	/* set serial port speed to 115200 bauds */
 	(void)cfsetspeed(&current_termios, B115200);
 

Modified: trunk/Drivers/ccid/src/reader.conf.in
===================================================================
--- trunk/Drivers/ccid/src/reader.conf.in	2014-01-28 13:15:22 UTC (rev 6831)
+++ trunk/Drivers/ccid/src/reader.conf.in	2014-01-28 14:50:43 UTC (rev 6832)
@@ -1,10 +1,14 @@
 # Gemalto reader with serial communication
 #  - n is the serial port to use n in [0..3]
 #  - reader is the reader name. It is needed for multi-slot readers.
-#    Possible reader values are: GemPCPinPad, GemCorePOSPro, GemCoreSIMPro,
-#    GemPCTwin (default value)
+#    Possible reader values are: 
+#     GemCorePOSPro
+#     GemCoreSIMPro
+#     GemCoreSIMPro2
+#     GemPCPinPad
+#     GemPCTwin (default value)
 # example: /dev/ttyS0:GemPCPinPad
+#DEVICENAME        /dev/ttySn[:reader]
 #FRIENDLYNAME      "GemPCTwin serial"
-#DEVICENAME        /dev/ttySn[:reader]
 #LIBPATH           TARGET
 #CHANNELID         n




More information about the Pcsclite-cvs-commit mailing list