10_WS980: v1.5.0 - fix fhem-crash when autodiscovery fails

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24727 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
choenig 2021-07-11 12:24:22 +00:00
parent 80d372e533
commit a3b873e247
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 10_WS980: v.1.5.0 fix fhem-crash when autodiscovery fails
- change: 10_WS980: allow to ignore invalid values
- feature: 49_SSCam: new value 8.2.8-xxxx for attr simu_SVSversion
- bugfix: 76_SMAInverter:fix ETOTAL/LOADTOTAL bug

View File

@ -33,7 +33,7 @@ use warnings;
use IO::Socket::INET;
use POSIX qw(strftime);
my $version = "1.4.0";
my $version = "1.5.0";
#------------------------------------------------------------------------------------------------------
# global constants
@ -451,10 +451,18 @@ sub WS980_autodiscoverIP($)
WS980_Log($hash, 4, "received raw reply: " . WS980_hexDump($rawbuf));
my ($typeStr, $buf) = WS980_handleReply($hash, $rawbuf);
my ($ip1, $ip2, $ip3, $ip4, $port, $stationName) = unpack("x[6]CCCCnC/A", $buf);
WS980_Log($hash, 2, "reply: $ip1, $ip2, $ip3, $ip4, $port, $stationName");
return (sprintf("%d.%d.%d.%d", $ip1, $ip2, $ip3, $ip4), $port);
if (defined($buf)) {
my ($ip1, $ip2, $ip3, $ip4, $port, $stationName) = unpack("x[6]CCCCnC/A", $buf);
WS980_Log($hash, 2, "autodiscovery-reply: $ip1, $ip2, $ip3, $ip4, $port, $stationName");
return (sprintf("%d.%d.%d.%d", $ip1, $ip2, $ip3, $ip4), $port);
}
else
{
WS980_Log($hash, 1, "autodiscovery failed: looks like the reply could not be decoded");
return (undef,undef);
}
}