From 07deaa2a5860fce33e1623d300e3dda775acf1d1 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Tue, 30 Nov 2021 16:16:42 -0700 Subject: [PATCH] it compiles! --- .gitignore | 1 + Controller.cpp | 5 +++-- Main.cpp | 30 ++++++++++++++++++++++++++++++ Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 Main.cpp create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index cc0eafc..dc59682 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ #files configure.h +configure.mk # Executables tcd diff --git a/Controller.cpp b/Controller.cpp index e3b17f1..35b0213 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -129,9 +129,10 @@ void CController::ReadReflector() if (reader.Receive(&tcpack, 40)) { //create a std::shared_ptr to a new packet auto packet = std::make_shared(tcpack); + unsigned int devnum; switch (packet->GetCodecIn()) { case ECodecType::dstar: - unsigned int devnum = current_dstar_vocoder / 3; + devnum = current_dstar_vocoder / 3; //send it to the next available dstar vocoder dstar_device[devnum]->SendData(current_dstar_vocoder%3, packet->GetDStarData()); //push the packet onto that vocoder's queue @@ -140,7 +141,7 @@ void CController::ReadReflector() IncrementDStarVocoder(); break; case ECodecType::dmr: - unsigned int devnum = current_dmr_vocoder / 3; + devnum = current_dmr_vocoder / 3; //send it to the next avaiable dmr vocoder dmr_device[devnum]->SendData(current_dmr_vocoder%3, packet->GetDMRData()); //push the packet onto that vocoder's queue diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..120b1e1 --- /dev/null +++ b/Main.cpp @@ -0,0 +1,30 @@ +// urfd -- The universal reflector +// Copyright © 2021 Thomas A. Early N7TAE +// +// 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include + +#include "Controller.h" + +int main() +{ + CController controller; + if (controller.Start()) + return EXIT_FAILURE; + + controller.Stop(); + + return EXIT_SUCCESS; +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dad89e6 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +#Copyright (C) 2021 by Thomas A. Early, N7TAE + +include configure.mk + +# If you are going to change this path, you will +# need to update the systemd service script +BINDIR = /usr/local/bin + +GCC = g++ + +ifeq ($(debug), true) +CFLAGS = -ggdb3 -W -Werror -Icodec2 -MMD -MD -std=c++11 +else +CFLAGS = -W -Werror -Icodec2 -MMD -MD -std=c++11 +endif + +LDFLAGS = -pthread + +SRCS = $(wildcard *.cpp) $(wildcard codec2/*.cpp) +OBJS = $(SRCS:.cpp=.o) +DEPS = $(SRCS:.cpp=.d) +EXE = tcd + +$(EXE) : $(OBJS) + $(GCC) $(LDFLAGS) $(OBJS) -o $@ + +%.o : %.cpp + $(GCC) $(CFLAGS) -c $< -o $@ + +clean : + $(RM) $(EXE) $(OBJS) $(DEPS) + +-include $(DEPS) + +# The install and uninstall targets need to be run by root +install : $(EXE) + cp $(EXE) $(BINDIR) + cp ../systemd/$(EXE).service /etc/systemd/system/ + systemctl enable $(EXE) + systemctl daemon-reload + systemctl start $(EXE) + +uninstall : + systemctl stop $(EXE) + systemctl disable $(EXE) + systemctl daemon-reload + rm -f /etc/systemd/system/$(EXE).service + rm -f $(BINDIR)/$(EXE) + systemctl daemon-reload