Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4806d2e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jun 7 22:21:10 2022 +0200

    Bump fhem/fhem-controls-actions from 2.0.3 to 2.1.0 (#1105)

    Bumps [fhem/fhem-controls-actions](https://github.com/fhem/fhem-controls-actions) from 2.0.3 to 2.1.0.
    - [Release notes](https://github.com/fhem/fhem-controls-actions/releases)
    - [Commits](fhem/fhem-controls-actions@v2.0.3...v2.1.0)

    ---
    updated-dependencies:
    - dependency-name: fhem/fhem-controls-actions
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 6bb37f9
Author: sidey79 <7968127+sidey79@users.noreply.github.com>
Date:   Tue May 31 17:12:21 2022 +0200

    Basic funkbus support (#1102)

    * SD_ProtocolData.pm

    added funkbus protocol 119 from forum
    https://forum.fhem.de/index.php/topic,19065.msg1217972.html#msg1217972

    * SD_Protocols.pm
    - sub mcBit2Funkbus added
    - sub mc2dmc added
    - Tests added
  • Loading branch information
HomeAutoUser committed Jun 8, 2022
1 parent 192fe7b commit 9bbf715
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ jobs:
persist-credentials: false
- name: update controls file (FHEM)
if: needs.pr_check.outputs.result != 'true'
uses: fhem/fhem-controls-actions@v2.0.3
uses: fhem/fhem-controls-actions@v2.1.0
with:
filename: controls_signalduino.txt
- name: update controls file (lib)
if: needs.pr_check.outputs.result != 'true'
uses: fhem/fhem-controls-actions@v2.0.3
uses: fhem/fhem-controls-actions@v2.1.0
with:
filename: controls_signalduino.txt
directory: FHEM/lib
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ jobs:
find ./FHEM -name "$FILE" -exec cp $FPATH "{}" \;
done
- name: update controls file (FHEM)
uses: fhem/fhem-controls-actions@v2.0.3
uses: fhem/fhem-controls-actions@v2.1.0
with:
filename: controls_signalduino.txt
- name: update controls file (lib)
uses: fhem/fhem-controls-actions@v2.0.3
uses: fhem/fhem-controls-actions@v2.1.0
with:
filename: controls_signalduino.txt
directory: FHEM/lib
Expand Down
23 changes: 20 additions & 3 deletions FHEM/lib/SD_ProtocolData.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###########################################################################################################################################
# $Id: SD_ProtocolData.pm 3.5.4 2022-04-16 09:19:56Z elektron-bbs $
# $Id: SD_ProtocolData.pm 3.5.4 2022-05-30 20:10:51Z sidey79 $
# The file is part of the SIGNALduino project.
# All protocol definitions are contained in this file.
#
Expand Down Expand Up @@ -86,7 +86,7 @@ package lib::SD_ProtocolData;
use strict;
use warnings;

our $VERSION = '1.44';
our $VERSION = '1.45';

our %protocols = (
"0" => ## various weather sensors (500 | 9100)
Expand Down Expand Up @@ -573,7 +573,7 @@ package lib::SD_ProtocolData;
format => 'twostate',
preamble => 'P13#',
clientmodule => 'FLAMINGO',
#modulematch => '',
# => '',
length_min => '24',
length_max => '24',
},
Expand Down Expand Up @@ -3177,6 +3177,23 @@ package lib::SD_ProtocolData;
length_min => '24',
length_max => '25',
},

"119" => ## Funkbus
#
{
name => 'Funkbus',
comment => 'only Typ 43',
id => '119',
clockrange => [490,520], # min , max
format => 'manchester',
clientmodule => 'IFB',
#modulematch => '',
preamble => 'J',
length_min => '47',
length_max => '52',
method => \&lib::SD_Protocols::mcBit2Funkbus,
},

########################################################################
#### ### register informations from other hardware protocols #### ####

Expand Down
113 changes: 112 additions & 1 deletion FHEM/lib/SD_Protocols.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-30 10:19:30Z elektron-bbs $
# $Id: SD_ProtocolData.pm 3.5.x 2022-05-30 20:10:51Z sidey79 $
#
# The file is part of the SIGNALduino project
# v3.5.x - https://github.com/RFD-FHEM/RFFHEM
Expand Down Expand Up @@ -411,7 +411,118 @@ sub LengthInRange {
return (1,q{});
}


############################# package lib::SD_Protocols, test exists
=item mc2dmc()
This function is a helper for remudlation of a manchester signal to a differental manchester signal afterwards
Input: $object,$bitData (string)
Output:
string of converted bits
or array (-1,"Error message")
=cut

sub mc2dmc
{
my $self = shift // carp 'Not called within an object' && return (0,'no object provided');
my $bitData = shift // carp 'bitData must be perovided' && return (0,'no bitData provided');

my @bitmsg;
my $i;

$bitData =~ s/1/lh/g; # 0 ersetzen mit low high
$bitData =~ s/0/hl/g; # 1 ersetzen durch high low ersetzen

for ($i=1;$i<length($bitData)-1;$i+=2)
{
push (@bitmsg, (substr($bitData,$i,1) eq substr($bitData,$i+1,1)) ? 0 : 1); # demodulated differential manchester
}
return join "", @bitmsg ; # demodulated differential manchester as string
}


############################# package lib::SD_Protocols, test exists
=item mcBit2Funkbus()
This function is a output helper for funkbus manchester signals.
Input: $object,$name,$bitData,$id,$mcbitnum
Output:
hex string
or array (-1,"Error message")
=cut

sub mcBit2Funkbus
{
my $self = shift // carp 'Not called within an object' && return (0,'no object provided');
my $name = shift // 'anonymous';
my $bitData = shift // carp 'bitData must be perovided' && return (0,'no bitData provided');
my $id = shift // carp 'protocol ID must be provided' && return (0,'no protocolId provided');
my $mcbitnum = shift // length $bitData;

return (-1,' message is to short') if ($mcbitnum < $self->checkProperty($id,'length_min',-1) );
return (-1,' message is to long') if (defined $self->getProperty($id,'length_max' ) && $mcbitnum > $self->getProperty($id,'length_max') );

$self->_logging( qq[lib/mcBitFunkbus, $name Funkbus: raw=$bitData], 5 );

$bitData =~ s/1/lh/g; # 0 ersetzen mit low high
$bitData =~ s/0/hl/g; # 1 ersdetzen durch high low ersetzen

my $s_bitmsg = $self->mc2dmc($bitData); # Convert to differential manchester

if ($id == 119) {
my $pos = index($s_bitmsg,'01100');
if ($pos >= 0 && $pos < 5) {
$s_bitmsg = '001' . substr($s_bitmsg,$pos);
return (-1,'wrong bits at begin') if (length($s_bitmsg) < 48);
} else {
return (-1,'wrong bits at begin');
}
} else {
$s_bitmsg = q[0] . $s_bitmsg;
}

my $data;
my $xor = 0;
my $chk = 0;
my $p = 0; # parity
my $hex = q[];
for (my $i=0; $i<6;$i++) { # checksum
$data = oct(q[b].substr($s_bitmsg, $i*8,8));
$hex .= sprintf('%02X', $data);
if ($i<5) {
$xor ^= $data;
} else {
$chk = $data & 0x0F;
$xor ^= $data & 0xE0;
$data &= 0xF0;
}
while ($data) { # parity
$p^=($data & 1);
$data>>=1;
}
}
return (-1,'parity error') if ($p == 1);

my $xor_nibble = (($xor & 0xF0) >> 4) ^ ($xor & 0x0F);
my $result = 0;
$result = ($xor_nibble & 0x8) ? $result ^ 0xC : $result;
$result = ($xor_nibble & 0x4) ? $result ^ 0x2 : $result;
$result = ($xor_nibble & 0x2) ? $result ^ 0x8 : $result;
$result = ($xor_nibble & 0x1) ? $result ^ 0x3 : $result;

return (-1,'checksum error') if ($result != $chk);

$self->_logging( qq[lib/mcBitFunkbus, $name Funkbus: len=]. length($s_bitmsg).q[ bit49=].substr($s_bitmsg,48,1).qq[ parity=$p res=$result chk=$chk msg=$s_bitmsg hex=$hex], 4 );

return (1,$hex);
}



=item MCRAW()
This function is desired to be used as a default output helper for manchester signals.
Expand Down
4 changes: 2 additions & 2 deletions controls_signalduino.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ UPD 2022-04-15_20:58:20 35384 FHEM/14_SD_WS09.pm
UPD 2020-04-13_23:15:56 14325 FHEM/14_SD_WS_Maverick.pm
UPD 2021-08-11_21:38:30 37904 FHEM/41_OREGON.pm
UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm
UPD 2022-04-17_21:56:43 229099 FHEM/lib/SD_ProtocolData.pm
UPD 2022-03-07_20:25:23 75991 FHEM/lib/SD_Protocols.pm
UPD 2022-05-30_22:10:08 229520 FHEM/lib/SD_ProtocolData.pm
UPD 2022-05-30_19:35:15 79342 FHEM/lib/SD_Protocols.pm
13 changes: 5 additions & 8 deletions t/FHEM/00_SIGNALduino/08_DeviceData_rmsg.t
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,18 @@ InternalTimer(time()+1, sub {
my @TestList = (
{
testname => 'Test with pre-release SD_Device_ProtocolList',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/pre-release/FHEM/lib/SD_Device_ProtocolList.json',
todo => 'Checking with pre-release Version of SD_Device_ProtocolList which can fail',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/pre-release/FHEM/lib/SD_Device_ProtocolList.json',
todo => 'Checking with pre-release Version of SD_Device_ProtocolList which can fail',
},
{
testname => 'Test with master SD_Device_ProtocolList',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/master/FHEM/lib/SD_Device_ProtocolList.json',
todo => 'Checking with master Version of SD_Device_ProtocolList which can fail',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/master/FHEM/lib/SD_Device_ProtocolList.json',
todo => 'Checking with master Version of SD_Device_ProtocolList which can fail',
},
{
testname => 'Test with patched SD_Device_ProtocolList',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/patch-fixTests/FHEM/lib/SD_Device_ProtocolList.json',
url => 'https://raw.githubusercontent.com/RFD-FHEM/SIGNALduino_TOOL/patch-fixTests/FHEM/lib/SD_Device_ProtocolList.json',
},



);


Expand Down
40 changes: 40 additions & 0 deletions t/SD_Protocols/02_mc2dmc.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env perl
use strict;
use warnings;

use Test2::V0;
use lib::SD_Protocols;
use Test2::Tools::Compare qw{is};

plan(3);

my ($rcode,$bitresult);
my $Protocols =
new lib::SD_Protocols( filetype => 'json', filename => './t/SD_Protocols/test_protocolData.json' );



subtest 'mc2dmc without arguments' => sub {
plan(1);

my $bitData='110010';
$bitresult=$Protocols->mc2dmc();
is($bitresult,q[no bitData provided],q[check result mc2dmc]);
};

subtest 'mc2dmc 1001 => 010' => sub {
plan(1);

my $bitData='1001';
$bitresult=$Protocols->mc2dmc($bitData);
is($bitresult,q[010],q[check result mc2dmc]);
};


subtest 'mc2dmc 110010 => 10100' => sub {
plan(1);

my $bitData='110010';
$bitresult=$Protocols->mc2dmc($bitData);
is($bitresult,q[10100],q[check result mc2dmc]);
};
45 changes: 45 additions & 0 deletions t/SD_Protocols/02_mcBit2Funkbus.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env perl
use strict;
use warnings;

use Test2::V0;
use lib::SD_Protocols;
use Test2::Tools::Compare qw{is};

plan(3);

my $id=119;
my ($rcode,$hexresult);
my $Protocols =
new lib::SD_Protocols( filetype => 'json', filename => './t/SD_Protocols/test_protocolData.json' );

# Mock protocol for this test
$Protocols->{_protocols}->{119}{length_min} = 47;
$Protocols->{_protocols}->{119}{length_max} = 52;

subtest 'mcBit2Funkbus good message' => sub {
plan(2);

my $bitData='1001110101001111001111110111010101010101101000000000';
($rcode,$hexresult)=$Protocols->mcBit2Funkbus(q[some_name],$bitData,$id,length $bitData);
is($rcode,1,q[check returncode for mcBit2Funkbus]);
is($hexresult,q[2C175F30008F],q[check result mcBit2Funkbus]);
};

subtest 'mcBit2Funkbus wrong parity' => sub {
plan(2);

my $bitData='100111010100111100111111011101010101010110110000000';
($rcode,$hexresult)=$Protocols->mcBit2Funkbus(q[some_name],$bitData,$id,length $bitData);
is($rcode,-1,q[check returncode for mcBit2Funkbus]);
is($hexresult,q[parity error],q[check result mcBit2Funkbus]);
};

subtest 'mcBit2Funkbus wrong checksum' => sub {
plan(2);

my $bitData='1001110101001111101111110111010101010101101000000000';
($rcode,$hexresult)=$Protocols->mcBit2Funkbus(q[some_name],$bitData,$id,length $bitData);
is($rcode,-1,q[check returncode for mcBit2Funkbus]);
is($hexresult,q[checksum error],q[check result mcBit2Funkbus]);
};

0 comments on commit 9bbf715

Please sign in to comment.