EasyBAC API

EasyBAC API v1.0, last updated on Feb 20, 2006. Copyright © 2006 Cimetrics, Inc.

In this document:

Overview

EasyBAC provides a framework which performs BACnet processing on behalf of a microprocessor.

The framework's primary tasks are:

BACnet device exposed to the BACnet network implements the following BIBBs:

This matches BACnet B-ASC profile without support for Who-Has/I-Have and DCC.

BACnet Object Database is created by the EasyBAC based on the configuration downloaded in advance and saved to the EasyBAC's flash memory. This configuration is created and downloaded over Ethernet using a special PC-based configuration tool.

NOTE: In future version object database donwloading over RS-232 may be supported as well.

Some of the parameters (such as device's IP address or value of the Device Object_Identifier property) are unknown until deployment and are configured in the field over the Web using the EasyBAC's built-in Web server.

Communication between EasyBAC and the microprocessor is performed using custom protocol over an RS-232 link.

BACnet-side Behavior

BACnet Object Types Supported

This section describes BACnet object types that are supported by the EasyBAC. Not every property defined by the BACnet standard for a given object type is supported by the Object Database. This section lists supported and unsupported properties for every supported object type.

Supported properties are presented in a per-object table where the Value column specifies source for the property value:

Is Writable column indicates whether this property appears writable to the BACnet network.

The following BACnet object types are supported:

Device
Property Value Is Writable
Object_Identifier configured at install-time (unique internetwork-wide)
Object_Name configured at install-time (unique internetwork-wide)
Location configured at install-time
Description configured at install-time
Vendor_Name download
Vendor_Identifier download
Model_Name download
Firmware_Revision download
Application_Software_Version download
Object_Type DEVICE
System_Status OPERATIONAL
APDU_Timeout 3 sec
Number_Of_APDU_Retries 3
Protocol_Version 1
Protocol_Revision 4
Protocol_Services_Supported { READ-PROPERTY, WRITE-PROPERTY, WHO-IS, I-AM }
Protocol_Object_Types_Supported { DEVICE, AI, AO, AV, BI, BO, BV, MSI, MSO, MSV }
Object_List based on downloaded configuration
Max_APDU_Length_Accepted 1024
Segmentation_Supported NO-SEGMENTATION
Device_Address_Binding empty
Database_Revision download

The following optional properties are not present: Max_Segments_Accepted, VT_Classes_Supported, Active_VT_Sessions, Local_Time, Local_Date, UTC_Offset, Daylight_Savings_Status, APDU_Segment_Timeout, List_Of_Session_Keys, Time_Synchronization_Recipients, Max_Master, Max_Info_Frames, Configuration_Files, Last_Restore_Time, Backup_Failure_Timeout, Active_COV_Subscriptions, Slave_Proxy_Enable, Manual_Slave_Address_Binding, Auto_Slave_Discovery, Slave_ Address_Binding, Profile_Name.

Analog Input
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Units download
Description download
Device_Type download
Min_Pres_Value download
Max_Pres_Value download
Resolution download
Object_Type ANALOG-INPUT
Present_Value variable (initial value is 0.0)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: Update_Interval, COV_Increment, Time_Delay, Notification_Class, High_Limit, Low_Limit, Deadband, Limit_Enable, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Analog Output
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Units download
Relinquish_Default download Yes
Description download
Device_Type download
Min_Pres_Value download
Max_Pres_Value download
Resolution download
Object_Type ANALOG-OUTPUT
Present_Value variable (calculated from Priority_Array and Relinquish_Default) Yes
Priority_Array variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: COV_Increment, Time_Delay, Notification_Class, High_Limit, Low_Limit, Deadband, Limit_Enable, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Analog Value
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Units download
Relinquish_Default 1) download Yes
Description download
Object_Type ANALOG-VALUE
Present_Value variable (calculated from Priority_Array and Relinquish_Default if these properties are present) Optionally2)
Priority_Array 1) variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

1)These properties are optional, they may be present if Present_Value property is writable. Either both are present or both are absent. If these properties are present, Present_Value is commandable, otherwise it is not.

