Giter Club home page Giter Club logo

bacnet-stack / bacnet-stack Goto Github PK

View Code? Open in Web Editor NEW
347.0 37.0 173.0 31.43 MB

BACnet Protocol Stack library provides a BACnet application layer, network layer and media access (MAC) layer communications services.

Home Page: http://bacnet.sourceforge.net/

GDB 0.01% Makefile 1.84% Shell 0.15% Batchfile 0.02% C 90.59% C++ 0.85% HTML 0.91% Assembly 3.21% Lua 0.07% Perl 0.16% CMake 2.19% Dockerfile 0.01%
bacnet bacnet-ip bacnet-library bacnet-client bacnet-server c ip ipv4 ipv6 embedded

bacnet-stack's Issues

make BACDL_DEFINE=-DBACDL_ALL=1 fail

make BACDL_DEFINE=-DBACDL_ALL=1 fail
make BACDL_ALL=1 fail
make BACDL_DEFINE=-DBACDL_ALL=1 BACDL_ALL=1 fail

So how to make it support all the datalinks?

CMakeLists MS/TP issue

Wondering if the CMakeLists.txt should be changed like so:

    ...
-   $<$<BOOL:${BACDL_MSTP}>:src/bacnet/datalink/mstp.h>
+   $<$<BOOL:${BACDL_MSTP}>:src/bacnet/datalink/mstp.c>
    src/bacnet/datalink/mstpdef.h
    src/bacnet/datalink/mstp.h
    ...

Currently if BACDL_MSTP is defined, the line will be the same as the one two lines down.

If so, I can create a PR.

do new release to github

some build systems normally take tags and not commits e.g. yocto build system, conan package manager

It would be great if we could make a e.g. patch release as now we have cmake support and can use this to be cross platform.

unused var warnings when not PRINT_ENABLED

While compiling for Zephyr with PRINT_ENABLED false, the following warnings were reported. Each needs the auto variable definition to also be conditionally compiled.

src/bacnet/basic/service/h_ccov.c:71:28: warning: unused variable 'pProperty_value' [-Wunused-variable]
BACNET_PROPERTY_VALUE *pProperty_value = NULL;

src/bacnet/basic/service/h_rpm_a.c:201:10: warning: unused variable 'array_value' [-Wunused-variable]
bool array_value = false;

src/bacnet/basic/service/h_ucov.c:64:28: warning: unused variable 'pProperty_value' [-Wunused-variable]
BACNET_PROPERTY_VALUE *pProperty_value = NULL;

APDU Timeout!

Hello,

I've built the latest source from github on Fedora 31 and trying to connect to Siemens PXC100E.D (configured and running).

Ethernet: enp6s0 - 10.180.220.8 by DHCP
Controller: 10.180.220.6 static, BDT/FDT enabled
Firewall: off

[zoltan@fedora bin]$ env BACNET_IFACE=enp6s0 ./bacwi -1
Device MAC (hex) SNET SADR (hex) APDU


4194303 0A:B4:DC:02:BA:C0 0 00 1476
2124801 0A:B4:DC:06:BA:C0 0 00 1476

Total Devices: 2

[zoltan@fedora bin]$ env BACNET_IFACE=enp6s0 ./bacepics -v 2124801
Error: APDU Timeout! (10s)
}
End of BACnet Protocol Implementation Conformance Statement

[zoltan@fedora bin]$ env BACNET_IFACE=enp6s0 ./bacepics -v 4194303
Error: Unable to bind to 4194303 after waiting 10 seconds.
Error: APDU Timeout! (11s)

[zoltan@fedora bin]$ env BACNET_IFACE=enp6s0 ./bacepics -t 0A:B4:DC:06:BA:C0 -v 2124801
Error: APDU Timeout! (10s)
}
End of BACnet Protocol Implementation Conformance Statement

[zoltan@fedora bin]$ env BACNET_IFACE=enp6s0 ./bacepics -t 0A:B4:DC:02:BA:C0 -v 4194303
Error: APDU Timeout! (10s)
}
End of BACnet Protocol Implementation Conformance Statement

What should I do to get the communication working? My understanding is that this should work out of box, if compile was successful.
I have no clue what is the 4194303 device, only one Bacnet device is on the network.

