From 037f60ea06a08418ca6f3fdb29a8a17ad90694dd Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 14 Mar 2016 20:24:51 +0000 Subject: [PATCH] Set debugging on a per-file basis. --- Config.h | 4 +--- DMRIdleRX.cpp | 2 ++ DMRSlotRX.cpp | 16 +++++++++------- DStarRX.cpp | 13 ++++++------- IO.cpp | 2 ++ SampleRB.cpp | 1 - SerialPort.cpp | 16 +++++++--------- SerialPort.h | 5 +++-- SerialRB.cpp | 1 - YSFRX.cpp | 8 +++++--- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Config.h b/Config.h index 9189105..5b7a4b1 100644 --- a/Config.h +++ b/Config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 by Jonathan Naylor G4KLX + * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * * 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 @@ -19,8 +19,6 @@ #if !defined(CONFIG_H) #define CONFIG_H -// #define WANT_DEBUG - // Allow the use of the COS line to lockout the modem // #define USE_COS_AS_LOCKOUT diff --git a/DMRIdleRX.cpp b/DMRIdleRX.cpp index 5b4adbd..44a596e 100644 --- a/DMRIdleRX.cpp +++ b/DMRIdleRX.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// #define WANT_DEBUG + #include "Config.h" #include "Globals.h" #include "DMRIdleRX.h" diff --git a/DMRSlotRX.cpp b/DMRSlotRX.cpp index c266ad2..163ffe8 100644 --- a/DMRSlotRX.cpp +++ b/DMRSlotRX.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define WANT_DEBUG + #include "Config.h" #include "Globals.h" #include "DMRSlotRX.h" @@ -119,25 +121,25 @@ bool CDMRSlotRX::processSample(q15_t sample) switch (dataType) { case DT_DATA_HEADER: - // DEBUG3("DMRSlotRX: data header for slot/data type", m_slot ? 2U : 1U, dataType); + DEBUG3("DMRSlotRX: data header for slot/data type", m_slot ? 2U : 1U, dataType); m_endPtr = NOENDPTR; serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); break; case DT_VOICE_LC_HEADER: - // DEBUG3("DMRSlotRX: voice header for slot/data type", m_slot ? 2U : 1U, dataType); + DEBUG3("DMRSlotRX: voice header for slot/data type", m_slot ? 2U : 1U, dataType); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); break; case DT_VOICE_PI_HEADER: - // DEBUG3("DMRSlotRX: pi header for slot/data type", m_slot ? 2U : 1U, dataType); + DEBUG3("DMRSlotRX: pi header for slot/data type", m_slot ? 2U : 1U, dataType); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); break; case DT_TERMINATOR_WITH_LC: - // DEBUG2("DMRSlotRX: terminator for slot", m_slot ? 2U : 1U); + DEBUG2("DMRSlotRX: terminator for slot", m_slot ? 2U : 1U); m_endPtr = NOENDPTR; serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); break; default: - // DEBUG3("DMRSlotRX: data sync for slot/data type", m_slot ? 2U : 1U, dataType); + DEBUG3("DMRSlotRX: data sync for slot/data type", m_slot ? 2U : 1U, dataType); m_endPtr = NOENDPTR; serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); break; @@ -145,14 +147,14 @@ bool CDMRSlotRX::processSample(q15_t sample) } } else if (m_control == 0x20U) { // Voice sync - // DEBUG2("DMRSlotRX: voice sync for slot", m_slot ? 2U : 1U); + DEBUG2("DMRSlotRX: voice sync for slot", m_slot ? 2U : 1U); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); m_syncCount = 0U; m_n = 0U; } else { m_syncCount++; if (m_syncCount >= MAX_SYNC_LOST_FRAMES) { - // DEBUG2("DMRSlotRX: lost for slot", m_slot ? 2U : 1U); + DEBUG2("DMRSlotRX: lost for slot", m_slot ? 2U : 1U); serial.writeDMRLost(m_slot); m_syncCount = 0U; m_threshold = 0; diff --git a/DStarRX.cpp b/DStarRX.cpp index b77ddd6..d0cb104 100644 --- a/DStarRX.cpp +++ b/DStarRX.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX * * 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 @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// #define WANT_DEBUG + #include "Config.h" #include "Globals.h" #include "DStarRX.h" @@ -319,7 +321,7 @@ void CDStarRX::processNone(bool bit) // Exact matching of the frame sync sequence if (countBits32((m_patternBuffer & FRAME_SYNC_MASK) ^ FRAME_SYNC_DATA) == 0U) { - // DEBUG1("DStarRX: found frame sync in None"); + DEBUG1("DStarRX: found frame sync in None"); ::memset(m_rxBuffer, 0x00U, DSTAR_FEC_SECTION_LENGTH_BYTES); m_rxBufferBits = 0U; @@ -371,7 +373,6 @@ void CDStarRX::processHeader(bool bit) unsigned char header[DSTAR_HEADER_LENGTH_BYTES]; bool ok = rxHeader(m_rxBuffer, header); if (ok) { - // DEBUG1("DStarRX: header checksum ok"); io.setDecode(true); serial.writeDStarHeader(header, DSTAR_HEADER_LENGTH_BYTES); @@ -382,8 +383,6 @@ void CDStarRX::processHeader(bool bit) m_rxState = DSRXS_DATA; m_dataBits = MAX_SYNC_BITS; } else { - // DEBUG1("DStarRX: header checksum failed"); - // The checksum failed, return to looking for syncs m_rxState = DSRXS_NONE; } @@ -401,7 +400,7 @@ void CDStarRX::processData(bool bit) // Fuzzy matching of the end frame sequences if (countBits32((m_patternBuffer & END_SYNC_MASK) ^ END_SYNC_DATA) <= END_SYNC_ERRS) { - // DEBUG1("DStarRX: Found end sync in Data"); + DEBUG1("DStarRX: Found end sync in Data"); io.setDecode(false); serial.writeDStarEOT(); @@ -440,7 +439,7 @@ void CDStarRX::processData(bool bit) // We've not seen a data sync for too long, signal RXLOST and change to RX_NONE m_dataBits--; if (m_dataBits == 0U) { - // DEBUG1("DStarRX: data sync timed out, lost lock"); + DEBUG1("DStarRX: data sync timed out, lost lock"); io.setDecode(false); serial.writeDStarLost(); diff --git a/IO.cpp b/IO.cpp index 9981773..d1dab5e 100644 --- a/IO.cpp +++ b/IO.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// #define WANT_DEBUG + #include "Config.h" #include "Globals.h" #include "IO.h" diff --git a/SampleRB.cpp b/SampleRB.cpp index 1d1f9e6..6494a99 100644 --- a/SampleRB.cpp +++ b/SampleRB.cpp @@ -19,7 +19,6 @@ Boston, MA 02110-1301, USA. */ #include "SampleRB.h" -#include "Debug.h" CSampleRB::CSampleRB(uint16_t length) : m_length(length), diff --git a/SerialPort.cpp b/SerialPort.cpp index 97cb463..72d5cb7 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// #define WANT_DEBUG + #include "Config.h" #include "Globals.h" @@ -255,31 +257,31 @@ void CSerialPort::setMode(MMDVM_STATE modemState) { switch (modemState) { case STATE_DMR: - // DEBUG1("Mode set to DMR"); + DEBUG1("Mode set to DMR"); dstarRX.reset(); ysfRX.reset(); break; case STATE_DSTAR: - // DEBUG1("Mode set to D-Star"); + DEBUG1("Mode set to D-Star"); dmrIdleRX.reset(); dmrRX.reset(); ysfRX.reset(); break; case STATE_YSF: - // DEBUG1("Mode set to System Fusion"); + DEBUG1("Mode set to System Fusion"); dmrIdleRX.reset(); dmrRX.reset(); dstarRX.reset(); break; case STATE_CALIBRATE: - // DEBUG1("Mode set to Calibrate"); + DEBUG1("Mode set to Calibrate"); dmrIdleRX.reset(); dmrRX.reset(); dstarRX.reset(); ysfRX.reset(); break; default: - // DEBUG1("Mode set to Idle"); + DEBUG1("Mode set to Idle"); // STATE_IDLE break; } @@ -689,8 +691,6 @@ void CSerialPort::write(const uint8_t* data, uint16_t length, bool flush) #endif } -#if defined(WANT_DEBUG) - void CSerialPort::writeDump(const uint8_t* data, uint8_t length) { ASSERT(length <= 252U); @@ -870,5 +870,3 @@ void CSerialPort::writeAssert(bool cond, const char* text, const char* file, lon write(reply, count, true); } -#endif - diff --git a/SerialPort.h b/SerialPort.h index 0d8ce7c..c6cb0a7 100644 --- a/SerialPort.h +++ b/SerialPort.h @@ -44,16 +44,17 @@ public: void writeCalData(const uint8_t* data, uint8_t length); -#if defined(WANT_DEBUG) void writeDump(const uint8_t* data, uint8_t length); + void writeSamples(const q15_t* data, uint8_t length); + void writeDebug(const char* text); void writeDebug(const char* text, int16_t n1); void writeDebug(const char* text, int16_t n1, int16_t n2); void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3); void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4); + void writeAssert(bool cond, const char* text, const char* file, long line); -#endif private: #if defined(__MBED__) diff --git a/SerialRB.cpp b/SerialRB.cpp index 97912c2..ed11711 100644 --- a/SerialRB.cpp +++ b/SerialRB.cpp @@ -19,7 +19,6 @@ Boston, MA 02110-1301, USA. */ #include "SerialRB.h" -#include "Debug.h" CSerialRB::CSerialRB(uint16_t length) : m_length(length), diff --git a/YSFRX.cpp b/YSFRX.cpp index f10dea0..d343ef5 100644 --- a/YSFRX.cpp +++ b/YSFRX.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2016 by Jonathan Naylor G4KLX * * 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 @@ -16,6 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +// #define WANT_DEBUG + #include "Config.h" #include "Globals.h" #include "YSFRX.h" @@ -503,7 +505,7 @@ void CYSFRX::processData(q15_t sample) // We've not seen a data sync for too long, signal RXLOST and change to RX_NONE m_lostCount--; if (m_lostCount == 0U) { - // DEBUG1("YSFRX: sync timed out, lost lock"); + DEBUG1("YSFRX: sync timed out, lost lock"); io.setDecode(false); serial.writeYSFLost(); @@ -528,7 +530,7 @@ void CYSFRX::processData(q15_t sample) serial.writeYSFData(m_outBuffer, YSF_FRAME_LENGTH_BYTES + 1U); if (ok && (FICH[0U] & 0xC0U) == 0x80U) { - // DEBUG1("YSFRX: end of transmission"); + DEBUG1("YSFRX: end of transmission"); io.setDecode(false); m_state = YSFRXS_NONE; } else {