tofferoma

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

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

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

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

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

LudovicRousseau

My Elixir sample is ready.
See Ludovic Rousseau's blog: PC/SC sample in Elixir

Thanks to alll

Where Next?

Popular in Questions Top

pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement