Skip to content

Commit 0103ded

Browse files
committed
Increased BACnet Basic server application thread stack size to avoid stack overflow.
1 parent 0e28579 commit 0103ded

File tree

12 files changed

+95
-43
lines changed

12 files changed

+95
-43
lines changed

zephyr/samples/profiles/b-ld/prj.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CONFIG_BACDL_BIP=y
4444
CONFIG_BACDL_BIP_PORT=47808
4545
# don't define index if you want to use the default interface
4646
# note: with DHCP and AutoIP enabled, index 0=AutoIP, 1=DHCP
47-
CONFIG_BACDL_BIP_ADDRESS_INDEX=1
47+
# CONFIG_BACDL_BIP_ADDRESS_INDEX=1
4848

4949
# networking
5050
CONFIG_NETWORKING=y
@@ -62,7 +62,7 @@ CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2
6262
# Dynamic IP address
6363
CONFIG_NET_DHCPV4=y
6464
CONFIG_NET_DHCPV4_LOG_LEVEL_DBG=n
65-
CONFIG_NET_IPV4_AUTO=y
65+
CONFIG_NET_IPV4_AUTO=n
6666
CONFIG_NET_IPV4_AUTO_LOG_LEVEL_DBG=n
6767
CONFIG_NET_ICMPV4_LOG_LEVEL_DBG=n
6868
# read the MAC address from settings and set via net_mgmt()

zephyr/samples/profiles/b-ld/src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
#include "bacnet_osif/bacnet_log.h"
2929
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3030

31-
static const uint32_t Device_Instance = 260124;
31+
/* FIXME: get the device instance and name from settings! */
32+
static const uint32_t Device_Instance = 260125;
33+
static const char *Device_Name = "BACnet Lighting Device (B-LD)";
34+
/* object instances */
3235
static const uint32_t Lighting_Instance = 1;
3336

