diff --git a/.gitignore b/.gitignore index dfe2e1a6..f87d063a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,5 @@ cmake-build-debug cmake-build-release .idea -include/reactor-uc/config.h !lfc/bin diff --git a/CMakeLists.txt b/CMakeLists.txt index c73f9b69..ad6ce0e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ set(BUILD_UNIT_TESTS OFF CACHE BOOL "Build unit tests") set(TEST_COVERAGE OFF CACHE BOOL "Compute test coverage") set(ASAN OFF CACHE BOOL "Compile with AddressSanitizer") set(PLATFORM "POSIX" CACHE STRING "Platform to target") -set(EVENT_QUEUE_SIZE 10 CACHE STRING "Static size of the event queue") -set(REACTION_QUEUE_SIZE 10 CACHE STRING "Static size of the reaction queue") -set(NETWORK_POSIX_TCP OFF CACHE BOOL "Use POSIX TCP NetworkChannel") +set(EVENT_QUEUE_SIZE 32 CACHE STRING "Static size of the event queue") +set(REACTION_QUEUE_SIZE 32 CACHE STRING "Static size of the reaction queue") +set(NETWORK_CHANNEL_TCP_POSIX OFF CACHE BOOL "Use POSIX TCP NetworkChannel") # Code coverage setup if(TEST_COVERAGE) @@ -30,7 +30,7 @@ endif() if(BUILD_TESTS) set(BUILD_LF_TESTS ON) set(BUILD_UNIT_TESTS ON) - set(NETWORK_POSIX_TCP ON) # TODO: This is currently needed because one of the tests uses this stack, we need a nicer way of selecting build options for tests and apps. + set(NETWORK_CHANNEL_TCP_POSIX ON) # TODO: This is currently needed because one of the tests uses this stack, we need a nicer way of selecting build options for tests and apps. set(CMAKE_BUILD_TYPE "Debug") find_program(CLANG_TIDY clang-tidy) if (CLANG_TIDY) @@ -68,21 +68,21 @@ else () message(FATAL_ERROR "No valid platform specified") endif () -add_compile_definitions("PLATFORM_${PLATFORM}") -# TODO: Improve this here -if(NETWORK_POSIX_TCP) - target_compile_definitions(reactor-uc PRIVATE NETWORK_POSIX_TCP) +# Add compile definitions for platform and network channel specifics. +target_compile_definitions(reactor-uc PRIVATE "PLATFORM_${PLATFORM}") + +# Add compile definitions for event and reaction queue sizes. Has to be PUBLIC because they are used in the header files. +target_compile_definitions(reactor-uc PUBLIC EVENT_QUEUE_SIZE=${EVENT_QUEUE_SIZE}) +target_compile_definitions(reactor-uc PUBLIC REACTION_QUEUE_SIZE=${REACTION_QUEUE_SIZE}) + +if(NETWORK_CHANNEL_TCP_POSIX) + target_compile_definitions(reactor-uc PRIVATE NETWORK_CHANNEL_TCP_POSIX) endif() target_compile_options(reactor-uc PRIVATE -Wall -Wextra -Werror) add_compile_options (-fdiagnostics-color=always) target_include_directories(reactor-uc PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/external) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/reactor-uc/config.h.in - ${CMAKE_CURRENT_SOURCE_DIR}/include/reactor-uc/config.h -) - if(BUILD_UNIT_TESTS) set(UNITY_DIR ${CMAKE_CURRENT_LIST_DIR}/external/Unity) include(CTest) diff --git a/examples/posix/federated/CMakeLists.txt b/examples/posix/federated/CMakeLists.txt index c7379fb6..4b329478 100644 --- a/examples/posix/federated/CMakeLists.txt +++ b/examples/posix/federated/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20.0) project(reactor-uc-posix-hello) set(PLATFORM "POSIX" CACHE STRING "") -set(NETWORK_POSIX_TCP ON CACHE STRING "") +set(NETWORK_CHANNEL_TCP_POSIX ON CACHE STRING "") add_subdirectory(../../../ reactor-uc) add_executable(sender sender.c) diff --git a/examples/riot/blinky/Makefile b/examples/riot/blinky/Makefile index 61759277..6135bfb6 100755 --- a/examples/riot/blinky/Makefile +++ b/examples/riot/blinky/Makefile @@ -13,6 +13,6 @@ DEVELHELP ?= 1 QUIET ?= 1 # Enable reactor-uc features -CFLAGS += -DNETWORK_POSIX_TCP +CFLAGS += -DNETWORK_CHANNEL_TCP_POSIX include $(CURDIR)/../../../make/riot/riot.mk diff --git a/examples/riot/hello/Makefile b/examples/riot/hello/Makefile index a444960e..a566a09f 100755 --- a/examples/riot/hello/Makefile +++ b/examples/riot/hello/Makefile @@ -13,6 +13,6 @@ DEVELHELP ?= 1 QUIET ?= 1 # Enable reactor-uc features -# CFLAGS += -DNETWORK_POSIX_TCP +# CFLAGS += -DNETWORK_CHANNEL_TCP_POSIX include $(CURDIR)/../../../make/riot/riot.mk diff --git a/examples/zephyr/basic_federated/federated_receiver1/CMakeLists.txt b/examples/zephyr/basic_federated/federated_receiver1/CMakeLists.txt index 153844fd..19be1be4 100644 --- a/examples/zephyr/basic_federated/federated_receiver1/CMakeLists.txt +++ b/examples/zephyr/basic_federated/federated_receiver1/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(reactor-uc-zephyr) # TODO: Improve the way of pickng which Network channels to add to the build. -set(NETWORK_POSIX_TCP ON CACHE BOOL "blah") +set(NETWORK_CHANNEL_TCP_POSIX ON CACHE BOOL "blah") set(PLATFORM "ZEPHYR" CACHE STRING "Platform to target") add_subdirectory(../../../../ reactor-uc) diff --git a/examples/zephyr/basic_federated/federated_receiver2/CMakeLists.txt b/examples/zephyr/basic_federated/federated_receiver2/CMakeLists.txt index 153844fd..19be1be4 100644 --- a/examples/zephyr/basic_federated/federated_receiver2/CMakeLists.txt +++ b/examples/zephyr/basic_federated/federated_receiver2/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(reactor-uc-zephyr) # TODO: Improve the way of pickng which Network channels to add to the build. -set(NETWORK_POSIX_TCP ON CACHE BOOL "blah") +set(NETWORK_CHANNEL_TCP_POSIX ON CACHE BOOL "blah") set(PLATFORM "ZEPHYR" CACHE STRING "Platform to target") add_subdirectory(../../../../ reactor-uc) diff --git a/examples/zephyr/basic_federated/federated_sender/CMakeLists.txt b/examples/zephyr/basic_federated/federated_sender/CMakeLists.txt index 8b2011f6..cd444078 100644 --- a/examples/zephyr/basic_federated/federated_sender/CMakeLists.txt +++ b/examples/zephyr/basic_federated/federated_sender/CMakeLists.txt @@ -5,7 +5,7 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(reactor-uc-zephyr) # TODO: Improve the way of pickng which Network channels to add to the build. -set(NETWORK_POSIX_TCP ON CACHE BOOL "blah") +set(NETWORK_CHANNEL_TCP_POSIX ON CACHE BOOL "blah") set(PLATFORM "ZEPHYR" CACHE STRING "Platform to target") add_subdirectory(../../../../ reactor-uc) diff --git a/include/reactor-uc/config.h.in b/include/reactor-uc/config.h.in deleted file mode 100644 index 0c50dfe9..00000000 --- a/include/reactor-uc/config.h.in +++ /dev/null @@ -1,9 +0,0 @@ -// This file is code-generated based on command line variables passed to -// CMake during compilation. Do not edit this file. -#ifndef REACTOR_UC_CONFIG_H -#define REACTOR_UC_CONFIG_H - -#define EVENT_QUEUE_SIZE @EVENT_QUEUE_SIZE@ -#define REACTION_QUEUE_SIZE @REACTION_QUEUE_SIZE@ - -#endif diff --git a/include/reactor-uc/queues.h b/include/reactor-uc/queues.h index 37b6d61e..65847e6c 100644 --- a/include/reactor-uc/queues.h +++ b/include/reactor-uc/queues.h @@ -1,7 +1,6 @@ #ifndef REACTOR_UC_QUEUES_H #define REACTOR_UC_QUEUES_H -#include "reactor-uc/config.h" #include "reactor-uc/error.h" #include "reactor-uc/event.h" #include "reactor-uc/reaction.h" diff --git a/make/riot/external_modules/reactor-uc/Makefile.dep b/make/riot/external_modules/reactor-uc/Makefile.dep index c3ceaedc..43b5051c 100644 --- a/make/riot/external_modules/reactor-uc/Makefile.dep +++ b/make/riot/external_modules/reactor-uc/Makefile.dep @@ -3,8 +3,8 @@ USEMODULE += ztimer64_usec USEMODULE += nanopb USEMODULE += proto -# If Feature NETWORK_POSIX_TCP is enabled -ifeq ($(filter -DNETWORK_POSIX_TCP, $(CFLAGS)), -DNETWORK_POSIX_TCP) +# If Feature NETWORK_CHANNEL_TCP_POSIX is enabled +ifeq ($(filter -DNETWORK_CHANNEL_TCP_POSIX, $(CFLAGS)), -DNETWORK_CHANNEL_TCP_POSIX) # Enable networking USEMODULE += netdev_default USEMODULE += auto_init_gnrc_netif diff --git a/src/network_channel.c b/src/network_channel.c index 5b04fc73..e5cf390b 100644 --- a/src/network_channel.c +++ b/src/network_channel.c @@ -1,3 +1,23 @@ -#ifdef NETWORK_POSIX_TCP +#if defined(PLATFORM_POSIX) +#ifdef NETWORK_CHANNEL_TCP_POSIX #include "platform/posix/tcp_ip_channel.c" -#endif \ No newline at end of file +#endif + +#elif defined(PLATFORM_ZEPHYR) +#ifdef NETWORK_CHANNEL_TCP_POSIX +#include "platform/posix/tcp_ip_channel.c" +#endif + +#elif defined(PLATFORM_RIOT) +#ifdef NETWORK_CHANNEL_TCP_POSIX +#include "platform/posix/tcp_ip_channel.c" +#endif + +#elif defined(PLATFORM_PICO) +#ifdef NETWORK_CHANNEL_TCP_POSIX +#error "NETWORK_POSIC_TCP not supported on PICO" +#endif + +#else +#error "Platform not supported" +#endif