diff --git a/lib/Insteon_PLM.pm b/lib/Insteon_PLM.pm index ba3763603..6339bc543 100644 --- a/lib/Insteon_PLM.pm +++ b/lib/Insteon_PLM.pm @@ -626,19 +626,24 @@ sub _parse_data { } elsif ($parsed_prefix eq $prefix{all_link_clean_failed} and ($message_length == 12)) { #ALL-Link Cleanup Failure Report - # extract out the pertinent parts of the message for display purposes - # bytes 0-1 - group; 2-7 device address - my $failure_group = substr($message_data,0,2); - my $failure_device = substr($message_data,2,6); - - &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure from device: " - . "$failure_device and group: $failure_group") if $main::Debug{insteon} >= 2; + if ($self->active_message){ + # extract out the pertinent parts of the message for display purposes + # bytes 0-1 - group; 2-7 device address + my $failure_group = substr($message_data,0,2); + my $failure_device = substr($message_data,2,6); + + &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure from device: " + . "$failure_device and group: $failure_group") if $main::Debug{insteon} >= 2; - my $failed_object = &Insteon::get_object($failure_device,'01'); - my $message = new Insteon::InsteonMessage('all_link_direct_cleanup', $failed_object, - $self->active_message->command, $failure_group); - push(@{$$failed_object{command_stack}}, $message); - $failed_object->_process_command_stack(); + my $failed_object = &Insteon::get_object($failure_device,'01'); + my $message = new Insteon::InsteonMessage('all_link_direct_cleanup', $failed_object, + $self->active_message->command, $failure_group); + push(@{$$failed_object{command_stack}}, $message); + $failed_object->_process_command_stack(); + } else { + &::print_log("[Insteon_PLM] DEBUG2: Received all-link cleanup failure." + . " But there is no pending message.") if $main::Debug{insteon} >= 2; + } } elsif ($parsed_prefix eq $prefix{all_link_record} and ($message_length == 20)) @@ -681,15 +686,27 @@ sub _parse_data { # so, slow things down if (!($nack_count)) { - my $nack_delay = ($::config_parms{Insteon_PLM_disable_throttling}) ? 0.3 : 1.0; - &::print_log("[Insteon_PLM] DEBUG3: Interface extremely busy. Resending command" - . " after delaying for $nack_delay second") if $main::Debug{insteon} >= 3; - $self->_set_timeout('xmit',$nack_delay * 1000); - $self->active_message->no_hop_increase(1); - $self->retry_active_message(); - $process_next_command = 0; + if ($self->active_message){ + my $nack_delay = ($::config_parms{Insteon_PLM_disable_throttling}) ? 0.3 : 1.0; + &::print_log("[Insteon_PLM] DEBUG3: Interface extremely busy. Resending command" + . " after delaying for $nack_delay second") if $main::Debug{insteon} >= 3; + $self->_set_timeout('xmit',$nack_delay * 1000); + $self->active_message->no_hop_increase(1); + $self->retry_active_message(); + $process_next_command = 0; + } else { + &::print_log("[Insteon_PLM] DEBUG3: Interface extremely busy." + . " No message to resend.") if $main::Debug{insteon} >= 3; + } $nack_count++; } + #Remove the leading NACK bytes and place whatever remains into fragment for next read + $parsed_data =~ s/^(15)*//; + if ($parsed_data ne ''){ + $$self{_data_fragment} .= $parsed_data; + ::print_log("[Insteon_PLM] DEBUG3: Saving parsed data fragment: " + . $parsed_data) if( $main::Debug{insteon} >= 3); + } } else {