[Pcsclite-cvs-commit] r6247 - /trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Sat Mar 24 19:09:34 UTC 2012


Author: rousseau
Date: Sat Mar 24 19:09:34 2012
New Revision: 6247

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6247
Log:
Unitary test for FEATURE_CCID_ESC_COMMAND and Xiring Leo readers

Added:
    trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py   (with props)

Added: trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py?rev=6247&op=file
==============================================================================
--- trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py (added)
+++ trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py Sat Mar 24 19:09:34 2012
@@ -1,0 +1,51 @@
+#! /usr/bin/env python
+
+"""
+#   FEATURE_CCID_ESC_COMMAND_Xiring.py: Unitary test for
+#   FEATURE_CCID_ESC_COMMAND
+#   Copyright (C) 2012  Ludovic Rousseau
+
+"""
+
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program; if not, see <http://www.gnu.org/licenses/>.
+
+from smartcard.System import readers
+from smartcard.pcsc.PCSCPart10 import (getFeatureRequest, hasFeature,
+    getTlvProperties, FEATURE_CCID_ESC_COMMAND, SCARD_SHARE_DIRECT)
+
+# use the first reader
+card_connection = readers()[0].createConnection()
+card_connection.connect(mode=SCARD_SHARE_DIRECT)
+
+# get CCID Escape control code
+feature_list = getFeatureRequest(card_connection)
+
+ccid_esc_command = hasFeature(feature_list, FEATURE_CCID_ESC_COMMAND)
+if ccid_esc_command is None:
+    raise Exception("The reader does not support FEATURE_CCID_ESC_COMMAND")
+
+# get the TLV PROPERTIES
+tlv = getTlvProperties(card_connection)
+
+# check we are using a Xiring Leo v1 or v2 reader
+if tlv['PCSCv2_PART10_PROPERTY_wIdVendor'] == 0x0F14 \
+    and (tlv['PCSCv2_PART10_PROPERTY_wIdProduct'] in [0x0037, 0x0038]):
+
+    # proprietary escape command for Xiring readers
+    version = [ord(c) for c in "VERSION"]
+    res = card_connection.control(ccid_esc_command, version)
+    print res
+    print ''.join([chr(x) for x in res])
+else:
+    print "Xiring Leo reader not found"

Propchange: trunk/PCSC/UnitaryTests/FEATURE_CCID_ESC_COMMAND_Xiring.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Pcsclite-cvs-commit mailing list