MiczFlor / RPi-Jukebox-RFID

A Raspberry Pi jukebox, playing local music, podcasts, web radio and streams triggered by RFID cards, web app or home automation. All plug and play via USB. GPIO scripts available.
http://phoniebox.de
MIT License
1.38k stars 397 forks source link

Emulate HID Keyboard with pcscd? #532

Closed eingemaischt closed 5 years ago

eingemaischt commented 5 years ago

I do have many RFID reader - most of them to read the ePersonalausweis in Germany - and one old "TouchATag"-Reader.

Most of them are working with pcscd - pcscd recognizes cards and prints out the ATRs in debug mode.

My idea: Does anyone know if it is possible to emulate a HID-Device for example with python? It would be easy to connect to pcscd in the background, retrieve serials and retype them as "virtual keyboard"...

eingemaischt commented 5 years ago

This would allow the RainerSCT-Reader to be used as well (the Rainer was a free giveaway in "ComputerBild" years ago when the ePerso was introduced).

eingemaischt commented 5 years ago

Sorry for spamming - there seems to be a "keyboard" library for python. ( https://pypi.org/project/keyboard/ )

But looking into the Reader.py(.experimental) it may be easier to access pcscd directly. With some time in the next days I may have a deeper look.

Are there any asumptions regarding the maximum length (or allowed characters) of the serial?

eingemaischt commented 5 years ago

I just install RFIDIOt for a fast test - and tested some Mifare Classics and "TouchATag"-Tags:

pi@phoniebox:~/RFIDIOt $ sudo ./multiselect.py 
multiselect v0.1n (using RFIDIOt v1.0k)
  Reader: PCSC SCM Microsystems Inc. SCL01x Contactless Reader [SCL01x Contactless Reader] (21161041208526) 00 00

    Tag ID: 04CEFED9A12580
    Tag ID: 04CEFED9A12580
    Tag ID: B2DCFA13
    Tag ID: 04184E52FE2080
    Tag ID: 04184E52FE2080
    Tag ID: D29BDEBE
    Tag ID: A226E3BB
    Tag ID: A226E3BB
    Tag ID: D2A9DEBE
    Tag ID: 8EBDD437
    Tag ID: AC032889
^CTraceback (most recent call last):
  File "./multiselect.py", line 57, in <module>
    sys.stdout.flush()
KeyboardInterrupt
pi@phoniebox:~/RFIDIOt $ 

The interesting part: It waits until a card is inserted and then only prints out the Tag ID - That's exactly what we need (plus a filtering, some are printed twice).

If I have some time the next days I'll try to implement something in the Reader.py.(experimental).

eingemaischt commented 5 years ago

OK, emulating a keyboard is too dirty - I implemented a "Reader" using RFIDIOt. Have a look at #533 or https://github.com/TeGuy/RPi-Jukebox-RFID