Behaviours: gen_server.
A connection to a particular card or card reader, over which APDUs may be exchanged.
{ok, Readers} = pcsc_card_db:list_readers(), [Reader | _] = Readers, {ok, Card} = pcsc_card:start(Reader, shared, [t1, t0]), ok = pcsc_card:begin_transaction(Card), {ok, Replies} = pcsc_card:command(Card, #apdu_cmd{cla = iso, ins = select, data = <<...>>}), ok = pcsc_card:end_transaction(Card).
mod_or_fmt() = pcsc_apdu_transform:mod() | pcsc_apdu_transform:format()
options() = #{transforms => [pcsc_apdu_transform:mod()]}
Additional options for start_link/4
.
transforms
: initial set of transformation modules
to be used (see set_transforms/2
)begin_transaction/1 | Begins a transaction, for cards open in shared mode. |
command/2 | Sends a command, using the format of the last transformation module enabled. |
command/3 | Sends a command using a specific format or transformation module. |
disconnect/1 | Disconnects from the card and shuts down this pcsc_card
process. |
end_transaction/1 | Ends a transaction, for cards open in shared mode. |
end_transaction/2 | Ends a transaction, for cards open in shared mode. |
set_transforms/2 | Changes the set of transform modules in use for the connection. |
start/3 | Starts a connection to a PCSC card in the given reader. |
start/4 | Starts a connection to a PCSC card in the given reader, with additional options. |
start_link/3 | Starts a connection to a PCSC card in the given reader, supervised by the current process. |
start_link/4 | Starts a connection to a PCSC card in the given reader, supervised by the current process, with additional options. |
begin_transaction(Pid::pid()) -> ok | {error, term()}
Begins a transaction, for cards open in shared
mode.
Note that beginning a transaction will open a monitor on the calling process,
and if it dies then the transaction will be ended with reset
disposition.
command(Pid::pid(), Cmd::term()) -> {ok, [term()]} | {error, term()}
Sends a command, using the format of the last transformation module
enabled. By default, iso7816
is the only transform enabled,
meaning this function should be given iso7816:apdu_cmd()
records, and will return iso7816:apdu_reply()
records.
command(Pid::pid(), ModOrFormat::mod_or_fmt(), Cmd::term()) -> {ok, [term()]} | {error, term()}
Sends a command using a specific format or transformation module.
The type of the Cmd
argument and the returned list items is
set by the transform in question.
disconnect(Pid::pid()) -> ok | {error, term()}
Disconnects from the card and shuts down this pcsc_card
process.
end_transaction(Pid::pid()) -> ok | {error, term()}
Ends a transaction, for cards open in shared
mode.
end_transaction(Pid::pid(), Dispos::pcsc:disposition()) -> ok | {error, term()}
Ends a transaction, for cards open in shared
mode. The
additional Disposition
argument can be used to indicate whether
to reset or power down the card after the end of this transaction.
set_transforms(Pid::pid(), ModStack::[pcsc_apdu_transform:mod()]) -> ok | {error, term()}
Changes the set of transform modules in use for the connection. Takes a list of transformation module names, ordered from "cooked" to "raw". The final module on the list must produce type "binary", raw APDU data to be sent on the wire.
start(RdrName::pcsc:rdrname(), ShareMode::pcsc:sharemode(), PrefProtos::[pcsc:protocol()]) -> {ok, pid()} | {error, term()}
Starts a connection to a PCSC card in the given reader. Once this returns
ok, the connection is ready to use. If ShareMode
is set to
shared
, however, then a transaction will need to be begun before
APDUs can be send with command/2-3
start(RdrName::pcsc:rdrname(), ShareMode::pcsc:sharemode(), PrefProtos::[pcsc:protocol()], Opts::options()) -> {ok, pid()} | {error, term()}
Starts a connection to a PCSC card in the given reader, with additional
options. See also start/3
.
start_link(RdrName::pcsc:rdrname(), ShareMode::pcsc:sharemode(), PrefProtos::[pcsc:protocol()]) -> {ok, pid()} | {error, term()}
Starts a connection to a PCSC card in the given reader, supervised by
the current process. See also start/3
.
start_link(RdrName::pcsc:rdrname(), ShareMode::pcsc:sharemode(), PrefProtos::[pcsc:protocol()], Opts::options()) -> {ok, pid()} | {error, term()}
Starts a connection to a PCSC card in the given reader, supervised by
the current process, with additional options. See also start/3
.
Generated by EDoc