From e8db7e1d538f9658d6f2a7042c9a4396e0bb53d3 Mon Sep 17 00:00:00 2001 From: Siddharth Chandrasekaran Date: Mon, 12 Jul 2021 21:42:18 +0200 Subject: [PATCH] TRS: Add initial template for Transparent Reader Support We borrow the same design ideas from osdp_file.[ch] as that came out pretty neatly without introducing any regressions to existing functionality. So to enable TRS, do one of: cmake -DCONFIG_OSDP_TRS=on (or) configure.sh --enable-trs Signed-off-by: Siddharth Chandrasekaran --- configure.sh | 10 ++++++++++ src/CMakeLists.txt | 11 +++++++++++ src/osdp_cp.c | 1 + src/osdp_pd.c | 1 + src/osdp_trs.c | 18 ++++++++++++++++++ src/osdp_trs.h | 5 +++++ 6 files changed, 46 insertions(+) create mode 100644 src/osdp_trs.c create mode 100644 src/osdp_trs.h diff --git a/configure.sh b/configure.sh index c95fe4a6..d6cef7ef 100755 --- a/configure.sh +++ b/configure.sh @@ -23,6 +23,7 @@ usage() { --static-pd Setup PD single statically --lib-only Only build the library --file Compile support for file tx command + --enable-trs Enable support for Transparant Reader Support --osdpctl Build osdpctl tool -f, --force Use this flags to override some checks -h, --help Print this help @@ -41,6 +42,7 @@ while [ $# -gt 0 ]; do --static-pd) STATIC_PD=1;; --lib-only) LIB_ONLY=1;; --file) FILE=1;; + --enable-trs) ENABLE_TRS=1;; --osdpctl) OSDPCTL=1;; -f|--force) FORCE=1;; -h|--help) usage; exit 0;; @@ -90,6 +92,10 @@ if [[ ! -z "${FILE}" ]]; then CCFLAGS+=" -DCONFIG_OSDP_FILE" fi +if [[ ! -z "${ENABLE_TRS}" ]]; then + CCFLAGS+=" -DCONFIG_OSDP_TRS" +fi + ## Repo meta data echo "Extracting source code meta information" PROJECT_VERSION=$(perl -ne 'print if s/^project\(libosdp VERSION ([0-9.]+)\)$/\1/' CMakeLists.txt) @@ -140,6 +146,10 @@ if [[ ! -z "${FILE}" ]]; then LIBOSDP_SOURCES+=" src/osdp_file.c" fi +if [[ ! -z "${ENABLE_TRS}" ]]; then + LIBOSDP_SOURCES+=" src/osdp_trs.c" +fi + if [[ ! -z "${OSDPCTL}" ]]; then TARGETS+=" osdpctl.elf" fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad1f0b7f..bfc68d86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ option(CONFIG_OSDP_PACKET_TRACE "Enable raw packet trace for diagnostics" OFF) option(CONFIG_OSDP_SKIP_MARK_BYTE "Don't send the leading mark byte (0xFF)" OFF) option(CONFIG_DISABLE_PRETTY_LOGGING "Don't colorize log ouputs" OFF) option(CONFIG_OSDP_FILE "Enabled support for OSDP File Transfer" OFF) +option(CONFIG_OSDP_TRS "Enabled Transparent Reader Support" OFF) if (CONFIG_OSDP_PACKET_TRACE) list(APPEND LIB_OSDP_DEFINITIONS "-DCONFIG_OSDP_PACKET_TRACE") @@ -30,6 +31,10 @@ if (CONFIG_OSDP_FILE) list(APPEND LIB_OSDP_DEFINITIONS "-DCONFIG_OSDP_FILE") endif() +if (CONFIG_OSDP_TRS) + list(APPEND LIB_OSDP_DEFINITIONS "-DCONFIG_OSDP_TRS") +endif() + # static and shared library names set(LIB_OSDP_SHARED osdp) set(LIB_OSDP_STATIC osdpstatic) @@ -63,6 +68,12 @@ if (CONFIG_OSDP_FILE) ) endif() +if (CONFIG_OSDP_TRS) + list(APPEND LIB_OSDP_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/osdp_trs.c + ) +endif() + list(APPEND LIB_OSDP_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/utils/include ${PROJECT_SOURCE_DIR}/include diff --git a/src/osdp_cp.c b/src/osdp_cp.c index 0ec00ace..dbbbd0a8 100644 --- a/src/osdp_cp.c +++ b/src/osdp_cp.c @@ -8,6 +8,7 @@ #include "osdp_common.h" #include "osdp_file.h" +#include "osdp_trs.h" #define LOG_TAG "CP : " diff --git a/src/osdp_pd.c b/src/osdp_pd.c index b0554dc4..9ff7e1ac 100644 --- a/src/osdp_pd.c +++ b/src/osdp_pd.c @@ -6,6 +6,7 @@ #include "osdp_common.h" #include "osdp_file.h" +#include "osdp_trs.h" #ifndef CONFIG_OSDP_STATIC_PD #include diff --git a/src/osdp_trs.c b/src/osdp_trs.c new file mode 100644 index 00000000..5456b667 --- /dev/null +++ b/src/osdp_trs.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2021 Siddharth Chandrasekaran + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _OSDP_TRS_H_ +#define _OSDP_TRS_H_ + +#include "osdp_common.h" + +#ifdef CONFIG_OSDP_TRS + +#else /* CONFIG_OSDP_TRS */ + +#endif /* CONFIG_OSDP_TRS */ + +#endif /* _OSDP_TRS_H_ */ \ No newline at end of file diff --git a/src/osdp_trs.h b/src/osdp_trs.h new file mode 100644 index 00000000..5d460f03 --- /dev/null +++ b/src/osdp_trs.h @@ -0,0 +1,5 @@ +/* + * Copyright (c) 2021 Siddharth Chandrasekaran + * + * SPDX-License-Identifier: Apache-2.0 + */