From 2b99cb3f3d43c48d9292707725b6618b18944d42 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 22 Aug 2016 20:59:28 +0200 Subject: Remove dabUtils.{h,cpp}, move to utils Also remove the obsolete dump code --- src/DabMultiplexer.cpp | 4 ---- src/DabMultiplexer.h | 1 - src/DabMux.cpp | 1 - src/Makefile.am | 1 - src/dabUtils.cpp | 52 -------------------------------------------------- src/dabUtils.h | 35 --------------------------------- src/fig/FIG0.cpp | 1 - src/utils.cpp | 15 +++++++++++++++ src/utils.h | 11 +++++++++++ 9 files changed, 26 insertions(+), 95 deletions(-) delete mode 100644 src/dabUtils.cpp delete mode 100644 src/dabUtils.h diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 1707a50..12876aa 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -701,10 +701,6 @@ void DabMultiplexer::mux_frame(std::vector >& outputs } } -#ifdef DUMP_BRIDGE - dumpBytes(dumpData, sizeSubChannel, stderr); -#endif // DUMP_BRIDGE - #if HAVE_OUTPUT_EDI /********************************************************************** *********** Finalise and send EDI ******************************** diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h index ab56090..e069da5 100644 --- a/src/DabMultiplexer.h +++ b/src/DabMultiplexer.h @@ -40,7 +40,6 @@ #include "utils.h" #include "UdpSocket.h" #include "InetAddress.h" -#include "dabUtils.h" #include "PcDebug.h" #include "MuxElements.h" #include "RemoteControl.h" diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 94e292f..0420e34 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -122,7 +122,6 @@ typedef DWORD32 uint32_t; #include "crc.h" #include "UdpSocket.h" #include "InetAddress.h" -#include "dabUtils.h" #include "PcDebug.h" #include "DabMux.h" #include "MuxElements.h" diff --git a/src/Makefile.am b/src/Makefile.am index 268437c..c572ef3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -99,7 +99,6 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \ UdpSocket.h UdpSocket.cpp \ bridge.h bridge.c \ crc.h crc.c \ - dabUtils.h dabUtils.cpp \ fig/FIG.h fig/FIG.cpp \ fig/FIG0.cpp fig/FIG0.h \ fig/FIG1.cpp fig/FIG1.h \ diff --git a/src/dabUtils.cpp b/src/dabUtils.cpp deleted file mode 100644 index dd2965b..0000000 --- a/src/dabUtils.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the - Queen in Right of Canada (Communications Research Center Canada) - */ -/* - This file is part of ODR-DabMux. - - ODR-DabMux 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. - - ODR-DabMux 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 ODR-DabMux. If not, see . - */ - -#include "dabUtils.h" - -long gregorian2mjd(int year,int month,int day) -{ - long MJD; - - //This is the algorithm for the JD, just substract 2400000.5 for MJD - year += 8000; - if(month < 3) { - year--; - month += 12; - } - MJD = (year * 365) + (year / 4) - (year / 100) + (year / 400) - 1200820 - + ((month * 153 + 3) / 5) - 92 + (day - 1); - - return (long)(MJD - 2400000.5); //truncation, loss of data OK! -} - - -void dumpBytes(void* data, int size, FILE* out) -{ - fprintf(out, "Packet of %i bytes", size); - - for (int index = 0; index < size; ++index) { - if ((index % 8) == 0) { - fprintf(out, "\n 0x%.4x(%.4i):", index, index); - } - fprintf(out, " 0x%.2x", ((unsigned char*)data)[index]); - } - fprintf(out, "\n\n"); -} diff --git a/src/dabUtils.h b/src/dabUtils.h deleted file mode 100644 index 9ef31d7..0000000 --- a/src/dabUtils.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the - Queen in Right of Canada (Communications Research Center Canada) - */ -/* - This file is part of ODR-DabMux. - - ODR-DabMux 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. - - ODR-DabMux 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 ODR-DabMux. If not, see . - */ - -#ifndef DABUTILS -#define DABUTILS - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -long gregorian2mjd(int year,int month,int day); -void dumpBytes(void* data, int size, FILE* out = stdout); - - -#endif // DABUTILS diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index 3bd1307..650baa4 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -26,7 +26,6 @@ */ #include "fig/FIG0.h" -#include "dabUtils.h" #include "utils.h" namespace FIC { diff --git a/src/utils.cpp b/src/utils.cpp index 7221453..7a20c43 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -54,6 +54,21 @@ void get_dab_time(time_t *time, uint32_t *millis) } +uint32_t gregorian2mjd(int year, int month, int day) +{ + //This is the algorithm for the JD, just substract 2400000.5 for MJD + year += 8000; + if(month < 3) { + year--; + month += 12; + } + uint32_t JD = + (year * 365) + (year / 4) - (year / 100) + (year / 400) - 1200820 + + ((month * 153 + 3) / 5) - 92 + (day - 1); + + return (uint32_t)(JD - 2400000.5); //truncation, loss of data OK! +} + /* We use fprintf here because this doesn't have * to go to the log. * But all information below must go into the log. diff --git a/src/utils.h b/src/utils.h index 7ffa325..f65bba8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -37,6 +37,17 @@ void update_dab_time(void); void get_dab_time(time_t *time, uint32_t *millis); +/* Convert a date and time into the modified Julian date + * used in FIG 0/10 + * + * Year is four digit format. + * Months are Jan=1, Feb=2, etc. + * First day of the month is 1, as usual. + * + * Returns corresponding MJD + */ +uint32_t gregorian2mjd(int year, int month, int day); + /* Shows the introductory header on program start */ void header_message(); -- cgit v1.2.3