Commit Graph

33 Commits

Author SHA1 Message Date
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 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 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 4a7b7763c2 Feature/add memap cstack usage ports (#661)
* Added memap, avstack, and checkstackusage tools to STM32F4xx Makefile and CMake builds to calculate CSTACK depth and RAM usage

* Added memap, cstack, and ram-usage recipes to stm32f10x port Makefile.  Added Cmake build.

* Removed local dlmstp.c module from stm32f10x port, and used the common datalink dlmstp.c module with MS/TP extended frames and zero-config support.

* Added .nm and .su to .gitignore to skip the analysis file residue.
2024-05-31 14:39:25 -05:00
Steve Karg 52f3f08cb1 Bugfix/fix redundant compiler flags (#658)
* Improved GCC compiler flags in ARM, OS, and test builds. Removed redundant flags, and made them consistent across various builds.

* Fixed redundant redeclaration of various functions detected by change in compiler flags.

* Fixed string truncation warning in bip-init detected by change in compiler flags.

* Fixed some set-but-not-used variables by creating dummy functions instead of using macros.
2024-05-30 10:59:54 -05:00
Steve Karg 770be70688 Chore/bacnet-sc-unrelated-cleanup (#620)
* Added required linux Ethernet library for ethernet build

* Added .obj to gitignore

* Fixed BACnet port for APPLE to use BSD in CMake

* Changed format in CMake to enable cleaner SC merge

* Added create-object and delete-object recipes in GCC Makefile

* Added datalink timer to all example OS apps

* Changed most microcontroller ports to use BACAPP_MINIMAL to specify which datatypes can be written.

* Fixed zephyr OS for BACnet/IP warning

* Fixed zephyr OS log to not require log_strdup

* Added writefile API to file object example

* Added API to device-client to make it more robust.

* Added API in network-port object for getting the ASCII object-name

* Added debug print with a timestamp option

* Added debug print with hex dump print

* Added API to network port object for activate and discard

* Added default define for debug with timestamp

* Added prototype in header for disabled debug printf.

* Added fifo peek ahead function to peek at more than one byte.

* Added get-mac value for network port that uses buffer rather than octetstring
2024-04-19 12:54:56 -05:00
Steve Karg 1520f2c612 Add core stack headers into bacdef.h and cleanup includes. (#602)
* Added dependent BACnet stack headers into bacdef.h file.

* Changed bacdef.h and other stack includes in c/h files to have a common pattern.

* Moved bits.h, bytes.h, and bacnet_stack_exports.h under bacnet/basic/sys/ folder.
2024-03-15 16:58:52 -05:00
Ondřej Hruška 340bd09561 Implement missing data types for calendar and schedule (#474)
* Added the SpecialEvent struct for the Exception_Schedule property of Schedule, encode/decode/same functions, unit tests, and integrated into bacapp functions.

* Added the CalendarEntry struct for the Date_List property of Calendar and the SpecialEvent struct, encode/decode functions, unit tests, and integrated into bacapp functions.

* Added the DateRange struct for the Effective_Period property of Schedule, encode/decode functions, unit tests, and integrated into bacapp functions.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2024-02-01 10:57:46 -06:00
Steve Karg 34b1d24bb7 Build/add cmake to ports at91sam7 (#560)
* added CMake to AT91SAM7S port example

* Add ports AT91SAM7S and STM32F4xx CMake builds into pipeline
2024-01-27 16:00:22 -06:00
Steve Karg e1efca9d9e Fix MSTP slave FSM for Data-Expecting-Reply frames (#538)
* Fix MSTP subordinate nodes Data-Expecting-Reply handling

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-11-20 19:08:28 -06:00
Steve Karg 0b5474d36e Ignore ReinitializeDevice and DeviceCommunicationControl service password (#518)
* Fix device object ReinitializeDevice service handling examples of no-password in the device. Add unit testing of device object ReinitializeDevice service.  Add API for setting ReinitializeDevice device object password.

* Fix DeviceCommunicationControl service handling example of no-password in the device.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-10-18 21:32:44 -05:00
Steve Karg 0001f85f29 Bugfix/network port object link speeds (#488)
* fix ports/xplained build under Linux

* fix network port object link-speeds property

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-09-08 17:41:56 -05:00
Steve Karg 4efaf097c0 Fix [bug#80] npdu_decode via deprecation (#447)
* Fix [bug#80] npdu_decode via deprecation

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-07-10 17:27:10 -05:00
Steve Karg ced9dff0f2 Added AddListElement and RemoveListElement services (#418)
* Added AddListElement and RemoveListElement services

Added list-element codec and unit tests.
Added BACnetDestination codec and unit tests.
Added RecipientList handling to NotificationClass object.
Added AddListElement and RemoveListElement client example app.

* Fix defects found by scan-build and CPPCHECK

* Update ports errors found during CI builds

* Update zephy os test build missing files in CMakeLists

---------

Co-authored-by: Ondřej Hruška <ondra@ondrovo.com>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-04-16 14:12:11 -05:00
Steve Karg e517df0d47 Bugfix/bacnet array encoding overflows (#414)
* Add common BACnetARRAY encode function to fix Device object list buffer overflow. Refactor device, analog-output, access-door and binary-output objects to use common BACnetARRAY encoder.

* Fix non-POSIX builds (win32).

* Cleanup some ports/stm32 build warnings
---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2023-04-13 20:43:54 -05:00
Ondřej Hruška 7cdab61d72 Schedule encoding/decoding (#319)
* schedule: add decode_daily_schedule() and encode_daily_schedule()

* schedule: encode/decode implemented + add to bacapp

* add safe encode/decode functions for timevalue, schedule function renaming

* fix unit tests build failing

* add IDEA and test temporary files to .gitignore

* try to make "deprecated" work in MSVC

* add WeeklySchedule compare function

* add bacnet_weeklyschedule_context_decode()

* Add basic test for WeeklySchedule

* Fix WeeklySchedule parsing and snprintf, decoder verified with real hardware

* try to fix windows build

* improve boolean parsing in 'bacapp_parse_application_data'

* add parse function for weekly schedule

* allow types > 16 in bacwp, show the decoded value before sending

* add bacapp binaries to gitignore

* remove bacwp logging

* Add error checking to bacapp_parse_application_data

* try to fix windows build

* fix avr build

* Fix error handling in RP Ack

* add singleDay flag

* show day name in single day weeklyschedule snprintf

* show weeklyschedule inner tag in snprintf

* improve weeklyschedule parsing and printing, supports type names now

* add weekly schedule to bacapp_decode_data

* move bacnet/bacnet_plat_compat.h to bacnet/basic/sys/platform.h

* disable tag limit also in bacwpm

* add ifdef's around strtoX helper functions in bacapp

* move strtox to BACAPP_PRINT_ENABLED ifdef in bacapp

* fix stm32 makefiles

* fix at91sam7s build

* use BACNET_UNSIGNED_INTEGER in BACnet_Short_Application_Data_Value

* fix capitalization in BACnet_Daily_Schedule

* add name to BACNET_TIME_VALUE struct

* change bacwp bacwpm to use bacapp_known_property_tag()

* fix some macros in bacdcode missing parentheses

* Remove dummy fields from BACNET_SHORT_APPLICATION_DATA_VALUE, replace remaining uses of upcasting (adds extra overhead but is maybe safer), rename short DV to Primitive

* fix new ci warnings

* more fixes for ancient C

* fix tests no longer building

* primitive value renamed to shorter name
2022-09-05 09:27:15 -05:00
Steve Karg a945588340 Bugfix/print property name units lighting (#313)
* Fix EPICS property name proprietary range

* Fix Lighting Command decode length

* add function to determine property name and units proprietary range

* improve test coverage for AI, AO, AV, BI, BO, BV, LO

* refactor common property encoding to proplist module

* add decoder for priority array

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-07-29 17:11:38 -05:00
Steve Karg 1f41341c09 Feature/what is network number handling (#304)
* Add What-Is-Network-Number handling.

Add What-Is-Network-Number and Network-Number-Is network layer handling.
Refactor npdu_encode_npdu_network() from router specific code.
Add unit test for NDPU network message
Add app for What-Is-Network-Number
Add app for Network-Number-Is
Add send helper for What-Is-Network-Number
Add send helper for Network-Number-Is

* added sys/debug.c to ports builds for use of debug_printf() in npdu handler.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-07-14 15:34:45 -05:00
Steve Karg 38d213b47c Feature/color objects color command (#302)
* added BACnetColorCommand and BACnetxyColor encoding and unit testing

* Added Color object and unit testing.

* Added Color Temperature object and Unit test

* Fix BVLC unit test warning.

* add port Makefile for extra types

* added RGB to and from CIE xy utility in sys folder, and add unit tests.

* added cmake-win32 target

* Change RP and RPM to use known property decoder.

Add color object RP and RPM decoding and printing
Fix RPM print for new reserved range above 4194303
Change default protocol-revision to 24 for Color object

* Integrate Color and Color Temperature objects into demo apps

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-07-13 09:54:36 -05:00
Steve Karg f147283293 Feature/apdu null length returned (#285)
* Add APDU as NULL to get BACnet type lengths.

* Fix bacapp copy test to succeed

* fix BACnet REAL and DOUBLE decode

* Add unit test for NULL APDU encoding for length

* Add unit tests for bacapp context

* refactor host-n-port to hostnport.c module

* fix BVLC decoder

* additional unit testing for bacapp

* include bacdevobjpropref module in builds

* simplify bacapp snprintf to be able to return length

* adjust compiler for variable-length arrays

* fix bug found by scan-build

Authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-06-01 15:42:50 -05:00
Steve Karg 12a5e48b3e Bugfix/btl mstp local broadcast discard (#248)
* Discard Confirmed PDU DNER on local broadcast. Discard DER on local broacast.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-04-02 08:44:04 -05:00
Nick Schaf b31cb43e22 Avoid redefining MSTP timeouts (#230)
* Avoid redefining MSTP timeouts

* Remove duplicate MS/TP time definitions

Ports of MS/TP datalink included #defines of several time values, which
were already defined in src/bacnet/datalink/mstpdef.h.  All those ports
already include that header.
2022-02-26 08:58:57 -06:00
Steve Karg 295f127c2b Feature/makefile add apps library (#218)
* add BACnet stack library at apps/lib

* convert apps to use apps/lib for smaller binary

* fix -DBACDL_ALL=1 build

* fix piface build

* datalink MAX_MPDU and MAX_HEADER cleanup

* add bip6 to git workflow

* fix system library dependency of BACnet library

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2022-01-29 15:55:40 -06:00
Steve Karg 7cb63dcf06 RP and RPM Network Port indefinite object instance (#146)
* RP and RPM Network Port indefinite object instance

Added ReadProperty and ReadPropertyMultiple handling for
Network Port object indefinite object instance 4194303.

* Add network port object to some examples

* Fix stm32f10x build

* Fix Endian order of network port IP UDP port

* Add network port object to BDK Makefile

* Add network port object header to BDK device.c

* fix BDK and AT91SAM7S port builds

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2021-01-07 10:21:11 -06:00
Roy Schneider 764e0e8448 Feature/zeroing rx buffer remain (#90)
* Added zeroing rx buffer remain

* Added zeroing rx buffer remain

* Added safety margin for the rx-buffer in the different ports.

* Added safety margin for the receive buffer.

* Added DoxyGen comments.

* Fixed checking return value when calculating distance between opening and closing tag on multiple properties.
2020-05-24 09:19:52 -05:00
Steve Karg ec923e51a3 Bugfix/device object protocol revision 14 property list (#82)
* Added property-list to device object for client applications

* Added property-list to some AVR ARM and RX62 ports

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2020-05-02 14:01:09 -05:00
Steve Karg fdd49f1791 Feature/make pretty apps and ports (#80)
* Added pretty-apps and pretty-ports make targets

* pretty-fied apps folder C files

* Pretty-fied ports folder C and H files

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
2020-04-30 10:13:11 -05:00
Steve Karg 9c41180145 Add ifdef to bit definitions to avoid conflicts with other libraries. Refactor BITx to use BIT macro. (#45) 2020-02-18 08:21:54 -06:00
Geert Linders f8ce70470c Fix (most) compilation warnings in Intel C++ Compiler (#38)
* Use BACNET_OBJECT_TYPE for all object type variables.

* Fix ICC "mixing enumerated type" warnings for assignments and parameters.

* Network Port: Use enums for state structs and remove erroneous bounds checks copy-pasted from IP_Subnet_Prefix setter.

* Fix ICC "unreachable statement" warnings.

* Fix ICC "unused variable" warnings when printing is disabled.

* Fix ICC "mixing enumerated type" warnings for struct initializers { 0 } by ensuring the first member is an integer type.

* Send_GetEvent_Global: Return 0 (invalid TSM invoke ID) instead of -1 = 255 (technically valid invoke ID) on failure.

* Fix ICC "pointless comparison" warnings.

* Fix wrong import in objects.c (memset being used).

* Fix signedness warnings and inconsistencies. Include -1 = 255 check in cov_address_get().

* Add some guards for BACAPP_LIGHTING_COMMAND to avoid errors/warnings.

* RPM test fixes

* Address requested changes. (#38)
2020-01-23 08:18:47 -06:00
Geert Linders 76abcaedd1 Reduce Tusage_timeout for all ports. (#37) 2020-01-22 17:07:44 -06:00
Steve Karg 738ef825b0 Feature/port arm build check (#34)
* add GCC ARM compiler to travis pre-script and add some ARM ports to job
2020-01-19 19:43:50 -06:00
Steve Karg d50c190957 Issue 2 move folders and use deep path include file names to prevent collisions (#4)
* moving folders and files and adjust server demo build

* Fix Makefile for apps/server on Linux

* fix unit test source file folders

* fix datetime convert UTC functions. Add Code::Blocks project for datetime testing

* added some ignore extensions

* disable parallel make option

* fix build for abort, dcc, and epics apps

* fix build for dcc, epics, error, and getevent apps.

* Fixed building of all apps

* fix the ipv4 to ipv6 router app build

* Change indent style from Google to Webkit

* make pretty to re-format style

* removed common Makefile since we already had one and two was too many

* remove scripts from root folder that are no longer maintained or used

* remove mercurial EOL and ignore files for git repo

* remove .vscodeconfig files from repo

* tweak clang-format style

* clang-format src and apps with tweaked style

* added clang-tidy to fix readability if braces in src

* result of make tidy for src and apps

* fix clang-tidy mangling

* Added code::blocks project for BACnet server simulation

* added code::blocks linux project for WhoIs app

* update text files for EOL

* fix EOL in some files

* fixed make win32 apps for older gcc

* Removed Borland C++ Makefile in apps. Unable to maintain support for Borland C++ compiler.

* created codeblocks project for apps/epics for Windows

* fixing ports/xplained to work with new data structure.

* fix ports/xplained example for Atmel Studio compile

* fix ports/stm32f10x example for gcc Makefile compile

* fix ports/stm32f10x example for IAR EWARM compile

* fix ports/xplained timer callback

* fix ports/bdk_atxx_mspt build with subdirs

* fix ports/bdk_atxx_mspt build with subdirs

* updated git ignore for IAR build artifacts

* updated gitignore for non-tracked files and folders

* fixed bdk-atxx4-mstp port for Rowley Crossworks project file

* fixed bdk-atxx4-mstp port for GCC AVR Makefile

* fixed atmega168 port for IAR AVR and GCC AVR Makefile

* fixed at91sam7s port for IAR ARM and GCC ARM Makefile

* removed unmaintainable DOS, RTOS32, and atmega8 ports.  Updated rx62n (untested).

* changed arm7 to uip port
2019-12-13 15:19:10 -06:00
Steve Karg a42e8f507c adjust root folder 2019-10-08 23:47:53 -05:00