[LON-CAPA-cvs] cvs: modules /gerd/scantron scantronserver.pl
www
lon-capa-cvs@mail.lon-capa.org
Mon, 24 May 2004 22:00:09 -0000
www Mon May 24 18:00:09 2004 EDT
Modified files:
/modules/gerd/scantron scantronserver.pl
Log:
Get delimiter correct.
Index: modules/gerd/scantron/scantronserver.pl
diff -u modules/gerd/scantron/scantronserver.pl:1.2 modules/gerd/scantron/scantronserver.pl:1.3
--- modules/gerd/scantron/scantronserver.pl:1.2 Mon May 24 17:26:07 2004
+++ modules/gerd/scantron/scantronserver.pl Mon May 24 18:00:09 2004
@@ -52,9 +52,17 @@
}
# Reset scanner, put into escrow mode
print $client "0\ne\n";
- while (my $line=<$client>) {
- &analyse($client,$line);
- alarm(7200);
+# Data read loop
+ my $byte;
+ my $line='';
+ while (read($client,$byte,1)) {
+ if (unpack('h*',$byte) eq 'd0') {
+ &analyse($client,$line);
+ alarm(7200);
+ $line='';
+ } else {
+ $line.=$byte;
+ }
}
print "\n$$: Disconnect $hostname $clientip\n";
exit; # child leaves
@@ -65,6 +73,6 @@
#
sub analyse {
my ($client,$data)=@_;
- print "\nData: ".pack('h',$data)."\n";
+ print "\nData: ".unpack('h*',$data)."\n";
print $client "3\n";
}