Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Multiple Send delay #941

Merged
merged 34 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d49a1f0
Multiple set commands are not processed
sidey79 Jan 4, 2021
0b2e913
Automatic updated controls and CHANGED
actions-user Jan 5, 2021
57744d1
Update 00_SIGNALduino.pm
sidey79 Jan 5, 2021
d7374c0
Automatic updated controls and CHANGED
actions-user Jan 5, 2021
88ec37a
Multiple set commands are not processed
sidey79 Jan 9, 2021
b98ec05
Merge branch 'sidey79/issue823' of ssh://github.com/RFD-FHEM/RFFHEM i…
sidey79 Jan 9, 2021
b5a852b
Automatic updated controls and CHANGED
actions-user Jan 9, 2021
7632096
Updated version
sidey79 Jan 9, 2021
8629ecf
Automatic updated controls and CHANGED
actions-user Jan 9, 2021
e5e21b9
Try to reduce delay between 2. and 3. transmission
sidey79 Jan 17, 2021
fbf8c2b
Merge branch 'sidey79/issue823' of ssh://github.com/RFD-FHEM/RFFHEM i…
sidey79 Jan 17, 2021
47497c8
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
8f72199
Avoid timeout after response 2. send, do not delte $hash->{ucCmd} bec…
sidey79 Jan 17, 2021
ecb16a3
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
3908a7e
Avoid timeout after response 2. send, do not delte $hash->{ucCmd} bec…
sidey79 Jan 17, 2021
d2d086c
Merge branch 'sidey79/issue823' of ssh://github.com/RFD-FHEM/RFFHEM i…
sidey79 Jan 17, 2021
3d68973
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
1615c5c
Avoid timeout after response 2. send, do not delte $hash->{ucCmd} bec…
sidey79 Jan 17, 2021
c5182e4
Merge branch 'sidey79/issue823' of ssh://github.com/RFD-FHEM/RFFHEM i…
sidey79 Jan 17, 2021
a33c76f
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
7ad4566
Check if hashref exists to avoid warning
sidey79 Jan 17, 2021
960d8a6
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
d0a9ee7
Updated version string
sidey79 Jan 17, 2021
9969922
Automatic updated controls and CHANGED
actions-user Jan 17, 2021
d2bb44c
Multiple set commands are not processed
sidey79 Mar 5, 2021
576c6c5
Automatic updated controls and CHANGED
actions-user Mar 5, 2021
291a244
Updated test
sidey79 Mar 6, 2021
a20cbbb
Multiple set commands are not processed
sidey79 Mar 6, 2021
bd4770d
Merge branch 'master' into sidey79/issue823
sidey79 Jun 3, 2021
f922d5d
Automatic updated controls and CHANGED
actions-user Jun 3, 2021
e2b341c
Merge branch 'master' into sidey79/issue823
sidey79 Jun 5, 2021
c37b17d
Merge branch 'master' into sidey79/issue823
sidey79 Jun 7, 2021
d7a72d3
00_SIGNALduino.pm
sidey79 Jun 7, 2021
9f6c72b
Automatic updated controls and CHANGED
actions-user Jun 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2021-06-07 - 00_SIGNALduino.pm

Version updated to current date
2021-06-07 - Update doc - SD_ProtocolData.pm (#975)

* Update SD_ProtocolData.pm
Expand Down
20 changes: 13 additions & 7 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use List::Util qw(first);


use constant {
SDUINO_VERSION => '3.5.1+20210525',
SDUINO_VERSION => '3.5.2+20210607',
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
Expand Down Expand Up @@ -1264,10 +1264,14 @@ sub SIGNALduino_CheckSendRawResponse {
my $name=$hash->{NAME};
# zu testen der sendeQueue, kann wenn es funktioniert auf verbose 5
$hash->{logMethod}->($name, 4, "$name: CheckSendrawResponse, sendraw answer: $msg");
#RemoveInternalTimer("HandleWriteQueue:$name");
delete($hash->{ucCmd});
#SIGNALduino_HandleWriteQueue("x:$name"); # Todo #823 on github
InternalTimer(gettimeofday() + 0.1, \&SIGNALduino_HandleWriteQueue, "HandleWriteQueue:$name") if (scalar @{$hash->{QUEUE}} > 0 && InternalVal($name,'sendworking',0) == 0);
if ($msg =~ /D=[A-Za-z0-9]+;/ )
{
RemoveInternalTimer("HandleWriteQueue:$name");
SIGNALduino_HandleWriteQueue("x:$name"); # Todo #823 on github
} else {
InternalTimer(gettimeofday() , \&SIGNALduino_HandleWriteQueue, "HandleWriteQueue:$name") if (scalar @{$hash->{QUEUE}} > 0 && InternalVal($name,'sendworking',0) == 0);
}
}
return (undef);
}
Expand Down Expand Up @@ -1620,7 +1624,7 @@ sub SIGNALduino_AddSendQueue {
#SIGNALduino_Log3 $hash , 5, Dumper($hash->{QUEUE});

$hash->{logMethod}->($hash, 5,"$name: AddSendQueue, " . $hash->{NAME} . ": $msg (" . @{$hash->{QUEUE}} . ')');
InternalTimer(gettimeofday() + 0.1, \&SIGNALduino_HandleWriteQueue, "HandleWriteQueue:$name") if (scalar @{$hash->{QUEUE}} == 1 && InternalVal($name,'sendworking',0) == 0);
InternalTimer(gettimeofday(), \&SIGNALduino_HandleWriteQueue, "HandleWriteQueue:$name") if (scalar @{$hash->{QUEUE}} == 1 && InternalVal($name,'sendworking',0) == 0);
}

############################# package main, test exists
Expand Down Expand Up @@ -1810,9 +1814,11 @@ sub SIGNALduino_Read {
$hash->{logMethod}->($name, 5, "$name: Read, try asyncOutput of message $returnMessage");
my $ao = undef;
$ao = asyncOutput( $hash->{ucCmd}->{asyncOut}, $hash->{ucCmd}->{cmd}.': ' . $returnMessage ) if (defined($returnMessage));
$hash->{logMethod}->($name, 5, "$name: Read, asyncOutput failed $ao") if (defined($ao));
$hash->{logMethod}->($name, 5, "$name: Read, asyncOutput failed $ao") if (defined($ao));
}
if ( exists $hash->{ucCmd} && defined $hash->{ucCmd}->{cmd} && $hash->{ucCmd}->{cmd} ne "sendraw" ) {
delete $hash->{ucCmd} ;
}
delete($hash->{ucCmd});
}