2)May be either read-only or writable. Writable Present_Value may or may not be commandable.

The following optional properties are not present: COV_Increment, Time_Delay, Notification_Class, High_Limit, Low_Limit, Deadband, Limit_Enable, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Binary Input
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Polarity download
Description download
Device_Type download
Inactive_Text download
Active_Text download
Object_Type BINARY-INPUT
Present_Value variable (initial value is INACTIVE)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: Change_Of_State_Time, Change_Of_State_Count, Time_Of_State_Count_Reset, Elapsed_Active_Time, Time_Of_Active_Time_Reset, Time_Delay, Notification_Class, Alarm_Value, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Binary Output
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Polarity download
Relinquish_Default download Yes
Description download
Device_Type download
Inactive_Text download
Active_Text download
Object_Type BINARY-OUTPUT
Present_Value variable (calculated from Priority_Array and Relinquish_Default) Yes
Priority_Array variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: Change_Of_State_Time, Change_Of_State_Count, Time_Of_State_Count_Reset, Elapsed_Active_Time, Time_Of_Active_Time_Reset, Minimum_Off_Time, Minimum_On_Time, Time_Delay, Notification_Class, Feedback_Value, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Binary Value
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Relinquish_Default1) download Yes
Description download
Inactive_Text download
Active_Text download
Object_Type BINARY-VALUE
Present_Value variable (calculated from Priority_Array and Relinquish_Default if these properties are present) Optionally2)
Priority_Array1) variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

1)These properties are optional, they may be present if Present_Value property is writable. Either both are present or both are absent. If these properties are present, Present_Value is commandable, otherwise it is not.

2)May be either read-only or writable. Writable Present_Value may or may not be commandable.

The following optional properties are not present: Change_Of_State_Time, Change_Of_State_Count, Time_Of_State_Count_Reset, Elapsed_Active_Time, Time_Of_Active_Time_Reset, Minimum_Off_Time, Minimum_On_Time, Time_Delay, Notification_Class, Alarm_Value, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Multi-state Input
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Number_Of_States download
State_Text download
Description download
Device_Type download
Object_Type MULTISTATE-INPUT
Present_Value variable (initial value is 1)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: Time_Delay, Notification_Class, Alarm_Values, Fault_Values, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Multi-state Output
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Relinquish_Default download Yes
Number_Of_States download
State_Text download
Description download
Device_Type download
Object_Type MULTISTATE-OUTPUT
Present_Value variable (calculated from Priority_Array and Relinquish_Default) Yes
Priority_Array variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

The following optional properties are not present: Time_Delay, Notification_Class, Feedback_Value, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

Multi-state Value
Property Value Is Writable
Object_Identifier download (unique device-wide)
Object_Name download (unique device-wide)
Relinquish_Default1) download Yes
Number_Of_States download
State_Text download
Description download
Object_Type MULTISTATE-VALUE
Present_Value variable (calculated from Priority_Array and Relinquish_Default if these properties are present) Optionally2)
Priority_Array1) variable (initial value is all NULLs)
Status_Flags { 0, 0, 0, 0 }
Event_State NORMAL
Out_Of_Service FALSE Yes
Reliability No_Fault_Detected

1)These properties are optional, they may be present if Present_Value property is writable. Either both are present or both are absent. If these properties are present, Present_Value is commandable, otherwise it is not.

2)May be either read-only or writable. Writable Present_Value may or may not be commandable.

The following optional properties are not present: Time_Delay, Notification_Class, Alarm_Values, Fault_Values, Event_Enable, Acked_Transitions, Notify_Type, Event_Time_Stamps, Profile_Name.

BACnet Protocol Services Supported

EasyBAC supports the following BACnet protocol services:

Who-Is (Execute)

Upon receipt of a Who-Is request, EasyBAC initiates an I-Am request, as appropriate, using Device object's properties values for service request parameters.

Microprocessor is not involved in Who-Is request execution.

I-Am (Initiate)

EasyBAC initiates I-Am requests filled with Device object's properties values in the following situations:

