From ac2b9ab8f9e5111bf876e1dd39cfa456e47fa28b Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sun, 26 Jun 2016 12:10:03 +0000 Subject: [PATCH] 70_ONKYO_AVR.pm: use non-blocking connect for TCP connections (forum #msg464119) git-svn-id: https://svn.fhem.de/fhem/trunk@11717 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/70_ONKYO_AVR.pm | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/70_ONKYO_AVR.pm b/fhem/FHEM/70_ONKYO_AVR.pm index e778215a7..e64647e30 100644 --- a/fhem/FHEM/70_ONKYO_AVR.pm +++ b/fhem/FHEM/70_ONKYO_AVR.pm @@ -159,13 +159,30 @@ sub ONKYO_AVR_Define($$$) { $modules{ONKYO_AVR_ZONE}{defptr}{$name}{1} = $hash; $hash->{DeviceName} = @$a[2]; - $hash->{DeviceName} = $hash->{DeviceName} . ":60128" - if ( $hash->{DeviceName} =~ -/^\b(?:(?:2(?:[0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9])\.){3}(?:(?:2([0-4][0-9]|5[0-5])|[0-1]?[0-9]?[0-9]))\b$/ - ); - my $ret = DevIo_OpenDev( $hash, 0, "ONKYO_AVR_DevInit" ); - return $ret; + # connect using serial connection (old blocking style) + if ( $hash->{DeviceName} =~ m/^UNIX:(SEQPACKET|STREAM):(.*)$/ + || $hash->{DeviceName} =~ m/^FHEM:DEVIO:(.*)(:(.*))/ ) + { + my $ret = DevIo_OpenDev( $hash, 0, "ONKYO_AVR_DevInit" ); + return $ret; + } + + # connect using TCP connection (non-blocking style) + else { + # add missing port if required + $hash->{DeviceName} = $hash->{DeviceName} . ":60128" + if ( $hash->{DeviceName} !~ m/^(.+):([0-9]+)$/ ); + + DevIo_OpenDev( + $hash, 0, + "ONKYO_AVR_DevInit", + sub() { + my ( $hash, $err ) = @_; + Log3 $name, 2, "ONKYO_AVR $name: $err" if ($err); + } + ); + } } #####################################