[Pcsclite-cvs-commit] r6244 - /trunk/PCSC/UnitaryTests/control_get_firmware.py
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Fri Mar 23 09:44:16 UTC 2012
Author: rousseau
Date: Fri Mar 23 09:44:15 2012
New Revision: 6244
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6244
Log:
Use getTlvProperties() and PCSCv2_PART10_PROPERTY_wIdVendor
We now check the reader is a Gemalto one before sending an escape code
Modified:
trunk/PCSC/UnitaryTests/control_get_firmware.py
Modified: trunk/PCSC/UnitaryTests/control_get_firmware.py
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/UnitaryTests/control_get_firmware.py?rev=6244&op=diff
==============================================================================
--- trunk/PCSC/UnitaryTests/control_get_firmware.py (original)
+++ trunk/PCSC/UnitaryTests/control_get_firmware.py Fri Mar 23 09:44:15 2012
@@ -2,7 +2,7 @@
"""
# control_get_firmware.py: get firmware version of Gemalto readers
-# Copyright (C) 2009-2010 Ludovic Rousseau
+# Copyright (C) 2009-2012 Ludovic Rousseau
"""
# This program is free software; you can redistribute it and/or modify
@@ -20,16 +20,29 @@
from smartcard.System import readers
from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT,
- SCARD_LEAVE_CARD, SCARD_CTL_CODE)
+ SCARD_LEAVE_CARD, SCARD_CTL_CODE, getTlvProperties)
for reader in readers():
cardConnection = reader.createConnection()
cardConnection.connect(mode=SCARD_SHARE_DIRECT,
disposition=SCARD_LEAVE_CARD)
- get_firmware = [0x02]
- IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1)
- res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
- get_firmware)
print "Reader:", reader
- print "Firmware:", "".join([chr(x) for x in res])
+
+ # properties returned by IOCTL_FEATURE_GET_TLV_PROPERTIES
+ properties = getTlvProperties(cardConnection)
+
+ # Gemalto devices supports a control code to get firmware
+ if properties['PCSCv2_PART10_PROPERTY_wIdVendor'] == 0x08E6:
+ get_firmware = [0x02]
+ IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1)
+ res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
+ get_firmware)
+ print " Firmware:", "".join([chr(x) for x in res])
+ else:
+ print " Not a Gemalto reader"
+ try:
+ res = properties['PCSCv2_PART10_PROPERTY_sFirmwareID']
+ print " Firmware:", frimware
+ except KeyError:
+ print " PCSCv2_PART10_PROPERTY_sFirmwareID not supported"
More information about the Pcsclite-cvs-commit
mailing list