2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 13:24:56 +00:00

00_HMUARTLGW.pm: fix non-blocking connect, thanks Ralf9 (forum: msg483514)

git-svn-id: https://svn.fhem.de/fhem/trunk@12031 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mgernoth 2016-08-21 12:25:40 +00:00
parent 614e769f17
commit 04c87aaa40

View File

@ -207,7 +207,7 @@ sub HMUARTLGW_DoInit($)
DevIo_CloseDev($keepAlive); DevIo_CloseDev($keepAlive);
my ($ip, $port) = split(/:/, $hash->{DeviceName}); my ($ip, $port) = split(/:/, $hash->{DeviceName});
$keepAlive->{DeviceName} = "${ip}:" . ($port + 1); $keepAlive->{DeviceName} = "${ip}:" . ($port + 1);
DevIo_OpenDev($keepAlive, 0, "HMUARTLGW_DoInit", &HMUARTLGW_Connect); DevIo_OpenDev($keepAlive, 0, "HMUARTLGW_DoInit", \&HMUARTLGW_Connect);
$hash->{keepAlive} = $keepAlive; $hash->{keepAlive} = $keepAlive;
} }
@ -255,7 +255,7 @@ sub HMUARTLGW_Define($$)
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
return DevIo_OpenDev($hash, 0, "HMUARTLGW_DoInit", &HMUARTLGW_Connect); return DevIo_OpenDev($hash, 0, "HMUARTLGW_DoInit", \&HMUARTLGW_Connect);
} }
sub HMUARTLGW_Undefine($$;$) sub HMUARTLGW_Undefine($$;$)
@ -284,11 +284,11 @@ sub HMUARTLGW_Reopen($;$)
$hash = $hash->{lgwHash} if ($hash->{lgwHash}); $hash = $hash->{lgwHash} if ($hash->{lgwHash});
my $name = $hash->{NAME}; my $name = $hash->{NAME};
Log3($hash, 1, "HMUARTLGW ${name} Reopen"); Log3($hash, 4, "HMUARTLGW ${name} Reopen");
HMUARTLGW_Undefine($hash, $name, $noclose); HMUARTLGW_Undefine($hash, $name, $noclose);
return DevIo_OpenDev($hash, 1, "HMUARTLGW_DoInit", &HMUARTLGW_Connect); return DevIo_OpenDev($hash, 1, "HMUARTLGW_DoInit", \&HMUARTLGW_Connect);
} }
sub HMUARTLGW_Ready($) sub HMUARTLGW_Ready($)
@ -472,7 +472,8 @@ sub HMUARTLGW_SendPendingCmd($)
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
if ($hash->{XmitOpen} == 2) { if (defined($hash->{XmitOpen}) &&
$hash->{XmitOpen} == 2) {
if ($hash->{Helper}{PendingCMD}) { if ($hash->{Helper}{PendingCMD}) {
my $qLen = AttrVal($name, "qLen", 20); my $qLen = AttrVal($name, "qLen", 20);
if (scalar(@{$hash->{Helper}{PendingCMD}}) < $qLen) { if (scalar(@{$hash->{Helper}{PendingCMD}}) < $qLen) {
@ -586,6 +587,9 @@ sub HMUARTLGW_SendCmd($$)
{ {
my ($hash, $cmd) = @_; my ($hash, $cmd) = @_;
#Drop commands when device is not active
return if ($hash->{DevState} == HMUARTLGW_STATE_NONE);
push @{$hash->{Helper}{PendingCMD}}, { cmd => $cmd }; push @{$hash->{Helper}{PendingCMD}}, { cmd => $cmd };
return HMUARTLGW_SendPendingCmd($hash); return HMUARTLGW_SendPendingCmd($hash);
} }
@ -1670,7 +1674,7 @@ sub HMUARTLGW_Set($@)
readingsSingleUpdate($hash, "state", "closed", 1); readingsSingleUpdate($hash, "state", "closed", 1);
$hash->{XmitOpen} = 0; $hash->{XmitOpen} = 0;
} elsif($cmd eq "open") { } elsif($cmd eq "open") {
DevIo_OpenDev($hash, 0, "HMUARTLGW_DoInit", &HMUARTLGW_Connect); DevIo_OpenDev($hash, 0, "HMUARTLGW_DoInit", \&HMUARTLGW_Connect);
} elsif($cmd eq "restart") { } elsif($cmd eq "restart") {
HMUARTLGW_send($hash, HMUARTLGW_OS_CHANGE_APP, HMUARTLGW_DST_OS); HMUARTLGW_send($hash, HMUARTLGW_OS_CHANGE_APP, HMUARTLGW_DST_OS);
} }