MAX: fix a bug where we would loose received bytes (thanks Joachim for the help)
git-svn-id: https://svn.fhem.de/fhem/trunk@2191 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -217,23 +217,19 @@ MAXLAN_ReadAnswer($)
|
|||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
my $data = $hash->{PARTIAL};
|
|
||||||
|
|
||||||
#Read until we have a complete line
|
#Read until we have a complete line
|
||||||
until($data =~ m/\n/) {
|
until($hash->{PARTIAL} =~ m/\n/) {
|
||||||
my $buf = DevIo_SimpleRead($hash);
|
my $buf = DevIo_SimpleRead($hash);
|
||||||
if(!defined($buf)){
|
if(!defined($buf)){
|
||||||
Log 1, "MAXLAN_ReadAnswer: error during read";
|
Log 1, "MAXLAN_ReadAnswer: error during read";
|
||||||
return undef; #error occured
|
return undef; #error occured
|
||||||
}
|
}
|
||||||
$data .= $buf;
|
$hash->{PARTIAL} .= $buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rmsg;
|
my $rmsg;
|
||||||
($rmsg,$data) = split("\n", $data, 2);
|
($rmsg,$hash->{PARTIAL}) = split("\n", $hash->{PARTIAL}, 2);
|
||||||
$rmsg =~ s/\r//; #remove \r
|
$rmsg =~ s/\r//; #remove \r
|
||||||
#save partial data for next read
|
|
||||||
$hash->{PARTIAL} = $data;
|
|
||||||
return $rmsg;
|
return $rmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +255,13 @@ MAXLAN_Read($)
|
|||||||
return "" if(!defined($buf));
|
return "" if(!defined($buf));
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $data = $hash->{PARTIAL};
|
$hash->{PARTIAL} .= $buf;
|
||||||
$data .= $buf;
|
|
||||||
|
|
||||||
while($data =~ m/\n/) {
|
#while we have a complete line
|
||||||
|
while($hash->{PARTIAL} =~ m/\n/) {
|
||||||
my $rmsg;
|
my $rmsg;
|
||||||
($rmsg,$data) = split("\n", $data, 2);
|
($rmsg,$hash->{PARTIAL}) = split("\n", $hash->{PARTIAL}, 2);
|
||||||
$hash->{PARTIAL} = $data;
|
$rmsg =~ s/\r//;#remove \r
|
||||||
$rmsg =~ s/\r//;
|
|
||||||
MAXLAN_Parse($hash, $rmsg) if($rmsg);
|
MAXLAN_Parse($hash, $rmsg) if($rmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user