From 5e0ef691c60d99733654b23fbc225a6e0433eff2 Mon Sep 17 00:00:00 2001 From: HomeAutoUser Date: Wed, 26 May 2021 21:30:08 +0200 Subject: [PATCH 1/2] PERL WARNING - Kopp Fix - https://github.com/RFD-FHEM/RFFHEM/issues/968 (#972) * Update SD_Protocols.pm * fix https://github.com/RFD-FHEM/RFFHEM/issues/968 * 02_ConvKoppFreeControl.t * added test with to short data * Anzahl geplanter tests korrigiert --- CHANGED | 3 +++ FHEM/lib/SD_Protocols.pm | 21 ++++++++++++++++----- controls_signalduino.txt | 2 +- t/SD_Protocols/02_ConvKoppFreeControl.t | 14 +++++++++++++- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/CHANGED b/CHANGED index af5e96233..8c0725d5a 100644 --- a/CHANGED +++ b/CHANGED @@ -1,3 +1,6 @@ +2021-05-25 - Update SD_Protocols.pm + + * fix https://github.com/RFD-FHEM/RFFHEM/issues/968 2021-05-23 - new protocol 110 for ADE WS1907 Weather station (#970) * new protocol 110 for ADE WS1907 Weather station diff --git a/FHEM/lib/SD_Protocols.pm b/FHEM/lib/SD_Protocols.pm index 27eabe429..77bc2ede5 100644 --- a/FHEM/lib/SD_Protocols.pm +++ b/FHEM/lib/SD_Protocols.pm @@ -1,10 +1,10 @@ ################################################################################ # # The file is part of the SIGNALduino project -# v3.5.x - https://github.com/RFD-FHEM/RFFHEM/tree/dev-r35-xFSK +# v3.5.x - https://github.com/RFD-FHEM/RFFHEM # # 2016-2019 S.Butzek, Ralf9 -# 2019-2020 S.Butzek, HomeAutoUser, elektron-bbs +# 2019-2021 S.Butzek, HomeAutoUser, elektron-bbs # ################################################################################ package lib::SD_Protocols; @@ -13,7 +13,7 @@ use strict; use warnings; use Carp qw(croak carp); use Digest::CRC; -our $VERSION = '2.03'; +our $VERSION = '2.04'; use Storable qw(dclone); use Scalar::Util qw(blessed); @@ -1810,19 +1810,30 @@ sub ConvKoppFreeControl { my $self = shift // carp 'Not called within an object'; my $hexData = shift // croak 'Error: called without $hexdata as input'; + # kr07C2AD1A30CC0F0328 + # || |||| || ++-------- Transmitter Code 2 + # || |||| ++-------------- Keycode + # || ++++------------------ Transmitter Code 1 + # ++------------------------ kr wird von der culfw bei Empfang einer Kopp Botschaft als Kennung gesendet + # + # right rawMSG MN;D=07FA5E1721CC0F02FE000000000000; + # wrong rawMSG MN;D=0A018200CA043A90; + return ( 1, 'ConvKoppFreeControl, Usage: Input #1, $hexData needs to be at least 4 chars long' ) if ( length($hexData) < 4 ); # check double, in def length_min set my $anz = hex( substr( $hexData, 0, 2 ) ) + 1; + + return ( 1, 'ConvKoppFreeControl, hexData is to short' ) + if ( length($hexData) < $anz * 2 ); # check double, in def length_min set + my $blkck = 0xAA; for my $i ( 0 .. $anz - 1 ) { my $d = hex( substr( $hexData, $i * 2, 2 ) ); $blkck ^= $d; } - return ( 1, 'ConvKoppFreeControl, hexData is to short' ) - if ( length($hexData) < $anz * 2 ); # check double, in def length_min set my $checksum = hex( substr( $hexData, $anz * 2, 2 ) ); diff --git a/controls_signalduino.txt b/controls_signalduino.txt index 49df58872..1415dfb1e 100644 --- a/controls_signalduino.txt +++ b/controls_signalduino.txt @@ -15,4 +15,4 @@ UPD 2020-04-13_23:15:56 14325 FHEM/14_SD_WS_Maverick.pm UPD 2018-07-04_21:56:16 37910 FHEM/41_OREGON.pm UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm UPD 2021-05-23_09:43:59 208284 FHEM/lib/SD_ProtocolData.pm -UPD 2021-04-25_23:13:29 69564 FHEM/lib/SD_Protocols.pm +UPD 2021-05-25_13:14:26 69920 FHEM/lib/SD_Protocols.pm diff --git a/t/SD_Protocols/02_ConvKoppFreeControl.t b/t/SD_Protocols/02_ConvKoppFreeControl.t index 2a3c6083d..6543f3e0a 100644 --- a/t/SD_Protocols/02_ConvKoppFreeControl.t +++ b/t/SD_Protocols/02_ConvKoppFreeControl.t @@ -7,7 +7,7 @@ use Test2::V0; use lib::SD_Protocols qw(:ALL); use Test2::Tools::Compare qw{is like}; -plan(2); +plan(3); my $Protocols = new lib::SD_Protocols( filetype => 'json', filename => './t/SD_Protocols/test_protocolData.json' ); @@ -34,3 +34,15 @@ subtest 'test ConvKoppFreeControl, checksum wrong' => sub { like($ret[1],qr/!= checksum/,'check error message'); } }; + + +subtest 'test ConvKoppFreeControl, message to short' => sub { + plan(1); + subtest 'msg MN;D=0A018200CA043A90;R=204; (ID 102)' => sub { + plan(2); + my $hexMsg='0A018200CA043A90'; + my @ret=$Protocols->ConvKoppFreeControl($hexMsg) ; + is($#ret,1, 'ConvKoppFreeControl reported some error'); + like($ret[1],qr/to\sshort/,'check error message'); + } +}; From e7c792e9782c0d4c19b214811a80e2620f30b607 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 26 May 2021 19:30:25 +0000 Subject: [PATCH 2/2] Automatic updated controls and CHANGED --- CHANGED | 8 ++++++++ controls_signalduino.txt | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGED b/CHANGED index 8c0725d5a..9d8def240 100644 --- a/CHANGED +++ b/CHANGED @@ -1,3 +1,11 @@ +2021-05-26 - PERL WARNING - Kopp Fix - https://github.com/RFD-FHEM/RFFHEM/issues/968 (#972) + +* Update SD_Protocols.pm + * fix https://github.com/RFD-FHEM/RFFHEM/issues/968 + +* 02_ConvKoppFreeControl.t + * added test with to short data + * Anzahl geplanter tests korrigiert 2021-05-25 - Update SD_Protocols.pm * fix https://github.com/RFD-FHEM/RFFHEM/issues/968 diff --git a/controls_signalduino.txt b/controls_signalduino.txt index 1415dfb1e..40a1725d0 100644 --- a/controls_signalduino.txt +++ b/controls_signalduino.txt @@ -15,4 +15,4 @@ UPD 2020-04-13_23:15:56 14325 FHEM/14_SD_WS_Maverick.pm UPD 2018-07-04_21:56:16 37910 FHEM/41_OREGON.pm UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm UPD 2021-05-23_09:43:59 208284 FHEM/lib/SD_ProtocolData.pm -UPD 2021-05-25_13:14:26 69920 FHEM/lib/SD_Protocols.pm +UPD 2021-05-26_21:30:08 69920 FHEM/lib/SD_Protocols.pm