Microprocessor is not involved in I-Am request initiating.

ReadProperty (Execute)

All properties present in the Object Database are readable.

Upon receipt of a ReadProperty request, EasyBAC performs request validation and sends back an acknowledgement, as defined by the BACnet standard. In case of a success, EasyBAC sends back to the BACnet network positive acknowledgement (ReadProperty-ACK) containing current value of the requested property from the BACnet Object Database. In case of a failure, EasyBAC sends negative acknowledgement (BACnet-Error) with appropriate BACnet error class and error code.

Current value of a property in the Database may originate from:

Microprocessor is not directly involved in processing of the ReadProperty service requests. It is involved indirectly by changing values of properties in the Database by means of the Input_Property serial message.

WriteProperty (Execute)

Most of the properties in the BACnet Object Database are not writable and cannot be changed by means of a WriteProperty service request. See Object Types Supported for complete list of writable properties in each supported object type.

Upon receipt of a valid WriteProperty request, EasyBAC writes to the BACnet Object Database specified value of the the specified property of the specified object and sends back to the BACnet network positive acknowledgement, as defined by the BACnet standard. In case of a failure EasyBAC sends negative acknowledgement.

If the property being written is Present_Value or Relinquish_Default, and the object in question is not out of the service (see Handling Out_Of_Service Property), new property value is sent to the microprocessor using the Output_Property serial message. Output_Property serial message is sent asynchronously and may be sent to the microprocessor either after or before BACnet acknowledgement is actually sent over the BACnet network.

EasyBAC WriteProperty handler performs basic request validity checks, such as existence of the object specified, existence and writablity of the property specified. Standard-mandated BACnet logic is also implemented: see Handling Command Prioritization and Handling Out_Of_Service Property. However, application-level checks, such as checking Present_Value against device-specific bounds, are not performed.

Value of the priority parameter specified in a WriteProperty request for a commandable Present_Value property is included in the Output_Property serial message EasyBAC sends to the microprocessor.

Handling Command Prioritization

EasyBAC handles BACnet Command Prioritization defined by the BACnet standard automatically.

When a WriteProperty request is executed for a commandable Present_Value property (i.e. Present_Value in an Output object or a Value object with Priority_Array property), EasyBAC does the following:

Similarly, EasyBAC re-calculates Present_Value property when a WriteProperty request is executed for a Relinquish_Default property, and if Present_Value changes, EasyBAC sends new Present_Value to the microprocessor in an Output_Property serial message.

Handling Out_Of_Service Property

EasyBAC automatically handles changes of the Out_Of_Service property.

The Out_Of_Service property can be changed by both the microprocessor (by means of an Input_Property serial message) and from the BACnet network (by means of a WriteProperty BACnet service request). EasyBAC behavior does not depend on the source of the change, and is described below.

When Out_Of_Service property changes from FALSE to TRUE:

When Out_Of_Service property changes from TRUE to FALSE:

Handling Reliability Property

Upon receipt of a Input_Property with Property_ID set to Reliability EasyBAC automatically updates FAULT flag in the Status_Flags property in the BACnet Object Database: sets it if new Reliability value is not equal to NO_FAULT_DETECTED, and clears it otherwise.

EasyBAC API Serial Protocol

This section describes serial interface and communication protocol for the EasyBAC product.

UART Spec

EasyBAC uses the following serial interface for communication:

Timing

There are no special timing requirements.

Frame Format

All frames have the following format:

Field Length Value/Comment
Preamble two bytes X'55FF'
Message Type one byte  
Payload Length two bytes Most significant byte first
Header checksum one byte Calculation involves Message Type and Payload Length fields. If error checking is turned off (see Error Checking), value of this field must be 0
Payload variable Is present only if Payload Length is non-zero
Payload checksum one or two bytes Least significant byte first. Is present only if Payload Length is non-zero and some error checking method is used (see Error Checking)

The Message Type field is used to distinguish between different protocol messages:

EasyBAC_Started 0
Unlock_Database 1
Get_All 2
Get_All_Complete 3
Input_Property 4
Output_Property 5
Indicate_Property 6

