Commit Graph

3347 Commits

Author SHA1 Message Date
Patrick Grimm 712dda8bbe fix server app doesn't work with BAC_ROUTING (#783) 2024-10-04 13:47:52 -05:00
Patrick Grimm 90dcd9dca1 win32: fix ethernet and bip6 (#774)
Switch from WinPcap ton npcap.
Include npcap sdk in cmake
add libs for ipv6 in cmake
fix ethernet uninitialized var
2024-10-04 13:46:34 -05:00
Jonathan 442f0bdf1c gcc.yml : Add LEGACY flag to make bip-apps with GNU99 (#795)
Otherwise, there were a lot of warnings
2024-10-04 13:43:41 -05:00
Jonathan 97cb612d6d netport.c : Tiny improvements (#792) 2024-10-02 08:05:06 -05:00
Steve Karg c18768ba61 Fixed BACnetAccessRule application integration into Access Rights object. Improved unit testing and code coverage. (#790) 2024-09-30 14:04:30 -05:00
Steve Karg 7b18add6d3 Issues/issue 787 app bacepics misses optional parameters for the device object (#789)
* Added some optional properties into the object property lists up to protocol-revision 22

* Added serial-number property to basic device object example.
2024-09-27 16:22:58 -05:00
Steve Karg 3eee88dd31 Added optional description property to basic network port object example. (#788) 2024-09-27 14:43:41 -05:00
Steve Karg 4781582204 Changed ATmega168 port to ATmega328 on Uno R3 with DFR0259 RS485 shield (#784)
* Changed ATmega168 example for ATmega328 on Arduino Uno R3 with DFR0259 RS485 shield. Added ADC interface from BDK port and mapped to some AV objects. Removed MS/TP MAC address DIP switch GPIO and moved MS/TP configuration to AV objects. Added AV units property. Added some Uno R3 Digital Inputs and outputs mapped to some BV. Added AVR EEPROM from BDK port and mapped some non-volatile data including MAC address and max manager and baud rate, device ID and names and description and location.
2024-09-27 14:42:47 -05:00
Jonathan 6e4034a92d Fixed a warning emitted from arm-none-eabi-gcc in hostnport.c (#785) 2024-09-26 17:06:09 -05:00
Patrick Grimm cd3f79d544 Added ucix_get_list and ucix_set_list function (#780) 2024-09-24 16:24:28 -05:00
Patrick Grimm 93afcfe062 fix duplicated ports/bsd/bip-init.c (#781) 2024-09-24 16:23:38 -05:00
Patrick Grimm e451b3dc26 add uci include and lib for cmake (#779) 2024-09-23 11:52:27 -05:00
Patrick Grimm 55a242361d add ether support for mac os x (#775)
Depends on pcap (e.g. with Wireshark)
build with
#cmake .. -G"CodeBlocks - Unix Makefiles" -DBACDL_ETHERNET=ON -DBACDL_BIP=OFF -DBAC_ROUTING=OFF
run as normal user (not root) like Wireshark
2024-09-23 11:51:13 -05:00
Patrick Grimm a0ffd96f8f Fixed cmake dependencies to build readbdt, readfdt and router-ipv6 if BACDL_BIP=OFF (#777) 2024-09-23 09:52:36 -05:00
Steve Karg fe1fd39261 Added local tool aptfile to use with apt based development installation. (#772) 2024-09-21 09:26:34 -05:00
Steve Karg 3d86873346 Bugfix/read property multiple client errors (#765)
* Fixed variable data type for boolean in RPM structure.

* Fixed RPM error handling to use callback.

* Fixed bacrpm app example when not enough command line parameters are used

* Fixed empty-list EPICS printing.

* Fixed RPM-Ack processing for end of list-of-results

* Added minimal handling for segmentation-not-supported during RPM of object properties.
2024-09-21 09:26:09 -05:00
Tomasz Kazimierz Motyl 869a827d55 Secured Active-COV-Subscriptions property encoding. (#763) 2024-09-21 09:22:08 -05:00
Patrick Grimm 44757c755e bsd/rs485.c fix compiler warning (#771)
declaration-after-statement
2024-09-21 09:00:08 -05:00
Tomasz Kazimierz Motyl f4325f00b5 Fixed UTF-8 passwords for DeviceCommunicationControl to hold up to 20 UTF-8 characters (#767) 2024-09-19 08:37:36 -05:00
Jonathan b9adcc8097 Clean "types-limits" warnings (#766) 2024-09-19 08:31:49 -05:00
Patrick Grimm c9371baacd add mstp support for mac os x (#764)
build with
#cmake .. -G"CodeBlocks - Unix Makefiles" -DBACDL_MSTP=ON -DBACDL_BIP=OFF -DBAC_ROUTING=OFF
run with
#BACNET_IFACE="/dev/cu.usbserial-14320" BACNET_MSTP_MAC=03 BACNET_MSTP_BAUD=38400 ./readprop 2 device 2 77
2024-09-16 07:31:11 -05:00
Jonathan 6f35559170 Fix some typos (#762) 2024-09-11 08:20:32 -05:00
Tomasz Kazimierz Motyl 07d194ab05 Merge pull request #66 from se-apc/bugfix/cob_subscriptions_destination_indexing (#761)
Fixing order of operations so the dest_index gets written to the right slot instead of an initial MAX_COV_SUBSCRIPTIONS-1

Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-09-11 08:02:24 -05:00
Kari Argillander 98e8cf2147 Make it possible to select multiple datalinks (#717)
* datalink/dlenv: Rename addr -> addr6 when ipv6

If we are building this file with BACDL_BIP6 and BACDL_BIP enabled we
get two definitions for addr. For this reason rename other addr6 so
there will be no conflict.

* config: Reorder MAX_APDU selection so biggest is first

When multiple datalinks are selected we should guess biggest MAX_APDU.
To do that we need to order selection based on biggest to lowest. With
this change MAX_APDU should be more correct most of the times and user
does not need to specifie that by hand.

* Make it possible to select multiple datalinks

Before we had option to select all datalinks. Many times you however do
not need all datalinks but just some. Change logic so that it does not
matter if user selects multiple datalinks. Now user just select what
they want and everything should just work.

* dlenv: Move variables start of function

Because we use C89 we need to move variables start of block.

* datalink: Hide strings.h because Windows

Windows does not support strings.h. Hide it from it.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-09-04 13:32:31 -05:00
Steve Karg b7d03fd415 Added unit test for BACnetAccessRule 2024-09-02 09:18:47 -05:00
Steve Karg f1eaa4e154 [WIP] fixing BACnetAccessRule encoding and decoding. 2024-09-02 08:21:48 -05:00
Kari Argillander f806c5829b Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check

There is newer version from clang-format so use that. We do not yet want
18 as that is little bit too new.

* Format some thing by hand which clang-format "breaks"

Clang-format will format some things little bit off in some cases.
Format some things by hand so we get cleaner end result.

* Run clang-format with

```
pre-commit run --all-files clang-format
```

We have already in previously checked places where clang-format does not
make good format and ignored those (hopefully most of the things).

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-30 11:20:58 -05:00
Steve Karg 622a9e609e Moved west manifest, zephyr folder, and ports/zephyr folders to another repository bacnet-stack-zephyr (#757) 2024-08-30 11:01:18 -05:00
Steve Karg 8ee583a10c Added RP and RPM error code indications in callbacks (#756) 2024-08-29 14:09:22 -05:00
Kari Argillander a2f1d6959d Make most of functions const correct (#714)
* Make most of the functions const correct

Used clang-tidy and sonarlint to help find places where const could
pretty easily applied. Also lot of hand work.

This commit does not yet touch handlers and typedefs of those.

* Fix Arduino uno handler_who_is() has extra parenthesis

For some reason there is extra parenthesis. Remove it this is more
likely buildable.

* Bugfix/bacapp: Fix uninitilized array_index

We have changed bacapp_snprintf_value() to be const correct. After that
we got

```
/home/runner/work/bacnet-stack/bacnet-stack/src/bacnet/bacapp.c:3183:27: warning: 4th function call argument is an uninitialized value [core.CallAndMessage]
                ret_val = bacapp_snprintf_weeklyschedule(
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

So analyzer could now spot that we do not actually initilize array_index
at all. Fix this by setting array_index to zero. Note that I actually do
not know if zeroing is right thing to do here. I choose zero as if this
has worked before it is most likely that it will work with zero value.

* cmake: Add and ignore Wwrite-strings compiler option

Wwrite-strings helps find places where const correctness is broken.

Example it will warn about these

```C

void func1(char* str);

func("test") /* "test" is const so we should not pass it to func1().

char* func2()
{
  return "test"; /* func2() should return const char*.
}
```

We still need to ignore it as not all are fixed but let's add it already
so we remember that it should be opened at some point.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-29 14:08:02 -05:00
Kari Argillander 0177c59f4a Use pre-commit and editorconfig (#753)
* Add editorconfig and pre-commit config

Editorconfig is widly used and supported file. It says basic things how
files should be formatted.

pre-commit is tool which can automatically check some basic checks like
code formatting everytime someone makes commit. This can also be used in
CI to run these things. Then it is very easy to do same things locally
as in CI. This also makes easy to select clang-format version so
everyone is using same one.

* clang-format: Ignore folders where are external code

We should not format external code. Add clang-format files to exclude
those. We should move external code always to example external/ folder
so we can exclude those more easily.

* clang-format: Remove custom zephyr/.clang-gormat

This clang-format file where introduces before our root clang-format. It
does not make sense anymore as we have root clang-format. Removing this
will unifie formatting in whole repo.

* clang-format: Add couple new rules

Add couple new formatting rules.

Always align const to left side. We did have only one place where it was
right side so this make sense as it is already rule for us.

I choose also insertbraces becuase when I run this I notice that we have
lot of multiline code without braces. So very error prone places. This
will take error possibility away. Repo also always use braces even with
single line statments so this does not matter much.

* ci: Add pre-commit validation

Validate pre-commit in CI.

* format: Convert spaces to tabs in Makefiles

Makefile normally use tabs. We enforce that with editorconfig. Fix
couple places where spaces where still in use.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-28 17:04:00 -05:00
Kari Argillander 599033b7b0 Move some external files to external/ folder (#744)
It is lot easier to work with automatic formatters if we have external
files in different folder. For some tools we can example just exclude
external all together.

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-28 16:24:48 -05:00
Steve Karg 3d3e192ae9 Added object-name c-string getter function to basic objects so they can be referenced to free if dynamically created. (#754)
* Added basic object-name get for ASCII names to enable free if they were dynamically created. Added unit testing to validate the basic object ASCII object-name API.

* Removed static scope on character array used for name since the array gets copied into characterstring array and static is not needed.
2024-08-28 16:21:58 -05:00
Steve Karg b3c8c10c03 Fixed COV detection in the basic Binary Output object example. (#751) 2024-08-26 15:03:58 -05:00
Steve Karg 3e0370eee1 Updated Version to 1.3.8 for release on 2024-08-26 (#720) 2024-08-26 08:14:19 -05:00
Jonathan 9d570cd579 Add shield option explanation to ports/stm32f4xx/README.md (#749) 2024-08-26 07:40:47 -05:00
Kari Argillander 369da70f2a Strip tabs and trailing white spaces, and fix end of files (#748)
* format: Strip trailing whitespaces

We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.

Commit was generated with:

    pre-commit run --all-files trailing-whitespace

* format: Files should have exactly one new line end of them

It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.

Commit was generated with:

    pre-commit run --all-files end-of-file-fixer

* format: Convert tabs to spaces

Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.

Commit was generated with:

    pre-commit run --all-files remove-tabs

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-25 14:13:57 -05:00
Kari Argillander 9e0657424e Prepere repo so we can run auto formatters (#747)
* clang-format: Ignore javascript files

Ignore javascript files. Clang-format is not very good formatter for
javascript files anyway. If we ever need javascript formatter we should
use Prettier.

* clang-format: Ignore some lines in sources

Couple things get formatted really funky if we let clang-format format
those. Just ignore those locally.

* zephyr/tescase.yaml: Fix yaml syntax

pre-commit hook check-yaml did found out that there are two skips.
Remove another as this is not right syntax.

* Fix repo contains unicode replacement chars

When running pre-commit text-unicode-replacement-char it founds that
there is couple unicode replacemnt chars. Remove and replace these.

* Convert some tabs to spaces manually

We will soon auto format tabs to spaces. How ever it could not do couple
thing so fix those by hand first.

* Make files with shebang executables

It is good habit that if file has shebang then it is marked executable.
These where found with pre-commit check-shebang-scripts-are-executable
checker.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-23 17:58:41 -05:00
Steve Karg 36b5a3be98 Fixed MacOS specific usage during FreeBSD 11.4 build (#745)
* Fixed path of exports header in BSD ports. 

* Fixed MacOS specific include in BSD ports. 

* Fixed MacOS specific IOSSIOSPEED and IOSSDATALAT usage in BSD ports
2024-08-23 17:50:30 -05:00
Steve Karg eba1def58c Refactored required writable property function from epics app (#743) 2024-08-22 16:31:16 -05:00
Steve Karg f814ffbc49 Added API for intrinsic reporting properties in Binary Value and Binary Input objects (#742)
Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-08-22 15:31:08 -05:00
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