1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-04 22:19:38 +00:00

repair assigned-ids in hmlan

git-svn-id: https://svn.fhem.de/fhem/trunk@4681 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2014-01-18 10:09:07 +00:00
parent c6e9c0b2c8
commit 20ae7d4a39
2 changed files with 18 additions and 19 deletions

View File

@ -122,6 +122,8 @@ sub HMLAN_Define($$) {#########################################################
my @al = ();
@{$defs{$name}{helper}{log}{ids}} = \@al;
$defs{$name}{helper}{assId};
HMLAN_condUpdate($hash,253);#set disconnected
$hash->{STATE} = "disconnected";
@ -403,8 +405,6 @@ sub HMLAN_ReadAnswer($$$) {# This is a direct read for commands like get
}
}
my %lhash; # remember which ID is assigned to this HMLAN
sub HMLAN_Write($$$) {#########################################################
my ($hash,$fn,$msg) = @_;
if (length($msg)>22){
@ -427,9 +427,8 @@ sub HMLAN_Write($$$) {#########################################################
# my $IDnew = '+'.$dst.',00,01,'; # newChannel- trailing 01 to be sent if talk to neu channel
my $IDadd = '+'.$dst.',00,00,'; # guess: add ID?
if (!$lhash{$dst} && $dst ne "000000"){
if (!$hash->{assIDs}{$dst} && $dst ne "000000"){
HMLAN_SimpleWrite($hash, $IDadd);
# delete $hash->{helper}{$dst};
my $dN = CUL_HM_id2Name($dst);
if (!($dN eq $dst) && # name not found
!(CUL_HM_Get(CUL_HM_id2Hash($dst),$dN,"param","rxType") & ~0x04)){#config only
@ -439,9 +438,9 @@ sub HMLAN_Write($$$) {#########################################################
$hash->{helper}{$dst}{newChn} = '+'.$dst.',00,01,';
}
$hash->{helper}{$dst}{name} = CUL_HM_id2Name($dst);
$lhash{$dst} = 1;
$hash->{assignedIDs}=join(',',keys %lhash);
$hash->{assignedIDsCnt}=scalar(keys %lhash);
$hash->{assIDs}{$dst} = 1;
$hash->{assignedIDs}=join(',',keys %{$hash->{assIDs}});
$hash->{assignedIDsCnt}=scalar(keys %{$hash->{assIDs}});
}
}
my $tm = int(gettimeofday()*1000) % 0xffffffff;
@ -785,7 +784,7 @@ sub HMLAN_DoInit($) {##########################################################
HMLAN_condUpdate($hash,0xff);
$hash->{helper}{q}{cap}{$_}=0 foreach (keys %{$hash->{helper}{q}{cap}});
foreach (keys %lhash){delete ($lhash{$_})};# clear IDs - HMLAN might have a reset
foreach (keys %{$hash->{helper}{assIDs}}){delete ($hash->{helper}{assIDs}{$_})};# clear IDs - HMLAN might have a reset
$hash->{helper}{q}{keepAliveRec} = 1; # ok for first time
$hash->{helper}{q}{keepAliveRpt} = 0; # ok for first time

View File

@ -594,17 +594,17 @@ sub CUL_HM_Parse($$) {##############################
&& ($mTp eq '01' || $mTp eq '11')){
my $ioId = AttrVal($dhash->{IODev}{NAME},"hmId","-");
if($ioId ne $src){
CUL_HM_eventP($dhash,"ErrIoId_$src");
my ($evntCnt,undef) = split(' last_at:',$dhash->{"prot"."ErrIoId_$src"},2);
push @entities,CUL_HM_UpdtReadSingle($dhash,"sabotageAttackId","ErrIoId_$src cnt:$evntCnt",1);
}
CUL_HM_eventP($dhash,"ErrIoId_$src");
my ($evntCnt,undef) = split(' last_at:',$dhash->{"prot"."ErrIoId_$src"},2);
push @entities,CUL_HM_UpdtReadSingle($dhash,"sabotageAttackId","ErrIoId_$src cnt:$evntCnt",1);
}
if( defined $dhash->{helper}{cSnd} &&
$dhash->{helper}{cSnd} ne substr($msg,7)){
if( defined $dhash->{helper}{cSnd} &&
$dhash->{helper}{cSnd} ne substr($msg,7)){
CUL_HM_eventP($dhash,"ErrIoAttack");
my ($evntCnt,undef) = split(' last_at:',$dhash->{"prot"."ErrIoAttack"},2);
push @entities,CUL_HM_UpdtReadSingle($dhash,"sabotageAttack","ErrIoAttack cnt:$evntCnt",1);
}
my ($evntCnt,undef) = split(' last_at:',$dhash->{"prot"."ErrIoAttack"},2);
push @entities,CUL_HM_UpdtReadSingle($dhash,"sabotageAttack","ErrIoAttack cnt:$evntCnt",1);
}
}
###########
@ -3489,9 +3489,9 @@ sub CUL_HM_valvePosUpdt(@) {#update valve position periodically to please valve
my $vDevId = substr($vId,0,6);
my $msgCnt = ($hash->{helper}{vd}{msgCnt} + 1)%255;
# int32_t result = (((_address << 8) | messageCounter) * 1103515245 + 12345) >> 16;
# int32_t result = (((_address << 8) | messageCounter) * 1103515245 + 12345) >> 16;
# 4e6d = 20077 12996205 = C64E6D
# return (result & 0xFF) + 480;
# return (result & 0xFF) + 480;
my $idl = $hash->{helper}{vd}{idl}+$msgCnt;
my $lo = int(($idl*0x4e6d +12345)/0x10000)&0xff;
my $hi = ($hash->{helper}{vd}{idh}+$idl*198)&0xff;