Error Checking

EasyBAC can be configured at development time to use one of the following algorithms for checking errors in serial protocol messages:

Whatever error checking algorithm is used, message header layout remains the same.

Protocol Messages

EasyBAC and the microprocessor exchange unconfirmed messages of one of the types defined below. It is not guaranteed by the current EasyBAC implementation that every message sent by the microprocessor is received by the EasyBAC.

Every message consists of zero or more fields, depending on the message type.

Every message assumes certain actions taken by the receiving side. In some cases this involves responding with one or more messages. However, all messages are considered to be independent and not "replies" to any other message. This means that neither EasyBAC nor micrprocessor needs to block waiting for a response/confirmation after having sent out a message.

Object ID parameter used in Input_Property, Output_Property and Indicate_Property messages is encoded as 32-bit value having the following layout:

Property ID parameter used in Input_Property, Output_Property and Indicate_Property is encoded as 16-bit value (most significant byte first) matching the BACnetPropertyIdentifier enumeration.

Priority parameter used in Input_Property and Output_Property properties specifies priority for writing a commandable property in the range from 1 (the highest priority) to 16 (the lowest priority).

For Output_Property message Priority has the value specified by the original WriteProperty BACnet service request which triggered this serial message, or 0 if property in question is not commandable.

For Input_Property message Priority has the value chosen by the microprocessor. For non-commandable properties Priority parameter is ignored.

The following data types are used in Input_Property, Output_Property and Indicate_Property messages:
Data Type Type Encoding Length in Bytes Value Encoding
Enum8 0 1 single byte
Enum16 1 1 two bytes, most significant byte first
Unsigned16 2 2 two bytes, most significant byte first
Real 3 4 IEEE 754-1985 single precision (32-bit) floating-point number, most significant byte first
Bool 4 1 single byte: zero designates false, non-zero designates true

The following protocol messages are defined:

EasyBAC_Started

Message Type: 0

Initiated by EasyBAC. EasyBAC sends this message to the microprocessor every time it boots and is ready to work.

The EasyBAC_Started messages contains no fields.

A sample encoding of an EasyBAC_Started message:

    55:FF               -- preamble
    00                  -- message type (EasyBAC_Started)
    00:00               -- payload length
    EE                  -- header CRC8

Unlock_Database

Message Type: 1

Initiated by the microprocessor. Makes EasyBAC device visible on the BACnet network.

NOTE: In the current version, BACnet Object Database is never locked and the microprocessor does not need to use Unlock_Database message.

Upon receipt of an Unlock_Database message, EasyBAC broadcasts locally BACnet I-Am service request.

The Unlock_Database message contains no fields.

A sample encoding of an Unlock_Database message:

    55:FF               -- preamble
    01                  -- message type (Unlock_Database)
    00:00               -- payload length
    76                  -- header CRC8

Get_All

Message Type: 2

Initiated by the microprocessor. Queries EasyBAC about current values of Present_Value and Relinquish_Default properties of all Output and writable Value objects.

Upon receipt of a Get_All message, EasyBAC sends one Indicate_Property serial message to the microprocessor for every relevant property. In addition, following the last Indicate_Property message, EasyBAC sends one Get_All_Complete message.

The Get_All messages contains no fields.

A sample encoding of a Get_All message:

    55:FF               -- preamble
    02                  -- message type (Get_All)
    00:00               -- payload length
    DD                  -- header CRC8

Get_All_Complete

Message Type: 3

Initiated by EasyBAC. Notifies the microprocessor that all Indicate_Property messages triggered by Get_All have been sent.

The Get_All_Complete message contains no fields.

A sample encoding of a Get_All_Complete message:

    55:FF               -- preamble
    03                  -- message type (Get_All_Complete)
    00:00               -- payload length
    45                  -- header CRC8

Input_Property

Message Type: 4

Initiated by microprocessor. Requests EasyBAC to change value of a property in the BACnet Object Database.