Thanks

win32 port: undefined reference to mstimer_now'

root@debian:/home/kmd/bacnet-stack# make  BACNET_PORT=win32  router-mstp
make -s -C apps router-mstp
/usr/bin/i686-w64-mingw32-ld: /home/kmd/bacnet-stack/src/bacnet/basic/sys/mstimer.o:mstimer.c:(.text$mstimer_set+0xf): undefined reference to `mstimer_now'
/usr/bin/i686-w64-mingw32-ld: /home/kmd/bacnet-stack/src/bacnet/basic/sys/mstimer.o:mstimer.c:(.text$mstimer_elapsed+0x7): undefined reference to `mstimer_now'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:63: router-mstp.exe] Error 1
make[1]: *** [Makefile:287: router-mstp] Error 2
make: *** [Makefile:110: router-mstp] Error 2




execute tests with github ci

currently we are only building for the three major OSs, linux, mac, win32.

there are no tests beiing executed.
If tests were executed with CI, we could also get test coverage reports etc.

Zephyr module cleanup (west 0.8.0a1)

west 0.8.0a1 supports specifying manifest files elsewhere in the tree. This introduces the config setting 'manifest.file config' and clarifies the meaning of the config 'manifest.path'. This requires updating how this repository uses manifest files.

To Do:

  • Remove the top level west.yml
  • Add self to the zephyr/modules/** manifest files
    ? Clean out ZEPHYR_EXTRA_MODULES if no longer needed.

Zephyr struct sockaddr_in has no explicit padding field

In the Zephyr environment, the struct sockaddr_in definition does not include explicit padding fields. This means the src/BACnet/datalink references to the sin_zero padding field are invalid for that environment, resulting in portability issues.

Large BSS Size

Hi All,
Trying to implement a small server example based on ti-rtos gcc (~256k SRAM), I thought I read somewhere this stack had a very small footprint (on the order of 40k but I can't find where I got this information). So far I have enabled only the "I am" service, "Read Property" Service enabled. I really only need Analog Input objects for my demo, but even without using those i am still 190k over the BSS size in my chip. Is this target just too small to handle this stack?

Best,

Add cmake support

Cmake is the most used build system which is supported by most ides now (vscode, qtcreator, visual studio, clion, etc)

It is now also natively supported on windows with visual studio (open project and it works)

It would be great therefore to add cmaks support to this project
We could sponsor this feature

@skarg what do you think?

Crash with Alarms in Inneasoft BACnet Explorer

Inneasoft BACnet Explorer sends only 4 Bytes for getAlarmSummary: ADPU 02 75 2b 03
That leads to a crash because service_choice is NULL.

Fix: Replace line 334 in h_apdu.c if (apdu_len >= (len+2))
with

	if (apdu_len == (len + 1)) {
		*service_choice = apdu[len++];		// no request data as seen with Inneasoft BACnet Explorer
		*service_request = NULL;
		*service_request_len = 0;
	} else if (apdu_len >= (len+2)) {

Add SPDX license short-form identifier to source file headers

Software Package Data Exchange® (SPDX®) is an open standard for communicating software bill of material information (including components, licenses, copyrights, and security references).

Use SPDX short-form identifiers to communicate FOSS license information
in a simple, efficient, portable and machine-readable manner

The core source files are licensed:
/* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0 */

Most basic (demo) files are licensed as MIT:
/* SPDX-License-Identifier: MIT */

Segmentation fault apps/router using Debian 10 & CentOS 8

I am getting "Segmentation fault" errors while running the router app using Debian 10.7 and CentOS 8.3 Linux. Also tested Oracle Linux 8 and Fedora 33, same error. I had success running the router app using Debian 9.13 and CentOS 7.7. See gdb debug below:

(gdb) run -c init.cfg
Starting program: /home/router -c init.cfg
Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-127.el8.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
warning: Loadable section ".note.gnu.property" outside of ELF segments
I am router
opt = c
dev_type = bip
dev_type = mstp
cmd file parse success
[New Thread 0x7ffff7059700 (LWP 4545)]
Interface: ens18
IP Address: 10.42.32.183
IP Broadcast Address: 10.42.32.255
UDP Port: 0xBAC0 [47808]
[New Thread 0x7ffff6858700 (LWP 4546)]
Initializing...
RS485: Initializing /dev/ttyUSB0=success!
[New Thread 0x7ffff6057700 (LWP 4547)]

