tofferoma
How to access PCSC card readers via erlang/elixir?
Hi,
i was wondering if there is a way to access smart cards via a PCSC reader.
I was unable to find any lib or bindings to do so (here’s a list samples in different languages [1]).
Maybe there is a different way to accomplish the task, or there has never been a use case for erlang centric applications.
Thanks in advance
T
Most Liked
arjan
A while back I wrote a library which interfaces with libnfc compatible card readers:
It uses a NIF under the hood to do the device IO. It is quote limited at the moment though, it has only been used to read Mifare NFC cards. But it maybe could get you started.
arekinath
I’ve just recently had reason to put together a proper libpcsc binding for Erlang:
If you’re still looking, let me know what you think. Also includes some conveniences like ISO7816 command and response chaining support in an “APDU transform” so you can just send a long data field or get a long reply back.
I don’t use Elixir a lot myself, so I’m not sure how the API will look from that side, but I’m happy to try to improve it.
tofferoma
Thanks a lot. I will give it a try once I find some time a reader :).
In the meantime, you might want to contact Ludovic Rousseau to add the library to his list of PC/SC samples in different languages [1]
[1] https://ludovicrousseau.blogspot.com/2010/04/pcsc-sample-in-different-languages.html
tofferoma
So after some more research it is enough to add pcsc to the applications in src/blog.app.src
diff --git a/blog/src/blog.app.src b/blog/src/blog.app.src
index 4793c20..94b4591 100644
--- a/blog/src/blog.app.src
+++ b/blog/src/blog.app.src
@@ -5,7 +5,8 @@
{mod, {blog_app, []}},
{applications,
[kernel,
- stdlib
+ stdlib,
+ pcsc
]},
{env,[]},
{modules, []},
This makes the rebar3 shell command work. However, packaging a NIF with an escript seems to be more complicated [1], [2]. The shell example should be enough as a proof of concept though, as the packaging/release method is up to the user.
hope this helps
[1] Escript: can not load argon2_nif - wrong approach for CLI?
[2] escripts look for nifs (.so) in wrong location · Issue #2129 · erlang/rebar3 · GitHub
LudovicRousseau
My Elixir sample is ready.
See Ludovic Rousseau's blog: PC/SC sample in Elixir
Thanks to alll








