Skip to content

Commit

Permalink
Merge branch 'master' into update-cpan-install-method
Browse files Browse the repository at this point in the history
  • Loading branch information
sidey79 committed May 26, 2021
2 parents 59b99dc + e7c792e commit 2b6812e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
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
2021-05-23 - new protocol 110 for ADE WS1907 Weather station (#970)

* new protocol 110 for ADE WS1907 Weather station
Expand Down
21 changes: 16 additions & 5 deletions FHEM/lib/SD_Protocols.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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 ) );

Expand Down
2 changes: 1 addition & 1 deletion controls_signalduino.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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-26_21:30:08 69920 FHEM/lib/SD_Protocols.pm
14 changes: 13 additions & 1 deletion t/SD_Protocols/02_ConvKoppFreeControl.t
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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');
}
};

0 comments on commit 2b6812e

Please sign in to comment.