From eefee546169d9366ce003e8d1cbb0dc98391e6fe Mon Sep 17 00:00:00 2001 From: mgernoth Date: Sat, 30 Oct 2021 08:08:08 +0000 Subject: [PATCH] 00_HMUARTLGW.pm: improve timing compatibility with CUL (noansi) Patch from noansi, forum #122160 git-svn-id: https://svn.fhem.de/fhem/trunk@25153 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMUARTLGW.pm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fhem/FHEM/00_HMUARTLGW.pm b/fhem/FHEM/00_HMUARTLGW.pm index a83a2170b..311a6dff5 100644 --- a/fhem/FHEM/00_HMUARTLGW.pm +++ b/fhem/FHEM/00_HMUARTLGW.pm @@ -1,5 +1,6 @@ ############################################## # $Id$ +# noansi: modified for better timing compatibility with CUL # # HMUARTLGW provides support for the eQ-3 HomeMatic Wireless LAN Gateway # (HM-LGW-O-TW-W-EU) and the eQ-3 HomeMatic UART module (HM-MOD-UART), which @@ -1447,17 +1448,24 @@ sub HMUARTLGW_Parse($$$$) Log3($hash, 5, "HMUARTLGW ${name} Dispatch: ${dmsg}"); - my $wait = 0; - if (!(hex($flags) & (1 << 5))) { - #!BIDI - $wait = 0.100; - } else { - $wait = 0.300; - } - $wait -= $hash->{Helper}{RoundTrip}{Delay} if (defined($hash->{Helper}{RoundTrip}{Delay})); + if ($modules{CUL_HM}{defptr}{$src}) { + my $flgh = hex($flags); + my $wait = 0.100; + $wait += 0.200 if ($flgh & (1 << 5) && # BIDI + $modules{CUL_HM}{defptr}{$src}->{IODev}->{TYPE} =~ m/^(?:TSCUL|HMUARTLGW)$/s); + $wait -= 0.044 if ($flgh & (1 << 6)); # received from Repeater - $modules{CUL_HM}{defptr}{$src}{helper}{io}{nextSend} = $recvtime + $wait - if ($modules{CUL_HM}{defptr}{$src} && $wait > 0); + $wait -= $hash->{Helper}{RoundTrip}{Delay} + if (defined($hash->{Helper}{RoundTrip}{Delay})); + + if ($wait > 0) { + my $nextSend = $recvtime + $wait; + $modules{CUL_HM}{defptr}{$src}{helper}{io}{nextSend} = $nextSend + if (!defined($modules{CUL_HM}{defptr}{$src}{helper}{io}{nextSend}) || + $nextSend < $modules{CUL_HM}{defptr}{$src}{helper}{io}{nextSend} || + ($recvtime - $modules{CUL_HM}{defptr}{$src}{helper}{io}{nextSend}) > 0.09); # not allready set by previous IO + } + } Dispatch($hash, $dmsg, \%addvals); }