mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
90_SIGNALduino_un : fixed bug that can cause a crash (Forum#348854)
git-svn-id: https://svn.fhem.de/fhem/trunk@9618 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b9c3bc6d70
commit
841c8ec3d1
@ -98,18 +98,18 @@ SIGNALduino_un_Parse($$)
|
|||||||
|
|
||||||
## Try TX70DTH Decoding
|
## Try TX70DTH Decoding
|
||||||
my $SensorTyp = "TX70DTH";
|
my $SensorTyp = "TX70DTH";
|
||||||
my $channel = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,9,3));
|
my $channel = SIGNALduino_un_bin2dec(substr($bitData,9,3));
|
||||||
my $bin = substr($bitData,0,8);
|
my $bin = substr($bitData,0,8);
|
||||||
my $id = sprintf('%X', oct("0b$bin"));
|
my $id = sprintf('%X', oct("0b$bin"));
|
||||||
my $bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical";
|
my $bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical";
|
||||||
my $trend = "";
|
my $trend = "";
|
||||||
my $sendMode = "";
|
my $sendMode = "";
|
||||||
my $temp = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,16,8));
|
my $temp = SIGNALduino_un_bin2dec(substr($bitData,16,8));
|
||||||
if (substr($bitData,14,1) eq "1") {
|
if (substr($bitData,14,1) eq "1") {
|
||||||
$temp = $temp - 1024;
|
$temp = $temp - 1024;
|
||||||
}
|
}
|
||||||
$temp = $temp / 10;
|
$temp = $temp / 10;
|
||||||
my $hum = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,29,7));
|
my $hum = SIGNALduino_un_bin2dec(substr($bitData,29,7));
|
||||||
my $val = "T: $temp H: $hum B: $bat";
|
my $val = "T: $temp H: $hum B: $bat";
|
||||||
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp) sensor id=$id, channel=$channel, temp=$temp, hum=$hum, bat=$bat\n" ;
|
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp) sensor id=$id, channel=$channel, temp=$temp, hum=$hum, bat=$bat\n" ;
|
||||||
|
|
||||||
@ -124,12 +124,12 @@ SIGNALduino_un_Parse($$)
|
|||||||
# ID? CHN TMP ?? HUM
|
# ID? CHN TMP ?? HUM
|
||||||
$SensorTyp = "EAS800z";
|
$SensorTyp = "EAS800z";
|
||||||
$id = oct ("0b".substr($bitData,4,4));
|
$id = oct ("0b".substr($bitData,4,4));
|
||||||
$channel = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,9,3))+1;
|
$channel = SIGNALduino_un_bin2dec(substr($bitData,9,3))+1;
|
||||||
$temp = oct ("0b".substr($bitData,12,12))/10;
|
$temp = oct ("0b".substr($bitData,12,12))/10;
|
||||||
$bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical"; # Eventuell falsch!
|
$bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical"; # Eventuell falsch!
|
||||||
$hum = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,28,8));
|
$hum = SIGNALduino_un_bin2dec(substr($bitData,28,8));
|
||||||
$sendMode = int(substr($bitData,4,1)) eq "1" ? "auto" : "manual"; # Eventuell falsch!
|
$sendMode = int(substr($bitData,4,1)) eq "1" ? "auto" : "manual"; # Eventuell falsch!
|
||||||
my $type = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,0,4));
|
my $type = SIGNALduino_un_bin2dec(substr($bitData,0,4));
|
||||||
|
|
||||||
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp / type=$type) mode=$sendMode, sensor id=$id, channel=$channel, temp=$temp, hum=$hum, bat=$bat\n" ;
|
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp / type=$type) mode=$sendMode, sensor id=$id, channel=$channel, temp=$temp, hum=$hum, bat=$bat\n" ;
|
||||||
|
|
||||||
@ -157,12 +157,12 @@ SIGNALduino_un_Parse($$)
|
|||||||
my $bat = int(substr($bitData,8,1)) eq "0" ? "ok" : "critical";
|
my $bat = int(substr($bitData,8,1)) eq "0" ? "ok" : "critical";
|
||||||
my $trend = "";
|
my $trend = "";
|
||||||
my $sendMode = int(substr($bitData,11,1)) eq "0" ? "automatic" : "manual";
|
my $sendMode = int(substr($bitData,11,1)) eq "0" ? "automatic" : "manual";
|
||||||
my $temp = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,25,11));
|
my $temp = SIGNALduino_un_bin2dec(substr($bitData,25,11));
|
||||||
if (substr($bitData,24,1) eq "1") {
|
if (substr($bitData,24,1) eq "1") {
|
||||||
$temp = $temp - 2048
|
$temp = $temp - 2048
|
||||||
}
|
}
|
||||||
$temp = $temp / 10.0;
|
$temp = $temp / 10.0;
|
||||||
my $hum = SIGNALduino_SIGNALduino_bin2dec(substr($bitData,17,7));
|
my $hum = SIGNALduino_un_bin2dec(substr($bitData,17,7));
|
||||||
my $val = "T: $temp H: $hum B: $bat";
|
my $val = "T: $temp H: $hum B: $bat";
|
||||||
Log3 $hash, 4, "$name decoded protocolid: 6 $SensorTyp, sensor id=$id, channel=$channel, temp=$temp\n" ;
|
Log3 $hash, 4, "$name decoded protocolid: 6 $SensorTyp, sensor id=$id, channel=$channel, temp=$temp\n" ;
|
||||||
|
|
||||||
@ -250,11 +250,11 @@ SIGNALduino_un_Parse($$)
|
|||||||
{
|
{
|
||||||
my $SensorTyp = "perl NC-7367?";
|
my $SensorTyp = "perl NC-7367?";
|
||||||
my $id = oct ("0b".substr($bitData,4,4));
|
my $id = oct ("0b".substr($bitData,4,4));
|
||||||
my $channel = SIGNALduino_bin2dec(substr($bitData,9,3))+1;
|
my $channel = SIGNALduino_un_bin2dec(substr($bitData,9,3))+1;
|
||||||
my $temp = oct ("0b".substr($bitData,20,8))/10;
|
my $temp = oct ("0b".substr($bitData,20,8))/10;
|
||||||
my $bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical"; # Eventuell falsch!
|
my $bat = int(substr($bitData,8,1)) eq "1" ? "ok" : "critical"; # Eventuell falsch!
|
||||||
my $sendMode = int(substr($bitData,4,1)) eq "1" ? "auto" : "manual"; # Eventuell falsch!
|
my $sendMode = int(substr($bitData,4,1)) eq "1" ? "auto" : "manual"; # Eventuell falsch!
|
||||||
my $type = SIGNALduino_bin2dec(substr($bitData,0,4));
|
my $type = SIGNALduino_un_bin2dec(substr($bitData,0,4));
|
||||||
|
|
||||||
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp / type=$type) mode=$sendMode, sensor id=$id, channel=$channel, temp=$temp, bat=$bat\n" ;
|
Log3 $hash, 4, "$name decoded protocolid: 7 ($SensorTyp / type=$type) mode=$sendMode, sensor id=$id, channel=$channel, temp=$temp, bat=$bat\n" ;
|
||||||
|
|
||||||
@ -288,14 +288,14 @@ SIGNALduino_un_Attr(@)
|
|||||||
|
|
||||||
|
|
||||||
sub
|
sub
|
||||||
SIGNALduino_bin2dec($)
|
SIGNALduino_un_bin2dec($)
|
||||||
{
|
{
|
||||||
my $h = shift;
|
my $h = shift;
|
||||||
my $int = unpack("N", pack("B32",substr("0" x 32 . $h, -32)));
|
my $int = unpack("N", pack("B32",substr("0" x 32 . $h, -32)));
|
||||||
return sprintf("%d", $int);
|
return sprintf("%d", $int);
|
||||||
}
|
}
|
||||||
sub
|
sub
|
||||||
SIGNALduino_binflip($)
|
SIGNALduino_un_binflip($)
|
||||||
{
|
{
|
||||||
my $h = shift;
|
my $h = shift;
|
||||||
my $hlen = length($h);
|
my $hlen = length($h);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user