Commit Graph

3465 Commits

Author SHA1 Message Date
Patrick Grimm d3de5c9491 fix missing router-mstp in cmake (#820) 2024-10-21 07:53:32 -05:00
Patrick Grimm b9de08cf60 Feature/router bsd (#821)
* fix router compile warnings declaration-after-statement overlength-strings

* router disable PRINT(debug_level)

* ports rename dlmstp_[linux|bsd] to dlmstp_port

* copy ports/linux/dlmstp_port.c ports/bsd/dlmstp_port.c

* copy ports/linux/dlmstp_port.c ports/bsd/dlmstp_port.c

* fix typedef in bip_get_local_address_ioctl

* copy ports/linux/dlmstp_port.c ports/bsd/dlmstp_port.c

* add bsd support for router app

* fix clang __attribute__ optimize dont work
clang O2/O3/Os are also not working

* fix pre-commit

* fix bsd SO_BINDTODEVICE is not available

* add brew install libconfig for app router and bsd

* fix BACDL_MSTP test on macOS

* remove old comments
2024-10-21 07:53:01 -05:00
Patrick Grimm 57c3b81bb1 enable BACDL_ETHERNET test for macOS linux and windows (#822) 2024-10-21 07:44:54 -05:00
Patrick Grimm 987ce816ea fix EXC_BAD_ACCESS in datalink_set() strcasecmp() (#816)
If -DBACDL_MULTIPLE and runtime env BACNET_DATALINK is null
'''
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007ff819a0e782 libsystem_c.dylib`strcasecmp_l + 91
'''

Set default datalink with priority bip,bip6,mstp,ethernet,arcnet
2024-10-18 13:21:40 -05:00
Steve Karg f649e37bfa Fixed jquery.js used for syntax highlighting in PERL documentation (#817) 2024-10-18 13:20:42 -05:00
Steve Karg c3cb72bc41 Fixed BACNET_APPLICATION_DATA_VALUE declarations to be initialized so that the next pointer is NULL by default. (#814) 2024-10-18 07:43:39 -05:00
Steve Karg ac7dee0021 Issues/issue 811 mstpcap considers valid frames as invalid if used as a standalone tool (#812)
* Fixed mstpcap utility by setting This-Station to the MS/TP promiscuous mode address 255.

* Fixed MS/TP receive filter for valid data frames which was missing.

* Fixed MS/TP zero-config duplicate node detection

* Reset silence during MS/TP capture after writing packet to prevent endless packets when stream is interrupted.
2024-10-15 15:38:25 -05:00
Sergey Nazaryev 2b58f5b122 Fix the MSTP turnaround delay implementation. (#809)
The usleep() function takes microseconds, not milliseconds. So,
T_turnaround needs to be calculated in microseconds. If we don't do
this, at a baud rate of 9600, we end up waiting 4 microseconds instead
of 4 milliseconds, which goes against the rule.
2024-10-14 07:56:55 -05:00
Patrick Grimm b555e4a440 fix app router (#808)
with optimize Os the program exits with
bit out of range 0 - FD_SETSIZE on fd_set

Disable optimize for size by static set optimize 2

This Fix #793
2024-10-14 07:56:37 -05:00
Patrick Grimm 2d98e2f625 fix app router-ipv6: duplicate symbol (#807)
Makefile use Device_Object_Instance_Number from device-client.c (Device_Object_Instance_Number is not in bacnet.a from Makefile)

Cmake use Device_Object_Instance_Number from libbacnet-stac.a:device.c

This fix #778
2024-10-14 07:56:05 -05:00
Patrick Grimm a71d4b95eb Fix/router ipv6 test (#806)
* fix app router-ipv6: duplicate symbol
Makefile use Device_Object_Instance_Number from device-client.c (Device_Object_Instance_Number is not in bacnet.a from Makefile)

Cmake use Device_Object_Instance_Number from libbacnet-stac.a:device.c

This fix #778

* test ipv6
2024-10-14 07:55:04 -05:00
Patrick Grimm e71c4177a1 fix bsd/bip6.c:35:16: error: variadic macros are a C99 feature (#805)
Copy debug_fprintf_bip6() from linux
2024-10-11 09:46:17 -05:00
Steve Karg 52a2cd437a Fixed MS/TP FSM TS filter that was removed for zero-config permiscuous feature. (#803) 2024-10-10 15:50:57 -05:00
Tomasz Kazimierz Motyl bcb82841fb Merge pull request #78 from se-apc/bugfix/stack_smashing_on_cov_subscriptions_encoding (#802)
Resolving stack-smashing problem associated with variable length of subscriber's process ID 2..5 bytes

Co-authored-by: Tomasz Kazimierz Motyl <tomasz.motyl@se.com>
2024-10-09 12:31:13 -05:00
Patrick Grimm 385c6bbd5d fix app router-ipv6 cmake (#800)
remove not existing router-ipv6.h
2024-10-09 06:15:56 -05:00
Patrick Grimm 7178120176 fix app router cmake (#799)
Don't use return.
a) this is an if else
b) all apps below this would not be build
2024-10-08 12:54:53 -05:00
Steve Karg c4c1d9f921 Added define to control IP_DHCP_Enable property being present in Network Port object (#796) 2024-10-04 22:15:31 -05:00
Patrick Grimm 9d5c3ec515 fix app router cmake (#794)
add missing port/linux/dlmstp_linux.c used by mstpmodule.c
2024-10-04 13:48:40 -05:00
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