diff --git a/bacnet-stack/demo/perl/example_readprop.pl b/bacnet-stack/demo/perl/example_readprop.pl index dd36c430..29908bab 100644 --- a/bacnet-stack/demo/perl/example_readprop.pl +++ b/bacnet-stack/demo/perl/example_readprop.pl @@ -1,16 +1,53 @@ use warnings; use strict; -if (scalar(@ARGV) == 1) -{ - my $device = $ARGV[0]; - my ($resp, $failed) = ReadProperty($device, 'OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE'); +my ( + $device, # device instance number + $objectName, # object type name + $objectInst, # object instance number + $propName, # property name + $index, # property index +); - print "status was '$failed' and the response was '$resp'\n"; -} -else -{ - print "Must specify device instance number as an argument to this script\n"; +GetOptions( + 'device=i' => \$device, + 'objName=s' => \$objectName, + 'objInst=i' => \$objectInst, + 'property=s' => \$propName, + 'index=i' => \$index, +); + +Help() unless ( defined($device) && + defined($objectName) && + defined($objectInst) && + defined($propName) +); + +my ($resp, $failed) = ReadProperty($device, $objectName, $objectInst, $propName, $index); +print "status was '$failed' and the response was '$resp'\n"; + +sub Help { + print <