NAME

bacnet.pl - Scriptable BACnet communications


DESCRIPTION

This is a tool for scriptable BACnet communication. Users can write their own scripts using standard Perl syntax and API defined in this tool to perform desired execution sequences. For details on this tool's API, see Documentation.html. For other Perl documentation, see http://perldoc.perl.org


OPTIONS

Usage: bacnet.pl [program_options] [-- script_args]

This program executes a script in perl syntax to perform BACnet/IP operations.


 Possible program options:
   --script=s    The script to execute.
   --log=s       The file to log all output.
   --help        This help message.
 Possible environment variables are:
    BACNET_IFACE - set this value to dotted IP address of the interface (see
         ipconfig) for which you want to bind.  Default is the interface which
         Windows considers to be the default (how???).  Hence, if there is only a
         single network interface on Windows, the applications will choose it, and
         this setting will not be needed.
    BACNET_IP_PORT - UDP/IP port number (0..65534) used for BACnet/IP
         communications.  Default is 47808 (0xBAC0).
    BACNET_APDU_TIMEOUT - set this value in milliseconds to change the APDU
         timeout.  APDU Timeout is how much time a client waits for a response from
         a BACnet device.
    BACNET_BBMD_PORT - UDP/IP port number (0..65534) used for Foreign Device
         Registration.  Defaults to 47808 (0xBAC0).
    BACNET_BBMD_TIMETOLIVE - number of seconds used in Foreign Device
         Registration (0..65535). Defaults to 60000 seconds.
    BACNET_BBMD_ADDRESS - dotted IPv4 address of the BBMD or Foreign Device
         Registrar.


This tool's API

In addition to having all standard Perl flow control, functions, and modules, the this tool provides an API for performing BACnet communication functions.

ReadProperty

This function implements the ReadProperty service. There are no built in retry mechanisms. NOTE: all enumerations are defined in bacenum.h

Inputs to ReadProperty

Outputs from ReadProperty

Example of ReadProperty

The following example will read AV0.PresentValue from device 1234

    my ($res, $failed) = ReadProperty(1234, 'OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE');

ReadPropertyMultiple

This function implements the ReadPropertyMultiple service. There are no built in retry mechanisms. NOTE: all enumerations are defined in bacenum.h

Inputs to ReadPropertyMultiple

Outputs from ReadPropertyMultiple

Example of ReadPropertyMultiple

The following example will read AV0.PresentValue and AV1.PresentValue from device 1234

    my @RPM_request = ();
    my @RPM_answer = ();
    my $failed;
    push @RPM_request, ['OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE', -1];
    push @RPM_request, ['OBJECT_ANALOG_VALUE', 1, 'PROP_PRESENT_VALUE', -1];
    (undef, $failed) = ReadPropertyMultiple(1234, \@RPM_answer, @RPM_request);

WriteProperty

This function implements the WriteProperty service. There are no built in retry mechanisms. NOTE: all enumerations are defined in bacenum.h

Inputs to WriteProperty

Outputs from WriteProperty

Example of WriteProperty

The following example will write 1.0 to AV0.PresentValue in device 1234

    my ($res, $failed) = WriteProperty(1234, 'OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE', 'BACNET_APPLICATION_TAG_REAL', 1.0);

TimeSync

This function implements the TimeSync and UTCTimeSync services

Inputs to TimeSync

Outputs from TimeSync

Example of TimeSync

    $isFailure = TimeSync($deviceInstance, $1, $2, $3, $4, $5, $6) unless $isFailure;

Log

This function prints out to the desired method of logging (STDOUT or file). NewLine characters are not required when making calls to this function. If any NewLine characters are specified, they will be stripped out. To print an empty line, pass in a space as the message. NOTE: This function will honor previous requests to silence the log (see SilcenseLog for details)

Inputs to Log

Example of Log

The following example will print out "hello world"

    Log("Hello World");

SilenceLog

This function requests that all future log messages be either suppressed or enabled.

Inputs to SilenceLog

Outputs from SilenceLog

The previous value of whether or not the log was silenced before caling this function.

Example of SilenceLog

The following example will print out "hello", but not "world"

    Log("Hello");
    SilenceLog(1);
    Log("World");

Retry

This function will try to execute the requested command up to specified number of times, awaiting the requested answer, with a specified pause between retries. NOTE: the only functions which can be executed by this function are ones which return two parameres in the form of ($response, $isFailure)

Inputs to Retry

Outputs from Retry

Example of Retry

The following example will execute the ReadProperty function to read a property from an object (see ReadProperty for details on those arguments) with up to $maxRetries retries (with $retryDelay delay between retries) or unitl the desired answer of 42 is received.

    my ($resp, $isFailure) = Retry(
                \&ReadProperty, [$deviceInstance, 'OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE'],
                42, $maxRetries, $retryDelay
              );
    if ($isFailure)
    {
        die "Value was not 42. Last response was '$resp'";
    }

The following example will try to execute a WriteProperty (see that function for details on its arguments) until the write succeeds.

    my ($resp, $isFailure) = Retry(
                \&WriteProperty, [$deviceInstance, 'OBJECT_ANALOG_VALUE', 0, 'PROP_PRESENT_VALUE', 'BACNET_APPLICATION_TAG_REAL', 42.0],
                "Acknowledged", $maxRetries, $retryDelay
              );
    if ($isFailure)
    {
        die "Could not write 42. Last response was '$resp'";
    }