[Pcsclite-cvs-commit] r5280 - /trunk/PCSC/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Oct 5 14:06:45 UTC 2010


Author: rousseau
Date: Tue Oct  5 14:06:43 2010
New Revision: 5280

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5280
Log:
Call SCardGetStatusChange() in a endless loop

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

Added: trunk/PCSC/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py?rev=5280&op=file
==============================================================================
--- trunk/PCSC/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py (added)
+++ trunk/PCSC/UnitaryTests/SCardGetStatusChange/SCardGetStatusChange_loop.py Tue Oct  5 14:06:43 2010
@@ -1,0 +1,63 @@
+#! /usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+#   SCardGetStatusChange.py : Unit tests for unlock a SCardGetStatusChange()
+#   Copyright (C) 2010  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 2 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, write to the Free Software Foundation, Inc.,
+#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+from smartcard.System import readers
+from smartcard.scard import *
+
+import sys
+
+hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
+hresult, readers = SCardListReaders(hcontext, [])
+
+# initialise the states of the readers
+readerstates = {}
+for reader in readers:
+    readerstates[reader] = (reader, SCARD_STATE_UNAWARE)
+print "values", readerstates.values()
+(hresult, states) = SCardGetStatusChange(hcontext, 0, readerstates.values())
+print SCardGetErrorMessage(hresult)
+print states
+
+for state in states:
+    readername, eventstate, atr = state
+    print "readername:", readername
+    print "eventstate:", hex(eventstate)
+    print "atr:", atr
+    readerstates[readername] = (readername, eventstate)
+print "values", readerstates.values()
+
+while 1:
+    # timeout is 1000 ms
+    (hresult, states) = SCardGetStatusChange(hcontext, 1000, readerstates.values())
+    print SCardGetErrorMessage(hresult)
+    print states
+
+    for state in states:
+        print state
+        readername, eventstate, atr = state
+        print "readername:", readername
+        print "eventstate:", hex(eventstate)
+        print "atr:", atr
+        readerstates[readername] = (readername, eventstate)
+    print "values", readerstates.values()
+
+hresult = SCardReleaseContext(hcontext)
+print SCardGetErrorMessage(hresult)

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




More information about the Pcsclite-cvs-commit mailing list