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:
parent
1edb1ece2d
commit
351b24a59b
@ -1,6 +1,8 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
- SVN
|
- SVN
|
||||||
|
- change: integrated OWServer/OWDevice nonblocking and random start
|
||||||
|
time patches (justme1968 & Boris)
|
||||||
- feature: Add new module Dashboard
|
- feature: Add new module Dashboard
|
||||||
- feature: Add new module ONKYO_AVR
|
- feature: Add new module ONKYO_AVR
|
||||||
- feature: SYSSTAT: allow (remote) monitoring via snmp, support
|
- feature: SYSSTAT: allow (remote) monitoring via snmp, support
|
||||||
|
@ -251,6 +251,7 @@ OWServer_Read($@)
|
|||||||
if(AttrVal($hash->{NAME},"nonblocking",undef) && $init_done) {
|
if(AttrVal($hash->{NAME},"nonblocking",undef) && $init_done) {
|
||||||
$hash->{".path"}= $path;
|
$hash->{".path"}= $path;
|
||||||
pipe(READER,WRITER);
|
pipe(READER,WRITER);
|
||||||
|
#READER->autoflush(1);
|
||||||
WRITER->autoflush(1);
|
WRITER->autoflush(1);
|
||||||
|
|
||||||
my $pid= fork;
|
my $pid= fork;
|
||||||
@ -259,7 +260,7 @@ OWServer_Read($@)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalTimer(gettimeofday()+20, "OWServer_TimeoutChild", $pid, 0);
|
InternalTimer(gettimeofday()+10, "OWServer_TimeoutChild", $pid, 0);
|
||||||
if($pid == 0) {
|
if($pid == 0) {
|
||||||
close READER;
|
close READER;
|
||||||
$ret= OWNet::read($hash->{DEF},$path);
|
$ret= OWNet::read($hash->{DEF},$path);
|
||||||
@ -277,8 +278,21 @@ OWServer_Read($@)
|
|||||||
|
|
||||||
Log3 $hash, 5, "OWServer child ID for reading '$path' is $pid";
|
Log3 $hash, 5, "OWServer child ID for reading '$path' is $pid";
|
||||||
close WRITER;
|
close WRITER;
|
||||||
chomp($ret= <READER>);
|
# 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;
|
close READER;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$ret= $hash->{fhem}{owserver}->read($path);
|
$ret= $hash->{fhem}{owserver}->read($path);
|
||||||
$ret =~ s/^\s+//g if(defined($ret));
|
$ret =~ s/^\s+//g if(defined($ret));
|
||||||
|
@ -508,9 +508,10 @@ OWDevice_UpdateValues($) {
|
|||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
}
|
}
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
InternalTimer(int(gettimeofday())+$hash->{fhem}{interval}, "OWDevice_UpdateValues", $hash, 0)
|
# http://forum.fhem.de/index.php/topic,16945.0/topicseen.html#msg110673
|
||||||
if(defined($hash->{fhem}{interval}));
|
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";
|
Log3 $name, 5, "$name: alerting: $alerting";
|
||||||
|
|
||||||
if( $init_done ) {
|
if( $init_done ) {
|
||||||
|
$hash->{fhem}{rand} = 0;
|
||||||
delete $modules{OWDevice}{NotifyFn};
|
delete $modules{OWDevice}{NotifyFn};
|
||||||
OWDevice_InitValues($hash);
|
OWDevice_InitValues($hash);
|
||||||
OWDevice_UpdateValues($hash) if(defined($hash->{fhem}{interval}));
|
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;
|
return undef;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user