mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
36_EleroStick.pm: added delay attribute for the send queue
git-svn-id: https://svn.fhem.de/fhem/trunk@11797 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b6ecb52c78
commit
ee96320475
@ -43,6 +43,7 @@ sub EleroStick_Initialize($) {
|
|||||||
"MatchList " .
|
"MatchList " .
|
||||||
"ChannelTimeout " .
|
"ChannelTimeout " .
|
||||||
"Interval " .
|
"Interval " .
|
||||||
|
"Delay " .
|
||||||
"$readingFnAttributes ";
|
"$readingFnAttributes ";
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -57,12 +58,15 @@ sub EleroStick_Enqueue($$) {
|
|||||||
my ($hash, $data) = @_;
|
my ($hash, $data) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
# EleroStick_SimpleWrite($hash, $data);
|
|
||||||
|
|
||||||
if(!$hash->{QUEUE}) {
|
if(!$hash->{QUEUE}) {
|
||||||
$hash->{QUEUE} = [$data];
|
$hash->{QUEUE} = [""];
|
||||||
###debugLog($name, "QUEUE created with: $data");
|
###debugLog($name, "QUEUE created with: $data");
|
||||||
EleroStick_StartQueueTimer($hash);
|
|
||||||
|
EleroStick_SimpleWrite($hash, $data);
|
||||||
|
my $timerName = $name . "#QueueTimer";
|
||||||
|
my $interval = 0.1;
|
||||||
|
InternalTimer(gettimeofday() + $interval, "EleroStick_OnQueueTimer", $timerName, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push(@{$hash->{QUEUE}}, $data);
|
push(@{$hash->{QUEUE}}, $data);
|
||||||
@ -76,15 +80,15 @@ sub EleroStick_StartQueueTimer($) {
|
|||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $timerName = $name . "#QueueTimer";
|
my $timerName = $name . "#QueueTimer";
|
||||||
|
my $interval = AttrVal($name, "Delay", 0.5);
|
||||||
my $interval = 0.5;
|
|
||||||
|
|
||||||
InternalTimer(gettimeofday() + $interval, "EleroStick_OnQueueTimer", $timerName, 0);
|
InternalTimer(gettimeofday() + $interval, "EleroStick_OnQueueTimer", $timerName, 0);
|
||||||
|
|
||||||
###debugLog($name, "Timer started: $timerName");
|
####debugLog($name, "Timer started: $timerName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=======================================================================================
|
#=======================================================================================
|
||||||
sub EleroStick_OnQueueTimer($) {
|
sub EleroStick_OnQueueTimer($) {
|
||||||
my ($timerName) = @_;
|
my ($timerName) = @_;
|
||||||
@ -345,7 +349,6 @@ sub EleroStick_Read($) {
|
|||||||
$hash->{buffer} .= $answer;
|
$hash->{buffer} .= $answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#todo: hier gibts manchmal Fehlermeldung $strLen nicht definiert
|
|
||||||
my $strLen = substr($hash->{buffer},3-1,2);
|
my $strLen = substr($hash->{buffer},3-1,2);
|
||||||
$strLen = hex($strLen);
|
$strLen = hex($strLen);
|
||||||
my $calLen = ($strLen * 2) + 4;
|
my $calLen = ($strLen * 2) + 4;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user