reorganize entire codebase structure; move common classes, files into a compile time static library; reorganize CMake files to make use of common static library to reduce compile time;

pull/45/head
Bryan Biedenkapp 2 years ago
parent 083bfd9bdb
commit 1379482fcc

@ -186,7 +186,11 @@ endif (ENABLE_TESTS)
#
install(TARGETS dvmhost DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS dvmcmd DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(FILES configs/config.example.yml configs/fne-config.example.yml configs/iden_table.dat configs/RSSI.dat configs/rid_acl.example.dat configs/talkgroup_rules.example.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/etc)
install(TARGETS dvmfne DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR))
install(TARGETS dvmmon DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR))
install(FILES configs/config.example.yml configs/fne-config.example.yml configs/monitor-config.example.yml configs/iden_table.dat configs/RSSI.dat configs/rid_acl.example.dat configs/talkgroup_rules.example.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/etc)
install(PROGRAMS tools/start-dvm.sh tools/stop-dvm.sh tools/dvm-watchdog.sh tools/stop-watchdog.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(CODE "execute_process(COMMAND bash \"-c\" \"sed -i 's/filePath: ./filePath: \\\\/var\\\\/log\\\\//' /usr/local/etc/config.example.yml\")")
install(CODE "execute_process(COMMAND bash \"-c\" \"sed -i 's/activityFilePath: ./activityFilePath: \\\\/var\\\\/log\\\\//' /usr/local/etc/config.example.yml\")")
@ -261,6 +265,7 @@ if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR))
COMMAND cp -v dvmhost ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp -v dvmcmd ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp -v dvmmon ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp -v dvmfne ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp ../tools/*.sh ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
COMMAND chmod +x ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/*.sh
COMMAND cp -v ../configs/*.yml ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
@ -275,6 +280,7 @@ else()
COMMAND touch ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/log/INCLUDE_DIRECTORY
COMMAND cp -v dvmhost ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp -v dvmcmd ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp -v dvmfne ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/bin
COMMAND cp ../tools/*.sh ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
COMMAND chmod +x ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm/*.sh
COMMAND cp -v ../configs/*.yml ${CMAKE_INSTALL_PREFIX_TARBALL}/dvm
@ -298,8 +304,10 @@ add_custom_target(old_install
COMMAND install -m 755 dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
COMMAND install -m 755 dvmcmd ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
COMMAND install -m 755 dvmmon ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
COMMAND install -m 755 dvmfne ${CMAKE_LEGACY_INSTALL_PREFIX}/bin
COMMAND install -m 644 ../configs/config.example.yml ${CMAKE_LEGACY_INSTALL_PREFIX}/config.example.yml
COMMAND install -m 644 ../configs/fne-config.example.yml ${CMAKE_LEGACY_INSTALL_PREFIX}/fne-config.example.yml
COMMAND install -m 644 ../configs/monitor-config.example.yml ${CMAKE_LEGACY_INSTALL_PREFIX}/monitor-config.example.yml
COMMAND install -m 644 ../configs/iden_table.dat ${CMAKE_LEGACY_INSTALL_PREFIX}/iden_table.dat
COMMAND install -m 644 ../configs/RSSI.dat ${CMAKE_LEGACY_INSTALL_PREFIX}/RSSI.dat
COMMAND install -m 644 ../configs/rid_acl.example.dat ${CMAKE_LEGACY_INSTALL_PREFIX}/rid_acl.dat
@ -321,6 +329,7 @@ add_custom_target(old_install-service
COMMAND usermod --groups dialout --append dvmhost || true
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/config.example.yml
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/fne-config.example.yml
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/monitor-config.example.yml
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/iden_table.dat
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/RSSI.dat
COMMAND chown dvmhost:dvmhost ${CMAKE_LEGACY_INSTALL_PREFIX}/rid_acl.dat

@ -7,8 +7,7 @@
#*
#*/
#/*
#* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
#* Copyright (C) 2022 by Natalie Moore <https://github.com/jelimoore>
#* Copyright (C) 2024 by Bryan Biedenkapp N2PLL
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU General Public License as published by
@ -24,160 +23,80 @@
#* along with this program; if not, write to the Free Software
#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#*/
#
## dvmhost source/header files
#
file(GLOB dvmhost_SRC
file(GLOB common_SRC
# DMR module
"src/dmr/*.h"
"src/dmr/*.cpp"
"src/dmr/acl/*.h"
"src/dmr/acl/*.cpp"
"src/dmr/data/*.h"
"src/dmr/data/*.cpp"
"src/dmr/edac/*.h"
"src/dmr/edac/*.cpp"
"src/dmr/lc/*.h"
"src/dmr/lc/*.cpp"
"src/dmr/lc/csbk/*.h"
"src/dmr/lc/csbk/*.cpp"
"src/dmr/lookups/*.h"
"src/dmr/lookups/*.cpp"
"src/dmr/packet*.h"
"src/dmr/packet/*.cpp"
"src/common/dmr/*.cpp"
"src/common/dmr/acl/*.cpp"
"src/common/dmr/data/*.cpp"
"src/common/dmr/lc/*.cpp"
"src/common/dmr/lc/csbk/*.cpp"
"src/common/dmr/lookups/*.cpp"
# P25 module
"src/p25/*.h"
"src/p25/*.cpp"
"src/p25/acl/*.h"
"src/p25/acl/*.cpp"
"src/p25/data/*.h"
"src/p25/data/*.cpp"
"src/p25/dfsi/*.h"
"src/p25/dfsi/*.cpp"
"src/p25/edac/*.h"
"src/p25/edac/*.cpp"
"src/p25/lc/*.h"
"src/p25/lc/*.cpp"
"src/p25/lc/tdulc/*.h"
"src/p25/lc/tdulc/*.cpp"
"src/p25/lc/tsbk/*.h"
"src/p25/lc/tsbk/*.cpp"
"src/p25/lookups/*.h"
"src/p25/lookups/*.cpp"
"src/p25/packet/*.h"
"src/p25/packet/*.cpp"
"src/common/p25/*.cpp"
"src/common/p25/acl/*.cpp"
"src/common/p25/data/*.cpp"
"src/common/p25/dfsi/*.cpp"
"src/common/p25/lc/*.cpp"
"src/common/p25/lc/tdulc/*.cpp"
"src/common/p25/lc/tsbk/*.cpp"
"src/common/p25/lookups/*.cpp"
# NXDN module
"src/nxdn/*.h"
"src/nxdn/*.cpp"
"src/nxdn/acl/*.h"
"src/nxdn/acl/*.cpp"
"src/nxdn/channel/*.h"
"src/nxdn/channel/*.cpp"
"src/nxdn/edac/*.h"
"src/nxdn/edac/*.cpp"
"src/nxdn/lc/*.h"
"src/nxdn/lc/*.cpp"
"src/nxdn/lc/rcch/*.h"
"src/nxdn/lc/rcch/*.cpp"
"src/nxdn/packet/*.h"
"src/nxdn/packet/*.cpp"
"src/common/nxdn/*.cpp"
"src/common/nxdn/acl/*.cpp"
"src/common/nxdn/channel/*.cpp"
"src/common/nxdn/edac/*.cpp"
"src/common/nxdn/lc/*.cpp"
"src/common/nxdn/lc/rcch/*.cpp"
# Core
"src/edac/*.h"
"src/edac/*.cpp"
"src/edac/rs/*.h"
"src/host/*.h"
"src/host/*.cpp"
"src/host/calibrate/*.h"
"src/host/calibrate/*.cpp"
"src/host/setup/*.h"
"src/host/setup/*.cpp"
"src/host/fne/*.h"
"src/host/fne/*.cpp"
"src/lookups/*.h"
"src/lookups/*.cpp"
"src/modem/*.h"
"src/modem/*.cpp"
"src/modem/port/*.h"
"src/modem/port/*.cpp"
"src/network/*.h"
"src/network/*.cpp"
"src/network/fne/*.h"
"src/network/fne/*.cpp"
"src/network/json/*.h"
"src/network/rest/*.h"
"src/network/rest/*.cpp"
"src/network/rest/http/*.h"
"src/network/rest/http/*.cpp"
"src/remote/RESTClient.cpp"
"src/remote/RESTClient.h"
"src/yaml/*.h"
"src/yaml/*.cpp"
"src/*.h"
"src/*.cpp"
"src/common/edac/*.cpp"
"src/common/lookups/*.cpp"
"src/common/network/*.cpp"
"src/common/network/rest/*.cpp"
"src/common/network/rest/http/*.cpp"
"src/common/yaml/*.cpp"
"src/common/*.cpp"
)
#
## dvmcmd source/header files
#
file(GLOB dvmcmd_SRC
"src/network/UDPSocket.h"
"src/network/UDPSocket.cpp"
"src/network/RESTDefines.h"
"src/network/json/*.h"
"src/network/rest/*.h"
"src/network/rest/*.cpp"
"src/network/rest/http/*.h"
"src/network/rest/http/*.cpp"
"src/remote/*.h"
"src/remote/*.cpp"
"src/edac/SHA256.h"
"src/edac/SHA256.cpp"
"src/Defines.h"
"src/Thread.h"
"src/Thread.cpp"
"src/Log.h"
"src/Log.cpp"
"src/Utils.h"
"src/Utils.cpp"
)
file(GLOB common_INCLUDE
# DMR module
"src/common/dmr/*.h"
"src/common/dmr/acl/*.h"
"src/common/dmr/data/*.h"
"src/common/dmr/lc/*.h"
"src/common/dmr/lc/csbk/*.h"
"src/common/dmr/lookups/*.h"
#
## dvmmon source/header files
#
file(GLOB dvmmon_SRC
"src/lookups/AffiliationLookup.h"
"src/lookups/LookupTable.h"
"src/lookups/IdenTableLookup.h"
"src/lookups/IdenTableLookup.cpp"
"src/modem/Modem.h"
"src/monitor/*.h"
"src/monitor/*.cpp"
"src/network/UDPSocket.h"
"src/network/UDPSocket.cpp"
"src/network/RESTDefines.h"
"src/network/json/*.h"
"src/network/rest/*.h"
"src/network/rest/*.cpp"
"src/network/rest/http/*.h"
"src/network/rest/http/*.cpp"
"src/remote/RESTClient.h"
"src/remote/RESTClient.cpp"
"src/edac/SHA256.h"
"src/edac/SHA256.cpp"
"src/yaml/*.h"
"src/yaml/*.cpp"
"src/Defines.h"
"src/Thread.h"
"src/Thread.cpp"
"src/Timer.h"
"src/Timer.cpp"
"src/Log.h"
"src/Log.cpp"
"src/Utils.h"
"src/Utils.cpp"
# P25 module
"src/common/p25/*.h"
"src/common/p25/acl/*.h"
"src/common/p25/data/*.h"
"src/common/p25/dfsi/*.h"
"src/common/p25/lc/*.h"
"src/common/p25/lc/tdulc/*.h"
"src/common/p25/lc/tsbk/*.h"
"src/common/p25/lookups/*.h"
# NXDN module
"src/common/nxdn/*.h"
"src/common/nxdn/acl/*.h"
"src/common/nxdn/channel/*.h"
"src/common/nxdn/edac/*.h"
"src/common/nxdn/lc/*.h"
"src/common/nxdn/lc/rcch/*.h"
# Core
"src/common/edac/*.h"
"src/common/edac/rs/*.h"
"src/common/lookups/*.h"
"src/common/network/*.h"
"src/common/network/json/*.h"
"src/common/network/rest/*.h"
"src/common/network/rest/http/*.h"
"src/common/yaml/*.h"
"src/common/*.h"
)
# Digital mode options and other compilation features
@ -314,10 +233,7 @@ if (DEBUG_TRELLIS)
add_definitions(-DDEBUG_TRELLIS)
endif (DEBUG_TRELLIS)
#
## dvmhost project
#
project(dvmhost)
project(common)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(Threads REQUIRED)
@ -327,11 +243,6 @@ target_include_directories(asio::asio INTERFACE ${ASIO_INCLUDE_DIR})
target_compile_definitions(asio::asio INTERFACE "ASIO_STANDALONE")
target_link_libraries(asio::asio INTERFACE Threads::Threads)
if (ENABLE_SETUP_TUI)
# add finalcut
target_include_directories(finalcut INTERFACE ${FINALCUT_INCLUDE_DIR})
endif (ENABLE_SETUP_TUI)
# Check if platform-specific functions exist
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG)
@ -350,69 +261,10 @@ if (HAVE_SENDMMSG)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DHAVE_SENDMMSG=1")
endif (HAVE_SENDMMSG)
add_executable(dvmhost ${dvmhost_SRC})
target_include_directories(dvmhost PRIVATE src)
if (ENABLE_SETUP_TUI)
target_link_libraries(dvmhost PRIVATE asio::asio finalcut Threads::Threads util)
else()
target_link_libraries(dvmhost PRIVATE asio::asio Threads::Threads util)
endif (ENABLE_SETUP_TUI)
set(CPACK_SET_DESTDIR true)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "dvmhost")
set(CPACK_DEBIAN_PACKAGE_NAME "dvmhost")
set(CPACK_PACKAGE_VENDOR "DVMProject")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The DVM Host software provides the host computer implementation of a mixed-mode DMR, P25 and/or NXDN or dedicated-mode DMR, P25 or NXDN repeater system that talks to the actual modem hardware. The host software; is the portion of a complete Over-The-Air modem implementation that performs the data processing, decision making and FEC correction for a digital repeater.")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "DVMProject Authors")
set(CPACK_DEBIAN_PACKAGE_VERSION "3.5.5")
set(CPACK_DEBIAN_PACKAGE_RELEASE "0")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/dvmproject")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm")
set(CPACK_DEBIAN_FILE_NAME ${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb)
include(CPack)
#
## dvmcmd project
#
project(dvmcmd)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(Threads REQUIRED)
# add ASIO
target_include_directories(asio::asio INTERFACE ${ASIO_INCLUDE_DIR})
target_compile_definitions(asio::asio INTERFACE "ASIO_STANDALONE")
target_link_libraries(asio::asio INTERFACE Threads::Threads)
add_executable(dvmcmd ${dvmcmd_SRC})
target_link_libraries(dvmcmd PRIVATE asio::asio Threads::Threads)
target_include_directories(dvmcmd PRIVATE src)
#
## dvmmon project
#
if (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR))
project(dvmmon)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(Threads REQUIRED)
# add ASIO
target_include_directories(asio::asio INTERFACE ${ASIO_INCLUDE_DIR})
target_compile_definitions(asio::asio INTERFACE "ASIO_STANDALONE")
target_link_libraries(asio::asio INTERFACE Threads::Threads)
# add finalcut
target_include_directories(finalcut INTERFACE ${FINALCUT_INCLUDE_DIR})
add_library(common STATIC ${common_SRC} ${common_INCLUDE})
target_include_directories(common PRIVATE src src/common)
add_executable(dvmmon ${dvmmon_SRC})
target_link_libraries(dvmmon PRIVATE asio::asio finalcut Threads::Threads)
target_include_directories(dvmmon PRIVATE src)
endif (ENABLE_TUI_SUPPORT AND (NOT DISABLE_MONITOR))
include(src/host/CMakeLists.txt)
include(src/fne/CMakeLists.txt)
include(src/monitor/CMakeLists.txt)
include(src/remote/CMakeLists.txt)

