2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 12:46:03 +00:00

34_SWAP.pm: fixed handling of mixed single bit / mulity byte endpoints, see forum: 34_SWAP.pm: fixed handling of single bit endpoints

git-svn-id: https://svn.fhem.de/fhem/trunk@8301 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2015-03-27 17:41:57 +00:00
parent 480de70d42
commit 75f90d4650

View File

@ -506,19 +506,21 @@ SWAP_Set($@)
} else {
my $len = $register->{size};
if( !$len ) {
my $max_position = 0;
my $max_pos = 0;
my $max_pos_size = 1;
foreach my $endpoint ( @{$register->{endpoints}} ) {
if( !defined($endpoint->{position}) ) {
$len = $endpoint->{size};
last;
}
$max_position = maxNum( $max_position, int($endpoint->{position}) );
$max_pos = maxNum( $max_pos, int($endpoint->{position}) );
$max_pos_size = int($endpoint->{size} + 0.9 );
$len += $endpoint->{size};
}
$len = maxNum( $len, $max_position+1 );
$len = maxNum( $len, $max_pos+$max_pos_size );
}
return "value has to be ". $len ." byte(s) in size" if( $len*2 != length( $arg2 ) );