retry sip response
[Biblio-RFID.git] / scripts / RFID-JSONP-server.pl
index 4bec23e..3e1d4fd 100755 (executable)
@@ -92,14 +92,18 @@ sub sip2_message {
        
        my $expect = substr($send,0,2) | 0x01;
 
        
        my $expect = substr($send,0,2) | 0x01;
 
-       my $in = <$sock>;
-       $in =~ s/^\n//;
-       warn "SIP2 <<<< ",dump($in), "\n";
+       my $in = '';
+       my $repeat = 1;
+       while ( $in eq '' && $repeat < 10 ) {
+               $in = <$sock>;
+               $in =~ s/^\n//;
+               $in =~ s/\r$//;
+               warn "SIP2 <<<< ",dump($in), " repeat: $repeat\n";
+               $repeat++;
+       }
 
        die "expected $expect" unless substr($in,0,2) != $expect;
 
 
        die "expected $expect" unless substr($in,0,2) != $expect;
 
-       $in =~ s/\r$//;
-
        my $hash;
        if ( $in =~ s/^([0-9\s]+)// ) {
                $hash->{fixed} = $1;
        my $hash;
        if ( $in =~ s/^([0-9\s]+)// ) {
                $hash->{fixed} = $1;