From 5560c5854b249e989560eca16f0304185167fdfd Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Mon, 10 Jun 2013 15:31:09 +0000 Subject: [PATCH] correct minor bugs, HMLAN log sequence git-svn-id: https://svn.fhem.de/fhem/trunk@3272 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 44 +++++++++++++++++++++--------------------- fhem/FHEM/10_CUL_HM.pm | 4 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index 55b5e86c8..92cc56ad2 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -234,8 +234,7 @@ sub HMLAN_uptime($$) {######################################################### my ($hash,$msec) = @_; $msec = hex($msec); - my $sec = int($msec/1000); - + my $sec = int($msec/1000); # my ($sysec, $syusec) = gettimeofday(); # my $symsec = int($sysec*1000+$syusec/1000); # if ($hash->{helper}{refTime} == 1){ #init referenceTime @@ -314,6 +313,7 @@ sub HMLAN_Parse($$) {########################################################## if($stat & 0x040A){ # do not parse this message, no valid content Log $ll5, "HMLAN_Parse: $name problems detected - please restart HMLAN"if($stat & 0x0400); Log $ll5, "HMLAN_Parse: $name discard" if($stat & 0x000A); + $hash->{helper}{$dst}{flg} = 0;#NACK is also a response, continue process return ;# message with no ack is send - do not dispatch } if ($mFld[1] !~ m/00(01|02|21|41|50)/ && $letter eq 'R'){ @@ -323,6 +323,13 @@ sub HMLAN_Parse($$) {########################################################## } Log $ll5, "HMLAN_Parse: $name special reply ".$mFld[1] if($stat & 0x0200); + #update some User information ------ + $hash->{uptime} = HMLAN_uptime($hash,$mFld[2]); + $hash->{RSSI} = $rssi; + $hash->{RAWMSG} = $rmsg; + $hash->{"${name}_MSGCNT"}++; + $hash->{"${name}_TIME"} = TimeNow(); + # HMLAN sends ACK for flag 'A0' but not for 'A4'(config mode)- # we ack ourself an long as logic is uncertain - also possible is 'A6' for RHS if (hex($flg)&0x4){#not sure: 4 oder 2 ? @@ -332,17 +339,11 @@ sub HMLAN_Parse($$) {########################################################## Log $ll5, "HMLAN_Parse: $name ACK config"; HMLAN_Write($hash,undef, "As15".$mNo."8002".$dst.$src."00"); } - #update some User information ------ - $hash->{uptime} = HMLAN_uptime($hash,$mFld[2]); - $hash->{RSSI} = $rssi; - $hash->{RAWMSG} = $rmsg; - $hash->{"${name}_MSGCNT"}++; - $hash->{"${name}_TIME"} = TimeNow(); if ($letter eq 'R' && $hash->{helper}{$src}{flg}){ $hash->{helper}{$src}{flg} = 0; #release send-holdoff if ($hash->{helper}{$src}{msg}){ #send delayed msg if any - Log $ll5,"HMLAN_SdDly: $name $src ".$hash->{helper}{$src}{msg}; + Log $ll5,"HMLAN_SdDly: $name $src"; HMLAN_SimpleWrite($hash, $hash->{helper}{$src}{msg}); } $hash->{helper}{$src}{msg} = ""; #clear message @@ -403,22 +404,11 @@ sub HMLAN_SimpleWrite(@) {##################################################### if ($DevDelay > 0.01); delete $hash->{helper}{nextSend}{$dst}; } - $msg =~ m/(.{9}).(..).(.{8}).(..).(.{8}).(..)(....)(.{6})(.{6})(.*)/; - Log $ll5, 'HMLAN_Send: '.$name.' S:'.$1 - .' stat: ' .$2 - .' t:' .$3 - .' d:' .$4 - .' r:' .$5 - .' m:' .$6 - .' ' .$7 - .' ' .$8 - .' ' .$9 - .' ' .$10; if ($dst ne $attr{$name}{hmId}){ #delay send if answer is pending if ( $hash->{helper}{$dst}{flg} && #HMLAN's ack pending ($hash->{helper}{$dst}{to} > gettimeofday())){#won't wait forever! $hash->{helper}{$dst}{msg} = $msg; #postpone message - Log $ll5,"HMLAN_Delay: $name msg delayed $dst $msg"; + Log $ll5,"HMLAN_Delay: $name $dst"; return; } my $flg = substr($msg,36,2); @@ -435,6 +425,17 @@ sub HMLAN_SimpleWrite(@) {##################################################### } $hash->{helper}{$dst}{chn} = $chn; } + $msg =~ m/(.{9}).(..).(.{8}).(..).(.{8}).(..)(....)(.{6})(.{6})(.*)/; + Log $ll5, 'HMLAN_Send: '.$name.' S:'.$1 + .' stat: ' .$2 + .' t:' .$3 + .' d:' .$4 + .' r:' .$5 + .' m:' .$6 + .' ' .$7 + .' ' .$8 + .' ' .$9 + .' ' .$10; } else{ Log $ll5, 'HMLAN_Send: '.$name.' I:'.$msg; @@ -459,7 +460,6 @@ sub HMLAN_DoInit($) {########################################################## HMLAN_SimpleWrite($hash, "Y03,00,"); HMLAN_SimpleWrite($hash, "Y03,00,"); HMLAN_SimpleWrite($hash, "T$s2000,04,00,00000000"); - $hash->{helper}{refTime}=0; foreach (keys %lhash){delete ($lhash{$_})};# clear IDs - HMLAN might have a reset diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 3d001b22d..182be000e 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -1497,7 +1497,7 @@ sub CUL_HM_parseCommon(@){##################################################### ($dhash?CUL_HM_hash2Name($dhash):$shash->{IODev}{NAME}), (-1)*(hex($rssi))) if ($rssi && $rssi ne '00' && $rssi ne'80'); - @{$modules{CUL_HM}{helper}{reqStatus}} = grep { $_ != $shash->{NAME} } + @{$modules{CUL_HM}{helper}{reqStatus}} = grep { $_ ne $shash->{NAME} } @{$modules{CUL_HM}{helper}{reqStatus}}; if ($pendType eq "StatusReq"){#it is the answer to our request my $chnSrc = $src.$shash->{helper}{respWait}{forChn}; @@ -2480,7 +2480,7 @@ sub CUL_HM_Set($@) { $st eq "motionDetector" ) && (!$single || $single ne "single")); $single = ($single eq "single")?1:"";#default to dual - $set = ($set eq "unset")?0:1; + $set = ($set && $set eq "unset")?0:1; my ($b1,$b2,$nrCh2Pair); $b1 = (!$roleD) ? hex($chn) : ($single?$bNo : ($bNo*2 - 1));