
Contents | Parent Topic | Previous Topic | Next Topic
This library is used for communicating with the SCAM executable via named pipes.
use Scam;
Be sure that the $SCAM variable is set to the correct value.
The following variable(s) can be set:
$SCAM
contains the command to execute SCAM. For example: "/usr/local/bin/scam". If you do not set this variable, a default value will be used. If you want your script to be portable, never set this value in your script.
$DEBUG
if set to 0, no debug messages will be printed. Otherwise, all data going to and coming from the SCAM program is printed on STDERR.
$DFL_WAIT
specifies the default waiting time.
init
starts the SCAM executable and sets up the communication with it.
recv
recv timeout
waits for output or error (or both) from the SCAM executable for at most timeout seconds. Without an argument it will wait for at most $DFL_WAIT seconds. Returns a list consisting of ($out,$err), where $out is the output from the SCAM executable and $err is the error from the SCAM program.
send string
sends string to the SCAM executable. string is the text you would normally have typed in yourself. A trailing \n is not necessary. This function is usually not called directly, but from other functions in this module. It is used for reader specific commands, however.
reader readername
selects the reader specified by readername. readername is the text you would normally type after the reader command in SCAM.
reset
talk string
sends string to the smart card. string is the text you would normally type after the send command, but without the trailing dot.
#!/usr/bin/perl
use Scam;
Scam::init();
Scam::reader("dumbmouse(wait_etu=100,conv=inverse,parity=odd)");
# Flush the serial port & the named pipe
Scam::send("dump");
Scam::recv();
Scam::reset();
($out, $err) = Scam::recv(5.2); # wait 5.2 seconds
chomp $out; chomp $err;
print "output = $out, error = $err\n";
The flush should not be necessary, but if we do not do this, for some reason the output on the named pipe is not correct the first time we read from it.
- The first read (typically after a reset) can output some strange results.
- The recv function assumes that if SCAM outputs both error and normal output, it is done simultaneously, i.e. fast enough for the Perl script. In SCAM v3.0 output and error are never sent at the same time, so this function will work fine.
- If a command outputs more than one line, it is the script programmer's responsibility to read all of them.
Contents | Parent Topic | Previous Topic | Next Topic