diff --git a/fhem/FHEM/00_CUL.pm b/fhem/FHEM/00_CUL.pm index f6854ee4e..6a9cb8cef 100755 --- a/fhem/FHEM/00_CUL.pm +++ b/fhem/FHEM/00_CUL.pm @@ -535,13 +535,15 @@ CUL_ReadAnswer($$$$) $mculdata .= $buf; } - # \n\n is socat special - if($mculdata =~ m/\r\n/ || $anydata || $mculdata =~ m/\n\n/ ) { - (undef, $mculdata) = CUL_prefix(0, $ohash, $mculdata); # Delete prefix - if($regexp && $mculdata !~ m/$regexp/) { - CUL_Parse($ohash, $hash, $ohash->{NAME}, $mculdata); + # Dispatch data in the buffer before the proper answer. + while(($mculdata =~ m/^([^\n]*\n)(.*)/s) || $anydata) { + my $line = ($anydata ? $mculdata : $1); + $mculdata = $2; + (undef, $line) = CUL_prefix(0, $ohash, $line); # Delete prefix + if($regexp && $line !~ m/$regexp/) { + CUL_Parse($ohash, $hash, $ohash->{NAME}, $line); } else { - return (undef, $mculdata) + return (undef, $line); } } } diff --git a/fhem/FHEM/DevIo.pm b/fhem/FHEM/DevIo.pm index 554a60087..c1c54509e 100644 --- a/fhem/FHEM/DevIo.pm +++ b/fhem/FHEM/DevIo.pm @@ -388,6 +388,7 @@ DevIo_Disconnected($) DevIo_CloseDev($hash); $readyfnlist{"$name.$dev"} = $hash; # Start polling $hash->{STATE} = "disconnected"; + setReadingsVal($hash, "state", "disconnected", TimeNow()); DoTrigger($name, "DISCONNECTED"); }