mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
CommandSet change, make , and - work at the same time
git-svn-id: https://svn.fhem.de/fhem/trunk@42 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e10f9cb1e9
commit
6514f45881
@ -223,6 +223,10 @@ FHZ_Define($$)
|
|||||||
$po->stopbits(1);
|
$po->stopbits(1);
|
||||||
$po->handshake('none');
|
$po->handshake('none');
|
||||||
|
|
||||||
|
$po->stty_icanon(0);
|
||||||
|
$po->stty_parmrk(0);
|
||||||
|
$po->stty_icrnl(0);
|
||||||
|
|
||||||
$hash->{PortObj} = $po;
|
$hash->{PortObj} = $po;
|
||||||
$hash->{FD} = $po->FILENO;
|
$hash->{FD} = $po->FILENO;
|
||||||
$hash->{DeviceName} = $dev;
|
$hash->{DeviceName} = $dev;
|
||||||
|
46
fhem/fhem.pl
46
fhem/fhem.pl
@ -60,6 +60,7 @@ sub TimeNow();
|
|||||||
sub WriteStatefile();
|
sub WriteStatefile();
|
||||||
sub XmlEscape($);
|
sub XmlEscape($);
|
||||||
sub fhem($);
|
sub fhem($);
|
||||||
|
sub fhz($);
|
||||||
sub doGlobalDef($);
|
sub doGlobalDef($);
|
||||||
|
|
||||||
sub CommandAttr($$);
|
sub CommandAttr($$);
|
||||||
@ -781,39 +782,30 @@ CommandSet($$)
|
|||||||
my $dev = $a[0];
|
my $dev = $a[0];
|
||||||
my @rets;
|
my @rets;
|
||||||
|
|
||||||
if(defined($defs{$dev})) {
|
|
||||||
|
|
||||||
return DoSet(@a);
|
|
||||||
|
|
||||||
} elsif($dev =~ m/,/) { # Enumeration (separated by ,)
|
|
||||||
|
|
||||||
foreach my $sdev (split(",", $dev)) {
|
foreach my $sdev (split(",", $dev)) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
if(!defined($defs{$sdev})) {
|
if(!defined($defs{$sdev})) {
|
||||||
push @rets, "Please define $sdev first";
|
push @rets, "Please define $sdev first";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a[0] = $sdev;
|
$a[0] = $sdev;
|
||||||
my $ret = DoSet(@a);
|
my $ret = DoSet(@a);
|
||||||
push @rets, $ret if($ret);
|
push @rets, $ret if($ret);
|
||||||
|
|
||||||
}
|
}
|
||||||
return join("\n", @rets);
|
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);
|
|
||||||
}
|
|
||||||
return join("\n", @rets);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return "Please define $dev first ($param)";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1593,6 +1585,14 @@ fhem($)
|
|||||||
return AnalyzeCommandChain($global_cl, $param);
|
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
|
sub
|
||||||
doGlobalDef($)
|
doGlobalDef($)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user