This message is primarily used to set value of the Present_Value property of an Input or Value object in the Database associated with a physical input device to the value obtained from this device. EasyBAC uses values in the Database to respond to ReadProperty BACnet service requests, so after a value has been written to the Database, it represents physical device to the BACnet network.

Microprocessor may also use this message to set values of Relinquish_Default, Reliability and Out_of_Service properties.

See Handling Out_Of_Service Property for exceptions to the normal message processing.

The Input_Property message consists of the following fields:
Object ID 4 bytes specifies object whose property must be set
Property ID 2 bytes specifies property whose value must be set
Priority 1 byte specifies priority for writing a commandable property in the range from 1 to 16; ignored when writing a non-commandable property
Data Type 1 byte Real (for Analog objects), Enum8 (for Binary objects) or Unsigned16 (for Multi-state objects)
Value N (depends on Data Type, see above)

A sample encoding of an Input_Property message:

    55:FF               -- preamble
    04                  -- message type (Input_Property)
    00:0C               -- payload length
    8c                  -- header CRC8
    00:00:00:01         -- Object ID (Analog-Input, 1)
    00:55               -- Property ID (Present-Value)
    10                  -- Priority (unused/default)
    03                  -- data type (Real)
    40:48:F5:C3         -- data value (3.14)
    17:D0               -- payload CRC16

Output_Property

Message Type: 5

Initiated by EasyBAC. Notifies microprocessor about a change of value of a property in the BACnet Object Database caused by execution of a WriteProperty BACnet service request.

Currently, EasyBAC sends this message to the microprocessor only to notify about change of the Present_Value or Relinquish_Default property in a Output or writable Value object.

EasyBAC doesn't send this message to the microprocessor if Out_Of_Service property in the object whose Present_Value has changed from the BACnet network has the value TRUE. When Out_Of_Service property value changes back to FALSE, EasyBAC immediately sends to the microprocessor Output_Property messages with the current Database Present_Value and Relinquish_Default (if present) property values.

Upon receipt of this message, microprocessor should apply delivered property value to the output associated with the object specified in the message.

The Output_Property message consists of the following fields:
Object ID 4 bytes identifies object whose property is delivered
Property ID 2 bytes specifies property whose value is delivered
Status Flags 1 byte indicates current Object status flags (see easybac.html for flags definitions)
Priority 1 byte specifies priority for writing a commandable property in the range from 1 to 16; 0 for default value or when writing a non-commandable property
Data Type 1 byte Real (for Analog objects), Enum8 (for Binary objects) or Unsigned16 (for Multi-state objects)
Value N (depends on Data Type, see above)

A sample encoding of an Output_Property message:

    55:FF               -- preamble
    05                  -- message type (Output_Property)
    00:0B               -- payload length
    E8                  -- header CRC8
    03:80:00:01         -- Object ID (Multistate-Output, 1)
    00:55               -- Property ID (Present-Value)
    00                  -- Status Flags (no fault detected, not	out-of-service)
    10                  -- Priority (unused/default)
    02                  -- data type (Unsigned16)
    02:2B               -- data value (555 decimal)
    B0:5C               -- payload CRC16

Indicate_Property

Message Type: 6

Sent by EasyBAC on request from the microprocessor. Indicates current value of a property.

The Indicate_Property message consists of the following fields:
Object ID 4 bytes identifies object whose property is delivered
Property ID 2 bytes specifies property whose value is delivered
Status Flags 1 byte indicates current Object status flags (see easybac.html for flags definitions)
Data Type 1 byte Real (for Analog objects), Enum8 (for Binary objects) or Unsigned16 (for Multi-state objects)
Value N (depends on Data Type, see above)

A sample encoding of an Indicate_Property message:

    55:FF               -- preamble
    06                  -- message type (Indicate_Property)
    00:0A               -- payload length
    BD                  -- header CRC8
    03:80:00:01         -- Object ID (Multistate-Output, 1)
    00:55               -- Property ID (Present-Value)
    00                  -- Status Flags (no fault detected, not	out-of-service)
    02                  -- data type (Unsigned16)
    02:2B               -- data value (555 decimal)
    FC:06               -- payload CRC16