projects
/
safeq
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4262030
)
test on real device, scanning somewhat work other things don't yet
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 22 Feb 2019 10:04:54 +0000
(11:04 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 22 Feb 2019 10:04:54 +0000
(11:04 +0100)
terminal-server.pl
patch
|
blob
|
history
diff --git
a/terminal-server.pl
b/terminal-server.pl
index
505023e
..
115e29b
100755
(executable)
--- a/
terminal-server.pl
+++ b/
terminal-server.pl
@@
-36,8
+36,10
@@
while(1) {
sub client_line {
my $line = <$client_socket>;
sub client_line {
my $line = <$client_socket>;
- $line =~ s/[\r\n]+$//;
- warn "<< $line\n";
+ if ( defined $line ) {
+ $line =~ s/[\r\n]+$//;
+ warn "<< $line\n";
+ }
return $line;
}
return $line;
}
@@
-51,7
+53,8
@@
while(1) {
my $total_charged = 0.00;
my $total_pages = 0;
sub credit {
my $total_charged = 0.00;
my $total_pages = 0;
sub credit {
- my $v = shift || $credit;
+ my $v = $credit;
+ $v = $_[0] if defined $_[0];
return sprintf "%1.2f kn", $v;
}
return sprintf "%1.2f kn", $v;
}
@@
-70,8
+73,12
@@
while(1) {
} elsif ( $line =~ m/\.CARD (\S+)/ ) {
my ($rfid_sid) = $1;
client_send ".CARD OK Ime Prezime (nobody\@example.com)";
} elsif ( $line =~ m/\.CARD (\S+)/ ) {
my ($rfid_sid) = $1;
client_send ".CARD OK Ime Prezime (nobody\@example.com)";
+ } elsif ( $line =~ m/\.PIN (\S+)/ ) {
+ my ($pin) = $1;
+ client_send ".PIN OK Ime Pinzime (nobody\@example.com)";
} elsif ( $line =~ m/\.ACTION$/ ) {
} elsif ( $line =~ m/\.ACTION$/ ) {
- client_send ".ACTION CMENUS0"; # FIXME can be CMENUS2
+ # CMENUS0 - no printer
+ client_send ".ACTION CMENUS68"; # FIXME can be CMENUS2
} elsif ( $line =~ m/\.ACTION COPY/ ) {
client_send ".ACTION COPY"; # safeq sends this twice
} elsif ( $line =~ m/\.ACTION COPY/ ) {
client_send ".ACTION COPY"; # safeq sends this twice
@@
-99,13
+106,16
@@
while(1) {
} elsif ( $line =~ m/\.ACTION PRINT ALL/ ) {
# FIXME
} elsif ( $line =~ m/\.ACTION PRINT ALL/ ) {
# FIXME
- } elsif ( $line =~ m/(\.NOP)/ ) {
+ } elsif ( $line =~ m/^\.NOP/ ) {
+ # XXX it's important to sleep, before sending response or
+ # interface on terminal device will be unresponsive
+ sleep 1;
client_send "$1";
} elsif ( $line =~ m/^\.END/ ) {
client_send ".DONE BLK WAIT";
client_send ".NOP";
my $nop = client_line;
client_send "$1";
} elsif ( $line =~ m/^\.END/ ) {
client_send ".DONE BLK WAIT";
client_send ".NOP";
my $nop = client_line;
- client_send "DONE $total_pages ".credit($total_charged);
+ client_send "
.
DONE $total_pages ".credit($total_charged);
warn "expected NOP got: $nop" unless $nop =~ m/NOP/;
my $null = client_line;
$client_socket->close;
warn "expected NOP got: $nop" unless $nop =~ m/NOP/;
my $null = client_line;
$client_socket->close;