The best way to build your small BACstac device

by Svetlana Lyons December 15, 2015

The best way to build your small BACstac device

One important trend in the 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 variaty and modest cost of different platforms such as Atmega or ARM. More and more companies are developing their own small BACstac devices and it is not a trivial task.

For the developers and anyone who wants to know more technical details here is in depth information why you want to use uBACstac.

1. UBACstac is well-structured and highly portable code.

  The same library source code is run unmodified on a wide range of architectures, from 8-bit ATMega to 32-bit ARM, to 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 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.

2. 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 wide range of architectures, ranging from bare-metal micro-controllers, to real-time OS, to general purpose OS. 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.

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

  - Zero copy architecture all the way from ASN.1 encoders in application to sending data to 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 windows size >one on 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 particular platform (DMA/ISR, even a daughter micro-controller).

  - Implementation is compatible with lock-free implementation. The libraries do not explicitly use any synchronization primitives, so they are compatible with any synchronization implementation.

4. 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.

5. uBACstac supports 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.

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

7. The software is well structured and interfaces are documented. The provided portable example is truly portable: it is compiled from the same source 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 code is a good starting point for developing a real-world production-grade BACnet device.

8. 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.




Svetlana Lyons
Svetlana Lyons

Author



Leave a comment

Comments will be approved before showing up.


Also in Cimetrics News

Cimetrics Professional Services Delivers the Promise of Analytics
Cimetrics Professional Services Delivers the Promise of Analytics

by Anto Budiardjo June 12, 2017

Combining cloud-based analytics with professional services to keep smart buildings performing.

Read More

A New Deal for Buildings - An Initiative for 21st Century Facilities
A New Deal for Buildings - An Initiative for 21st Century Facilities

by Anto Budiardjo May 31, 2017

Cimetrics is pleased to announce its support for a new industry initiative: A New Deal for Buildings.

Read More

Mass Innovation Nights #98: IoT at MITRE
Mass Innovation Nights #98: IoT at MITRE

by Svetlana Lyons May 11, 2017

Cimetrics had an honor to participate in the Mass Innovation Nights at MITRE last week in Bedford.

Read More

cimetrics.com Legal Terms and Conditions

June 29, 2016

cimetrics.com (the "Site") is owned by Cimetrics Inc. ("Cimetrics").

PLEASE READ THESE TERMS AND CONDITIONS CAREFULLY BEFORE USING THIS SITE.  YOU MAY NOT USE THIS SITE IF YOU DO NOT ACCEPT THE TERMS AND CONDITIONS.

Terms of Use

The information herein provided is for general informative purposes only, and no warranties or representations are made with respect thereto. The information may contain inaccuracies or typographical errors.  The information provided is subject to change at any time, and without notice. Changed information may include, but is not limited to, technical specifications and pricing. Binding declarations are only given after detailed enquiries.

BECAUSE THE INFORMATION IS NOT WARRANTED, ALL LIABILITY FOR THE ACCURACY OF THE INFORMATION IS EXPRESSLY EXCLUDED.

IN NO EVENT SHALL CIMETRICS, ITS OFFICERS, DIRECTORS, EMPLOYEES, PARENTS, AFFILIATES, SUCCESSORS OR ASSIGNS, BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OR PERFORMANCE OF THE CIMETRICS SITE, WITH THE DELAY OR INABILITY TO USE THE CIMETRICS SITE OR RELATED SERVICES, THE PROVISION OF OR FAILURE TO PROVIDE SERVICES, OR FOR ANY INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS OBTAINED THROUGH THE CIMETRICS SITE, OR OTHERWISE ARISING OUT OF THE USE OF THE CIMETRICS SITE, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF CIMETRICS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU. IF YOU ARE DISSATISFIED WITH ANY PORTION OF THE CIMETRICS SITE, OR WITH ANY OF THESE TERMS OF USE, YOUR SOLE AND EXCLUSIVE REMEDY IS TO DISCONTINUE USING THE CIMETRICS SITE.

Passwords

If you have been given a Password in order to gain access to certain information on this Site, or any other affiliates’ website, then you agree, as a condition of receiving said Password, that you shall keep the Password confidential. You shall only disclose the Password to your employees or agents who have a need to know. You are solely responsible for all activities that occur using your Password.

If you become aware of any unauthorized use of your Password, you agree to notify Cimetrics immediately.  Cimetrics reserves the right to revoke your Password access at any time for any reason whatsoever.

Copyrights and Trademarks

All information provided on the web pages of Cimetrics.com is protected by copyright. It is prohibited to copy, process, modify or commercially distribute this information without the express written permission of Cimetrics.

Analytika, Infometrics, Metermetrics, BACstac, BACstac/DN, and BAS-o-matic are trademarks or registered trademarks of Cimetrics.  The Analytika, Cimetrics, Infometrics and Metermetrics logos are trademarks or registered trademarks of Cimetrics.  All other trademarks are owned by their respective companies.

Links to Other Websites

This Site may from time to time contain links to other websites ("Linked Site") or other Internet information sources ("Third Party Source"). These links are provided solely as a convenience to users of this Site and do not constitute an endorsement, sponsorship or recommendation by Cimetrics.  Each Third Party Source or Linked Site may have its own terms of use and privacy policy. Cimetrics is not responsible for the content, availability, or policies of any Linked Site or Third Party Source, or any additional links contained therein.

Privacy

Please read the privacy policy for this Site, which is incorporated into these Terms and Conditions by reference.