if (exists($hash->{keepalive})) {
Expand Down
2 changes: 1 addition & 1 deletion controls_signalduino.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UPD 2021-05-28_16:17:04 222865 FHEM/00_SIGNALduino.pm
UPD 2021-06-07_22:53:27 223048 FHEM/00_SIGNALduino.pm
UPD 2020-06-15_17:41:39 17876 FHEM/10_FS10.pm
UPD 2020-05-26_11:51:12 20465 FHEM/10_SD_GT.pm
UPD 2016-09-18_21:22:06 10111 FHEM/14_BresserTemeo.pm
Expand Down
62 changes: 44 additions & 18 deletions t/FHEM/00_SIGNALduino/01_SIGNALduino_CheckSendRawResponse.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ use warnings;

use Test2::V0;
use Test2::Tools::Compare qw{is field U D match hash bag };
use Mock::Sub;
use Test2::Todo;

our %defs;

my $mock;
my $InternalTimer;

BEGIN {
$mock = Mock::Sub->new;
};

InternalTimer(time()+1, sub() {
my $targetHash = $defs{dummyDuino};
Expand All @@ -23,22 +17,32 @@ InternalTimer(time()+1, sub() {
'SM;',
'SN;',
);
$InternalTimer = $mock->mock('InternalTimer');

my $mock;

$mock = Test2::Mock->new(
track => 1,
class => 'main'
);
$mock->override( 'InternalTimer' => sub { } ) ;
$mock->override('RemoveInternalTimer' => sub { } ) ;
$mock->override('SIGNALduino_HandleWriteQueue' => sub { } ) ;

my $tracking = $mock->sub_tracking();

for my $respMsg (@respMsgs) {
$targetHash->{ucCmd} = "something";
$InternalTimer->reset;
$mock->clear_sub_tracking();

$targetHash->{ucCmd} = "something";
subtest qq[verify accept "$respMsg"] => sub {

subtest qq[sendworking=0, QUEUE = 0] => sub {
plan (2);
@{$targetHash->{QUEUE}} = ();
@{$targetHash->{QUEUE}} = ();
$targetHash->{sendworking} = 0;
SIGNALduino_CheckSendRawResponse($targetHash,$respMsg);

is($targetHash->{ucCmd},U,'Verify ucCmd deleted');
is($InternalTimer->called,0,'Verify internalTimer called');
is(scalar @{$tracking->{InternalTimer}},0,'Verify InternalTimer is not called');
};

subtest qq[sendworking=0, QUEUE = 1] => sub {
Expand All @@ -47,7 +51,7 @@ InternalTimer(time()+1, sub() {
SIGNALduino_CheckSendRawResponse($targetHash,$respMsg);

is($targetHash->{ucCmd},U,'Verify ucCmd deleted');
is($InternalTimer->called,1,'Verify internalTimer called');
is(scalar @{$tracking->{InternalTimer}},1,'Verify InternalTimer is called');
};

subtest qq[sendworking=1, QUEUE = 1] => sub {
Expand All @@ -56,13 +60,35 @@ InternalTimer(time()+1, sub() {
SIGNALduino_CheckSendRawResponse($targetHash,$respMsg);

is($targetHash->{ucCmd},U,'Verify ucCmd deleted');
is($InternalTimer->called,1,'Verify internalTimer is not called once more');
is(scalar @{$tracking->{InternalTimer}},1,'Verify InternalTimer is not called');

};
};

};

$InternalTimer->unmock;

for my $respMsg (qw /SR;D=AD0; /) {

subtest qq[verify accept "$respMsg" sendworking=0, QUEUE = 0] => sub {
$mock->clear_sub_tracking();
plan (4);


@{$targetHash->{QUEUE}} = ();
$targetHash->{sendworking} = 0;
SIGNALduino_CheckSendRawResponse($targetHash,'SR;D=AD0;');

is($targetHash->{ucCmd},U,'Verify ucCmd deleted');
is(scalar @{$tracking->{RemoveInternalTimer}},1,'Verify RemoveInternalTimer called');
is(scalar @{$tracking->{SIGNALduino_HandleWriteQueue}},1,'Verify SIGNALduino_HandleWriteQueue called');
is(scalar @{$tracking->{InternalTimer}},0,'Verify InternalTimer is not called');

$mock->restore('RemoveInternalTimer');
$mock->restore('SIGNALduino_HandleWriteQueue');
$mock->restore('InternalTimer');
}; }

$mock->reset_all;
done_testing();
exit(0);

Expand Down