if it's not, we will exit 1 and expect something else to restart us
(while true loop in shell, or goto in bat file)
use Time::HiRes qw(ualarm);
use Data::Dump qw(dump);
use Time::HiRes qw(ualarm);
use Data::Dump qw(dump);
+my $debug = $ENV{DEBUG};
+
=head1 NAME
Biblio::RFID::Reader::INET - emulate serial port over TCP socket
=head1 NAME
Biblio::RFID::Reader::INET - emulate serial port over TCP socket
sub write {
my $self = shift;
sub write {
my $self = shift;
+ $self->_check_connected;
+ warn ">> write ",dump(@_) if $debug;
my $count = $self->SUPER::print(@_);
$self->flush;
#warn "XX ",ref($self), " write response: $count ", dump(@_);
my $count = $self->SUPER::print(@_);
$self->flush;
#warn "XX ",ref($self), " write response: $count ", dump(@_);
sub read_char_time { $read_char_time = $_[1] * 1_000 || 1_000_000 };
sub read_const_time {};
sub read_char_time { $read_char_time = $_[1] * 1_000 || 1_000_000 };
sub read_const_time {};
my $self = shift;
my $len = shift || die "no length?";
my $self = shift;
my $len = shift || die "no length?";
#warn "XX ",ref($self), " read $len timeout $read_char_time";
my $buffer;
eval {
#warn "XX ",ref($self), " read $len timeout $read_char_time";
my $buffer;
eval {
- #warn "## read $len ",dump($buffer);
+ $self->_check_connected;
+
+ warn "<< read $len ",dump($buffer) if $debug;
return ( $len, $buffer );
}
return ( $len, $buffer );
}
+sub _check_connected {
+ my $self = shift;
+ return if $self->connected;
+
+ warn "LOST TCP Connection";
+ exit 1;
+}
+