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

sub SIGNALduino_CheckccConfResponse - is more robust #1015 #1031

Merged
merged 10 commits into from
Nov 4, 2021
9 changes: 7 additions & 2 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 00_SIGNALduino.pm v3.5.2 2021-08-29 21:54:48Z elektron-bbs $
# $Id: 00_SIGNALduino.pm v3.5.2 2021-11-02 09:46:17Z HomeAutoUser $
#
# v3.5.2 - https://github.com/RFD-FHEM/RFFHEM/tree/master
# The module is inspired by the FHEMduino project and modified in serval ways for processing the incoming messages
Expand Down Expand Up @@ -39,7 +39,7 @@ use List::Util qw(first);


use constant {
SDUINO_VERSION => '3.5.2+20210829', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_VERSION => '3.5.2+20211102', # Datum wird automatisch bei jedem pull request aktualisiert
SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device
SDUINO_INIT_WAIT => 2,
SDUINO_INIT_MAXRETRY => 3,
Expand Down Expand Up @@ -1174,6 +1174,11 @@ sub SIGNALduino_CheckCmdsResponse {
sub SIGNALduino_CheckccConfResponse {
my (undef,$str) = split('=', $_[1]);
my $var;

# https://github.com/RFD-FHEM/RFFHEM/issues/1015 | value can arise due to an incorrect transmission from serial
# $str = "216%E857C43023B900070018146C040091";
return ('invalid value from uC. Only hexadecimal values are allowed. Please query again.',undef) if($str !~ /^[A-F0-9a-f]+$/);

my %r = ( '0D'=>1,'0E'=>1,'0F'=>1,'10'=>1,'11'=>1,'12'=>1,'1B'=>1,'1D'=>1, '15'=>1);
foreach my $a (sort keys %r) {
$var = substr($str,(hex($a)-13)*2, 2);
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-08-30_16:54:51 229349 FHEM/00_SIGNALduino.pm
UPD 2021-11-01_22:21:50 229643 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 2021-08-11_21:38:30 10096 FHEM/14_BresserTemeo.pm
Expand Down
11 changes: 10 additions & 1 deletion t/FHEM/00_SIGNALduino/02_SIGNALduino_CheckccConfResponse.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Test2::Tools::Compare qw{ is };
our %defs;

InternalTimer(time(), sub {
plan(2);
plan(3);

subtest 'Test cconf response ASK/OOK (C0Dn11=10B07157C43023B900070018146C070091)' => sub {
plan(3);
Expand All @@ -31,6 +31,15 @@ InternalTimer(time(), sub {
is(ReadingsVal($target,"cc1101_config_ext",undef),"Modulation: 2-FSK, Syncmod: 16/16 sync word bits detected, Deviation: 57.13 kHz");
};

subtest 'Test cconf response wrong value (C0Dn11=216%E857C43023B900070018146C040091)' => sub {
plan(1);
my $target='dummyDuino';
my $targetHash = $defs{$target};

my ($ret)=SIGNALduino_CheckccConfResponse($targetHash,"C0Dn11=216%E857C43023B900070018146C040091");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Würde ich sicherheitshalber in einfache quotes packen.

is($ret,'invalid value from uC. Only hexadecimal values are allowed. Please query again.','check return message');
};

exit(0);
}, 0);

Expand Down