2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

integrated OWServer/OWDevice nonblocking and random start time patches

git-svn-id: https://svn.fhem.de/fhem/trunk@4427 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2013-12-20 16:04:16 +00:00
parent 1edb1ece2d
commit 351b24a59b
3 changed files with 26 additions and 5 deletions

View File

@ -1,6 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- SVN
- change: integrated OWServer/OWDevice nonblocking and random start
time patches (justme1968 & Boris)
- feature: Add new module Dashboard
- feature: Add new module ONKYO_AVR
- feature: SYSSTAT: allow (remote) monitoring via snmp, support

View File

@ -251,6 +251,7 @@ OWServer_Read($@)
if(AttrVal($hash->{NAME},"nonblocking",undef) && $init_done) {
$hash->{".path"}= $path;
pipe(READER,WRITER);
#READER->autoflush(1);
WRITER->autoflush(1);
my $pid= fork;
@ -259,7 +260,7 @@ OWServer_Read($@)
return undef;
}
InternalTimer(gettimeofday()+20, "OWServer_TimeoutChild", $pid, 0);
InternalTimer(gettimeofday()+10, "OWServer_TimeoutChild", $pid, 0);
if($pid == 0) {
close READER;
$ret= OWNet::read($hash->{DEF},$path);
@ -277,8 +278,21 @@ OWServer_Read($@)
Log3 $hash, 5, "OWServer child ID for reading '$path' is $pid";
close WRITER;
# http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673
my ($rout,$rin, $eout,$ein) = ('','', '','');
vec($rin, fileno(READER), 1) = 1;
$ein = $rin;
my $nfound = select($rout=$rin, undef, $eout=$ein, 4);
if( $nfound ) {
chomp($ret= <READER>);
RemoveInternalTimer($pid);
} else {
Log3 undef, 1, "OWServer: read timeout for child $pid";
$hash->{READ_FAILED} = 0 if( !$hash->{READ_FAILED} );
$hash->{READ_FAILED}++;
}
close READER;
} else {
$ret= $hash->{fhem}{owserver}->read($path);
$ret =~ s/^\s+//g if(defined($ret));

View File

@ -508,9 +508,10 @@ OWDevice_UpdateValues($) {
readingsEndUpdate($hash,1);
}
RemoveInternalTimer($hash);
InternalTimer(int(gettimeofday())+$hash->{fhem}{interval}, "OWDevice_UpdateValues", $hash, 0)
if(defined($hash->{fhem}{interval}));
# http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673
InternalTimer(int(gettimeofday())+$hash->{fhem}{rand}+$hash->{fhem}{interval},
"OWDevice_UpdateValues", $hash, 0) if(defined($hash->{fhem}{interval}));
$hash->{fhem}{rand} = 0;
}
###################################
@ -653,9 +654,13 @@ OWDevice_Define($$)
Log3 $name, 5, "$name: alerting: $alerting";
if( $init_done ) {
$hash->{fhem}{rand} = 0;
delete $modules{OWDevice}{NotifyFn};
OWDevice_InitValues($hash);
OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval}));
} else {
$hash->{fhem}{rand} = int(rand(20));
Log3 $name, 5, "$name: initial delay: $hash->{fhem}{rand}";
}
return undef;