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

Update 00_Signalduino.pm: Halbe letzte Bits bei MS rekonstruieren #491

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
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
14 changes: 14 additions & 0 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2058,10 +2058,12 @@ SIGNALduino_Parse_MS($$$$%)

my $pstr;
my %patternLookupHash=();
my %endPatternLookupHash=();

$valid = $valid && ($pstr=SIGNALduino_PatternExists($hash,\@{$ProtocolListSIGNALduino{$id}{sync}},\%patternList,\$rawData)) >=0;
Debug "Found matched sync with indexes: ($pstr)" if ($debug && $valid);
$patternLookupHash{$pstr}="" if ($valid); ## Append Sync to our lookuptable
$endPatternLookupHash{substr($pstr,0,length($pstr)-1)}="" if ($valid); ## Append Sync to our lookuptable
my $syncstr=$pstr; # Store for later start search

Debug "sync not found " if (!$valid && $debug); # z.B. [1, -18]
Expand All @@ -2071,13 +2073,22 @@ SIGNALduino_Parse_MS($$$$%)
$valid = $valid && ($pstr=SIGNALduino_PatternExists($hash,\@{$ProtocolListSIGNALduino{$id}{one}},\%patternList,\$rawData)) >=0;
Debug "Found matched one with indexes: ($pstr)" if ($debug && $valid);
$patternLookupHash{$pstr}="1" if ($valid); ## Append Sync to our lookuptable
$endPatternLookupHash{substr($pstr,0,length($pstr)-1)}="1" if ($valid); ## Append Sync to our lookuptable
sidey79 marked this conversation as resolved.
Show resolved Hide resolved
#SIGNALduino_Log3 $name, 4, "$name: Sync 1 ".$pstr." -> ".substr($pstr,0,length($pstr)-1)." eingetragen" if ($valid);
#Debug "added $pstr " if ($debug && $valid);
Debug "one pattern not found" if ($debug && !$valid);


$valid = $valid && ($pstr=SIGNALduino_PatternExists($hash,\@{$ProtocolListSIGNALduino{$id}{zero}},\%patternList,\$rawData)) >=0;
Debug "Found matched zero with indexes: ($pstr)" if ($debug && $valid);
$patternLookupHash{$pstr}="0" if ($valid); ## Append Sync to our lookuptable
if ($valid && !(exists($endPatternLookupHash{substr($pstr,0,length($pstr)-1)}))) {
$endPatternLookupHash{substr($pstr,0,length($pstr)-1)}="0" ;
#SIGNALduino_Log3 $name, 4, "$name: Sync 0 ".$pstr." -> ".substr($pstr,0,length($pstr)-1)." eingetragen";
} else {
delete $endPatternLookupHash{substr($pstr,0,length($pstr)-1)};
Copy link
Contributor

Choose a reason for hiding this comment

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

wen 0 und 1 die gleiche Sequez bis zum vorletzten haben, dann kann man 0 bzw. 1 nicht bestimmen. Deshalb löschst Du hier den Eintrag.
Habe ich das richtig verstanden`?

Copy link
Author

Choose a reason for hiding this comment

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

Genau. Da ich in Perl nicht zu Hause bin hoffe ich, das die Lösung so ok ist. Allerdings kann ich mit dieser Methode den Zweig für float nicht lösen.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alles gut. Um float würde ich mir keine all zu großen Gedanken machen.

#SIGNALduino_Log3 $name, 4, "$name: Sync geloescht";
}
Debug "zero pattern not found" if ($debug && !$valid);

if (defined($ProtocolListSIGNALduino{$id}{float}))
Expand Down Expand Up @@ -2115,6 +2126,9 @@ SIGNALduino_Parse_MS($$$$%)
#Debug $patternLookupHash{substr($rawData,$i,$signal_width)}; ## Get $signal_width number of chars from raw data string
if (exists $patternLookupHash{$sig_str}) { ## Add the bits to our bit array
push(@bit_msg,$patternLookupHash{$sig_str})
} elsif ((length($sig_str)< $signal_width ) && (exists $endPatternLookupHash{$sig_str})) {
SIGNALduino_Log3 $name, 5, "$name: letztes Bit rekonstruiert.";
sidey79 marked this conversation as resolved.
Show resolved Hide resolved
push(@bit_msg,$endPatternLookupHash{$sig_str})
} else {
SIGNALduino_Log3 $name, 5, "$name: Found wrong signalpattern, catched ".scalar @bit_msg." bits, aborting demodulation";
last;
Expand Down