Thread 1 "router" received signal SIGSEGV, Segmentation fault.
0x00000000004083f4 in create_network_message ()
Missing separate debuginfos, use: yum debuginfo-install libconfig-1.5-9.el8.x86_64
(gdb)

Stm32 port: pin remapping

the two default I/O in the stm32 example dont appear to change actual physical pins when requested to set or clear its values. Which physical IOs are mapped to the ones recognized by the software? And how could one change those?

Can't build /ports/linux/dlmstp_linux.h on Alpine Linux

In file included from /src/ports/linux/rs485.c:73:
/src/ports/linux/dlmstp_linux.h:29:10: fatal error: bits/pthreadtypes.h: No such file or directory
   29 | #include "bits/pthreadtypes.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
cc: error: /src/ports/linux/rs485.o: No such file or directory
size: 'mstpcap': No such file
cp: can't stat 'mstpcap': No such file or directory

I think all that needs to be done is to replace bits/pthreadtypes.h with sys/types.h.

How to set network number in bacserv

I use Network_Port_Network_Number_Set(1, 49999) to set the network number as 49999 in bacserv sample app,
and then I use YABE to explore my sample bacserv, I can find the network number is 49999 in "OBJECT_NETWORK_PORT:1" of my simulated device.

But when I use "./bacwi --dnet 49999" to request bacnet device with network 49999, I can not find any device, only find device by "./bacwi --dnet 0".

Does any one can help me to know what wrong and guide me to correct it? Thanks a lot.

Python wrapper for BACnet/MSTP

Hi ! I'm wondering if I could have some help from you to build a C Extension from the stack to allow Python to use MSTP.

Speed and timers being at the core of MSTP, it's very hard (let say it won't be possible) to have MSTP working in pure Python... but it would be possible as a C extension.

My C knowledge is -2 on a scale of 0 to 10... but I could help with the Python part.

[ref] https://docs.python.org/3/extending/building.html

That would be a super nice add-on to our projects.

https://github.com/ChristianTremblay/BAC0
https://github.com/JoelBender/bacpypes

Thanks !

Higher Level Abstraction

Hello, are there any plans for higher levels of abstraction for your stack? Something like a communication object for client/server use with methods for reading/writing data or subscripe covs. Its really hard to start working with your stack. All demos work fine but there is no starting point for using the stack in own applications.

apps/router need bip.o?

admin@ubuntu:~/bacnet-stack/apps$ make router make -s -b -C router make[1]: *** No rule to make target '../../src/bacnet/datalink/bip.o', needed by 'router'. Stop. Makefile:278: recipe for target 'router' failed make: *** [router] Error 2

How to add multiple device object in BACnet server demo(using BACnet/IP).

Setup details:
BACnet server application running on Linux system (Ubuntu 18.04).
Yabe(Yet another BACnet explorer) on windows system to get the BACnet the server information.
Bacnet Stack from branch bacnet-stack-1.0

  • To add multiple device object, we have modified Device_Count API so that we can have more than one device object. we can see multiple device objects in Yabe(yet another BACnet explorer) tool, but the fields(instance number, name) are same for all the device objects.

Checked multiple demos but not able to find the one with multiple device object. The gateway demo is adding multiple routing device but the demo is not getting compiled(instruction used: make -s -C apps/gateway). Inside CMakeLists.txt gateway related lines(527 and 528) are commented.

The objective of my project is to have multiple BACnet device object and each device object should have multiple analog/binary input/output objects.

APDU Timeout! and TSM Timeout!

Hello,

I've built the latest source from github on Ubuntu 16.04 and trying to connect to Legrand RCU (Bacnet enabled Room Control Unit).

Ethernet: eth0 - 192.168.0.222 by DHCP.