@ -35,7 +35,7 @@
#if !defined(__AES_CRYPTO_H__)
#define __AES_CRYPTO_H__
#include "Defines.h"
#include "common/Defines.h"
namespace crypto
{

@ -21,7 +21,7 @@
#if !defined(__CLOCK_H__)
#define __CLOCK_H__
#include "Defines.h"
#include "common/Defines.h"
#include <sys/time.h>
#include <chrono>

@ -12,7 +12,7 @@
//
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2018-2022 by Bryan Biedenkapp N2PLL
* Copyright (C) 2018-2024 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,8 +28,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(__DEFINES_H__)
#define __DEFINES_H__
#if !defined(__COMMON_DEFINES_H__)
#define __COMMON_DEFINES_H__
#include <stdint.h>
@ -106,10 +106,10 @@ typedef unsigned long long ulong64_t;
#define __GIT_VER_HASH__ "00000000"
#endif
#define __PROG_NAME__ "Digital Voice Modem (DVM) Host"
#define __PROG_NAME__ ""
#define __NET_NAME__ "DVM_DMR_P25"
#define __EXE_NAME__ "dvmhost"
#define __VER__ "D03.56.00 (" __GIT_VER__ ")"
#define __EXE_NAME__ ""
#define __VER__ "D03.60.00-alpha (" __GIT_VER__ ")"
#define __BUILD__ __DATE__ " " __TIME__
#define HOST_SW_API
@ -365,4 +365,4 @@ typedef std::unique_ptr<uint8_t[]> UInt8Array;
public: __forceinline type& get##propName(void) const { return m_##variableName; } \
__forceinline void set##propName(type& val) { m_##variableName = val; }
#endif // __DEFINES_H__
#endif // __COMMON_DEFINES_H__

@ -12,7 +12,7 @@
//
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2018-2019 by Bryan Biedenkapp N2PLL
* Copyright (C) 2018-2024 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Log.h"
#include "network/Network.h"
#include "network/BaseNetwork.h"
#include <sys/time.h>
@ -43,6 +43,7 @@
#include <ctime>
#include <cassert>
#include <cstring>
#include <iostream>
// ---------------------------------------------------------------------------
// Constants
@ -50,7 +51,6 @@
#define EOL "\r\n"
const uint32_t ACT_LOG_BUFFER_LEN = 501U;
const uint32_t LOG_BUFFER_LEN = 4096U;
// ---------------------------------------------------------------------------
@ -59,20 +59,16 @@ const uint32_t LOG_BUFFER_LEN = 4096U;
static uint32_t m_fileLevel = 0U;
static std::string m_filePath;
static std::string m_actFilePath;
static std::string m_fileRoot;
static std::string m_actFileRoot;
static network::Network* m_network;
static network::BaseNetwork* m_network;
static FILE* m_fpLog = nullptr;
static FILE* m_actFpLog = nullptr;
uint32_t g_logDisplayLevel = 2U;
bool g_disableTimeDisplay = false;
static struct tm m_tm;
static struct tm m_actTm;
static std::ostream m_outStream{std::cerr.rdbuf()};
@ -82,6 +78,24 @@ static char LEVELS[] = " DMIWEF";
// Global Functions
// ---------------------------------------------------------------------------
/// <summary>
/// Helper to get the current log file level.
/// </summary>
/// <returns></returns>
uint32_t CurrentLogFileLevel() { return m_fileLevel; }
/// <summary>
/// Helper to get the current log file path.
/// </summary>
/// <returns></returns>
std::string LogGetFilePath() { return m_filePath; }
/// <summary>
/// Helper to get the current log file root.
/// </summary>
/// <returns></returns>
std::string LogGetFileRoot() { return m_fileRoot; }
/// <summary>
/// Helper to open the detailed log file, file handle.
/// </summary>
@ -117,38 +131,6 @@ static bool LogOpen()
return m_fpLog != nullptr;
}
/// <summary>
/// Helper to open the activity log file, file handle.
/// </summary>
/// <returns>True, if log file is opened, otherwise false.
static bool ActivityLogOpen()
{
if (m_fileLevel == 0U)
return true;
time_t now;
::time(&now);
struct tm* tm = ::gmtime(&now);
if (tm->tm_mday == m_actTm.tm_mday && tm->tm_mon == m_actTm.tm_mon && tm->tm_year == m_actTm.tm_year) {
if (m_actFpLog != nullptr)
return true;
}
else {
if (m_actFpLog != nullptr)
::fclose(m_actFpLog);
}
char filename[200U];
::sprintf(filename, "%s/%s-%04d-%02d-%02d.activity.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
m_actFpLog = ::fopen(filename, "a+t");
m_actTm = *tm;
return m_actFpLog != nullptr;
}
/// <summary>
/// Internal helper to set an output stream to direct logging to.
/// </summary>
@ -158,6 +140,13 @@ void __InternalOutputStream(std::ostream& stream)
m_outStream.rdbuf(stream.rdbuf());
}
/// <summary>Gets the instance of the Network class to transfer the activity log with.</summary>
void* LogGetNetwork()
{
// NO GOOD, VERY BAD, TERRIBLE HACK
return (void*)m_network;
}
/// <summary>
/// Sets the instance of the Network class to transfer the activity log with.
/// </summary>
@ -169,100 +158,7 @@ void LogSetNetwork(void* network)
#endif
// note: The Network class is passed here as a void so we can avoid including the Network.h
// header in Log.h. This is dirty and probably terrible...
m_network = (network::Network*)network;
}
/// <summary>
/// Initializes the activity log.
/// </summary>
/// <param name="filePath">Full-path to the activity log file.</param>
/// <param name="fileRoot">Prefix of the activity log file name.</param>
bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot)
{
#if defined(CATCH2_TEST_COMPILATION)
return true;
#endif
m_actFilePath = filePath;
m_actFileRoot = fileRoot;
m_network = nullptr;
return ::ActivityLogOpen();
}
/// <summary>
/// Finalizes the activity log.
/// </summary>
void ActivityLogFinalise()
{
#if defined(CATCH2_TEST_COMPILATION)
return;
#endif
if (m_actFpLog != nullptr)
::fclose(m_actFpLog);
}
/// <summary>
/// Writes a new entry to the activity log.
/// </summary>
/// <remarks>This is a variable argument function.</remarks>
/// <param name="mode">Digital mode (usually P25 or DMR).</param>
/// <param name="sourceRf">Flag indicating that the entry was generated from an RF event.</param>
/// <param name="msg">Formatted string to write to activity log.</param>
void ActivityLog(const char *mode, const bool sourceRf, const char* msg, ...)
{
#if defined(CATCH2_TEST_COMPILATION)
return;
#endif
assert(mode != nullptr);
assert(msg != nullptr);
char buffer[ACT_LOG_BUFFER_LEN];
struct timeval now;
::gettimeofday(&now, NULL);
struct tm* tm = ::gmtime(&now.tv_sec);
if (strcmp(mode, "") == 0) {
::sprintf(buffer, "A: %04d-%02d-%02d %02d:%02d:%02d.%03lu ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec / 1000U);
}
else {
::sprintf(buffer, "A: %04d-%02d-%02d %02d:%02d:%02d.%03lu %s %s ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec / 1000U, mode, (sourceRf) ? "RF" : "Net");
}
va_list vl;
va_start(vl, msg);
::vsnprintf(buffer + ::strlen(buffer), ACT_LOG_BUFFER_LEN - 1U, msg, vl);
va_end(vl);
bool ret = ::ActivityLogOpen();
if (!ret)
return;
if (m_network != nullptr) {
m_network->writeActLog(buffer);
}
if (m_fileLevel == 0U)
return;
::fprintf(m_actFpLog, "%s\n", buffer);
::fflush(m_actFpLog);
if (2U >= m_fileLevel && m_fileLevel != 0U) {
bool ret = ::ActivityLogOpen();
if (!ret)
return;
::fprintf(m_fpLog, "%s\n", buffer);
::fflush(m_fpLog);
}
if (2U >= g_logDisplayLevel && g_logDisplayLevel != 0U) {
::fprintf(stdout, "%s" EOL, buffer);
::fflush(stdout);
}
m_network = (network::BaseNetwork*)network;
}
/// <summary>

@ -12,7 +12,7 @@
//
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2018-2019 by Bryan Biedenkapp N2PLL
* Copyright (C) 2018-2024 by Bryan Biedenkapp N2PLL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@
#if !defined(__LOG_H__)
#define __LOG_H__
#include "Defines.h"
#include "common/Defines.h"
#include <string>
@ -75,16 +75,19 @@ extern bool g_disableTimeDisplay;
/// <summary>Internal helper to set an output stream to direct logging to.</summary>
extern HOST_SW_API void __InternalOutputStream(std::ostream& stream);
/// <summary>Helper to get the current log file level.</summary>
extern HOST_SW_API uint32_t CurrentLogFileLevel();
/// <summary>Helper to get the current log file path.</summary>
extern HOST_SW_API std::string LogGetFilePath();
/// <summary>Helper to get the current log file root.</summary>
extern HOST_SW_API std::string LogGetFileRoot();
/// <summary>Gets the instance of the Network class to transfer the activity log with.</summary>
extern HOST_SW_API void* LogGetNetwork();
/// <summary>Sets the instance of the Network class to transfer the activity log with.</summary>
extern HOST_SW_API void LogSetNetwork(void* network);
/// <summary>Initializes the activity log.</summary>
extern HOST_SW_API bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot);
/// <summary>Finalizes the activity log.</summary>
extern HOST_SW_API void ActivityLogFinalise();
/// <summary>Writes a new entry to the activity log.</summary>
extern HOST_SW_API void ActivityLog(const char* mode, const bool sourceRf, const char* msg, ...);
/// <summary>Initializes the diagnostics log.</summary>
extern HOST_SW_API bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel, bool disableTimeDisplay = false);
/// <summary>Finalizes the diagnostics log.</summary>

