From cb1970846488cb48479935d2273745b1ecf7d47a Mon Sep 17 00:00:00 2001 From: ntruchsess <> Date: Tue, 29 Oct 2013 23:34:53 +0000 Subject: [PATCH] fix FRM_poll not polling the right FD when connected by tcp git-svn-id: https://svn.fhem.de/fhem/trunk@4133 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_FRM.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/10_FRM.pm b/fhem/FHEM/10_FRM.pm index 75e57383a..a44d124a8 100755 --- a/fhem/FHEM/10_FRM.pm +++ b/fhem/FHEM/10_FRM.pm @@ -209,6 +209,10 @@ sub FRM_Ready($) { sub FRM_Tcp_Connection_Close($) { my $hash = shift; TcpServer_Close($hash); + if ($hash->{SNAME}) { + my $shash = $main::defs{$hash->{SNAME}}; + $hash->{SocketDevice} = undef if (defined $shash); + } my $dev = $hash->{DeviceName}; my $name = $hash->{NAME}; if (defined $name) { @@ -361,6 +365,7 @@ sub FRM_DoInit($) { } while (time < $endTicks and !$found); if ($found) { $shash->{FirmataDevice} = $device; + $shash->{SocketDevice} = $hash; FRM_apply_attribute($shash,"sampling-interval"); FRM_apply_attribute($shash,"i2c-config"); FRM_forall_clients($shash,\&FRM_Init_Client,undef); @@ -549,7 +554,16 @@ sub FRM_string_observer sub FRM_poll { my ($hash) = @_; - if (defined $hash->{FD}) { + if (defined $hash->{SocketDevice} and defined $hash->{SocketDevice}->{FD}) { + my ($rout, $rin) = ('', ''); + vec($rin, $hash->{SocketDevice}->{FD}, 1) = 1; + my $nfound = select($rout=$rin, undef, undef, 0.1); + my $mfound = vec($rout, $hash->{SocketDevice}->{FD}, 1); + if($mfound && defined $hash->{FirmataDevice}) { + $hash->{FirmataDevice}->poll(); + } + return $mfound; + } elsif (defined $hash->{FD}) { my ($rout, $rin) = ('', ''); vec($rin, $hash->{FD}, 1) = 1; my $nfound = select($rout=$rin, undef, undef, 0.1);