root@Milan-One:/var/www/Milan/bacnet-stack-master/bin# ./bacwi -1
;Device MAC (hex) SNET SADR (hex) APDU
;-------- -------------------- ----- -------------------- ----
7141 C0:A8:00:DE:BA:C0 0 00 1000
;
; Total Devices: 1

  1. APDU Timotout Error
    root@Milan-One:/var/www/Milan/bacnet-stack-master/bin# cd bacnet-stack-master/bin/./bacepics -v 7141
    -bash: cd: bacnet-stack-master/bin/./bacepics: No such file or directory
    root@Milan-One:/var/www/Milan/bacnet-stack-master/bin# ./bacepics -v 7141
    Error: APDU Timeout! (10s)
    }
    End of BACnet Protocol Implementation Conformance Statement

  2. TSM Timotout Error:
    root@Milan-One:/var/www/Milan/bacnet-stack-master/bin# ./bacwp 7141 1 0 85 16 -1 0 0
    Error: TSM Timeout!
    root@Milan-One:/var/www/Milan/bacnet-stack-master/bin# ./bacrp 7141 1 1 87
    Error: TSM Timeout!

What should I do to get the communication working? My understanding is that this should work out of box, if compile was successful.

Thanks

Error Build ESP32

I get an error when I build a project ..\ports\esp32.
I have followed the readme.txt but failed
libraries/bacnet/bacnet/datalink/bip.h:26:21: fatal error: bacport.h: No such file or directory
Can Team help me?

Changing Project Name Causes Issues

Hello, I am looking to change the Cmakelists file slightly so it can build two separate shared libraries of the stack, one for IP and the other for MSTP. It would look something like this:

if(BACDL_BIP)
project(bacnet-ip VERSION 1.0.0 LANGUAGES C)
elseif(BACDL_MSTP)
project(bacnet-mstp VERSION 1.0.0 LANGUAGES C)
endif()

However, before even adding that, if I try change the existing project from:

project(bacnet-stack VERSION 1.0.0 LANGUAGES C)

to something slightly different:

project(bacnet-stack1 VERSION 1.0.0 LANGUAGES C)

When set to "bacnet-stack", the library produced works and is usable in my project. If set to "bacnet-stack1" though, the library is over 100 KB smaller and seems to be missing a lot of symbols and cannot be used with my project.

I am just wondering do you know if there is a way to get around this so the resultant stack library produced can be named something other than libbacnet-stack.so

Cant build on FreeBSD 11

Is anyone trying even to run and build BACNET stack on FreeBSD 11/12 ? Under FreeBSD 11 64bit I cannot go far:

krmx@fbsd11:~/bacnet-stack-bacnet-stack-1.0.0 % gmake BACNET_PORT=bsd all
gmake -s -C apps all
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:435:16: warning: variable 'addr_ptr' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    } else if (sockaddr_ptr->sa_family == AF_INET6) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:438:12: note: uninitialized use occurs here
    return addr_ptr;
           ^~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:435:12: note: remove the 'if' if its condition is always true
    } else if (sockaddr_ptr->sa_family == AF_INET6) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:432:19: note: initialize the variable 'addr_ptr' to silence this warning
    void *addr_ptr;
                  ^
                   = NULL
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:465:24: warning: variable 'rv' is uninitialized when used here [-Wuninitialized]
                return rv;
                       ^~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:451:12: note: initialize the variable 'rv' to silence this warning
    char rv; /* return value */
           ^
            = '\0'
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:471:24: warning: variable 'addr_ptr' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            } else if (strcmp(request, "netmask") == 0) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:474:17: note: uninitialized use occurs here
            if (addr_ptr) {
                ^~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:471:20: note: remove the 'if' if its condition is always true
            } else if (strcmp(request, "netmask") == 0) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:463:27: note: initialize the variable 'addr_ptr' to silence this warning
            void *addr_ptr;
                          ^
                           = NULL
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/bip-init.c:625:9: warning: unused variable 'sock_fd' [-Wunused-variable]
    int sock_fd = 0;
        ^
4 warnings generated.
/usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/mstimer-init.c:31:10: fatal error: 'mach/clock.h' file not found
#include <mach/clock.h>
         ^~~~~~~~~~~~~~
