Tel: +1-617-350-7550

BACnet for small platforms

The best way to implement BACnet on your small platform

October 09, 2019

One important trend in the building systems market has been the growing emphasis on integrated systems. By enabling products from different vendors to interact with one another, interoperable building systems based on the BACnet open standard improve building management, increase operational efficiency and flexibility, and hold down service and expansion costs. The power of today’s BACnet-based systems continues to increase as the number of interoperable devices increases.

Another trend is the variety and modest cost of platforms such as Atmel ATmega, ARM Cortex-M, and Linux-based systems. More and more companies are developing their own small BACnet devices and it is not a trivial task to do this correctly. That's why we have developed uBACstac - BACnet Protocol stack for small devices. With uBACstac you can build simple BACnet-enabled devices such as meters, humidifiers, thermostats and other application specific controllers. It supports not only B-ASC, but also B-AAC, BSS and BSA  profiles. We used all our experience building various BACnet Stacks (for more than 20 years) to create a simple, elegant and helpful solution for anyone who wants to implement a BACnet device on a small platform. Many manufactures are using uBACstac to create BACnet compliant BTL listed products.

BACnet on Arduino platformBACnet on Atmel platform

What makes the uBACstac a great choice for developing a BACnet-compliant device? It is our deep knowledge of BACnet and attention to detail:

1. uBACstac supports MS/PT (master) and BACnet/IP data links.

At compilation time uBACstac can be configured to support one or both data links. If compiled with support for both datalinks, then the active data link is selected at start time.

BACnet/IP can be run on platforms which provide TCP/IP implementation, like FreeRTOS+lwIP, POSIX systems or even low-end micro-controllers with external TCP/IP processor. BACnet/IP implementation includes Foreign Device functionality.

2. uBACstac is well-structured and highly portable code designed for small platforms.

The same library source code is run unmodified on a wide range of architectures, from 8-bit ATMega to 32-bit ARM, to 64-bit POSIX (Linux) OS.

There is a well-defined and documented interface for communication with underlying hardware or operating system facilities.

Porting to a new hardware platform is as simple as it can be. For example, to implement MS/TP, only platform-specific timer ISR and UART routines for initialization and sending/receiving a byte are required. A typical implementation is under 5KB of liberally commented source code.

3. The uBACstac design is very flexible. Being just a couple of libraries, it can be easily adapted to an existing framework or integrated with an existing application. The uBACstac can be run on a wide range of architectures, ranging from bare-metal micro-controllers to real-time OSs to general purpose OSs. It does not impose any restrictions on the platform: no threads are required, no synchronization primitives (mutexes, semaphores, etc.), no memory allocation (malloc/new). These facilities can be used with uBACstac, but the portable uBACstac code does not use these.

4. uBACstac features a highly effective implementation of BACnet protocol.

  • Zero copy architecture all the way from ASN.1 encoders in an application to sending data to a UART, and back. The PDU payload is never copied or moved.
  • State of the art MS/TP implementation with optional fully backward-compatible extension to the BACnet standard allowing a window size of one on an MS/TP network.
  • Low-level receive/transmit UART functions are fully decoupled from the portable MS/TP FSM implementation, allowing the most effective implementation for a platform (DMA/ISR, even a daughter micro-controller).
  • The uBACstac is compatible with lock-free implementation. The libraries do not explicitly use any synchronization primitives, so they are compatible with any synchronization implementation.

5. uBACstac features predictable latency and is compatible with hard real time devices. The libraries do not 'sleep' or run a 'busy loop' or 'polling loop' internally.

The application code is fully decoupled from the BACnet protocol transaction state machines, so application code is not blocked when the protocol state machine is "waiting" for a message or "sending" a message to the network.

6. uBACstac supports application-layer message segmentation. This is a non-trivial task, and if the framework is not engineered for segmentation in the first place, then it is very hard to add segmentation support at a later stage.

7. uBACstac is configurable at compilation time, allowing an application developer to disable certain features, like segmentation or DCC service support, minimizing the memory footprint and processing burden.

8. The software is well structured, and interfaces are documented. The provided portable example is truly portable: it is compiled from the same source code on all supported platforms.

The example is not a trivial "switch ()/case ()" all-properties-hardcoded program, but is a flexible code, maintaining a simple object/property database. The application not only shows how basic BACnet services (like Read-Property, Read-Property-Multiple, Write-Property, Write-Property-Multiple, etc) can be implemented, but also features a full-fledged implementation of Alarm and Event reporting, including managing subscriptions, processing Event Notifications and providing BACnet clients with Event Information. The code is a good starting point for developing a real-world production-grade BACnet device. 

9. The software is designed and implemented to be robust in a real-world environment. The corner cases and possible protocol errors are treated thoroughly. For example, ASN.1 encoders check for buffer overflows and prevent memory corruption, if the encoded value does not fit in the allocated buffer. In addition, the uBACstac software transparently allocates buffers for segmented responses as needed; the application developer does not need to be concerned with this.

Learn More about uBACstac



Leave a comment

Comments will be approved before showing up.


Also in Cimetrics News

CyberSecurity Recap November 2019
CyberSecurity Recap November 2019

November 21, 2019

BACnet/SC and BAS cybersecurity, IBM unifying cybersecurity, CISA small business cybersecurity guide, New Deal Cybersecurity Summit and more..

Read More

October, 2019 Newsletter - New Deal for Buildings, Cybersecurity Summit, BACnet Consulting for Facility Managers/Building Owners and more..
October, 2019 Newsletter - New Deal for Buildings, Cybersecurity Summit, BACnet Consulting for Facility Managers/Building Owners and more..

October 31, 2019

Read More

CyberSecurity Recap October 2019
CyberSecurity Recap October 2019

October 18, 2019

New Deal Cybersecurity Summit, Future of Cybersecurity, National Security Awareness month, Security Vs Security, Cyberattacks affecting smart buildings and more..

Read More