From 603ac103d3f7489d55a7aeb7a60815dc2715f4eb Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 15 Oct 2014 17:11:03 +0200 Subject: [PATCH] scan only 3M reader in checkin/checkout --- examples/selfcheck.js | 10 +++++++--- scripts/RFID-JSONP-server.pl | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/selfcheck.js b/examples/selfcheck.js index 3c825bb..18b93f0 100644 --- a/examples/selfcheck.js +++ b/examples/selfcheck.js @@ -16,6 +16,7 @@ if(!window.console) { var state; var scan_timeout; var pending_jsonp = 0; +var only_reader = ''; // timeout warning dialog var tick_timeout = 25; // s @@ -36,11 +37,13 @@ function change_page(new_state) { $('.checkin').show(); circulation_type = 'checkin'; borrower_cardnumber = 0; // fake + only_reader = '/only/3M'; } else if ( new_state == 'checkout' ) { new_state = 'circulation'; // page has different name $('.checkout').show(); $('.checkin').hide(); circulation_type = 'checkout'; + only_reader = '/only/3M'; } state = new_state; @@ -59,6 +62,7 @@ function change_page(new_state) { book_barcodes = {}; $('ul#books').html(''); // clear book list $('#books_count').html( 0 ); + only_reader = ''; scan_tags(); } @@ -138,10 +142,10 @@ function scan_tags() { if ( pending_jsonp ) { console.debug('scan_tags disabled ', pending_jsonp, ' requests waiting'); } else { - console.info('scan_tags'); + console.info('scan_tags', only_reader); pending_jsonp++; - $.getJSON("/scan?callback=?", got_visible_tags).fail( function(data) { - console.error('scan error'); + $.getJSON("/scan"+only_reader+"?callback=?", got_visible_tags).fail( function(data) { + console.error('scan error pending jsonp', pending_jsonp); pending_jsonp--; }); } diff --git a/scripts/RFID-JSONP-server.pl b/scripts/RFID-JSONP-server.pl index f363d42..cc1d279 100755 --- a/scripts/RFID-JSONP-server.pl +++ b/scripts/RFID-JSONP-server.pl @@ -198,7 +198,7 @@ sub http_server { my @tags = $rfid->tags( reader => sub { my $reader = shift; return 1 unless $only; - if ( ref $reader =~ m/\Q$only\E/i ) { + if ( ref($reader) =~ m/$only/i ) { return 1; } return 0; @@ -293,7 +293,8 @@ sub http_server { $rfid->write_afi( $sid => chr( $afi->{secure} ) ); } } else { - print $client "HTTP/1.0 500 $method not implemented\r\n\r\n"; + print $client "HTTP/1.0 501 $method not implemented\r\n\r\n"; + warn "ERROR 501 $request\n"; } if ( $hash ) { @@ -303,9 +304,11 @@ sub http_server { } else { print $client "HTTP/1.0 404 Unkown method\r\n\r\n"; + warn "ERROR 404 $request\n"; } } else { print $client "HTTP/1.0 500 No method\r\n\r\n"; + warn "ERROR 500 $request\n"; } close $client; -- 2.20.1