2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

66_ECMD: new attribute autoReopen

git-svn-id: https://svn.fhem.de/fhem/trunk@13257 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2017-01-28 15:43:00 +00:00
parent 09cbc27d01
commit 9b077abce7
2 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,6 @@
# 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 ins - feature: 66_ECMD: new attribute autoReopen
- feature: 66_ECMD: new attribute autoReopen
- bugfix: 98_DOIFtools.pm: fixed bug from last change
- update: 98_DOIFtools.pm: some code rework
- update: 98_DOIFtools.pm: dynamic column width in report

View File

@ -86,7 +86,7 @@ ECMD_Initialize($)
$hash->{GetFn} = "ECMD_Get";
$hash->{SetFn} = "ECMD_Set";
$hash->{AttrFn} = "ECMD_Attr";
$hash->{AttrList}= "classdefs split logTraffic:0,1,2,3,4,5 timeout partial requestSeparator responseSeparator";
$hash->{AttrList}= "classdefs split logTraffic:0,1,2,3,4,5 timeout partial requestSeparator responseSeparator autoReopen";
}
#####################################
@ -623,6 +623,19 @@ ECMD_Write($$$)
{
my ($hash,$msg,$expect) = @_;
my $name= $hash->{NAME};
my $lastWrite= defined($hash->{fhem}{".lastWrite"}) ? $hash->{fhem}{".lastWrite"} : 0;
my $now= gettimeofday();
my $autoReopen= AttrVal($name, "autoReopen", undef);
if(defined($autoReopen)) {
my ($timeout,$delay)= split(',',$autoReopen);
ECMD_Reopen($hash) if($now>$lastWrite+$timeout);
sleep($delay);
}
$hash->{fhem}{".lastWrite"}= $now;
my $answer;
my $ret= "";
my $requestSeparator= $hash->{fhem}{".requestSeparator"};
@ -802,6 +815,10 @@ ECMD_Write($$$)
The response separator is only appended to commands split by means of a
request separator. The default is to have no response separator, i.e. responses are simply concatenated. Use a response separator that does not occur in the actual response.
</li>
<li>autoReopen &lt;timeout&gt;,&lt;delay&gt;<br>
If this attribute is set, the device is automatically reopened if no bytes were written for &lt;timeout&gt seconds or more. After reopening
FHEM waits &lt;delay&gt; seconds before writing to the device. Use the delay with care because it stalls FHEM completely.
</li>
<li><a href="#verbose">verbose</a></li>
</ul>
<br><br>