2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

47_OBIS: fixed bug with 64 bit integer numbers

git-svn-id: https://svn.fhem.de/fhem/trunk@24113 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
gvzdus 2021-03-28 20:54:42 +00:00
parent 034db039e0
commit e4033b7995
2 changed files with 17 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: 47_OBIS: fixed bug with 64 bit integer numbers
- change: 46_TeslaPowerwall2AC: Code rewrite for new Auth API and
modul structure
- new: 69_SoftliqCloud: New Module

View File

@ -417,13 +417,25 @@ sub OBIS_Parse_List
} elsif ($tltype == 0x50 || $tltype == 0x60) {
# Signed (5) or Unsigned (6) Int
my $num = 0;
my $subme = 0;
if ($tltype==0x60 && $len>3 && $result[0]=~/^1-0:16\.7\.0/ && $hash->{helper}{DZGHACK}) {
$tltype = 0x50;
}
$num = ord chop($_[3]) if ($len--);
my $subme = ($tltype == 0x50) && ($num & 0x80) ? ( 1 << (8*($len+1)) ) : 0;
while ($len-- > 0) {
$num = ($num<<8) | ord chop($_[3]);
if ($len==8) {
$num = unpack($tltype = 0x50 ? 'q>' : 'Q>',
chop($_[3]).chop($_[3]).chop($_[3]).chop($_[3]).
chop($_[3]).chop($_[3]).chop($_[3]).chop($_[3]));
} elsif ($len==4) {
$num = unpack($tltype = 0x50 ? 'l>' : 'L>',
chop($_[3]).chop($_[3]).chop($_[3]).chop($_[3]));
} elsif ($len<8) {
$num = ord chop($_[3]) if ($len--);
$subme = ($tltype == 0x50) && ($num & 0x80) ? ( 1 << (8*($len+1)) ) : 0;
while ($len-- > 0) {
$num = ($num<<8) | ord chop($_[3]);
}
} else {
Log3 $hash, 1, "OBIS - Number sized over 8 bytes - no support implemented yet";
}
push @result, ($num-$subme);
} elsif ($tltype == 0x40) {