From 6514f45881c515b521a02d117a1b147f5472f11f Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 31 Mar 2007 06:28:08 +0000 Subject: [PATCH] CommandSet change, make , and - work at the same time git-svn-id: https://svn.fhem.de/fhem/trunk@42 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_FHZ.pm | 4 ++++ fhem/fhem.pl | 50 ++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/fhem/FHEM/00_FHZ.pm b/fhem/FHEM/00_FHZ.pm index 4fbe04008..74fd29a1e 100755 --- a/fhem/FHEM/00_FHZ.pm +++ b/fhem/FHEM/00_FHZ.pm @@ -223,6 +223,10 @@ FHZ_Define($$) $po->stopbits(1); $po->handshake('none'); + $po->stty_icanon(0); + $po->stty_parmrk(0); + $po->stty_icrnl(0); + $hash->{PortObj} = $po; $hash->{FD} = $po->FILENO; $hash->{DeviceName} = $dev; diff --git a/fhem/fhem.pl b/fhem/fhem.pl index b6a29ed3d..16954f488 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -60,6 +60,7 @@ sub TimeNow(); sub WriteStatefile(); sub XmlEscape($); sub fhem($); +sub fhz($); sub doGlobalDef($); sub CommandAttr($$); @@ -781,39 +782,30 @@ CommandSet($$) my $dev = $a[0]; my @rets; - if(defined($defs{$dev})) { + foreach my $sdev (split(",", $dev)) { - return DoSet(@a); - - } elsif($dev =~ m/,/) { # Enumeration (separated by ,) - - foreach my $sdev (split(",", $dev)) { - if(!defined($defs{$sdev})) { - push @rets, "Please define $sdev first"; - next; + if($sdev =~ m/-/) { # Range (separated by -) + my @lim = split("-", $sdev); + foreach my $sd (sort keys %defs) { + next if($sd lt $lim[0] || $sd gt $lim[1]); + $a[0] = $sd; + my $ret = DoSet(@a); + push @rets, $ret if($ret); } - $a[0] = $sdev; - my $ret = DoSet(@a); - push @rets, $ret if($ret); + next; } - return join("\n", @rets); - } elsif($dev =~ m/-/) { # Range (separated by -) - - my @lim = split("-", $dev); - foreach my $sdev (keys %defs) { - next if($sdev lt $lim[0] || $sdev gt $lim[1]); - $a[0] = $sdev; - my $ret = DoSet(@a); - push @rets, $ret if($ret); + if(!defined($defs{$sdev})) { + push @rets, "Please define $sdev first"; + next; } - return join("\n", @rets); - } else { - - return "Please define $dev first ($param)"; + $a[0] = $sdev; + my $ret = DoSet(@a); + push @rets, $ret if($ret); } + return join("\n", @rets); } @@ -1593,6 +1585,14 @@ fhem($) return AnalyzeCommandChain($global_cl, $param); } +# the "old" name, kept to make upgrade process easier +sub +fhz($) +{ + my $param = shift; + return AnalyzeCommandChain($global_cl, $param); +} + sub doGlobalDef($) {