mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-28 02:44:53 +00:00
Fixed infinite sending loop in strange cases
git-svn-id: https://svn.fhem.de/fhem/trunk@1883 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4f600b5d39
commit
9ebe8e2588
fhem
@ -521,6 +521,7 @@ KM271_Read($)
|
|||||||
if($buf eq "10") {
|
if($buf eq "10") {
|
||||||
if($hash->{DATASENT}) {
|
if($hash->{DATASENT}) {
|
||||||
delete($hash->{DATASENT});
|
delete($hash->{DATASENT});
|
||||||
|
delete($hash->{RETRYCOUNT});
|
||||||
# Delete the command from the list
|
# Delete the command from the list
|
||||||
shift @{$hash->{SENDBUFFER}};
|
shift @{$hash->{SENDBUFFER}};
|
||||||
if ($hash->{NOTIFY}) {
|
if ($hash->{NOTIFY}) {
|
||||||
@ -529,59 +530,71 @@ KM271_Read($)
|
|||||||
goto INTERNAL_NOTIFY; # Timer changes are not reflected by the heater
|
goto INTERNAL_NOTIFY; # Timer changes are not reflected by the heater
|
||||||
}
|
}
|
||||||
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}});
|
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}});
|
||||||
return;
|
|
||||||
}
|
|
||||||
# Delete the command only after receiving ACK
|
|
||||||
$data = shift @{$hash->{SENDBUFFER}};
|
|
||||||
unshift @{$hash->{SENDBUFFER}}, $data;
|
|
||||||
# Dirty trick: separate notify message after the colon
|
|
||||||
my @dataList = split(":", $data);
|
|
||||||
$data = $dataList[0];
|
|
||||||
$data = KM271_encode($data);
|
|
||||||
$data .= "1003";
|
|
||||||
$crc = KM271_crc($data);
|
|
||||||
$data .= $crc;
|
|
||||||
$hash->{DATASENT} = $data;
|
|
||||||
$hash->{ERROR} = 0;
|
|
||||||
if (@dataList > 1) {
|
|
||||||
# Set notify message
|
|
||||||
$hash->{NOTIFY} = $dataList[1];
|
|
||||||
} else {
|
} else {
|
||||||
delete($hash->{NOTIFY});
|
# Delete the command only after receiving ACK
|
||||||
|
$data = shift @{$hash->{SENDBUFFER}};
|
||||||
|
unshift @{$hash->{SENDBUFFER}}, $data;
|
||||||
|
# Dirty trick: separate notify message after the colon
|
||||||
|
my @dataList = split(":", $data);
|
||||||
|
$data = $dataList[0];
|
||||||
|
$data = KM271_encode($data);
|
||||||
|
$data .= "1003";
|
||||||
|
$crc = KM271_crc($data);
|
||||||
|
$data .= $crc;
|
||||||
|
$hash->{DATASENT} = $data;
|
||||||
|
$hash->{ERROR} = 0;
|
||||||
|
$hash->{RETRYCOUNT} = 0;
|
||||||
|
if (@dataList > 1) {
|
||||||
|
# Set notify message
|
||||||
|
$hash->{NOTIFY} = $dataList[1];
|
||||||
|
} else {
|
||||||
|
delete($hash->{NOTIFY});
|
||||||
|
}
|
||||||
|
DevIo_SimpleWrite($hash, $data, 1); # Send the data
|
||||||
}
|
}
|
||||||
DevIo_SimpleWrite($hash, $data, 1); # Send the data
|
|
||||||
} else {
|
} else {
|
||||||
if($hash->{DATASENT}) {
|
if($hash->{DATASENT}) {
|
||||||
|
my $newStart = 0;
|
||||||
if ($buf eq "15") {
|
if ($buf eq "15") {
|
||||||
Log 1, "$name: NAK!"; # NACK from the KM271
|
Log 1, "$name: NAK!"; # NACK from the KM271
|
||||||
|
if(++$hash->{ERROR} > 5) {
|
||||||
|
$newStart = 1;
|
||||||
|
} else {
|
||||||
|
DevIo_SimpleWrite($hash, $hash->{DATASENT}, 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log 1, "$name: Bogus data after sending packet ($buf)"; # Strange response from the KM271
|
Log 1, "$name: Bogus data after sending packet ($buf)"; # Strange response from the KM271
|
||||||
|
$newStart = 1;
|
||||||
}
|
}
|
||||||
if($hash->{ERROR}++ > 5) {
|
if ($newStart) {
|
||||||
Log 1, "$name: Sending ($hash->{DATASENT}) aborted!";
|
# Start all over again
|
||||||
|
Log 1, "$name: Sending attempt for ($hash->{DATASENT}) failed!";
|
||||||
|
if(++$hash->{RETRYCOUNT} > 3) {
|
||||||
|
# Abort sending the actual command
|
||||||
|
Log 1, "$name: Sending ($hash->{DATASENT}) not successful!";
|
||||||
|
shift @{$hash->{SENDBUFFER}};
|
||||||
|
delete($hash->{RETRYCOUNT});
|
||||||
|
}
|
||||||
delete($hash->{DATASENT});
|
delete($hash->{DATASENT});
|
||||||
delete($hash->{NOTIFY});
|
delete($hash->{NOTIFY});
|
||||||
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}});
|
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}});
|
||||||
} else {
|
|
||||||
DevIo_SimpleWrite($hash, $hash->{DATASENT}, 1);
|
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
|
DevIo_SimpleWrite($hash, "02", 1);
|
||||||
}
|
}
|
||||||
DevIo_SimpleWrite($hash, "02", 1);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
if ($buf eq "02") { # KM271 Wants to send
|
||||||
elsif ($buf eq "02") { # KM271 Wants to send
|
DevIo_SimpleWrite($hash, "10", 1); # We are ready
|
||||||
DevIo_SimpleWrite($hash, "10", 1); # We are ready
|
$hash->{PARTIAL} = "";
|
||||||
$hash->{PARTIAL} = "";
|
$hash->{WAITING} = time;
|
||||||
$hash->{WAITING} = Time::HiRes::time;
|
$hash->{ERROR} = 0;
|
||||||
$hash->{ERROR} = 0;
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
# After timeout get out of waiting mode
|
# After timeout get out of waiting mode
|
||||||
delete($hash->{WAITING}) if(Time::HiRes::time - $hash->{WAITING} > 2);
|
delete($hash->{WAITING}) if(time - $hash->{WAITING} > 2.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{PARTIAL} .= $buf;
|
$hash->{PARTIAL} .= $buf;
|
||||||
@ -592,7 +605,7 @@ KM271_Read($)
|
|||||||
if(KM271_crc($data . "1003") ne $crc) {
|
if(KM271_crc($data . "1003") ne $crc) {
|
||||||
Log 1, "Wrong CRC in $name: $crc";
|
Log 1, "Wrong CRC in $name: $crc";
|
||||||
DevIo_SimpleWrite($hash, "15", 1); # NAK
|
DevIo_SimpleWrite($hash, "15", 1); # NAK
|
||||||
if($hash->{ERROR}++ > 5) {
|
if(++$hash->{ERROR} > 5) {
|
||||||
delete($hash->{WAITING});
|
delete($hash->{WAITING});
|
||||||
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}}); # Want to send
|
DevIo_SimpleWrite($hash, "02", 1) if(@{$hash->{SENDBUFFER}}); # Want to send
|
||||||
}
|
}
|
||||||
|
@ -4414,10 +4414,12 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<li>Brenner_Laufzeit2_Minuten2
|
<li>Brenner_Laufzeit2_Minuten2
|
||||||
<li>Brenner_Laufzeit2_Minuten1
|
<li>Brenner_Laufzeit2_Minuten1
|
||||||
<li>Brenner_Laufzeit2_Minuten
|
<li>Brenner_Laufzeit2_Minuten
|
||||||
|
<li>Brenner_Mod_Stellglied
|
||||||
<li>ERR_Fehlerspeicher1
|
<li>ERR_Fehlerspeicher1
|
||||||
<li>ERR_Fehlerspeicher2
|
<li>ERR_Fehlerspeicher2
|
||||||
<li>ERR_Fehlerspeicher3
|
<li>ERR_Fehlerspeicher3
|
||||||
<li>ERR_Fehlerspeicher4
|
<li>ERR_Fehlerspeicher4
|
||||||
|
<li>ERR_Letzter_Fehlerstatus
|
||||||
<li>HK1_Ausschaltoptimierung
|
<li>HK1_Ausschaltoptimierung
|
||||||
<li>HK1_Betriebswerte1
|
<li>HK1_Betriebswerte1
|
||||||
<li>HK1_Betriebswerte2
|
<li>HK1_Betriebswerte2
|
||||||
@ -4450,8 +4452,6 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<li>Kessel_Integral1
|
<li>Kessel_Integral1
|
||||||
<li>Kessel_Vorlaufisttemperatur
|
<li>Kessel_Vorlaufisttemperatur
|
||||||
<li>Kessel_Vorlaufsolltemperatur
|
<li>Kessel_Vorlaufsolltemperatur
|
||||||
<li>Letzter_Fehlerstatus
|
|
||||||
<li>Mod_Brenner_Stellglied
|
|
||||||
<li>Modulkennung
|
<li>Modulkennung
|
||||||
<li>NoData
|
<li>NoData
|
||||||
<li>Versionsnummer_NK
|
<li>Versionsnummer_NK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user