mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +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->handshake('none');
|
||||
|
||||
$po->stty_icanon(0);
|
||||
$po->stty_parmrk(0);
|
||||
$po->stty_icrnl(0);
|
||||
|
||||
$hash->{PortObj} = $po;
|
||||
$hash->{FD} = $po->FILENO;
|
||||
$hash->{DeviceName} = $dev;
|
||||
|
50
fhem/fhem.pl
50
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($)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user