pcsc_scan on Windows
Since version 1.5.0 of pcsc-tools (see "New version of pcsc-tools: 1.5.0, 1.5.1, 1.5.2") it is possible to build and run pcsc_scan on Windows.
MSYS2
From the project webpage:MSYS2 is a software distro and building platform for Windows
At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.
It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.
Using MSYS2 it is easy to build/port a Unix program on Windows.
Build
To build the program use the classic sequence:- ./configure
- make
$ ./configure configure: loading site script /etc/config.site checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking build system type... x86_64-pc-msys checking host system type... x86_64-pc-msys checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.exe checking for suffix of executables... .exe checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes configure: WARNING: libpcsclite not found by pkg-config checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking winscard.h usability... yes checking winscard.h presence... yes checking for winscard.h... yes checking for SCardEstablishContext... yes checking for ANSI C header files... (cached) yes checking for unistd.h... (cached) yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking for string.h... (cached) yes checking stdio.h usability... yes checking stdio.h presence... yes checking for stdio.h... yes checking for stdlib.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking whether sys/types.h defines makedev... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating config.h config.status: executing depfiles commands
Windows does not use pcsc-lite but its own natice WinSCard implementation. So it is not surprising that libpcsclite is not found by the configure script. What is important is that the header file winscard.h is found and that the function
SCardEstablishContext()
can be used.$ make make all-am make[1] : on entre dans le répertoire « /home/Ludovic/pcsc-tools » CC pcsc_scan-pcsc_scan.o CCLD pcsc_scan.exe make[1] : on quitte le répertoire « /home/Ludovic/pcsc-tools »
Run
$ ./pcsc_scan.exe PC/SC device scanner V 1.5.2 (c) 2001-2017, Ludovic Rousseau Using reader plug'n play mechanism Scanning present readers... 0: Broadcom Corp Contacted SmartCard 0 1: Broadcom Corp Contactless SmartCard 0 Tue May 30 18:04:07 2017 Reader 0: Broadcom Corp Contacted SmartCard 0 Card state: Card removed, Reader 1: Broadcom Corp Contactless SmartCard 0 Card state: Card removed, Reader 2: \\?PnP?\Notification Card state:
Limitations
The program has some limitations:- the special reader name
\\?PnP?\Notification
, used for reader hotplug events, has its name listed.
This is not the case on GNU/Linux or macOS. - the program does not exit when the key sequence
Ctrl
-C
is used. On Unix the Control-C sequence is used to send a SIGINT signal to the process. On Windows I do not know an equivalent.
To quit pcsc_scan you have to terminate the process using the task manager. Not really a good User eXperience.
Conclusion
I do not plan to put a lot of effort into the Windows version of pcsc_scan. It was just an experiment.If you want a change you can submit a Pull Request at the pcsc-tools github project.