3437
/**
@@ -70,6 +73,7 @@ static void BACnet_Lighting_Device_Init_Handler(void *context)
7073
/* initialize objects for this basic sample */
7174
Device_Init(NULL);
7275
Device_Set_Object_Instance_Number(Device_Instance);
76+
Device_Object_Name_ANSI_Init(Device_Name);
7377
Lighting_Output_Create(Lighting_Instance);
7478
Lighting_Output_Name_Set(Lighting_Instance, "Light-1");
7579
Lighting_Output_Write_Present_Value_Callback_Set(
@@ -92,7 +96,7 @@ static void BACnet_Lighting_Device_Task_Handler(void *context)
9296

9397
int main(void)
9498
{
95-
LOG_INF("*** BACnet Lighting Device (B-LD) ***");
99+
LOG_INF("BACnet Device: %s", Device_Name);
96100
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
97101
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
98102
bacnet_basic_init_callback_set(BACnet_Lighting_Device_Init_Handler,

zephyr/samples/profiles/b-ls/prj.conf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CONFIG_BACNETSTACK_BACNET_BASIC=y
2727
# BACnet Library - options
2828
CONFIG_BACNET_MAX_CHARACTER_STRING_BYTES=128
2929
CONFIG_BACAPP_MINIMAL=y
30-
# BACnet Library - objects
30+
# BACnet Library - basic objects
3131
CONFIG_BACNET_BASIC_OBJECT_NETWORK_PORT=y
3232
CONFIG_BACAPP_HOST_N_PORT=y
3333
CONFIG_BACNET_BASIC_OBJECT_LIGHTING_OUTPUT=y
@@ -50,13 +50,12 @@ CONFIG_BACDL_BIP=y
5050
CONFIG_BACDL_BIP_PORT=47808
5151
# don't define index if you want to use the default interface
5252
# note: with DHCP and AutoIP enabled, index 0=AutoIP, 1=DHCP
53-
CONFIG_BACDL_BIP_ADDRESS_INDEX=1
53+
# CONFIG_BACDL_BIP_ADDRESS_INDEX=1
5454

5555
# networking
5656
CONFIG_NETWORKING=y
5757
CONFIG_NET_L2_ETHERNET=y
58-
#CONFIG_NET_ARP=y
59-
#CONFIG_NET_TCP=y
58+
CONFIG_NET_ARP=y
6059
CONFIG_NET_UDP=y
6160
CONFIG_NET_SHELL=y
6261
CONFIG_NET_SOCKETS=y
@@ -68,7 +67,7 @@ CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2
6867
# Dynamic IP address
6968
CONFIG_NET_DHCPV4=y
7069
CONFIG_NET_DHCPV4_LOG_LEVEL_DBG=n
71-
CONFIG_NET_IPV4_AUTO=y
70+
CONFIG_NET_IPV4_AUTO=n
7271
CONFIG_NET_IPV4_AUTO_LOG_LEVEL_DBG=n
7372
CONFIG_NET_ICMPV4_LOG_LEVEL_DBG=n
7473
# read the MAC address from settings and set via net_mgmt()

zephyr/samples/profiles/b-ls/src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
#include "bacnet_osif/bacnet_log.h"
3434
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3535

36+
/* FIXME: get the device instance and name from settings! */
37+
static const uint32_t Device_Instance = 260126;
38+
static const char *Device_Name = "BACnet Lighting Supervisor (B-LS)";
3639
/* instances for our objects */
37-
static const uint32_t Device_Instance = 260124;
3840
static const uint32_t Lighting_Instance = 1;
3941
static const uint32_t Binary_Lighting_Instance = 1;
4042
static const uint32_t Channel_Instance = 1;
@@ -115,6 +117,7 @@ static void BACnet_Lighting_Device_Init_Handler(void *context)
115117
/* initialize objects for this basic sample */
116118
Device_Init(NULL);
117119
Device_Set_Object_Instance_Number(Device_Instance);
120+
Device_Object_Name_ANSI_Init(Device_Name);
118121
/* lighting output object */
119122
Lighting_Output_Create(Lighting_Instance);
120123
Lighting_Output_Name_Set(Lighting_Instance, "Light-1");
@@ -172,7 +175,7 @@ static void BACnet_Lighting_Device_Task_Handler(void *context)
172175

173176
int main(void)
174177
{
175-
LOG_INF("*** BACnet Lighting Device (B-LD) ***");
178+
LOG_INF("BACnet Device: %s", Device_Name);
176179
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
177180
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
178181
bacnet_basic_init_callback_set(BACnet_Lighting_Device_Init_Handler,

zephyr/samples/profiles/b-sa/prj.conf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CONFIG_BACDL_BIP=y
4343
CONFIG_BACDL_BIP_PORT=47808
4444
# don't define index if you want to use the default interface
4545
# note: with DHCP and AutoIP enabled, index 0=AutoIP, 1=DHCP
46-
CONFIG_BACDL_BIP_ADDRESS_INDEX=1
46+
# CONFIG_BACDL_BIP_ADDRESS_INDEX=1
4747

4848
# networking
4949
CONFIG_NETWORKING=y
@@ -61,19 +61,14 @@ CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2
6161
# Dynamic IP address
6262
CONFIG_NET_DHCPV4=y
6363
CONFIG_NET_DHCPV4_LOG_LEVEL_DBG=n
64-
CONFIG_NET_IPV4_AUTO=y
64+
CONFIG_NET_IPV4_AUTO=n
6565
CONFIG_NET_IPV4_AUTO_LOG_LEVEL_DBG=n
6666
CONFIG_NET_ICMPV4_LOG_LEVEL_DBG=n
6767
# read the MAC address from settings and set via net_mgmt()
6868
CONFIG_NET_MGMT_EVENT=y
6969
CONFIG_NET_L2_ETHERNET_MGMT=y
7070
CONFIG_NET_CONNECTION_MANAGER=y
7171

72-
# Static IP address pre-configuration
73-
#CONFIG_NET_CONFIG_SETTINGS=y
74-
#CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
75-
#CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
76-
#CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
7772
# Network debug config
7873
CONFIG_NET_LOG=y
7974
CONFIG_NET_SHELL=y

zephyr/samples/profiles/b-sa/src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
#include "bacnet_osif/bacnet_log.h"
2929
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3030

31-
static const uint32_t Device_Instance = 260123;
31+
/* FIXME: get the device instance and name from settings! */
32+
static const uint32_t Device_Instance = 260124;
33+
static const char *Device_Name = "BACnet Smart Actuator (B-SA)";
34+
/* object instances */
3235
static const uint32_t Actuator_Instance = 1;
3336
/* timer for Actuator Update Interval */
3437
static struct mstimer Actuator_Update_Timer;
@@ -50,6 +53,7 @@ static void BACnet_Smart_Actuator_Init_Handler(void *context)
5053
/* initialize objects for this basic sample */
5154
Device_Init(NULL);
5255
Device_Set_Object_Instance_Number(Device_Instance);
56+
Device_Object_Name_ANSI_Init(Device_Name);
5357
Analog_Output_Create(Actuator_Instance);
5458
Analog_Output_Name_Set(Actuator_Instance, "Actuator");
5559
Analog_Output_Units_Set(Actuator_Instance, UNITS_PERCENT);
@@ -88,7 +92,7 @@ static void BACnet_Smart_Actuator_Task_Handler(void *context)
8892

8993
int main(void)
9094
{
91-
LOG_INF("*** BACnet Smart Actuator (B-SA) ***");
95+
LOG_INF("BACnet Device: %s", Device_Name);
9296
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
9397
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
9498
bacnet_basic_init_callback_set(BACnet_Smart_Actuator_Init_Handler,

zephyr/samples/profiles/b-ss/prj.conf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,27 @@ CONFIG_BACNET_BASIC_DEVICE_SHELL=y
4141
# BACnet Datalink Options
4242
CONFIG_BACDL_BIP=y
4343
CONFIG_BACDL_BIP_PORT=47808
44-
CONFIG_BACDL_BIP_ADDRESS_INDEX=0
44+
# don't define index if you want to use the default interface
45+
# note: with DHCP and AutoIP enabled, index 0=AutoIP, 1=DHCP
46+
# CONFIG_BACDL_BIP_ADDRESS_INDEX=1
4547

4648
# networking
4749
CONFIG_NETWORKING=y
48-
#CONFIG_NET_ARP=y
49-
#CONFIG_NET_TCP=y
50+
CONFIG_NET_ARP=y
5051
CONFIG_NET_UDP=y
5152
CONFIG_NET_SHELL=y
5253
CONFIG_NET_SOCKETS=y
54+
CONFIG_NET_IPV4=y
55+
CONFIG_NET_IPV4_LOG_LEVEL_DBG=n
56+
CONFIG_NET_IF_MAX_IPV4_COUNT=2
57+
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=2
58+
CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2
5359
# Dynamic IP address
5460
CONFIG_NET_DHCPV4=y
55-
CONFIG_NET_IPV4_AUTO=y
56-
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=2
57-
# Static IP address pre-configuration
58-
#CONFIG_NET_CONFIG_SETTINGS=y
59-
#CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
60-
#CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
61-
#CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
61+
CONFIG_NET_DHCPV4_LOG_LEVEL_DBG=n
62+
CONFIG_NET_IPV4_AUTO=n
63+
CONFIG_NET_IPV4_AUTO_LOG_LEVEL_DBG=n
64+
CONFIG_NET_ICMPV4_LOG_LEVEL_DBG=n
6265
# Network debug config
6366
CONFIG_NET_LOG=y
6467
CONFIG_NET_SHELL=y

zephyr/samples/profiles/b-ss/src/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
#include "bacnet_osif/bacnet_log.h"
2929
LOG_MODULE_DECLARE(bacnet, CONFIG_BACNETSTACK_LOG_LEVEL);
3030

31+
/* FIXME: get the device instance and name from settings! */
3132
static const uint32_t Device_Instance = 260123;
33+
static const char *Device_Name = "BACnet Smart Sensor (B-SS)";
34+
/* object instances */
3235
static const uint32_t Sensor_Instance = 1;
3336
/* timer for Sensor Update Interval */
3437
static struct mstimer Sensor_Update_Timer;
@@ -51,6 +54,7 @@ static void BACnet_Smart_Sensor_Init_Handler(void *context)
5154
/* initialize objects for this basic sample */
5255
Device_Init(NULL);
5356
Device_Set_Object_Instance_Number(Device_Instance);
57+
Device_Object_Name_ANSI_Init(Device_Name);
5458
Analog_Input_Create(Sensor_Instance);
5559
Analog_Input_Name_Set(Sensor_Instance, "Sensor");
5660
Analog_Input_Present_Value_Set(Sensor_Instance, 25.0f);
@@ -85,7 +89,7 @@ static void BACnet_Smart_Sensor_Task_Handler(void *context)
8589

8690
int main(void)
8791
{
88-
LOG_INF("*** BACnet Smart Sensor (B-SS) ***");
92+
LOG_INF("BACnet Device: %s", Device_Name);
8993
LOG_INF("BACnet Stack Version " BACNET_VERSION_TEXT);
9094
LOG_INF("BACnet Stack Max APDU: %d", MAX_APDU);
9195
bacnet_basic_init_callback_set(BACnet_Smart_Sensor_Init_Handler, NULL);

zephyr/subsys/bacnet_basic/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
# @copyright SPDX-License-Identifier: Apache-2.0
66
zephyr_library(bacnet_basic)
77

8+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_STACK_SIZE \"${CONFIG_BACNET_BASIC_SERVER_STACK_SIZE}\"")
9+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_PRIORITY \"${CONFIG_BACNET_BASIC_SERVER_PRIORITY}\"")
10+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_APP_PRIORITY \"${CONFIG_BACNET_BASIC_SERVER_APP_PRIORITY}\"")
11+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_KSLEEP \"${CONFIG_BACNET_BASIC_SERVER_KSLEEP}\"")
12+
813
zephyr_library_include_directories(include)
914

1015
zephyr_library_sources(

zephyr/subsys/bacnet_basic/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,24 @@ if BACNETSTACK_BACNET_BASIC
4949
help
5050
BACnet Stack KSLEEP time in milliseconds
5151

52+
config BACNET_BASIC_SERVER_APP_PRIORITY
53+
int "App init priority"
54+
default 0
55+
help
56+
This sets the starting priority of the thread.
57+
58+
config BACNET_BASIC_SERVER_PRIORITY
59+
int "BACnet server thread priority"
60+
default 50
61+
help
62+
This sets the execution priority of the thread.
63+
64+
config BACNET_BASIC_SERVER_STACK_SIZE
65+
int "BACnet server stack size"
66+
default 8192
67+
help
68+
This sets the stack size of the thread.
69+
70+
5271

5372
endif # BACNETSTACK_BACNET_SETTINGS

0 commit comments

Comments
 (0)