mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
softbuffer fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@113 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
71a7bf3f45
commit
28301215ce
@ -351,6 +351,8 @@
|
||||
- feature: softwarebuffer for FHT devices (Dirk 17.10)
|
||||
- feature: FHT low temperatur warning and offset (Dirk 17.10)
|
||||
- change: change FHT state into warnings (Dirk 17.10)
|
||||
NOTE: you'll get an undefined type state &
|
||||
undefined type unknown_85 after upgrade.
|
||||
- feature: Softwarebuffer code simplified (Rudi 22.11)
|
||||
- bugfix: bug #12327 doppeltes my
|
||||
- bugfix: set STATE from trigger
|
||||
|
@ -296,7 +296,7 @@ FHZ_Parse($$)
|
||||
$msg = substr($msg, 4, 2);
|
||||
}
|
||||
|
||||
Log 4, "FHZ $name $type: $msg)";
|
||||
Log 4, "FHZ $name $type: $msg";
|
||||
$def->{CHANGED}[0] = "$type: $msg";
|
||||
return $hash->{NAME};
|
||||
}
|
||||
@ -343,7 +343,7 @@ FHZ_ReadAnswer($$)
|
||||
for(;;) {
|
||||
|
||||
vec($rin, $hash->{FD}, 1) = 1;
|
||||
my $nfound = select($rin, undef, undef, 3);
|
||||
my $nfound = select($rin, undef, undef, 3); # 3 seconds timeout
|
||||
if($nfound < 0) {
|
||||
next if ($! == EAGAIN() || $! == EINTR() || $! == 0);
|
||||
die("Select error $nfound / $!\n");
|
||||
@ -352,8 +352,7 @@ FHZ_ReadAnswer($$)
|
||||
|
||||
my $buf = $hash->{PortObj}->input();
|
||||
|
||||
# Log 5, "FHZ/RAW: " . unpack('H*',$buf);
|
||||
Log 4, "FHZ/RAW: " . unpack('H*',$buf);
|
||||
Log 5, "FHZ/RAW: " . unpack('H*',$buf);
|
||||
$mfhzdata .= $buf;
|
||||
next if(length($mfhzdata) < 2);
|
||||
|
||||
|
@ -321,7 +321,7 @@ FHT_Parse($$)
|
||||
if(!$val) {
|
||||
# This is a confirmation message. We reformat it so that
|
||||
# it looks like a real message, and let the rest parse it
|
||||
Log 4, "FHT $name confirmation: $cde)";
|
||||
Log 4, "FHT $name confirmation: $cde";
|
||||
$val = substr($cde, 2, 2);
|
||||
$cde = substr($cde, 0, 2) . "0069";
|
||||
$confirm = 1;
|
||||
@ -399,9 +399,6 @@ FHT_Parse($$)
|
||||
} elsif($type eq "lowtemp-offset") {
|
||||
$val = sprintf("%d.0 (Celsius)", $val)
|
||||
|
||||
} elsif($type =~ m/echo_/) { # Ignore these messages
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
$def->{READINGS}{$type}{TIME} = $tn;
|
||||
@ -409,17 +406,19 @@ FHT_Parse($$)
|
||||
$def->{CHANGED}[0] = "$type: $val";
|
||||
$def->{STATE} = "$type: $val" if($type eq "measured-temp");
|
||||
|
||||
Log 4, "FHT $name ($type: $val)";
|
||||
Log 4, "FHT $name $type: $val";
|
||||
|
||||
################################
|
||||
# Softbuffer: deleted confirmed commands
|
||||
my $io = $hash->{IODev};
|
||||
if($confirm && keys(%{$io->{SOFTBUFFER}})) {
|
||||
if($confirm) {
|
||||
my $found;
|
||||
my $io = $def->{IODev};
|
||||
foreach my $key (sort keys %{$io->{SOFTBUFFER}}) {
|
||||
my $h = $io->{SOFTBUFFER}{$key};
|
||||
if($h->{HASH}->{NAME} eq $name &&
|
||||
$h->{CMD} eq $type) {
|
||||
my $hcmd = $h->{CMD};
|
||||
$hcmd = "init" if($hcmd eq "refreshvalues");
|
||||
Log 5, "FHT check $h->{HASH}->{NAME} eq $name && $hcmd eq $type";
|
||||
if($h->{HASH}->{NAME} eq $name && $hcmd eq $type) {
|
||||
$found = $key;
|
||||
last;
|
||||
}
|
||||
@ -440,6 +439,7 @@ doSoftBuffer($)
|
||||
my $now = gettimeofday();
|
||||
|
||||
my $count = 0;
|
||||
my $fhzbuflen = -999;
|
||||
foreach my $key (keys %{ $io->{SOFTBUFFER} }) {
|
||||
|
||||
$count++;
|
||||
@ -457,8 +457,10 @@ doSoftBuffer($)
|
||||
}
|
||||
}
|
||||
|
||||
next if(getFhzBuffer($io) < $minFhzHardwareBuffer);
|
||||
$fhzbuflen = getFhzBuffer($io) if($fhzbuflen == -999);
|
||||
next if($fhzbuflen < $minFhzHardwareBuffer);
|
||||
sendCommand($h->{HASH}, $h->{CMD}, $h->{VAL}, $h->{ARG});
|
||||
$fhzbuflen -= ($h->{CMD} eq "refreshvalues" ? 7 : 5);
|
||||
$h->{SENDTIME} = $now;
|
||||
$h->{NSENT}++;
|
||||
|
||||
@ -491,13 +493,12 @@ getFhzBuffer($)
|
||||
|
||||
return $minFhzHardwareBuffer if(IsDummy($io->{NAME}));
|
||||
|
||||
Log 4, "getFhzBuffer";
|
||||
for(;;) {
|
||||
FHZ_Write($io, "04", "c90185");
|
||||
|
||||
my $msg = FHZ_ReadAnswer($io, "fhtbuf");
|
||||
|
||||
return hex(substr($msg, 16, 2)) if($msg && $msg =~ m/^[0-9]+$/);
|
||||
Log 5, "getFhzBuffer: $count $msg";
|
||||
|
||||
return hex(substr($msg, 16, 2)) if($msg && $msg =~ m/^[0-9A-F]+$/i);
|
||||
return 0 if($count++ > 5);
|
||||
}
|
||||
}
|
||||
@ -517,8 +518,6 @@ sendCommand($$$$)
|
||||
my $havefhz = ($hash->{IODev} && defined($hash->{IODev}->{FD}));
|
||||
IOWrite($hash, "04", $arg);
|
||||
sleep(1) if($havefhz);
|
||||
IOWrite($hash, "04", "c90185"); # Check the fht buffer
|
||||
sleep(1) if($havefhz);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -135,7 +135,7 @@ my %intAt; # Internal at timer hash.
|
||||
my $intAtCnt=0;
|
||||
my $reread_active = 0;
|
||||
my $AttrList = "room comment";
|
||||
my $cvsid = '$Id: fhem.pl,v 1.30 2007-11-26 14:56:45 rudolfkoenig Exp $';
|
||||
my $cvsid = '$Id: fhem.pl,v 1.31 2007-11-27 15:17:47 rudolfkoenig Exp $';
|
||||
|
||||
$init_done = 0;
|
||||
|
||||
@ -1628,8 +1628,10 @@ DoTrigger($$)
|
||||
$defs{$dev}{INTRIGGER}=1;
|
||||
my $ret = "";
|
||||
foreach my $n (sort keys %defs) {
|
||||
Log 5, "$dev trigger: Checking $n for notify";
|
||||
$ret .= CallFn($n, "NotifyFn", $defs{$n}, $defs{$dev});
|
||||
if($modules{$defs{$n}{TYPE}}{NotifyFn}) {
|
||||
Log 5, "$dev trigger: Checking $n for notify";
|
||||
$ret .= CallFn($n, "NotifyFn", $defs{$n}, $defs{$dev});
|
||||
}
|
||||
}
|
||||
delete($defs{$dev}{INTRIGGER});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user