12/14/2017 Ludovic Rousseau's blog: PCSC sample in Python using pythonpcsclite
更多 下一个博客» 创建博客 登录
Ludovic Rousseau's blog
My activities related to smart card and Free Software (as in free speech).
Friday, December 5, 2014 Google+ Badge
PCSC sample in Python using pythonpcsclite Ludovic Rousseau blog
Here is a new PCSC sample in Python language for the series PC/SC sample in different languages. Follow
I already presented, pyscard, a Python wrapper in "PCSC sample in Python". This wrapper is a different
implementation and API.
Blog Archive
Installation ► 2017 (33)
The installation is easy on a Debian system. A .deb package is provided (but the project is not part of ► 2016 (49)
Debian).
► 2015 (51)
Or you can rebuild the software from the source code. The current version is 0.13.
▼ 2014 (61)
The web site is http://pythonpcsclite.sourceforge.net/. The license is GNU Affero General Public License as ▼ December (11)
published by the Free Software Foundation, either version 3 of the License, or (at your option) any later Great OpenPGP smart card
version. article (in French)
OS X Yosemite bug:
SCardStatus returns
Source code SCARD_E_INS...
#!/usr/bin/env python OS X Yosemite bug:
SCardStatus() after a card
rese...
import pcsclite
OS X Yosemite bug:
import binascii SCardBeginTransaction()
after a...
SELECT = "\x00\xA4\x04\x00\x0A\xA0\x00\x00\x00\x62\x03\x01\x0C\x06\x01" OS X Yosemite bug:
SCardReconnect
COMMAND = "\x00\x00\x00\x00"
Feitian bR301 driver for iOS
now Free Software
try:
PySCard 1.6.16 released
context = pcsclite.Context()
readers = context.list_readers() OS X Yosemite bug:
SCardTransmit (pioSendPci
print "PCSC readers:", readers not c...
reader = readers[0] OS X Yosemite bug:
print "Using reader:", reader SCardGetAttrib
OS X Yosemite and smart
card = context.connect(reader) cards: known bugs
PCSC sample in Python using
pythonpcsclite
data = card.transmit(SELECT)
print binascii.b2a_hex(data) ► November (9)
► October (2)
data = card.transmit(COMMAND)
► September (5)
print data
► July (7)
print binascii.b2a_hex(data)
► June (4)
card.disconnect() ► April (4)
► March (5)
del card ► February (6)
del context
► January (8)
except Exception, message: ► 2013 (38)
print "Exception:", message ► 2012 (27)
► 2011 (46)
► 2010 (55)
Output
$ ./sample_pcsclite.py Search This Blog
PCSC readers: ('Gemalto PC Twin Reader 00 00',) Search
Using reader: Gemalto PC Twin Reader 00 00
9000
Subscribe To
https://ludovicrousseau.blogspot.jp/2014/12/pcscsampleinpythonusingpython.html 1/2
12/14/2017 Ludovic Rousseau's blog: PCSC sample in Python using pythonpcsclite
Hello world!? Posts
48656c6c6f20776f726c64219000
Comments
Comments Google+ Followers
The pythonpcsclite project started in 2007 according to the ChangeLog.txt file. I discovered the project only Ludovic Rousseau b…
very recently and open some bugs to make it build on my Debian system. Russell Stuart, the maintainer, was
very fast to fix the issues. Follow
Compared to pyscard
pythonpcsclite does not build on Mac OS X (see bug #5). I guess it also does not build on Windows but I
have not tested it myself. So if you want a Python wrapper for GNU/Linux, Mac OS X and Windows you
should use pyscard instead.
pythonpcsclite may provide good ideas that I could reuse in pyscard :)
As for pyscard, Python3 is not yet supported.
History
The pythonpcsclite project started in 2007. At the same time the pyscard project is made public (according to 336 have us in View
the dates in the subversion repository but I guess the pyscard project was already developed since some circles all
time).
According to the pythonpcsclite web site:
The obvious question is why use pythonpcsclite instead of the official one. Pythonpcsclite is a
fairly direct implementation of C API provided by pcsclite, so direct the documentation for
pcsclite applies to pythonpcsclite. Pyscard on the other hand builds on pcsclite to provide it's
own abstractions. I suspect the choice is more a matter of taste, and being an old C
programmer I prefer the directness of the C API, which pythonpcsclite emulates.
You have the freedom to select the wrapper you want to use. Compare the sample code above with the 2
examples at my previous article PCSC sample in Python to select the implementation you prefer.
Conclusion
I have not seen any advertising of this project on the Muscle mailing list. The project works fine (as far as I
tested) and may benefit to be used by more users.
Labels: code, pcsclite
Newer Post Home Older Post
Bitcoin
License: byncsa
This blog by Ludovic Rousseau is licensed under a Creative Commons AttributionNonCommercialShareAlike 3.0 Unported License.
Simple theme. Powered by Blogger.
https://ludovicrousseau.blogspot.jp/2014/12/pcscsampleinpythonusingpython.html 2/2