From: Dobrica Pavlinusic Date: Sat, 28 Jan 2017 11:02:41 +0000 (+0100) Subject: RFID create permanent port assigment after first bat download X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=40a6b9c87bc0e19ffec1d67e475f2520da29269e;p=koha.git RFID create permanent port assigment after first bat download --- diff --git a/ffzg/rfid/download.pl b/ffzg/rfid/download.pl index 405626f939..13059dd1d1 100755 --- a/ffzg/rfid/download.pl +++ b/ffzg/rfid/download.pl @@ -20,29 +20,36 @@ my $remote_host = $query->remote_host; my $server_name = $query->server_name; sub get_port { + my $write = shift; + my $exists = 0; my $path = "download/$remote_host"; my $port = 0; if ( -e $path ) { open(my $fh, '<', $path); $port = <$fh>; + $exists = 1; } else { - open(my $fh, '>', $path); my @nr = glob('reader/*:*'); my $nr = scalar @nr; warn "# nr = $nr\n"; $port = 9100 + $nr; - print $fh $port; - close($fh); + + if ( $write ) { + open(my $fh, '>', $path); + print $fh $port; + close($fh); + } } - return ( $port, $port - 100 ); + return ( $port, $port - 100, $exists ); } -my ( $serial_port, $json_port ) = get_port; +my ( $serial_port, $json_port, $exists ) = get_port; my $koha_url = "https://ffzg.koha-dev.rot13.org:8443/cgi-bin/koha/ffzg/rfid/reader/$server_name:$json_port/mainpage.pl"; +my $title = $remote_host . ' '. ( $exists ? 'REINSTALL' : 'INSTALL' ); if ( ! $download ) { - print $query->header, '', $remote_host, ''; + print $query->header, qq{$title

$title

}; } if ( $remote_host !~ m/^10\.60\./ ) { @@ -59,6 +66,7 @@ if ( $remote_host !~ m/^10\.60\./ ) { close($fh); exit 0; } elsif ( $download eq 'rfid.bat' ) { + ( $serial_port, $json_port, $exists ) = get_port( 1 ) if ! $exists; # write port once configuration is downloaded my $bat = qq{:loop\r\ncom2tcp.exe --ignore-dsr --baud 19200 \\\\.\\com2 $server_name $serial_port\r\ngoto loop\r\n}; print $bat; warn "BAT: ",dump($bat); @@ -69,17 +77,20 @@ if ( $remote_host !~ m/^10\.60\./ ) { } else { + print qq{Using exists port $serial_port on $server_name for configuration} if $exists; + print qq{ -

Create rfid directory

-

Download files to the rfid directory

+

Create rfid directory

+

Download files to the rfid directory

  1. com2tcp.exe serial port redirector
  2. rfid.bat script to start it
-

Create shortcut to rfid.bat on desktop

-

Run shortcut rfid.bat

-

Chceck if readedr works

-$koha_url -} +

Create shortcut to rfid.bat on desktop

+

Run shortcut rfid.bat

+

Chceck if readedr works and create shortcut on computer to it

+$koha_url + + }; }