diff --git a/FHEM/66_ECMD.pm b/FHEM/66_ECMD.pm index 29fad51f5..99f1df36a 100644 --- a/FHEM/66_ECMD.pm +++ b/FHEM/66_ECMD.pm @@ -46,7 +46,7 @@ ECMD_Initialize($) $hash->{GetFn} = "ECMD_Get"; $hash->{SetFn} = "ECMD_Set"; $hash->{AttrFn} = "ECMD_Attr"; - $hash->{AttrList}= "classdefs loglevel:0,1,2,3,4,5"; + $hash->{AttrList}= "classdefs nonl loglevel:0,1,2,3,4,5"; } ##################################### @@ -422,9 +422,10 @@ ECMD_Get($@) if($cmd eq "raw") { return "get raw needs an argument" if(@a< 3); + my $nonl= AttrVal($name, "nonl", 0); my $ecmd= join " ", @args; Log 5, $ecmd; - ECMD_SimpleWrite($hash, $ecmd); + ECMD_SimpleWrite($hash, $ecmd, $nonl); ($err, $msg) = ECMD_ReadAnswer($hash, "raw"); return $err if($err); } else { @@ -496,7 +497,11 @@ ECMD_EvalClassDef($$$) Log 5, "$name: evaluating >$line<"; # split line into command and definition my ($cmd, $def)= split("[ \t]+", $line, 2); - if($cmd eq "params") { + if($cmd eq "nonl") { + Log 5, "$name: no newline"; + $hash->{fhem}{classDefs}{$classname}{nonl}= 1; + } + elsif($cmd eq "params") { Log 5, "$name: parameters are $def"; $hash->{fhem}{classDefs}{$classname}{params}= $def; } elsif($cmd eq "set" || $cmd eq "get") { @@ -618,9 +623,10 @@ ECMD_Write($$) my $answer; my @r; my @ecmds= split "\n", $msg; + my $nonl= AttrVal($hash->{NAME}, "nonl", 0); foreach my $ecmd (@ecmds) { Log 5, "$hash->{NAME} sending $ecmd"; - ECMD_SimpleWrite($hash, $ecmd); + ECMD_SimpleWrite($hash, $ecmd, $nonl); $answer= ECMD_ReadAnswer($hash, "$ecmd"); push @r, $answer; Log 5, $answer; @@ -727,6 +733,9 @@ ECMD_Write($$)
  • classdefs
    A colon-separated list of <classname>=<filename>. The list is automatically updated if a class definition is added. You can directly set the attribute.
  • +
  • nonl
    A newline (\n) is automatically appended to every command string sent to the device + unless this attribute is set. Please note that newlines (\n) in a command string are interpreted + as separators to split the command string into several commands and are never literally sent.


  • @@ -809,7 +818,7 @@ ECMD_Write($$) This is to avoid undesired side effects from e.g. doubling of semicolons.

    --> The rules outlined in the documentation of perl specials for the <perl command> in the postprocessor definitions apply. - Note: Beware of undesired side effects from e.g. doubling of semicolon! + Note: Beware of undesired side effects from e.g. doubling of semicolons! The perl command acts on $_. The result of the perl command is the final result of the get or set command. diff --git a/FHEM/67_ECMDDevice.pm b/FHEM/67_ECMDDevice.pm index f2c018621..36e119572 100644 --- a/FHEM/67_ECMDDevice.pm +++ b/FHEM/67_ECMDDevice.pm @@ -402,8 +402,19 @@ ECMDDevice_Define($$) The set command is evaluated as follows: %pinmask is replaced by 8 to yield "io set ddr 2 ff\nioset port 2 08\nwait 1000\nio set port 2 00" after macro substitution. Perl - evaluates this to a literal string which is send as a plain ethersex command to the AVR-NET-IO line by line. -
    + evaluates this to a literal string. This string is split into lines (without trailing newline characters) + + + + These lines are sent as a plain ethersex commands to the AVR-NET-IO one by one. Each line is terminated with + a newline character unless the nonl attribute of the ECMDDevice is set. After + each line the answer from the ECMDDevice is read back. They are concatenated with newlines and returned + for further processing, e.g. by the postproc command. For any of the four plain ethersex commands, the AVR-NET-IO returns the string OK. They are concatenated and separated by line breaks (\n). The postprocessor takes the result from $_, substitutes it by the string success if it is OK\nOK\nOK\nOK, and then either