mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 08:11:44 +00:00
show single bit endpoints in readings
git-svn-id: https://svn.fhem.de/fhem/trunk@3573 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
259a49f849
commit
503f7fff96
@ -688,8 +688,16 @@ SWAP_updateReadings($$$)
|
|||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
foreach my $endpoint (@{$hash->{product}->{registers}->{$reg}->{endpoints}}) {
|
foreach my $endpoint (@{$hash->{product}->{registers}->{$reg}->{endpoints}}) {
|
||||||
my $position = 0;
|
my $position = 0;
|
||||||
$position = $endpoint->{position} * 2 if( defined($endpoint->{position}) );
|
my $value = "";
|
||||||
my $value = substr($data, $position, $endpoint->{size}*2);
|
$position = $endpoint->{position} if( defined($endpoint->{position}) );
|
||||||
|
if( $position =~ m/^(\d+)\.(\d+)$/ ) {
|
||||||
|
my $byte = hex( substr( $data, length($data) - 2 - $1*2, 2 ) );
|
||||||
|
my $mask = 0x01 << $2;
|
||||||
|
$value = "0";
|
||||||
|
$value = "1" if( $byte & $mask );
|
||||||
|
} else {
|
||||||
|
$value = substr($data, $position*2, $endpoint->{size}*2);
|
||||||
|
}
|
||||||
readingsBulkUpdate($hash, SWAP_regName($rid,$i,$endpoint), $value);
|
readingsBulkUpdate($hash, SWAP_regName($rid,$i,$endpoint), $value);
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user