@ -30,8 +30,8 @@
#if !defined(__RING_BUFFER_H__)
#define __RING_BUFFER_H__
#include "Defines.h"
#include "Log.h"
#include "common/Defines.h"
#include "common/Log.h"
#include <cstdio>
#include <cassert>

@ -30,7 +30,7 @@
#if !defined(__STOPWATCH_H__)
#define __STOPWATCH_H__
#include "Defines.h"
#include "common/Defines.h"
#include <sys/time.h>

@ -31,7 +31,7 @@
#if !defined(__THREAD_H__)
#define __THREAD_H__
#include "Defines.h"
#include "common/Defines.h"
#include <string>
#include <pthread.h>

@ -30,8 +30,8 @@
#if !defined(__THREAD_FUNC_H__)
#define __THREAD_FUNC_H__
#include "Defines.h"
#include "Thread.h"
#include "common/Defines.h"
#include "common/Thread.h"
#include <cassert>
#include <functional>

@ -31,7 +31,7 @@
#if !defined(__TIMER_H__)
#define __TIMER_H__
#include "Defines.h"
#include "common/Defines.h"
// ---------------------------------------------------------------------------
// Class Declaration

@ -26,7 +26,7 @@
#if !defined(__UTILS_H__)
#define __UTILS_H__
#include "Defines.h"
#include "common/Defines.h"
#include <string>

