From b3ce83db24dae431873f9ef7a46837448e684ce3 Mon Sep 17 00:00:00 2001 From: CityDweller Date: Mon, 23 Jan 2017 21:28:13 -0500 Subject: [PATCH] update to contain name of object when there is an error --- lib/UPBPIM.pm | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/UPBPIM.pm b/lib/UPBPIM.pm index 62be7e956..fa4719416 100644 --- a/lib/UPBPIM.pm +++ b/lib/UPBPIM.pm @@ -334,9 +334,28 @@ sub _parse_data { #UPB No Acknowledgement elsif ( uc( substr( $data, 1, 1 ) ) eq 'N' ) { $$self{xmit_in_progress} = 0; - &::print_log( - "$self->object_name: Reports device does not respond"); - pop( @{ $$self{command_stack} } ); + + + my $pop = pop( @{ $$self{command_stack} } ); + my $destination = unpack( "C", pack( "H*", substr( $pop, 6, 2 ) ) ); + my $msgid = unpack( "C", pack( "H*", substr( $pop, 10, 2 ) ) ); + my $command; + for my $key ( keys %UPB_Device::message_types ) + { + if ($UPB_Device::message_types{$key} == $msgid) + { + $command = $key; + last; + } + } + for my $obj ( @{ $$self{objects} } ) + { + if ($obj->device_id() == $destination ) + { + #&::print_log("$self->object_name: Reports device does not respond; LastCommand: $pop"); + &::print_log("UPBPIM reports that device: " . $obj->get_object_name . " does not respond to command: $command"); + } + } select( undef, undef, undef, .15 ); $self->process_command_stack(); }