1 error generated.
gmake[2]: *** [Makefile:37: /usr/home/krmx/bacnet-stack-bacnet-stack-1.0.0/ports/bsd/mstimer-init.o] Error 1
gmake[1]: *** [Makefile:210: readprop.all] Error 2
gmake: *** [Makefile:34: apps] Error 2

Questions:

  • what is this prefix ? bacnet-stack-bacnet-stack-1.0.0 ? can't you fix the release properly to have bacnet-stack only ?
  • any ideas about FreeBSD 11 compile errors ?

Manually setting the RTS pin for RS-485

First of all, thank you for this library, great work :)
I'm trying to to communicate with a BMT-DO4. This is working fine when using an USB RS-485 dongle. But as soon as I try to use the native RS-485 port instead of the USB dongle, the communication fails (sending a bind request, but can never bind until it timeouts).
My understanding is that I would need to manually set the RTS pin high and low depending on when I'm transmitting or receiving a frame.
Where would be the best place to add such a change? As far as I know/understand, libmodbus did something similar as it can be seen here:
https://github.com/stephane/libmodbus/blob/master/src/modbus-rtu.c

Arduino_uno port

Dear Steve;

I still have troubles compiling Arduino_uno port. Did you know who was the developer of that part of the stack?

Regards

Adriano

Add app handler in the demo of router?

I'm developing my bacnet program base on the demo of router. The demo currently can only route message from this port to the other.
How can the router handle the App message incoming for itself?

I try to add some app handler, for example, "read property", "I-am", etc., on the demo, but it seems not appropriately to do this because it has to judge which port to request/ack the message and it works not quite well.
can Anybody give me some suggestions?

Move folders and use deep path include file names to prevent collisions

Compiling and linking the BACnet Stack library with other libraries
has been a challenge to me and others over the years due to header
name collisions, function naming collisions, file name collisions, and
argument name collisions. I have some ideas about fixing those, but it
will require some movement in the folder structure, file name changes,
and some include file name changes. I've become a big fan of the
Linnaeus naming convention, and have been working with other libraries
(Contiki, cryptoauthlib, mbedtls) that do a good job of handling file
and folder naming to avoid collisions (mostly!).

References:
namingconventions.htm
contiki-ng
cryptoauthlib
mbedtls

Bacnet MSTP

Hello, I'm working on io for bacnet.
bacnet ip successfully completed but I do not know about mstp.

1.Do I need to separate devices as master slaves ? And how can I do this.?
2. Can you share with me sample code for mstp ?

Building shared bacnet-stack libraries using cmake fails + openssl

Hello,

While helping to package this project at conan-io/conan-center-index#909, I noticed some problems with bacnet-stack.

  • When building shared libraries using cmake, the build fails.
    I think this is because the linux build has not all files included.
  • Also, some files use OpenSSL, but the cmake script does not look for it.
    It requires a find_package(OpenSSL) somewhere + use of the variables/targets.
  • macos fails to build

Fixing these issues should also fix some potential problems with the static build.

travis output
https://travis-ci.com/madebr/bacnet-stack/jobs/288603211
changes to .travis.yml:
madebr@4204122

AI object value range

regarding ai object, is there a default range stated by the bacnet specification? like 0-100? or can it be just any float number? Im having an issue porting ai.c to the stm32 port, in which the max value being read by the ADC(around 4095 for the 12-bit ADC), is being read by the bacnet client as 5.7, and around half that(around 1.66V at the ADC input) is being read as 2.9~. Why is 4095~ integer being interpreted as 5.7? I know it's probably a type casting issue, but I can't figure it out. if there's an easy fix I'm not seeing, please help.

Indent and style for source code

Indent and style. It has been harder to find 'indent' on some platforms. I've been using clang-format for a lot of other projects, and it is easier to integrate into the continuous integration tools.
https://clang.llvm.org/docs/ClangFormat.html

Of course, finding a similar indent style to match the existing indent style in the BACnet Stack library using clang-format configurations has been challenging. But, clang-format does a much better job of preventing ugly code. Thus far I use the following - do you have any suggestions?

BasedOnStyle: google
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
BreakBeforeBraces: Linux
IndentWidth: 4
SortIncludes: false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.