@ -31,7 +31,7 @@
#if !defined(__DMR_DEFINES_H__)
#define __DMR_DEFINES_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -30,8 +30,8 @@
#if !defined(__DMR_UTILS_H__)
#define __DMR_UTILS_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
namespace dmr
{

@ -30,9 +30,9 @@
#if !defined(__DMR_SITE_DATA_H__)
#define __DMR_SITE_DATA_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/DMRUtils.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
#include "common/dmr/DMRUtils.h"
namespace dmr
{

@ -27,9 +27,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Defines.h"
#include "dmr/SlotType.h"
#include "edac/Golay2087.h"
#include "common/Defines.h"
#include "common/dmr/SlotType.h"
#include "common/edac/Golay2087.h"
using namespace dmr;

@ -30,7 +30,7 @@
#if !defined(__DMR_SLOT_TYPE_H__)
#define __DMR_SLOT_TYPE_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -30,7 +30,7 @@
#if !defined(__DMR_SYNC_H__)
#define __DMR_SYNC_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -31,9 +31,9 @@
#if !defined(__DMR_ACL__ACCESS_CONTROL_H__)
#define __DMR_ACL__ACCESS_CONTROL_H__
#include "Defines.h"
#include "lookups/RadioIdLookup.h"
#include "lookups/TalkgroupRulesLookup.h"
#include "common/Defines.h"
#include "common/lookups/RadioIdLookup.h"
#include "common/lookups/TalkgroupRulesLookup.h"
namespace dmr
{

@ -25,8 +25,8 @@
#if !defined(__DMR_DATA__DATA_H__)
#define __DMR_DATA__DATA_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
namespace dmr
{

@ -31,7 +31,7 @@
#if !defined(__DMR_DATA__DATA_HEADER_H__)
#define __DMR_DATA__DATA_HEADER_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -30,7 +30,7 @@
#if !defined(__DMR_DATA__EMB_H__)
#define __DMR_DATA__EMB_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -30,9 +30,9 @@
#if !defined(__DMR_DATA__EMBEDDED_DATA_H__)
#define __DMR_DATA__EMBEDDED_DATA_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/lc/LC.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
#include "common/dmr/lc/LC.h"
namespace dmr
{

@ -31,10 +31,10 @@
#if !defined(__DMR_LC__CSBK_H__)
#define __DMR_LC__CSBK_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "dmr/SiteData.h"
#include "lookups/IdenTableLookup.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
#include "common/dmr/SiteData.h"
#include "common/lookups/IdenTableLookup.h"
namespace dmr
{

@ -31,11 +31,11 @@
#if !defined(__DMR_LC__FULL_LC_H__)
#define __DMR_LC__FULL_LC_H__
#include "Defines.h"
#include "dmr/lc/LC.h"
#include "dmr/lc/PrivacyLC.h"
#include "dmr/SlotType.h"
#include "edac/BPTC19696.h"
#include "common/Defines.h"
#include "common/dmr/lc/LC.h"
#include "common/dmr/lc/PrivacyLC.h"
#include "common/dmr/SlotType.h"
#include "common/edac/BPTC19696.h"
namespace dmr
{

@ -31,8 +31,8 @@
#if !defined(__DMR_LC__LC_H__)
#define __DMR_LC__LC_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
namespace dmr
{

@ -27,8 +27,8 @@
#if !defined(__DMR_LC__PRIVACY_LC_H__)
#define __DMR_LC__PRIVACY_LC_H__
#include "Defines.h"
#include "dmr/DMRDefines.h"
#include "common/Defines.h"
#include "common/dmr/DMRDefines.h"
namespace dmr
{

@ -30,7 +30,7 @@
#if !defined(__DMR_LC__SHORT_LC_H__)
#define __DMR_LC__SHORT_LC_H__
#include "Defines.h"
#include "common/Defines.h"
namespace dmr
{

@ -26,29 +26,28 @@
#if !defined(__DMR_LC__CSBK_FACTORY_H__)
#define __DMR_LC__CSBK_FACTORY_H__
#include "Defines.h"
#include "common/Defines.h"
#include "dmr/lc/CSBK.h"
#include "dmr/lc/csbk/CSBK_ACK_RSP.h"
#include "dmr/lc/csbk/CSBK_ALOHA.h"
#include "dmr/lc/csbk/CSBK_BROADCAST.h"
#include "dmr/lc/csbk/CSBK_BSDWNACT.h"
#include "dmr/lc/csbk/CSBK_CALL_ALRT.h"
#include "dmr/lc/csbk/CSBK_DVM_GIT_HASH.h"
#include "dmr/lc/csbk/CSBK_EXT_FNCT.h"
#include "dmr/lc/csbk/CSBK_MAINT.h"
#include "dmr/lc/csbk/CSBK_NACK_RSP.h"
#include "dmr/lc/csbk/CSBK_P_CLEAR.h"
#include "dmr/lc/csbk/CSBK_P_GRANT.h"
#include "dmr/lc/csbk/CSBK_PD_GRANT.h"
#include "dmr/lc/csbk/CSBK_PRECCSBK.h"
#include "dmr/lc/csbk/CSBK_PV_GRANT.h"
#include "dmr/lc/csbk/CSBK_RAND.h"
#include "dmr/lc/csbk/CSBK_RAW.h"
#include "dmr/lc/csbk/CSBK_TD_GRANT.h"
#include "dmr/lc/csbk/CSBK_TV_GRANT.h"
#include "dmr/lc/csbk/CSBK_UU_ANS_RSP.h"
#include "dmr/lc/csbk/CSBK_UU_V_REQ.h"
#include "common/dmr/lc/CSBK.h"
#include "common/dmr/lc/csbk/CSBK_ACK_RSP.h"
#include "common/dmr/lc/csbk/CSBK_ALOHA.h"
#include "common/dmr/lc/csbk/CSBK_BROADCAST.h"
#include "common/dmr/lc/csbk/CSBK_BSDWNACT.h"
#include "common/dmr/lc/csbk/CSBK_CALL_ALRT.h"
#include "common/dmr/lc/csbk/CSBK_EXT_FNCT.h"
#include "common/dmr/lc/csbk/CSBK_MAINT.h"
#include "common/dmr/lc/csbk/CSBK_NACK_RSP.h"
#include "common/dmr/lc/csbk/CSBK_P_CLEAR.h"
#include "common/dmr/lc/csbk/CSBK_P_GRANT.h"
#include "common/dmr/lc/csbk/CSBK_PD_GRANT.h"
#include "common/dmr/lc/csbk/CSBK_PRECCSBK.h"
#include "common/dmr/lc/csbk/CSBK_PV_GRANT.h"
#include "common/dmr/lc/csbk/CSBK_RAND.h"
#include "common/dmr/lc/csbk/CSBK_RAW.h"
#include "common/dmr/lc/csbk/CSBK_TD_GRANT.h"
#include "common/dmr/lc/csbk/CSBK_TV_GRANT.h"
#include "common/dmr/lc/csbk/CSBK_UU_ANS_RSP.h"
#include "common/dmr/lc/csbk/CSBK_UU_V_REQ.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_ACK_RSP_H__)
#define __DMR_LC_CSBK__CSBK_ACK_RSP_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_ALOHA_H__)
#define __DMR_LC_CSBK__CSBK_ALOHA_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_BROADCAST_H__)
#define __DMR_LC_CSBK__CSBK_BROADCAST_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_BSDWNACT_H__)
#define __DMR_LC_CSBK__CSBK_BSDWNACT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_CALL_ALRT_H__)
#define __DMR_LC_CSBK__CSBK_CALL_ALRT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_EXT_FNCT_H__)
#define __DMR_LC_CSBK__CSBK_EXT_FNCT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_MAINT_H__)
#define __DMR_LC_CSBK__CSBK_MAINT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_NACK_RSP_H__)
#define __DMR_LC_CSBK__CSBK_NACK_RSP_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_PD_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_PD_GRANT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_PRECCSBK_H__)
#define __DMR_LC_CSBK__CSBK_PRECCSBK_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_PV_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_PV_GRANT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_P_CLEAR_H__)
#define __DMR_LC_CSBK__CSBK_P_CLEAR_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_P_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_P_GRANT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_RAND_H__)
#define __DMR_LC_CSBK__CSBK_RAND_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_RAW_H__)
#define __DMR_LC_CSBK__CSBK_RAW_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_TD_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_TD_GRANT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_TV_GRANT_H__)
#define __DMR_LC_CSBK__CSBK_TV_GRANT_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_UU_ANS_RSP_H__)
#define __DMR_LC_CSBK__CSBK_UU_ANS_RSP_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -26,8 +26,8 @@
#if !defined(__DMR_LC_CSBK__CSBK_UU_V_REQ_H__)
#define __DMR_LC_CSBK__CSBK_UU_V_REQ_H__
#include "Defines.h"
#include "dmr/lc/CSBK.h"
#include "common/Defines.h"
#include "common/dmr/lc/CSBK.h"
namespace dmr
{

@ -31,7 +31,7 @@
#if !defined(__AMBE_FEC_H__)
#define __AMBE_FEC_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

@ -30,13 +30,13 @@
#if !defined(__BCH_H__)
#define __BCH_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{
// ---------------------------------------------------------------------------
// Class Declaration
// Implements BoseChaudhuriHocquenghem codes for protecting P25 NID
// Implements Bose<EFBFBD>Chaudhuri<EFBFBD>Hocquenghem codes for protecting P25 NID
// data.
// ---------------------------------------------------------------------------

@ -30,7 +30,7 @@
#if !defined(__BPTC19696_H__)
#define __BPTC19696_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

@ -31,7 +31,7 @@
#if !defined(__CRC_H__)
#define __CRC_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

@ -30,7 +30,7 @@
#if !defined(__GOLAY2087_H__)
#define __GOLAY2087_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

@ -31,7 +31,7 @@
#if !defined(__GOLAY24128_H__)
#define __GOLAY24128_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

@ -30,7 +30,7 @@
#if !defined(__HAMMING_H__)
#define __HAMMING_H__
#include "Defines.h"
#include "common/Defines.h"
namespace edac
{

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.