[Pcsclite-cvs-commit] r2415 - trunk/pycsc/examples

Ludovic Rousseau rousseau at alioth.debian.org
Wed Feb 21 15:04:05 CET 2007


Author: rousseau
Date: 2007-02-21 15:04:04 +0100 (Wed, 21 Feb 2007)
New Revision: 2415

Modified:
   trunk/pycsc/examples/example_lowlevel.py
Log:
update to use the low level API


Modified: trunk/pycsc/examples/example_lowlevel.py
===================================================================
--- trunk/pycsc/examples/example_lowlevel.py	2007-02-21 14:01:30 UTC (rev 2414)
+++ trunk/pycsc/examples/example_lowlevel.py	2007-02-21 14:04:04 UTC (rev 2415)
@@ -1,12 +1,12 @@
 #!/usr/bin/python
 
-import pycsc
+import PyCSC.pycsc
 
 # binascii is used to tranform hexstrings into binary strings
 # and vice versa. the struct package could also be used.
 import binascii
 
-card = pycsc.pycsc()
+card = PyCSC.pycsc.pycsc()
 
 #Print reader name
 print "Connected to reader: " + card.status()["ReaderName"]
@@ -18,12 +18,12 @@
 # Print ATR
 print "Card Answer To Reset: " + binascii.b2a_hex(card.status()["ATR"])
 
-# For T=0 transmit, use pycsc.SCARD_PROTOCOL_T0
-# For T=1 transmit, use pycsc.SCARD_PROTOCOL_T1
+# For T=0 transmit, use PyCSC.pycsc.SCARD_PROTOCOL_T0
+# For T=1 transmit, use PyCSC.pycsc.SCARD_PROTOCOL_T1
 binascii.b2a_hex(card.transmit("\x00\xA4\x00\x00\x02\x3F\x00", 
-                 pycsc.SCARD_PROTOCOL_T0))
+                 PyCSC.pycsc.SCARD_PROTOCOL_T0))
 
-# Protocol argument is optional (default is pycsc.SCARD_PROTOCOL_T0)
+# Protocol argument is optional (default is PyCSC.pycsc.SCARD_PROTOCOL_T0)
 resp = card.transmit(binascii.a2b_hex("00A40000023F00"))
 
 print "APDU sent to card: Select MF"
@@ -33,33 +33,33 @@
 print "APDU sent to card: Get Response"
 print "Response: " + binascii.b2a_hex(card.transmit("\x00\xC0\x00\x00" + resp[-1]))
 
-readerName = pycsc.listReader()[0]
+readerName = PyCSC.pycsc.listReader()[0]
 # if reader is empty, should block until card is inserted
 # if reader is not empty, should return right away
-newState =  pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState':pycsc.SCARD_STATE_EMPTY}])
+newState =  PyCSC.pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState':PyCSC.pycsc.SCARD_STATE_EMPTY}])
 
 print newState
 
 # Shoud return immediately with current state
-newState =  pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState':pycsc.SCARD_STATE_UNAWARE}])
+newState =  PyCSC.pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState':PyCSC.pycsc.SCARD_STATE_UNAWARE}])
 
 # Block until any change of state
-newState =  pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState': newState[0]['EventState']}])
+newState =  PyCSC.pycsc.getStatusChange(ReaderStates=[{'Reader': readerName, 'CurrentState': newState[0]['EventState']}])
 
 print newState
 
 
 # This works:
-pycsc.getStatusChange(ReaderStates=newState)
+PyCSC.pycsc.getStatusChange(ReaderStates=newState)
 
 # And so does this (default value for CurrentState is SCARD_STATE_EMPTY):
 # This code should block if the reader is empty
 # This is NOT true on Windows. CurrentState/EventState seem to behave differently
 # The only way to block is the one listed aove (i.e. read the state
 # update CurrentState with the returned EventState and call getStatusChange again)
-pycsc.getStatusChange(ReaderStates=[{'Reader': readerName}])
+PyCSC.pycsc.getStatusChange(ReaderStates=[{'Reader': readerName}])
 
 # Block until card insertion with a 10000 ms timeout
-pycsc.getStatusChange(Timeout=10000, ReaderStates=[{'Reader': readerName}])
+PyCSC.pycsc.getStatusChange(Timeout=10000, ReaderStates=[{'Reader': readerName}])
 
 




More information about the Pcsclite-cvs-commit mailing list