mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 00:26:03 +00:00
parser input scan, valvePos, bug fix
git-svn-id: https://svn.fhem.de/fhem/trunk@4704 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4b58d49719
commit
f0e23d4608
@ -198,12 +198,13 @@ sub HMLAN_Attr(@) {############################################################
|
||||
(($val =~ m /^[0-9A-Fa-f]{32}$/ )?
|
||||
$val:
|
||||
unpack('H*', md5($val)));
|
||||
$retVal = "$aName set to $attr{$name}{$aName}";
|
||||
$retVal = "$aName set to $attr{$name}{$aName}"
|
||||
if($aVal ne $attr{$name}{$aName});
|
||||
}
|
||||
else{
|
||||
delete $attr{$name}{$aName};
|
||||
}
|
||||
my ($k1no,$k1,$k2no,$k2,$k3no,$k3)
|
||||
my ($k1no,$k1,$k2no,$k2,$k3no,$k3,$k4no,$k4,$k5no,$k5)
|
||||
=( "01",AttrVal($name,"hmKey","")
|
||||
,"02",AttrVal($name,"hmKey2","")
|
||||
,"03",AttrVal($name,"hmKey3","")
|
||||
@ -214,10 +215,14 @@ sub HMLAN_Attr(@) {############################################################
|
||||
if ($k1 =~ m/:/){($k1no,$k1) = split(":",$k1);}
|
||||
if ($k2 =~ m/:/){($k2no,$k2) = split(":",$k2);}
|
||||
if ($k3 =~ m/:/){($k3no,$k3) = split(":",$k3);}
|
||||
if ($k4 =~ m/:/){($k4no,$k4) = split(":",$k4);}
|
||||
if ($k5 =~ m/:/){($k5no,$k5) = split(":",$k5);}
|
||||
|
||||
HMLAN_SimpleWrite($defs{$name}, "Y01,".($k1?"$k1no,$k1":"00,"));
|
||||
HMLAN_SimpleWrite($defs{$name}, "Y02,".($k2?"$k2no,$k2":"00,"));
|
||||
HMLAN_SimpleWrite($defs{$name}, "Y03,".($k3?"$k3no,$k3":"00,"));
|
||||
HMLAN_SimpleWrite($defs{$name}, "Y04,".($k4?"$k4no,$k4":"00,"));
|
||||
HMLAN_SimpleWrite($defs{$name}, "Y05,".($k5?"$k5no,$k5":"00,"));
|
||||
return $retVal;
|
||||
}
|
||||
elsif($aName eq "hmMsgLowLimit"){
|
||||
|
@ -566,11 +566,13 @@ sub CUL_HM_Attr(@) {#################################
|
||||
);
|
||||
sub CUL_HM_Parse($$) {##############################
|
||||
my ($iohash, $msgIn) = @_;
|
||||
my $id = CUL_HM_Id($iohash);
|
||||
my $ioName = $iohash->{NAME};
|
||||
|
||||
my ($msg,$msgStat,$myRSSI,$msgIO) = split(":",$msgIn,4);
|
||||
# Msg format: Allnnffttssssssddddddpp...
|
||||
my (undef,$len,$mNo,$mFlg,$mTp,$src,$dst,$p) = unpack 'A1A2A2A2A2A6A6A*',$msg;
|
||||
my ($t,$len,$mNo,$mFlg,$mTp,$src,$dst,$p) = unpack 'A1A2A2A2A2A6A6A*',$msg;
|
||||
|
||||
return if (ref($iohash) ne 'HASH' || $t ne 'A' || length($msg)<20);
|
||||
|
||||
$p = "" if(!defined($p));
|
||||
my @mI = unpack '(A2)*',$p; # split message info to bytes
|
||||
return "" if($msgStat && $msgStat eq 'NACK');# lowlevel error
|
||||
@ -578,6 +580,8 @@ sub CUL_HM_Parse($$) {##############################
|
||||
my $shash = CUL_HM_id2Hash($src); #sourcehash - will be modified to channel entity
|
||||
my $devH = $shash; # source device hash
|
||||
my $dhash = CUL_HM_id2Hash($dst); # destination device hash
|
||||
my $id = CUL_HM_Id($iohash);
|
||||
my $ioName = $iohash->{NAME};
|
||||
CUL_HM_statCnt($ioName,"r");
|
||||
my $dname = ($dst eq "000000") ? "broadcast" :
|
||||
($dhash ? $dhash->{NAME} :
|
||||
@ -3502,12 +3506,10 @@ sub CUL_HM_Set($@) {
|
||||
}
|
||||
|
||||
#+++++++++++++++++ set/get support subroutines+++++++++++++++++++++++++++++++++
|
||||
my $updtValveCnt = 0;
|
||||
sub CUL_HM_valvePosUpdt(@) {#update valve position periodically to please valve
|
||||
my($in ) = @_;
|
||||
my(undef,$vId) = split(':',$in);
|
||||
my $hash = CUL_HM_id2Hash($vId);
|
||||
my $vDevId = substr($vId,0,6);
|
||||
my $msgCnt = ($hash->{helper}{vd}{msgCnt} + 1)%255;
|
||||
|
||||
# int32_t result = (((_address << 8) | messageCounter) * 1103515245 + 12345) >> 16;
|
||||
@ -3519,33 +3521,44 @@ sub CUL_HM_valvePosUpdt(@) {#update valve position periodically to please valve
|
||||
my $nextTimer = (($lo+$hi)&0xff)/4 + 120;#original - instable
|
||||
my $name = $hash->{NAME};
|
||||
my $vp = ReadingsVal($name,"valvePosTC","15 %");
|
||||
my $ackTime;
|
||||
$vp =~ s/ %//;
|
||||
$vp *=2.56;
|
||||
$vp = 255 if ($vp >255);
|
||||
my $tn = gettimeofday();
|
||||
my $delta = int(($tn - $hash->{helper}{vd}{next})*1000);
|
||||
Log3 $name,3,"VD-timing Critical ##### diff:$delta" if ($delta >100);
|
||||
foreach my $peer (sort(split(',',AttrVal($name,"peerIDs","")))) {
|
||||
next if (length($peer) != 8);
|
||||
$peer = substr($peer,0,6);
|
||||
my $pn = CUL_HM_id2Name($peer);
|
||||
$ackTime = ReadingsTimestamp($pn, "ValvePosition", "nix");
|
||||
CUL_HM_PushCmdStack($hash,sprintf("%02XA258%s%s%s%02X",$msgCnt,$vDevId
|
||||
,$peer,$hash->{helper}{virtTC},$vp));
|
||||
CUL_HM_PushCmdStack($hash,sprintf("%02XA258%s%s%s%02X"
|
||||
,$msgCnt,substr($vId,0,6)
|
||||
,substr($peer,0,6)
|
||||
,$hash->{helper}{virtTC},$vp));
|
||||
}
|
||||
|
||||
if ($ackTime && $ackTime ne $hash->{helper}{vd}{ackT} ) {
|
||||
$hash->{helper}{vd}{next} += $nextTimer;
|
||||
}
|
||||
else {
|
||||
$hash->{helper}{vd}{next} = $tn+$nextTimer;
|
||||
}
|
||||
$hash->{helper}{vd}{ackT} = $ackTime;
|
||||
$hash->{helper}{vd}{next} = $tn+$nextTimer;
|
||||
my $tn = gettimeofday();
|
||||
$hash->{helper}{vd}{nextF} = $hash->{helper}{vd}{next} + $nextTimer;
|
||||
$hash->{helper}{vd}{nextM} = $tn+$nextTimer;
|
||||
$hash->{helper}{vd}{msgCnt} = $msgCnt;
|
||||
$hash->{helper}{virtTC} = "00";
|
||||
CUL_HM_ProcessCmdStack($hash);
|
||||
InternalTimer($tn+10,"CUL_HM_valvePosTmr","valveTmr:$vId",0);
|
||||
}
|
||||
sub CUL_HM_valvePosTmr(@) {#calc next vd wakeup
|
||||
my($in ) = @_;
|
||||
my(undef,$vId) = split(':',$in);
|
||||
my $hash = CUL_HM_id2Hash($vId);
|
||||
my $ackTime;
|
||||
foreach my $peer (sort(split(',',AttrVal($hash->{NAME},"peerIDs","")))) {
|
||||
next if (length($peer) != 8);
|
||||
my $pn = CUL_HM_id2Name(substr($peer,0,6));
|
||||
$ackTime = ReadingsTimestamp($pn, "ValvePosition", "");
|
||||
}
|
||||
|
||||
if (!$ackTime || $ackTime eq $hash->{helper}{vd}{ackT} ){
|
||||
$hash->{helper}{vd}{next} = $hash->{helper}{vd}{nextF};
|
||||
Log3 $hash->{NAME},5,"CUL_HM $hash->{NAME} virtualTC use fail-timer";
|
||||
}
|
||||
else{
|
||||
$hash->{helper}{vd}{next} = $hash->{helper}{vd}{nextM};
|
||||
}
|
||||
$hash->{helper}{vd}{ackT} = $ackTime;
|
||||
InternalTimer($hash->{helper}{vd}{next},"CUL_HM_valvePosUpdt","valvePos:$vId",0);
|
||||
}
|
||||
sub CUL_HM_weather(@) {#periodically send weather data
|
||||
|
@ -275,7 +275,7 @@ sub HMinfo_tempList(@) { ######################################################
|
||||
my ($filter,$action,$fName)=@_;
|
||||
$filter = "." if (!$filter);
|
||||
$fName = "tempList.cfg" if (!$fName);
|
||||
$action = "save" if (!$action);
|
||||
$action = "" if (!$action);
|
||||
my $ret;
|
||||
if ($action eq "save"){
|
||||
open(aSave, ">$fName") || return("Can't open $fName: $!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user