use Scam;
Be sure that the $SCAM variable is set to the correct value.
$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.
inittimeout 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.
string to the SCAM executable. string is
the text you would normally have typed in yourself. A trailing
\n is not necessary.readername.
reader is the text you would normally type after the
reader command in SCAM.
string to the smart card. string is the
text you would normally type after the send command, 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.
recv function assumes that if SCAM outputs both error
and normal output, it is done simultaneously, i.e. fast enough for the
Perl script. At the time of the release of SCAM v3.0 beta output and error
are never sent at the same time, so this function will work fine.