Skip to content

Commit 25d1814

Browse files
committed
Fixed init and thread priorities for BACnet Basic samples.
1 parent 7a1ec55 commit 25d1814

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

zephyr/subsys/bacnet_basic/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
zephyr_library(bacnet_basic)
77

88
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}\"")
9+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_INIT_PRIORITY \"${CONFIG_BACNET_BASIC_SERVER_INIT_PRIORITY}\"")
10+
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY \"${CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY}\"")
1111
message(STATUS "BACNET BASIC: CONFIG_BACNET_BASIC_SERVER_KSLEEP \"${CONFIG_BACNET_BASIC_SERVER_KSLEEP}\"")
1212

1313
zephyr_library_include_directories(include)

zephyr/subsys/bacnet_basic/Kconfig

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@ 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.
52+
config BACNET_BASIC_SERVER_INIT_PRIORITY
53+
int "Initialization priority"
54+
default APPLICATION_INIT_PRIORITY
55+
range 0 99
56+
help
57+
Initialization priority in the main thread for BACnet Basic Server where 0 is the highest priority.
5758

58-
config BACNET_BASIC_SERVER_PRIORITY
59-
int "BACnet server thread priority"
60-
default 50
59+
config BACNET_BASIC_SERVER_THREAD_PRIORITY
60+
int "Thread priority"
61+
default 10
62+
range 0 NUM_PREEMPT_PRIORITIES
6163
help
62-
This sets the execution priority of the thread.
64+
This sets the thread priority of the BACnet Basic Server where 0 is the highest priority.
6365

6466
config BACNET_BASIC_SERVER_STACK_SIZE
6567
int "BACnet server stack size"

zephyr/subsys/bacnet_basic/server.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
#define CONFIG_BACNET_BASIC_SERVER_STACK_SIZE 8192
2626
#endif
2727

28-
#ifndef CONFIG_BACNET_BASIC_SERVER_PRIORITY
29-
#define CONFIG_BACNET_BASIC_SERVER_PRIORITY 10
28+
/* note: init runs in main thread with sub-priority of 0..99 */
29+
#ifndef CONFIG_BACNET_BASIC_SERVER_INIT_PRIORITY
30+
#define CONFIG_BACNET_BASIC_SERVER_INIT_PRIORITY 50
3031
#endif
3132

32-
#ifndef CONFIG_BACNET_BASIC_SERVER_APP_PRIORITY
33-
#define CONFIG_BACNET_BASIC_SERVER_APP_PRIORITY 90
33+
/* note: thread preemptive priority 0..15 */
34+
#ifndef CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY
35+
#define CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY 10
3436
#endif
3537

38+
/* note: sleep time in main loop in milliseconds */
3639
#ifndef CONFIG_BACNET_BASIC_SERVER_KSLEEP
3740
#define CONFIG_BACNET_BASIC_SERVER_KSLEEP 10
3841
#endif
@@ -67,7 +70,7 @@ static void server_thread(void)
6770
LOG_INF("Server: thread stack=%u bytes",
6871
CONFIG_BACNET_BASIC_SERVER_STACK_SIZE);
6972
LOG_INF("Server: thread priority=%u",
70-
CONFIG_BACNET_BASIC_SERVER_PRIORITY);
73+
CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY);
7174
LOG_INF("Server: thread sleep=%u milliseconds",
7275
CONFIG_BACNET_BASIC_SERVER_KSLEEP);
7376
LOG_INF("Server: initialized");
@@ -86,12 +89,12 @@ static int server_init(void)
8689
k_thread_create(&server_thread_data, server_thread_stack,
8790
K_THREAD_STACK_SIZEOF(server_thread_stack),
8891
(k_thread_entry_t)server_thread, NULL, NULL, NULL,
89-
K_PRIO_PREEMPT(CONFIG_BACNET_BASIC_SERVER_PRIORITY), 0,
92+
K_PRIO_PREEMPT(CONFIG_BACNET_BASIC_SERVER_THREAD_PRIORITY), 0,
9093
K_NO_WAIT);
9194
k_thread_name_set(&server_thread_data, "bacnet_server");
9295

9396
return 0;
9497
}
9598

9699
SYS_INIT(server_init, APPLICATION,
97-
CONFIG_BACNET_BASIC_SERVER_APP_PRIORITY);
100+
CONFIG_BACNET_BASIC_SERVER_INIT_PRIORITY);

0 commit comments

Comments
 (0)