19

I installed the following packages:

  • libusb-dev
  • libusb++-0.1-4c2
  • libccid
  • pcscd
  • libpcsclite1
  • libpcsclite-dev
  • List item
  • libpcsc-perl
  • pcsc-tools

But when I send the pcsc_scan command I received the below output :

root@bt:/# pcsc_scan
PC/SC device scanner
V 1.4.16 (c) 2001-2009, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.5.3
SCardEstablishContext: Service not available.
root@bt:/#

Why?

Note: I use BackTrack5

Ebrahim Ghasemi
  • 642
  • 4
  • 12
  • 25

2 Answers2

24

It look like your pcscd is not running (service pcscd start).

silhano
  • 356
  • 2
  • 3
  • I executed this `sudo service pcscd start` command on Mint LMDE. LED on smart card reader start to flash, but when I type again `sudo pcsc_scan` it gives me: `PC/SC device scanner V 1.4.27 (c) 2001-2011, Ludovic Rousseau Compiled with PC/SC lite version: 1.8.17 SCardEstablishContext: Service not available.` – matandked Dec 20 '18 at 03:49
  • systemctl enable pcscd systemctl start pcscd – Smile4ever Apr 25 '21 at 10:04
6

Quick strace pcsc_scan reveals that it tries to open a non-existing file /var/run/pcscd/pcscd.comm:

stat("/var/run/pcscd/pcscd.comm", 0x7fff315e9dc0) = -1 ENOENT (No such file or directory)
....
SCardEstablishContext: Service not available.
...
exit_group(-1)                          = ?
+++ exited with 255 +++

And indeed it does not exist:

$ ls /var/run/pcscd/pcscd.comm
ls: cannot access '/var/run/pcscd/pcscd.comm': No such file or directory

This is because there are two parts of pcscd: pcscd.service and pcscd.socket, where the latter is responsible for that missing file. Therefore, the proper solution will be:

sudo systemctl restart pcscd.socket

Demo:

$ ls /var/run/pcscd/pcscd.comm
ls: cannot access '/var/run/pcscd/pcscd.comm': No such file or directory
$ sudo systemctl restart pcscd.socket
$ ls /var/run/pcscd/pcscd.comm
/var/run/pcscd/pcscd.comm

Now you can properly enjoy your pcsc_scan.

sanmai
  • 1,162
  • 12
  • 16