2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 06:48:43 +00:00

FBAHA reconnect works now / get dect200 devInfo detects 546E absence

git-svn-id: https://svn.fhem.de/fhem/trunk@3260 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2013-06-08 06:39:24 +00:00
parent e9189ce190
commit a594a3bf34
2 changed files with 12 additions and 11 deletions

View File

@ -209,7 +209,9 @@ FBAHA_DoInit($)
{
my $hash = shift;
my $name = $hash->{NAME};
return FBAHA_Set($hash, ($name, "reregister"));
delete $hash->{HANDLE}; # else reregister fails / RELEASE is deadly
my $ret = FBAHA_Set($hash, ($name, "reregister"));
return $ret;
}
#####################################
@ -293,22 +295,20 @@ FBAHA_ReadAnswer($$$)
my ($hash, $arg, $regexp) = @_;
return ("No FD (dummy device?)", undef)
if(!$hash || ($^O !~ /Win/ && !defined($hash->{FD})));
my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 3);
for(;;) {
return ("Device lost when reading answer for get $arg", undef)
if(!$hash->{FD});
my $rin = '';
vec($rin, $hash->{FD}, 1) = 1;
my $nfound = select($rin, undef, undef, $to);
if($nfound < 0) {
next if ($! == EAGAIN() || $! == EINTR() || $! == 0);
my $err = $!;
my $nfound = select($rin, undef, undef, 3);
if($nfound <= 0) {
next if ($! == EAGAIN() || $! == EINTR());
my $err = ($! ? $! : "Timeout");
$hash->{TIMEOUT} = 1;
DevIo_Disconnected($hash);
return("FBAHA_ReadAnswer $arg: $err", undef);
}
return ("Timeout reading answer for get $arg", undef)
if($nfound == 0);
my $buf = DevIo_SimpleRead($hash);
return ("No data", undef) if(!defined($buf));

View File

@ -26,7 +26,7 @@ DevIo_DoSimpleRead($)
} elsif($hash->{TCPDev}) {
$res = sysread($hash->{TCPDev}, $buf, 256);
$buf = undef if(!defined($res));
$buf = "" if(!defined($res));
}
return $buf;
@ -142,7 +142,8 @@ DevIo_OpenDev($$$)
return;
}
my $conn = IO::Socket::INET->new(PeerAddr => $dev, Timeout => 3);
my $timeout = $hash->{TIMEOUT} ? $hash->{TIMEOUT} : 3;
my $conn = IO::Socket::INET->new(PeerAddr => $dev, Timeout => $timeout);
if($conn) {
delete($hash->{NEXT_OPEN})
@ -323,7 +324,7 @@ DevIo_Disconnected($)
# Without the following sleep the open of the device causes a SIGSEGV,
# and following opens block infinitely. Only a reboot helps.
sleep(5);
sleep(5) if($hash->{USBDEV});
DoTrigger($name, "DISCONNECTED");
}