Simplest Zephyr module + bacnet_stack config and hello sample
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Legrand North America, Inc.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Standard includes */
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* Zephyr includes */
|
||||||
|
#include <init.h>
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <sys/printk.h>
|
||||||
|
#include <sys/util.h>
|
||||||
|
#include <zephyr.h>
|
||||||
|
|
||||||
|
#include <logging/log.h>
|
||||||
|
LOG_MODULE_REGISTER(bacnet);
|
||||||
|
|
||||||
|
/* To do: init()
|
||||||
|
|
||||||
|
static int init(struct device *unused)
|
||||||
|
{
|
||||||
|
ARG_UNUSED(unused);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SYS_INIT(init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
# west config manifest.path <manifest_dir_from_topdir>
|
# west config manifest.path <manifest_dir_from_topdir>
|
||||||
#
|
#
|
||||||
# e.g. west config manifest.path zephyr/manifests/nrf5
|
# e.g. west config manifest.path bacnet-stack/zephyr/manifests/zp/zephyr
|
||||||
|
|
||||||
# NOTE: Since the schema requires at least one project name,
|
# NOTE: Since the schema requires at least one project name,
|
||||||
# the mapping of this repository must be described as a project
|
# the mapping of this repository must be described as a project
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||||
|
|
||||||
|
# Detect the platform reliably
|
||||||
|
if(ZEPHYR_BASE)
|
||||||
|
if (NOT CONFIG_BACNETSTACK)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(ZEPHYR YES)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "ZEPHYR_BASE needs to be defined for Zephyr builds")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# options managed through Kconfig and use names CONFIG_*
|
||||||
|
#
|
||||||
|
|
||||||
|
set(BACNET_PROTOCOL_REVISION 19)
|
||||||
|
|
||||||
|
message(STATUS "BACNETSTACK: using cmake ${CMAKE_VERSION}")
|
||||||
|
message(STATUS "BACNETSTACK: CMAKE_C_COMPILER_ID \"${CMAKE_C_COMPILER_ID}\"")
|
||||||
|
message(STATUS "BACNETSTACK: CMAKE_C_COMPILER_VERSION \"${CMAKE_C_COMPILER_VERSION}\"")
|
||||||
|
message(STATUS "BACNETSTACK: CMAKE_CXX_COMPILER_ID \"${CMAKE_CXX_COMPILER_ID}\"")
|
||||||
|
message(STATUS "BACNETSTACK: CMAKE_CXX_COMPILER_VERSION \"${CMAKE_CXX_COMPILER_VERSION}\"")
|
||||||
|
message(STATUS "BACNETSTACK: CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACNET_PROTOCOL_REVISION \"${BACNET_PROTOCOL_REVISION}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_BIP6 \"${CONFIG_BACDL_BIP6}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_BIP \"${CONFIG_BACDL_BIP}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_ARCNET \"${CONFIG_BACDL_ARCNET}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_MSTP \"${CONFIG_BACDL_MSTP}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_ETHERNET \"${CONFIG_BACDL_ETHERNET}\"")
|
||||||
|
message(STATUS "BACNETSTACK: BACDL_NONE \"${CONFIG_BACDL_NONE}\"")
|
||||||
|
|
||||||
|
#Do not allow in source builds
|
||||||
|
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||||
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||||
|
|
||||||
|
#
|
||||||
|
# sources
|
||||||
|
#
|
||||||
|
set(BACNETSTACK_SRCS
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# add ports
|
||||||
|
#
|
||||||
|
|
||||||
|
set(BACNETSTACK_PORT_DIRECTORY_PATH "")
|
||||||
|
|
||||||
|
message(STATUS "BACNETSTACK: building for Zephyr")
|
||||||
|
set(BACNETSTACK_PORT ${CMAKE_CURRENT_LIST_DIR}/../ports/zephyr)
|
||||||
|
|
||||||
|
list(
|
||||||
|
APPEND BACNETSTACK_SRCS
|
||||||
|
${BACNETSTACK_PORT}/main.c
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# library
|
||||||
|
#
|
||||||
|
|
||||||
|
zephyr_library()
|
||||||
|
|
||||||
|
zephyr_library_compile_definitions(
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_BIP}>:BACDL_BIP>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_BIP6}>:BACDL_BIP6>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_ARCNET}>:BACDL_ARCNET>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_MSTP}>:BACDL_MSTP>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_ETHERNET}>:BACDL_ETHERNET>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_NONE}>:BACDL_NONE>
|
||||||
|
$<$<BOOL:${CONFIG_BACNET_PROPERTY_LISTS}>:BACNET_PROPERTY_LISTS=1>
|
||||||
|
$<$<BOOL:${CONFIG_BACNET_ROUTING}>:BACNET_ROUTING>
|
||||||
|
$<$<BOOL:${CONFIG_BACAPP_PRINT_ENABLED}>:BACAPP_PRINT_ENABLED=1>
|
||||||
|
$<$<BOOL:${CONFIG_BACAPP_SNPRINTF_ENABLED}>:BACAPP_SNPRINTF_ENABLED=1>
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_library_sources(
|
||||||
|
${BACNETSTACK_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_include_directories(
|
||||||
|
${BACNETSTACK_PORT}
|
||||||
|
${BACNETSTACK_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(
|
||||||
|
app PRIVATE
|
||||||
|
BACNET_PROTOCOL_REVISION=${BACNET_PROTOCOL_REVISION}
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_BIP}>:BACDL_BIP>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_BIP6}>:BACDL_BIP6>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_ARCNET}>:BACDL_ARCNET>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_MSTP}>:BACDL_MSTP>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_ETHERNET}>:BACDL_ETHERNET>
|
||||||
|
$<$<BOOL:${CONFIG_BACDL_NONE}>:BACDL_NONE>
|
||||||
|
$<$<BOOL:${CONFIG_BACNET_PROPERTY_LISTS}>:BACNET_PROPERTY_LISTS=1>
|
||||||
|
$<$<BOOL:${CONFIG_BACNET_ROUTING}>:BACNET_ROUTING>
|
||||||
|
$<$<BOOL:${CONFIG_BACAPP_PRINT_ENABLED}>:BACAPP_PRINT_ENABLED=1>
|
||||||
|
$<$<BOOL:${CONFIG_BACAPP_SNPRINTF_ENABLED}>:BACAPP_SNPRINTF_ENABLED=1>
|
||||||
|
BACNET_STACK_STATIC_DEFINE
|
||||||
|
PRINT_ENABLED=1
|
||||||
|
)
|
||||||
|
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
# Feature configuration options for BACnet-Stack
|
||||||
|
|
||||||
|
# Copyright (c) 2020 Legrand North America, LLC.
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
menuconfig BACNETSTACK
|
||||||
|
bool "BACnet-Stack Support"
|
||||||
|
help
|
||||||
|
This option enables the BACnet-Stack BACnet library.
|
||||||
|
|
||||||
|
if BACNETSTACK
|
||||||
|
|
||||||
|
module = BACNET
|
||||||
|
module-str = Log level for BACnet
|
||||||
|
module-help = Enable BACnet library to output debug messages
|
||||||
|
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"
|
||||||
|
|
||||||
|
config BAC_ROUTING
|
||||||
|
bool "BACnet Routing"
|
||||||
|
help
|
||||||
|
Enable BACnet routing
|
||||||
|
|
||||||
|
config BACNET_PROPERTY_LISTS
|
||||||
|
bool "BACnet Property Lists"
|
||||||
|
help
|
||||||
|
Enable BACnet Property Lists
|
||||||
|
|
||||||
|
config BACDL_ETHERNET
|
||||||
|
bool "BACnet Ethernet datalink"
|
||||||
|
help
|
||||||
|
Enable BACnet Ethernet datalink
|
||||||
|
|
||||||
|
config BACDL_MSTP
|
||||||
|
bool "BACnet MSTP datalink"
|
||||||
|
help
|
||||||
|
Enable BACnet MSTP datalink
|
||||||
|
|
||||||
|
config BACDL_ARCNET
|
||||||
|
bool "BACnet ARCNET datalink"
|
||||||
|
help
|
||||||
|
Enable BACnet ARCNET datalink
|
||||||
|
|
||||||
|
config BACDL_BIP
|
||||||
|
bool "BACnet BIP datalink"
|
||||||
|
help
|
||||||
|
Enable BACnet BIP datalink
|
||||||
|
|
||||||
|
config BACDL_NONE
|
||||||
|
bool "BACnet without datalink"
|
||||||
|
help
|
||||||
|
Enable BACnet without datalink
|
||||||
|
|
||||||
|
config BACAPP_PRINT_ENABLED
|
||||||
|
bool "BACnet app print"
|
||||||
|
help
|
||||||
|
Enable BACnet app print
|
||||||
|
|
||||||
|
config BACAPP_SNPRINTF_ENABLED
|
||||||
|
bool "BACnet app snprintf"
|
||||||
|
help
|
||||||
|
Enable BACnet app snprintf
|
||||||
|
|
||||||
|
config BACDL_BIP_PORT
|
||||||
|
int "BACnet IPv4 UDP port"
|
||||||
|
default 47808
|
||||||
|
depends on BACDL_BIP
|
||||||
|
help
|
||||||
|
UDP port to listen on (default=47808)
|
||||||
|
|
||||||
|
config BACDL_BIP_ADDRESS_INDEX
|
||||||
|
int "Address index"
|
||||||
|
depends on BACDL_BIP
|
||||||
|
default 0
|
||||||
|
help
|
||||||
|
Select IPv4 address
|
||||||
|
|
||||||
|
config BACDL_BIP6
|
||||||
|
bool "BACnet BIP6"
|
||||||
|
help
|
||||||
|
Enable BACnet BIP6
|
||||||
|
|
||||||
|
config BACDL_BIP6_ADDRESS_INDEX
|
||||||
|
int "Unicast address index"
|
||||||
|
depends on BACDL_BIP6
|
||||||
|
default 0
|
||||||
|
help
|
||||||
|
Select IPv6 unicast address
|
||||||
|
|
||||||
|
config BACDL_BIP6_MCAST_ADDRESS
|
||||||
|
string "IPv6 multicast destination"
|
||||||
|
default "FF0E::BAC0"
|
||||||
|
depends on BACDL_BIP6
|
||||||
|
help
|
||||||
|
IPv6 multicast group address for BACNET.
|
||||||
|
|
||||||
|
config BACDL_BIP6_PORT
|
||||||
|
int "BACnet IPv6 UDP port"
|
||||||
|
default 47808
|
||||||
|
depends on BACDL_BIP6
|
||||||
|
help
|
||||||
|
UDP port to listen on (default=47808)
|
||||||
|
|
||||||
|
#rsource "subsys/Kconfig"
|
||||||
|
|
||||||
|
endif # BACNETSTACK
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020 Legrand North America, LLC.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# The west manifest file for upstream Zephyr Project's Zephyr repo.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# west init -m https://github.com/bacnet-stack/bacnet-stack
|
||||||
|
# west config manifest.path zephyr/manifests/zp/zephyr
|
||||||
|
# west update
|
||||||
|
|
||||||
|
manifest:
|
||||||
|
remotes:
|
||||||
|
- name: zephyrproject-rtos
|
||||||
|
url-base: https://github.com/zephyrproject-rtos
|
||||||
|
projects:
|
||||||
|
- name: zephyr
|
||||||
|
remote: zephyrproject-rtos
|
||||||
|
revision: v2.3.0 # Latest integrated release
|
||||||
|
import: true
|
||||||
|
path: zephyr
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020 Legrand North America, LLC.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
build:
|
||||||
|
cmake: zephyr
|
||||||
|
kconfig: zephyr/Kconfig
|
||||||
|
samples:
|
||||||
|
- zephyr/samples
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13.1)
|
||||||
|
|
||||||
|
get_filename_component(MY_PROJECT_BASENAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
|
|
||||||
|
# Find the directory of the Zephyr module
|
||||||
|
string(REGEX REPLACE
|
||||||
|
"\/zephyr\/samples\/[a-zA-Z_\-]*${MY_PROJECT_BASENAME}$" ""
|
||||||
|
MY_ZEPHYR_MODULE_SOURCE_DIR
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
list(APPEND ZEPHYR_EXTRA_MODULES
|
||||||
|
${MY_ZEPHYR_MODULE_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add an absolute directory path to the CMake variable
|
||||||
|
# SYSCALL_INCLUDE_DIRS. This ensures that the syscall machinery will
|
||||||
|
# be able to find the module's syscalls.
|
||||||
|
#TODO: list(APPEND SYSCALL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
project(${MY_PROJECT_BASENAME})
|
||||||
|
|
||||||
|
target_sources(app PRIVATE src/main.c)
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
.. _hello_bacnet_stack:
|
||||||
|
|
||||||
|
Hello BACnet-Stack
|
||||||
|
##################
|
||||||
|
|
||||||
|
Overview
|
||||||
|
********
|
||||||
|
|
||||||
|
A simple sample that can be used with any :ref:`supported board <boards>` and
|
||||||
|
prints "Hello BACnet-Stack" to the console.
|
||||||
|
|
||||||
|
Building and Running
|
||||||
|
********************
|
||||||
|
|
||||||
|
This application can be built and executed on QEMU as follows:
|
||||||
|
|
||||||
|
.. zephyr-app-commands::
|
||||||
|
:zephyr-app: samples/hello_bacnet_stack
|
||||||
|
:host-os: unix
|
||||||
|
:board: qemu_x86
|
||||||
|
:goals: run
|
||||||
|
:compact:
|
||||||
|
|
||||||
|
To build for another board, change "qemu_x86" above to that board's name.
|
||||||
|
|
||||||
|
Sample Output
|
||||||
|
=============
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
Hello BACnet-Stack! x86
|
||||||
|
|
||||||
|
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# nothing here
|
||||||
|
CONFIG_BACNETSTACK=y
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
sample:
|
||||||
|
description: Hello BACnet-Stack sample, the simplest BACnet-Stack
|
||||||
|
application
|
||||||
|
name: hello BACnet-Stack
|
||||||
|
common:
|
||||||
|
tags: introduction
|
||||||
|
harness: console
|
||||||
|
harness_config:
|
||||||
|
type: one_line
|
||||||
|
regex:
|
||||||
|
- "Hello BACnet-Stack! (.*)"
|
||||||
|
tests:
|
||||||
|
sample.basic.hello_bacnet_stack:
|
||||||
|
platform_whitelist: native_posix
|
||||||
|
tags: introduction
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Legrand North America, LLC.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr.h>
|
||||||
|
#include <sys/printk.h>
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
printk("Hello BACnet-Stack! %s\n", CONFIG_BOARD);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user