mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 12:46:03 +00:00
16_STACKABLE_CC.pm: add TCM option (Forum #60028)
git-svn-id: https://svn.fhem.de/fhem/trunk@12515 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
27060b0478
commit
01df83ad64
@ -26,6 +26,10 @@ STACKABLE_CC_Initialize($)
|
||||
$hash->{DelPrefix} = "STACKABLE_CC_DelPrefix";
|
||||
$hash->{noRawInform} = 1; # Our message was already sent as raw.
|
||||
$hash->{noAutocreatedFilelog} = 1;
|
||||
|
||||
$hash->{IOOpenFn} = "STACKABLE_IOOpenFn";
|
||||
$hash->{IOReadFn} = "STACKABLE_IOReadFn";
|
||||
$hash->{IOWriteFn} = "STACKABLE_IOWriteFn";
|
||||
}
|
||||
|
||||
#####################################
|
||||
@ -35,7 +39,9 @@ STACKABLE_CC_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
return "wrong syntax: define <name> STACKABLE_CC [CUL|SCC]"
|
||||
$hash->{TCM} = pop @a if(int(@a) == 4 && $a[3] eq "TCM");
|
||||
|
||||
return "wrong syntax: define <name> STACKABLE_CC [CUL|SCC] [TCM]"
|
||||
if(int(@a) != 3);
|
||||
|
||||
my $io = $defs{$a[2]};
|
||||
@ -48,15 +54,19 @@ STACKABLE_CC_Define($$)
|
||||
$io->{STACKED} = $hash->{NAME};
|
||||
$hash->{IODev} = $io;
|
||||
delete($io->{".clientArray"}); # Force a recompute
|
||||
|
||||
if(!$hash->{TCM}) {
|
||||
$hash->{initString} = $io->{initString};
|
||||
$hash->{CMDS} = "";
|
||||
$hash->{Clients} = $io->{Clients};
|
||||
$hash->{MatchList} = $io->{MatchList};
|
||||
CUL_DoInit($hash);
|
||||
}
|
||||
|
||||
$hash->{StackLevel} = $io->{StackLevel} ? $io->{StackLevel}+1 : 1;
|
||||
$hash->{STATE} = "Defined";
|
||||
|
||||
notifyRegexpChanged($hash, $a[2]);
|
||||
CUL_DoInit($hash);
|
||||
|
||||
return undef;
|
||||
}
|
||||
@ -123,7 +133,7 @@ STACKABLE_CC_Parse($$)
|
||||
}
|
||||
|
||||
sub
|
||||
STACKABLE_CC_DelPrefix($)
|
||||
STACKABLE_CC_DelPrefix($$)
|
||||
{
|
||||
my ($hash, $msg) = @_;
|
||||
$msg =~ s/^.//;
|
||||
@ -146,6 +156,36 @@ STACKABLE_CC_Undef($$)
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub
|
||||
STACKABLE_IOOpenFn($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
$hash->{FD} = $hash->{IODev}{IODev}{FD}; # Lets fool the TCM
|
||||
$hash->{IOReadFn} = "STACKABLE_IOReadFn";
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub
|
||||
STACKABLE_IOReadFn($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my $me = $hash->{IODev};
|
||||
my $buf = "";
|
||||
while($buf !~ m/\n/) {
|
||||
$buf .= DevIo_SimpleRead($me->{IODev}); # may block
|
||||
}
|
||||
$buf =~ s/[\r\n]//g;
|
||||
$buf = STACKABLE_CC_DelPrefix($me, $buf);
|
||||
return pack("H*",$buf);
|
||||
}
|
||||
|
||||
sub
|
||||
STACKABLE_IOWriteFn($$)
|
||||
{
|
||||
my ($hash, $msg) = @_;
|
||||
return IOWrite($hash, "", unpack("H*",$msg));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
@ -39,9 +39,15 @@ DevIo_DoSimpleRead($)
|
||||
$buf = "" if(!defined($res));
|
||||
|
||||
} elsif($hash->{IODev}) {
|
||||
|
||||
if($hash->{IOReadFn}) {
|
||||
$buf = CallFn($hash->{IODev}{NAME},"IOReadFn",$hash);
|
||||
|
||||
} else {
|
||||
$buf = $hash->{IODevRxBuffer};
|
||||
$hash->{IODevRxBuffer} = "";
|
||||
$buf = "" if(!defined($buf));
|
||||
}
|
||||
|
||||
}
|
||||
return $buf;
|
||||
|
Loading…
x
Reference in New Issue
Block a user