Commit Graph

3306 Commits

Author SHA1 Message Date
Steve Karg ab5481ff90 Fixed the length of the basic Network Port object MAC address property. (#741) 2024-08-22 08:10:10 -05:00
Kari Argillander 9662a76ebd Make clean build with MSVC /Wall (#740)
* ci: Fix compile warning as errors was not correct

We want to enable warning as errors both Windows and Linux. This is
easiest to do with cmake option as -Werror does not work with MSVC. Also
it is self explaining what it does so no comment needed.

* dlmstp_linux: Fix -Wdeclaration-after-statement compiler warnings

Make dlmstp_linux C89/C90 combatible

```
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘Timer_Silence’:
/bacnet-stack/ports/linux/dlmstp_linux.c:56:5: warning:
 ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   56 |     int32_t res;
      |     ^~~~~~~
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘dlmstp_init’:
/bacnet-stack/ports/linux/dlmstp_linux.c:795:5: warning:
 ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  795 |     struct termios newtio;
      |     ^~~~~~
```

* Fix warnings produces by MSVC

Now that we have enabled /Wall for MSVC we get some warnings with it
which can be easily fixed.

We get following warnings:

```
src\bacnet\bacstr.c(223,39): warning C4127: conditional expression is constant
apps\router-mstp\main.c(1123,1): warning C4702: unreachable code
apps\epics\main.c(885,53): warning C4459: declaration of 'myState' hides global declaration
```

* cmake: Use /Wall with MSVC

Make MSVC to build cleanly with Wall. This might matter for some Windows
developers. And you never know if MSVC will find more bugs.

* cmake: Improve router build

Router build gives some warnings as it is not C90 compatible. It is ok
that example is not following C90 rules. Also it is annoing to new user
to build this cmake as first error usually is that libconfig is not
found. Let's just give warning about this so first build will usually go
smoother.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-22 07:50:20 -05:00
Steve Karg 76d605e06b Added load control object into zephyr basic device example (#739) 2024-08-21 15:01:25 -05:00
Tomasz Kazimierz Motyl cbd5f43684 Added clauses c) and f) of 13.3.6 (out_of_range) algorithm and enabling transitions from high/low limit states to normal when Event_Enable = 0 for the basic Analog Value and Analog Input objects (#733) 2024-08-21 14:36:37 -05:00
Kari Argillander d92edd359f Fix couple compiler warnings (#737)
* linux/bip6: Use function over PRINTF macro

Our repo should be C89 compatibale. C89 does not support variac macros.
For this reason use variac functions. This also enables to print
different streams than just stderr.

Also now if something is changed in debug_fprintf it also affect here
which is good.

* Use __inline__ over inline in library

Use __inline__ over inline as that is C89/C90 combatible. With MSVC we
need to use __inline so just define __inline__ to it if not already.

* h_get_alarm_sum: Fix -Wself-assign compiler warning

We get Wself-assign if PRINT_ENABLED is 0

```
src/bacnet/basic/service/h_get_alarm_sum.c:129:16:
  warning: explicitly assigning value of variable of type 'int' to itself
  [-Wself-assign]
[build]   129 |     bytes_sent = bytes_sent;
[build]       |     ~~~~~~~~~~ ^ ~~~~~~~~~~
```

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-21 09:44:31 -05:00
Tomasz Kazimierz Motyl 5c20e6d505 Merge pull request #59 from se-apc/bugfix/out_of_resources_error_on_cov_address_list_depletion (#734)
We report an error: resources, no-space-to-add-list-element on reachng MAX_COV_ADDRESSES limit with COV subsriptions

Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-08-21 09:23:10 -05:00
Steve Karg 20c3b1c69c Fixed zephyr BACnet/IP for use in native_posix. Fixed zephyr logging level for BACnet. (#738) 2024-08-20 15:21:03 -05:00
Steve Karg f09a0ce5ed Added prototype for device object property list member to use for storing device data storing. (#735) 2024-08-19 09:32:52 -05:00
Steve Karg 032bf10994 Added mstpcap to apps/Makefile BSD build (#730) 2024-08-17 08:52:37 -05:00
Steve Karg e3098bbaa2 Added device WriteProperty callback for non-volatile storing in basic device examples. (#728) 2024-08-16 14:13:56 -05:00
Steve Karg e1002c433f Revert "Zephyr 3.7.0 integration fixes: (#723) (#724)"
This reverts commit 2d7a2961a2.
2024-08-16 09:02:24 -05:00
Steve Karg e9bcaa746c Fixed endless query in bac-rw module when error is returned. (#727) 2024-08-16 08:28:25 -05:00
Kari Argillander dab6d8af55 Build more code in CI (#725)
* bugfix/hostnport: Fix bacnet_fdt_entry_from_ascii() parse wrong
* apps/router: Fix Wstrict-prototypes compiler warnings
* apps/router: Fix -Wmissing-field-initializers compiler warning
* ports/linux: Fix -Wself-assign compiler warning
* ports/linux: Fix -Wunused-function compiler warning
* Fix -Wimplicit-function-declaration warnings
* ci: Add more compile options to enable more code build
* ci: Do not fail-fast our main matrix build
* cmake: Add -Wno-c99-extensions compiler option

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2024-08-15 11:20:10 -05:00
Greg Shue 2d7a2961a2 Zephyr 3.7.0 integration fixes: (#723) (#724)
- Update west.yml
- Update samples.yaml to new syntax, board names
- Patches to ports/zephyr (some stubs)

Verified by:

1. ./zephyr/scripts/twister -p unit_testing -T bacnet-stack/zephyr/tests

2. ./zephyr/scripts/twister -T bacnet-stack/zephyr/samples/ --integration

Fix #721

Co-authored-by: Gregory Shue <gregory.shue@legrand.com>
2024-08-15 07:24:09 -05:00
Kari Argillander 40c5570d64 Force C89/C90 compatible and for test C99 (#722)
* bacint: Do not use ULL suffix

For sake of be more compatible with C89/C90 let's not use ULL at all.
Overall conversion functions are lot cleaner now. Only idiotic thing is
in bacnet_unsigned_length() where we need to do shift. There is probably
better way to do that but could not come up any at resonable time.

* Force C89/C90 and for tests C99

bacnet-stack seems to be all compatible with C89/C90. This is probably
design choice. Let's force this in CMake so no one will break that by
accident.

In tests we are using some C99 features already. Let's not be to strict
about those as those are "just tests".

* Fix -Wdeclaration-after-statement warnings

To make code C89/C90 compatible fix -Wdeclaration-after-statement
warnings.

We got like following warning without this change.

```C
bacnet-stack/apps/epics/main.c:293:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement
  293 |     uint32_t Object_Instance;
      |     ^~~~~~~~
```

* cmake: Add -Wno-c99-extensions compiler option

Clang does not like _Bool which is used in stdbool.h files. For now
let's just ignore this. We could define that differently but let's think
that another time. Now goal is to get warning free CI with more code to
be builded in there.

* cmake: Add -Wno-long-long compiler option for apple

Apple seems to do stupid things with their system header. There is
UINT64_MAX with ULL suffix and not like in Linux and Windows

  __UINT64_C(18446744073709551615)

For this reason we need to ignore Wlong-long for it.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-15 07:23:04 -05:00
Steve Karg c1195dd8a0 Added CreateObject, DeleteObject, and COV to Integer Value object (#719)
Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-08-14 08:54:03 -05:00
Kari Argillander 6271632944 Add and fix compiler warnings (#718)
* Add and remove compiler warning compile options

Add some new compiler warnings. Some of those does not build clean so
ignore them for now. This also helps if some user use those options so
we ignore those for them also.

Also remove following ignores as they do not produce any warnings:

  - Wno-attributes
  - Wno-long-long
  - Wno-implicit-fallthrough

* Fix -Wmissing-declarations compiler warnings

Fix new -Wmissing-declarations compiler warnings. I tried to look which
should be in headers and which should be static. Might be that some
statics should be in header as it is not easy to choose if something
should be exported or not.

* Fix -Wmissing-field-initializers compiler warnings

If we use { { 0 } } compiler thinks we might have mean that we only
meant initialize first member of struct or have forgotton to add second
one. We could do { { 0 }, 0 } but we can just do { 0 } which tells
compiler that hey just intialize this whole thing to zero.

* tests: Fix couple -Wfloat-conversion warnings

Add f prefix to floating point numbers to get some double to float
warnings away.

* ci: Make warnings as errors with cmake main build

To keep repo more clean from warnings use Werror flag when building main
project.

Windows should need -DCMAKE_C_FLAGS="/WX" but we have not ignore errors
for that yet so let's not yet take it in use.

* ci: Build also tests in matrix build

Enable also tests to be builded in our main matrix build. This way tests
will be builded also with clang and in future also with MSVC. We also
keep build very clean now as all warnings as catched.

With this we can also take out -Werror from compile_options as we add
that in CI. It is not good practice to keep that option always on. It
makes development lot harder. See example this blog post [1].

[1]: https://embeddedartistry.com/blog/2017/05/22/werror-is-not-your-friend/

* getevent: Deprecate getevent_encode_apdu()

Steve suggested that we should deprecate getevent_encode_apdu() [1].

Suggested-by: Steve Karg

[1]: https://github.com/bacnet-stack/bacnet-stack/pull/718#discussion_r1715821735

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-13 16:32:44 -05:00
Kari Argillander cb243c36a8 Improve SPDX identifier coverage (#716)
* Change MIT license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change GPL exception license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change misc license texts to SPDX-License-Identifier

There are some external code in repo which are not licenses as most of
the stuff in this repo. We still want every file to have SPDX identifier
to easily grep licenses.

* Add currently used license files

Even though Bacnet-Stack is using SPDX identifiers we still need to give
those license files with source. For this reason add all license files
to license/ folder.

SPDX has also files which would make same thing but this is style which
example Linux kernel is using and it is quite clear so I choose that one
for now.

I choosed not yet bring CC-PDDC as that is not right license for those
files.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-12 15:33:02 -05:00
Steve Karg e5307e280c Added CreateObject and DeleteObject to Load Control object. (#713) 2024-08-11 19:14:27 -05:00
Steve Karg ebb8be067f Removed extraenous coverage recipe in test all recipe. 2024-08-07 11:44:15 -05:00
Steve Karg 81e83b19c1 Fixed Lighting Output unit test builds after recent fixes added debug printing and implicit float to double promotion. 2024-08-07 11:27:51 -05:00
Steve Karg 18d4b47b2c Fixed Lighting Output object lighting command decoding and ramp operations 2024-08-07 11:07:23 -05:00
Steve Karg 350bbe3331 Fixed implicit conversion from float to double in lighting output and color. 2024-08-06 17:22:27 -05:00
Steve Karg 19f276b7f2 Fixed implicit conversion of float to double when using snprintf() format specifier %f. 2024-08-06 16:41:42 -05:00
Steve Karg b5e0aa97fc revert LCOV changes to test Makefile 2024-08-06 16:30:56 -05:00
Steve Karg be65abe159 Fixed unit test compiler warnings 2024-08-06 16:19:08 -05:00
Steve Karg 1be0aa39b9 Fixed compile warnings and BACnet priority array decoding (#712)
* Fixed network port warning for unused static function.

* Fixed BACnetPriorityArray decoding in bacapp module

* Fixed epics print of BACnetDateTime complex data.
2024-08-06 14:10:03 -05:00
Steve Karg a1d91dbeb1 Updated B-SS profile sample build for Zephyr OS. (#711) 2024-08-06 09:52:10 -05:00
Steve Karg 61730e3d87 Fixed load control object and unit test. Added recipe to Makefile for Zephyr OS twister unit testing. (#710) 2024-08-06 08:28:01 -05:00
Steve Karg ebfaa5eb2c Added Exception_Schedule property to schedule object example. (#709) 2024-08-01 12:15:57 -05:00
Steve Karg 4ee3bb6fa2 Added create and delete methods to basic device object table for calendar object. 2024-07-31 09:42:41 -05:00
Eric Miller bdf63f4b19 Fixed typo in command line argument check of example app for BACnet Network-Number-Is (#707) 2024-07-30 12:03:54 -05:00
Steve Karg c55f5e2886 Added alaternate define for BACNET_NPDU_DATA as BACNET_NPCI_DATA. 2024-07-29 07:17:33 -05:00
Michael O'Neill 274781a8bc Added mstpcap for MacOS (#705)
* Updated the Makefile for mstpcap to accomodate macOS and to build the bacnet lib. Compiling working version of mstpcap on macOS 14, although compiling should work on many earlier versions.  The --extcap-interfaces flag now works for macOS which allows one to use mstpcap as an extcap for Wireshark while listing the available serial ports and baud rates.

* note: Had to use uname to figure out if one is on Darwin/macOS vs vanilla BSD. From there, macOS specific supported features and location are used. For instance, the 76800 baud rate is natively supported.

* note: MacOS doesn't like placing the mstpcap executable in the global extcap plugin directory as it corrupts the Wireshark executable from an xattr and SIP (System Integrity Protection) perspective and macOS will refuse to run it calling it 'corrupt'. One could turn off xattr stuff, using xattr -cr, but could be risky long term. A safer, permissible workaround is to place the executable in the user .local extcap directory: '/Users/<your_user_name>/.local/lib/wireshark/extcap/'. If the directory doesn't exist just create it and copy the executable there.

* note: make the executable from the root or apps folder, as there are defines in the apps folder that are common to all the apps. The mstpcap executable is copied to bacnet-stack/bin/ folder.

---------

Co-authored-by: Michael O'Neill <em.pee.oh@gmail.com>
2024-07-26 16:23:40 -05:00
Steve Karg 4326128e72 Secure ReadProperty decoding and BACnetActionCommand (#702)
* Refactored and secured BACnetActionCommand codec into bacaction.c module for command object and added to bacapp module encode/decode with define for enabling and pseudo application tag for internal use.

* Simplified bacapp_data_len() and moved into bacdcode module as bacnet_enclosed_data_len() function.

* Secured ReadProperty-REQUEST and -ACK decoding.

* Removed deprecated Keylist_Key() functions from usage.

* Removed pseudo application datatypes from bacapp_data_decode() which only uses primitive application tag encoded values.

* Defined INT_MAX when it is not already defined by compiler or libc.

* Deprecated bacapp_decode_application_data_len() and bacapp_decode_context_data_len() as they are no longer used in any code in the library.

* Added BACnetScale to bacapp module. Improved complex property value decoding. Refactored bacapp_decode_known_property() function.

* Refactored and improved the bacapp_snprintf() function for printing EPICS.

* Fixed Lighting Output WriteProperty to handle known property decoding.
2024-07-25 17:12:08 -05:00
Steve Karg 923eaf2313 Added some dependency into zephyr kconfig for BACnet/IP builds. Updated simple sensor sample. 2024-07-24 10:38:24 -05:00
Steve Karg 4694b9b2eb Added bacnet-basic callback in zephyr subsys to include init and task in same thread. 2024-07-23 15:27:39 -05:00
Eric Miller 39f08d253b Modifications for ASHRAE 135-2020cn engineering units (#703) 2024-07-22 16:39:13 -05:00
Steve Karg 766e0c020d Create bacnet strnlen and stricmp to avoid libc compiler problems 2024-07-22 16:22:36 -05:00
Steve Karg 3864421ac8 Fixed compile warning in network port object. 2024-07-22 16:04:40 -05:00
Steve Karg 142d50db16 Added more kconfig for zephyr build. Added more creatable objects for zephyr build. 2024-07-22 15:40:20 -05:00
Steve Karg 3246d6bd72 Fixed zephyr B-SS sample build under native_sim 2024-07-22 14:56:12 -05:00
Önder Görmez 55f757c8a2 Fix typo (#701)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2024-07-21 10:19:30 -05:00
Steve Karg e2349b719f Fixed bitstring-value header file duplication. 2024-07-19 17:22:13 -05:00
Steve Karg 00ab206075 * Changed header file include guards to unique namespace. Updated file headers comments with SPDX [issue #55] (#666) 2024-07-19 17:16:28 -05:00
Steve Karg 1e889b633c Added Zephyr settings and basic device in subsys. (#697)
* Added Zephyr settings subsys to enable storing of BACnet values according to BACnet object property value path.

* Added BACnet Basic features to enable basic samples. Refactored the zephyr BACnet profile B-SS sample to use BACnet basic subsys.
2024-07-19 17:12:20 -05:00
Steve Karg 90714c094c Fixed BACnetHostNPort known property decoding. (#700)
* Fixed BACnetHostNPort known property decoding.

* Added BDT-Entry and FDT-Entry to BACapp for known property encoding/decoding.
2024-07-19 16:45:09 -05:00
Nandkishor Biradar fd2f33b522 Fixed MS/TP that was not working in ports/win32 (#694) 2024-07-19 07:53:16 -05:00
GauiStori e984a19885 Added reject response to unknown reserved network layer message types. (#690) 2024-07-17 14:37:36 -05:00
GauiStori a12c552601 Added a check for apdu_len exceeding MAX_APDU in apdu_handler() for confirmed service and ignore the message if the APDU portion of the message is too long. (#696) 2024-07-17 12:13:56 -05:00