From 9e0657424e0851f396e3b3ce5bf79c66c9e246af Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Sat, 24 Aug 2024 01:58:41 +0300 Subject: [PATCH] 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 --- .clang-format | 3 + CMakeLists.txt | 8 +-- aptfile | 0 bin/bacroute.sh | 0 bin/bacrpd.sh | 0 .../bdk-atxx4-mstp/bootloader/preprocessor.sh | 0 ports/bsd/bacport.h | 58 +++++++++---------- ports/bsd/datetime-init.c | 2 +- ports/linux/bip-init.c | 2 +- .../nbproject/Package-default.bash | 0 ports/pic18f6720/hardware.h | 6 +- .../nbproject/Package-default.bash | 0 ports/pic18f97j60/hardware.h | 6 +- ports/stm32f4xx/stm32f4xx_conf.h | 2 +- ports/xplained/adc-hdw.h | 4 +- ports/xplained/bacnet.h | 4 +- src/bacnet/basic/object/gateway/gw_device.c | 2 +- src/bacnet/basic/object/netport.h | 4 +- src/bacnet/basic/object/piv.c | 2 +- src/bacnet/basic/sys/ringbuf.h | 2 + src/bacnet/config.h | 7 ++- src/bacnet/datalink/bvlc6.c | 14 ++--- src/bacnet/datalink/dlmstp.c | 8 +-- src/bacnet/readrange.c | 2 +- zephyr/subsys/Kconfig | 24 ++++---- .../tests/bacnet/datalink/bvlc/testcase.yaml | 1 - 26 files changed, 84 insertions(+), 77 deletions(-) mode change 100644 => 100755 aptfile mode change 100644 => 100755 bin/bacroute.sh mode change 100644 => 100755 bin/bacrpd.sh mode change 100644 => 100755 ports/bdk-atxx4-mstp/bootloader/preprocessor.sh mode change 100644 => 100755 ports/pic18f6720/BACnet-Server.X/nbproject/Package-default.bash mode change 100644 => 100755 ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash diff --git a/.clang-format b/.clang-format index e9bcdf99..41a7d109 100644 --- a/.clang-format +++ b/.clang-format @@ -18,4 +18,7 @@ IndentWidth: 4 UseTab: Never SortIncludes: false ColumnLimit: 80 +--- +Language: JavaScript +DisableFormat: true ... diff --git a/CMakeLists.txt b/CMakeLists.txt index b380ed68..255ac84e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,10 +39,10 @@ option( "compile the bacpoll app" ON) - option( - BACNET_BUILD_BACDISCOVER_APP - "compile the bacdiscover app" - ON) +option( + BACNET_BUILD_BACDISCOVER_APP + "compile the bacdiscover app" + ON) option( BACDL_ETHERNET diff --git a/aptfile b/aptfile old mode 100644 new mode 100755 diff --git a/bin/bacroute.sh b/bin/bacroute.sh old mode 100644 new mode 100755 diff --git a/bin/bacrpd.sh b/bin/bacrpd.sh old mode 100644 new mode 100755 diff --git a/ports/bdk-atxx4-mstp/bootloader/preprocessor.sh b/ports/bdk-atxx4-mstp/bootloader/preprocessor.sh old mode 100644 new mode 100755 diff --git a/ports/bsd/bacport.h b/ports/bsd/bacport.h index 80ddb03e..cc8e4942 100644 --- a/ports/bsd/bacport.h +++ b/ports/bsd/bacport.h @@ -10,47 +10,47 @@ #define BACPORT_H /* common unix sockets headers needed */ -#include /* basic system data types */ -#include /* timeval{} for select() */ -#include /* timespec{} for pselect() */ -#include /* sockaddr_in{} and other Internet defns */ -#include /* inet(3) functions */ -#include /* for nonblocking */ -#include -#include -#include -#include -#include -#include -#include /* for S_xxx file mode constants */ -#include /* for iovec{} and readv/writev */ -#include -#include -#include /* for Unix domain sockets */ +#include /* basic system data types */ +#include /* timeval{} for select() */ +#include /* timespec{} for pselect() */ +#include /* sockaddr_in{} and other Internet defns */ +#include /* inet(3) functions */ +#include /* for nonblocking */ +#include +#include +#include +#include +#include +#include +#include /* for S_xxx file mode constants */ +#include /* for iovec{} and readv/writev */ +#include +#include +#include /* for Unix domain sockets */ -#ifdef HAVE_SYS_SELECT_H -#include /* for convenience */ +#ifdef HAVE_SYS_SELECT_H +#include /* for convenience */ #endif -#ifdef HAVE_POLL_H -#include /* for convenience */ +#ifdef HAVE_POLL_H +#include /* for convenience */ #endif -#ifdef HAVE_STRINGS_H -#include /* for convenience */ +#ifdef HAVE_STRINGS_H +#include /* for convenience */ #endif /* Three headers are normally needed for socket/file ioctl's: * , , and . */ -#ifdef HAVE_SYS_IOCTL_H -#include +#ifdef HAVE_SYS_IOCTL_H +#include #endif -#ifdef HAVE_SYS_FILIO_H -#include +#ifdef HAVE_SYS_FILIO_H +#include #endif -#ifdef HAVE_SYS_SOCKIO_H -#include +#ifdef HAVE_SYS_SOCKIO_H +#include #endif #include diff --git a/ports/bsd/datetime-init.c b/ports/bsd/datetime-init.c index 810f99dd..25b63787 100644 --- a/ports/bsd/datetime-init.c +++ b/ports/bsd/datetime-init.c @@ -69,7 +69,7 @@ bool datetime_local(BACNET_DATE *bdate, * int tm_wday Day of week [0,6] (Sunday =0). * int tm_yday Day of year [0,365]. * int tm_isdst Daylight Savings flag. - * long tm_gmtoff offset from UTC in seconds + * long tm_gmtoff offset from UTC in seconds */ datetime_set_date(bdate, (uint16_t)tblock->tm_year + 1900, (uint8_t)tblock->tm_mon + 1, (uint8_t)tblock->tm_mday); diff --git a/ports/linux/bip-init.c b/ports/linux/bip-init.c index d73e5f5d..b6cb88bb 100644 --- a/ports/linux/bip-init.c +++ b/ports/linux/bip-init.c @@ -837,7 +837,7 @@ static int createSocket(struct sockaddr_in *sin) if (status < 0) { if (BIP_Debug) { perror("SO_BINDTODEVICE: "); - } + } } /* bind the socket to the local port number and IP address */ status = diff --git a/ports/pic18f6720/BACnet-Server.X/nbproject/Package-default.bash b/ports/pic18f6720/BACnet-Server.X/nbproject/Package-default.bash old mode 100644 new mode 100755 diff --git a/ports/pic18f6720/hardware.h b/ports/pic18f6720/hardware.h index 963b99fd..cd35d85e 100644 --- a/ports/pic18f6720/hardware.h +++ b/ports/pic18f6720/hardware.h @@ -22,9 +22,9 @@ enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE }; #define RESTART_WDT() { _asm CLRWDT _endasm } /* ************************************************************************* - define ENABLE_GLOBAL_INT() INTCONbits.GIE = 1 � - #define DISABLE_GLOBAL_INT() INTCONbits.GIE = 0 � - #define ENABLE_PERIPHERAL_INT() INTCONbits.PEIE = 1 � + define ENABLE_GLOBAL_INT() INTCONbits.GIE = 1 + #define DISABLE_GLOBAL_INT() INTCONbits.GIE = 0 + #define ENABLE_PERIPHERAL_INT() INTCONbits.PEIE = 1 #define DISABLE_PERIPHERAL_INT() INTCONbits.PEIE = 0 *************************************************************************** */ #define ENABLE_HIGH_INT() INTCONbits.GIE = 1 diff --git a/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash b/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash old mode 100644 new mode 100755 diff --git a/ports/pic18f97j60/hardware.h b/ports/pic18f97j60/hardware.h index 4942452c..f31801b6 100644 --- a/ports/pic18f97j60/hardware.h +++ b/ports/pic18f97j60/hardware.h @@ -45,9 +45,9 @@ enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE }; #define RESTART_WDT() { _asm CLRWDT _endasm } /* ************************************************************************* - define ENABLE_GLOBAL_INT() INTCONbits.GIE = 1 � - #define DISABLE_GLOBAL_INT() INTCONbits.GIE = 0 � - #define ENABLE_PERIPHERAL_INT() INTCONbits.PEIE = 1 � + define ENABLE_GLOBAL_INT() INTCONbits.GIE = 1 + #define DISABLE_GLOBAL_INT() INTCONbits.GIE = 0 + #define ENABLE_PERIPHERAL_INT() INTCONbits.PEIE = 1 #define DISABLE_PERIPHERAL_INT() INTCONbits.PEIE = 0 *************************************************************************** */ #define ENABLE_HIGH_INT() INTCONbits.GIE = 1 diff --git a/ports/stm32f4xx/stm32f4xx_conf.h b/ports/stm32f4xx/stm32f4xx_conf.h index 0d714670..3ae8d1c4 100644 --- a/ports/stm32f4xx/stm32f4xx_conf.h +++ b/ports/stm32f4xx/stm32f4xx_conf.h @@ -81,7 +81,7 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U diff --git a/ports/xplained/adc-hdw.h b/ports/xplained/adc-hdw.h index 38ac6b4d..65d91c5f 100644 --- a/ports/xplained/adc-hdw.h +++ b/ports/xplained/adc-hdw.h @@ -13,7 +13,7 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ void adc_init (void); uint16_t adc_result_12bit(uint8_t channel); @@ -22,5 +22,5 @@ extern "C" #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ #endif diff --git a/ports/xplained/bacnet.h b/ports/xplained/bacnet.h index 29ff501f..907c00c6 100644 --- a/ports/xplained/bacnet.h +++ b/ports/xplained/bacnet.h @@ -13,7 +13,7 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ void bacnet_init (void); void bacnet_task (void); @@ -22,5 +22,5 @@ extern "C" #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ #endif diff --git a/src/bacnet/basic/object/gateway/gw_device.c b/src/bacnet/basic/object/gateway/gw_device.c index 05830264..bc72e00d 100644 --- a/src/bacnet/basic/object/gateway/gw_device.c +++ b/src/bacnet/basic/object/gateway/gw_device.c @@ -165,7 +165,7 @@ BACNET_ADDRESS *Get_Routed_Device_Address(int idx) * devices with routing. * * @param my_address [out] Points to the currently active Device Object's - * BACnet address. + * BACnet address. */ void routed_get_my_address(BACNET_ADDRESS *my_address) { diff --git a/src/bacnet/basic/object/netport.h b/src/bacnet/basic/object/netport.h index 4397e1ca..ed715577 100644 --- a/src/bacnet/basic/object/netport.h +++ b/src/bacnet/basic/object/netport.h @@ -198,10 +198,10 @@ extern "C" { BACNET_STACK_EXPORT bool Network_Port_IP_DHCP_Enable( - uint32_t object_instance); + uint32_t object_instance); BACNET_STACK_EXPORT bool Network_Port_IP_DHCP_Enable_Set( - uint32_t object_instance, bool value); + uint32_t object_instance, bool value); BACNET_STACK_EXPORT bool Network_Port_IP_DNS_Server( diff --git a/src/bacnet/basic/object/piv.c b/src/bacnet/basic/object/piv.c index 98fba6e1..73364ae8 100644 --- a/src/bacnet/basic/object/piv.c +++ b/src/bacnet/basic/object/piv.c @@ -222,7 +222,7 @@ int PositiveInteger_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata) apdu_len = encode_application_enumerated(&apdu[0], CurrentAV->Units); break; - /* BACnet Testing Observed Incident oi00109 + /* BACnet Testing Observed Incident oi00109 Positive Integer Value / Units returned wrong datatype - missing break. Revealed by BACnet Test Client v1.8.16 ( www.bac-test.com/bacnet-test-client-download ) BITS: BIT00031 BC diff --git a/src/bacnet/basic/sys/ringbuf.h b/src/bacnet/basic/sys/ringbuf.h index 44d9e435..e0975109 100644 --- a/src/bacnet/basic/sys/ringbuf.h +++ b/src/bacnet/basic/sys/ringbuf.h @@ -19,12 +19,14 @@ * @{ */ #ifndef NEXT_POWER_OF_2 +/* clang-format off */ #define B2(x) ( (x) | ( (x) >> 1) ) #define B4(x) ( B2(x) | ( B2(x) >> 2) ) #define B8(x) ( B4(x) | ( B4(x) >> 4) ) #define B16(x) ( B8(x) | ( B8(x) >> 8) ) #define B32(x) (B16(x) | (B16(x) >>16) ) #define NEXT_POWER_OF_2(x) (B32((x)-1) + 1) +/* clang-format on */ #endif /** @} */ diff --git a/src/bacnet/config.h b/src/bacnet/config.h index 54e5cef5..0e01769e 100644 --- a/src/bacnet/config.h +++ b/src/bacnet/config.h @@ -130,7 +130,9 @@ /* BACAPP decodes WriteProperty service requests Choose the datatypes that your application supports */ -#if !(defined(BACAPP_ALL) || \ +/* clang-format off */ +#if !( \ + defined(BACAPP_ALL) || \ defined(BACAPP_MINIMAL) || \ defined(BACAPP_NULL) || \ defined(BACAPP_BOOLEAN) || \ @@ -166,6 +168,7 @@ defined(BACAPP_TYPES_EXTRA)) #define BACAPP_ALL #endif +/* clang-format on */ #if defined (BACAPP_ALL) #define BACAPP_MINIMAL @@ -210,6 +213,7 @@ #define BACAPP_SHED_LEVEL #endif +/* clang-format off */ #if defined(BACAPP_DOUBLE) || \ defined(BACAPP_DATETIME) || \ defined(BACAPP_DATERANGE) || \ @@ -231,6 +235,7 @@ defined(BACAPP_SHED_LEVEL) #define BACAPP_COMPLEX_TYPES #endif +/* clang-format on */ /* ** Set the maximum vector type sizes diff --git a/src/bacnet/datalink/bvlc6.c b/src/bacnet/datalink/bvlc6.c index 46862391..e49fbead 100644 --- a/src/bacnet/datalink/bvlc6.c +++ b/src/bacnet/datalink/bvlc6.c @@ -1465,9 +1465,9 @@ int bvlc6_decode_secure_bvll(uint8_t *pdu, * * This message provides a mechanism whereby a foreign device * shall cause a BBMD to distribute a Forwarded-NPDU - * BVLC to the local multicast domain, to all BBMD�s configured - * in the BBMD�s BDT, and to all foreign devices in the - * BBMD�s FDT. + * BVLC to the local multicast domain, to all BBMD's configured + * in the BBMD's BDT, and to all foreign devices in the + * BBMD's FDT. * * @param pdu - buffer to store the encoding * @param pdu_size - size of the buffer to store encoding @@ -1696,10 +1696,10 @@ int bvlc6_broadcast_distribution_table_encode(uint8_t *apdu, { int len = 0; - len = bvlc6_broadcast_distribution_table_list_encode(NULL, + len = bvlc6_broadcast_distribution_table_list_encode(NULL, bdt_head); if (len <= apdu_size) { - len = bvlc6_broadcast_distribution_table_list_encode(apdu, + len = bvlc6_broadcast_distribution_table_list_encode(apdu, bdt_head); } else { len = BACNET_STATUS_ERROR; @@ -1800,10 +1800,10 @@ int bvlc6_foreign_device_table_encode(uint8_t *apdu, { int len = 0; - len = bvlc6_foreign_device_table_list_encode(NULL, + len = bvlc6_foreign_device_table_list_encode(NULL, fdt_head); if (len <= apdu_size) { - len = bvlc6_foreign_device_table_list_encode(apdu, + len = bvlc6_foreign_device_table_list_encode(apdu, fdt_head); } else { len = BACNET_STATUS_ERROR; diff --git a/src/bacnet/datalink/dlmstp.c b/src/bacnet/datalink/dlmstp.c index bbb43c6d..8d60a4f2 100644 --- a/src/bacnet/datalink/dlmstp.c +++ b/src/bacnet/datalink/dlmstp.c @@ -152,8 +152,8 @@ static bool MSTP_Compare_Data_Expecting_Reply( request.address.mac[0] = src_address; request.address.mac_len = 1; offset = bacnet_npdu_decode( - &request_pdu[0], request_pdu_len, NULL, &request.address, - &request.npdu_data); + &request_pdu[0], request_pdu_len, NULL, &request.address, + &request.npdu_data); if (request.npdu_data.network_layer_message) { return false; } @@ -170,8 +170,8 @@ static bool MSTP_Compare_Data_Expecting_Reply( /* decode the reply data */ bacnet_address_copy(&reply.address, dest_address); offset = bacnet_npdu_decode( - &reply_pdu[0], reply_pdu_len, &reply.address, NULL, - &reply.npdu_data); + &reply_pdu[0], reply_pdu_len, &reply.address, NULL, + &reply.npdu_data); if (reply.npdu_data.network_layer_message) { return false; } diff --git a/src/bacnet/readrange.c b/src/bacnet/readrange.c index 1eeb180f..ce641d81 100644 --- a/src/bacnet/readrange.c +++ b/src/bacnet/readrange.c @@ -393,7 +393,7 @@ int rr_decode_service_request( * ReadRange-ACK ::= SEQUENCE { * objectIdentifier [0] BACnetObjectIdentifier, * propertyIdentifier [1] BACnetPropertyIdentifier, - * propertyArrayIndex [2] Unsigned OPTIONAL , -- used only with + * propertyArrayIndex [2] Unsigned OPTIONAL, -- used only with * array datatype resultFlags [3] BACnetResultFlags, itemCount [4] * Unsigned, itemData [5] SEQUENCE OF ABSTRACT-SYNTAX.&TYPE, * firstSequenceNumber [6] Unsigned32 OPTIONAL -- used only if 'Item diff --git a/zephyr/subsys/Kconfig b/zephyr/subsys/Kconfig index 6a79c0a9..53fbc86b 100644 --- a/zephyr/subsys/Kconfig +++ b/zephyr/subsys/Kconfig @@ -11,16 +11,14 @@ rsource "object/Kconfig" rsource "server/Kconfig" config BACNET_SHELL - bool "BACnet Shell" - default n - select SHELL - select CONSOLE - select KERNEL_SHELL - select THREAD_MONITOR - select THREAD_NAME - select DEVICE_SHELL - select LOG - help - Enable BACnet Shell support - - + bool "BACnet Shell" + default n + select SHELL + select CONSOLE + select KERNEL_SHELL + select THREAD_MONITOR + select THREAD_NAME + select DEVICE_SHELL + select LOG + help + Enable BACnet Shell support diff --git a/zephyr/tests/bacnet/datalink/bvlc/testcase.yaml b/zephyr/tests/bacnet/datalink/bvlc/testcase.yaml index 7810df31..dbc81221 100644 --- a/zephyr/tests/bacnet/datalink/bvlc/testcase.yaml +++ b/zephyr/tests/bacnet/datalink/bvlc/testcase.yaml @@ -1,6 +1,5 @@ common: skip: true # TODO: Remove skip when zephyr v3.0.0 nested conflicting definitions resolved. - skip: true #TODO: debug test for Zephyr v3.2.0 tests: bacnet.datalink.bvlc.unit: tags: bacnet