2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

66_ECMD: new attribute stop

git-svn-id: https://svn.fhem.de/fhem/trunk@16372 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2018-03-10 13:09:24 +00:00
parent c68982e31b
commit daab52dd85
2 changed files with 317 additions and 294 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.
- feature: 66_ECMD: new attribute stop
- change: 93_DbLog: V3.8.9, commandref revised
- feature: fhem.pl: OldReading* added (Forum #85406)
- feature: 93_DbRep: V7.14.3, minTimestamp - get lowest timestamp in database
@ -3974,4 +3975,3 @@
- 2005-10-27 (1.3)
- Bugfix: multiple at commands at the same time.

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 autoReopen";
$hash->{AttrList}= "classdefs split logTraffic:0,1,2,3,4,5 timeout partial requestSeparator responseSeparator autoReopen stop:0,1";
}
#####################################
@ -218,12 +218,21 @@ ECMD_Ready($)
return ($InBytes && $InBytes>0);
}
#####################################
sub
ECMD_isStopped($)
{
my $dev = shift; # name or hash
$dev = $dev->{NAME} if(defined($dev) && ref($dev) eq "HASH");
my $isDisabled = AttrVal($dev, "stop", 0);
}
#####################################
sub
ECMD_SimpleRead($)
{
my $hash = shift;
return undef if ECMD_isStopped($hash);
my $answer= DevIo_SimpleRead($hash);
ECMD_Log $hash, undef, "read " . dq($answer);
return $answer;
@ -233,6 +242,7 @@ sub
ECMD_SimpleWrite($$)
{
my ($hash, $msg) = @_;
return undef if ECMD_isStopped($hash);
ECMD_Log $hash, undef, "write " . dq($msg);
DevIo_SimpleWrite($hash, $msg, 0);
}
@ -243,6 +253,8 @@ ECMD_SimpleExpect($$$)
my ($hash, $msg, $expect) = @_;
my $name= $hash->{NAME};
return undef if ECMD_isStopped($name);
my $timeout= AttrVal($name, "timeout", 3.0);
my $partialTimeout= AttrVal($name, "partial", 0.0);
@ -293,6 +305,7 @@ sub
ECMD_Clear($)
{
my $hash = shift;
return undef if ECMD_isStopped($hash);
# Clear the pipe
DevIo_TimeoutRead($hash, 0.1);
@ -318,9 +331,14 @@ ECMD_Get($@)
return "get raw needs an argument" if(@a< 3);
my $ecmd= join " ", @args;
$ecmd= AnalyzePerlCommand(undef, $ecmd);
$answer= ECMD_SimpleExpect($hash, $ecmd, ".*");
# poor man's error catching...
if($ecmd =~ "^Bareword \"") {
$answer= $ecmd;
} else {
$answer= ECMD_SimpleExpect($hash, $ecmd, ".*");
}
} else {
return "get $cmd: unknown command ";
return "Unknown argument $cmd, choose one of raw";
}
$hash->{READINGS}{$cmd}{VAL} = $answer;
@ -571,6 +589,7 @@ sub
ECMD_Reopen($)
{
my ($hash) = @_;
return undef if ECMD_isStopped($hash);
DevIo_CloseDev($hash);
DevIo_OpenDev($hash, 1, undef);
@ -819,6 +838,10 @@ ECMD_Write($$$)
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>stop<br>
Disables read/write access to the device if set to 1. No data is written to the physical ECMD device. A read request always returns an undefined result.
This attribute can be used to temporarily disable a device that is not available.
</li>
<li><a href="#verbose">verbose</a></li>
</ul>
<br><br>