Skip to content

Commit

Permalink
Fixed debugging for CMxx, now process data the first time it's sent.
Browse files Browse the repository at this point in the history
mochad now does deduping for us, which caused the "skip the first send"
code to work and never see a resend.
This was disabled and the first send does what we need.
  • Loading branch information
marcmerlin committed May 3, 2020
1 parent 0628f37 commit a635e12
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/X10_CMxx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ back out to the powerline, use mh/code/common/x10_rf_relay.pl.
Also see X10_W800.pm for a similar interface.
This is how decoding works:
CMxx: X10RF data from mochad: 15 1A 80 7F 09 00
X10_CMXX: reordered data: 01 fe a8 58
x10_cmxx: this is x10 security data
X10_CMXX: security: device_id = 0xa8, cmd = 0x01
X10_CMXX: security: class_id = sensor, item_id = a8, state = NormalMax
a8: x10sec_test set NormalMax
CMxx: sending bytes to process, got state NormalMax
CMxx: skipping decoded data received from mochad: 05/03 16:23:29 Rx RFSEC Addr: 15:09:00 Func: Contact_normal_max_DS10A
=cut

use strict;
Expand Down Expand Up @@ -127,7 +137,7 @@ sub check_for_data {
foreach my $line ( split( /\n/, $buffer ) ) {

if ( not $line =~ /.* Raw data received: / ) {
&::print_log("CMxx: decoded data received from mochad: $line")
&::print_log("CMxx: skipping decoded data received from mochad: $line")
if $main::Debug{cmxx};
return;
}
Expand All @@ -149,7 +159,8 @@ sub check_for_data {
# Data gets sent multiple times
# - Check time
# - Process data only on the 2nd occurance, to avoid noise (seems essential)
my $duplicate_threshold = 1; # 2nd occurance; set to 0 to omit duplicate check
#my $duplicate_threshold = 1; # 2nd occurance; set to 0 to omit duplicate check
my $duplicate_threshold = 0; # mochad does deduplication now
my $duplicate_count = duplicate_count($data);
if ( $duplicate_count == $duplicate_threshold ) {
my @bytes;
Expand All @@ -164,7 +175,10 @@ sub check_for_data {
$byteidx++;
}

# This calls X10_RF::decode_rf_bytes which in turn
# calls rf_process_security and rf_set_RF_Item
my $state = X10_RF::decode_rf_bytes( 'X10_CMxx', @bytes );
&::print_log("CMxx: sent bytes to process, got state ".$state) if $main::Debug{cmxx};

# If the decode_rf_bytes routine didn't like the data that it got,
# we just drop the data (it's been preprocessed by mochad, so we can't hope to fix
Expand Down

0 comments on commit a635e12

Please sign in to comment.