From 843f83611d4d404b81fa4246c0698a17ab771f04 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 3 Feb 2016 07:20:48 +0000 Subject: [PATCH] Add extra debugging for D-Star. --- DStarControl.cpp | 24 ++++++++++++++++++------ DStarSlowData.cpp | 3 +++ Makefile | 2 +- Version.h | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/DStarControl.cpp b/DStarControl.cpp index efb9d1a..c211123 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -100,15 +100,19 @@ bool CDStarControl::writeModem(unsigned char *data) CDStarHeader header(data + 1U); // Is this a transmission destined for a repeater? - if (!header.isRepeater()) + if (!header.isRepeater()) { + LogMessage("D-Star, non repeater RF header received"); return false; + } unsigned char callsign[DSTAR_LONG_CALLSIGN_LENGTH]; header.getRPTCall1(callsign); // Is it for us? - if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) + if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) { + LogMessage("D-Star, received RF header for wrong repeater - %8.8s", callsign); return false; + } unsigned char gateway[DSTAR_LONG_CALLSIGN_LENGTH]; header.getRPTCall2(gateway); @@ -205,7 +209,7 @@ bool CDStarControl::writeModem(unsigned char *data) } return false; - } else { + } else if (type == TAG_DATA) { if (m_state == RS_LISTENING) { // The sync is regenerated by the modem so can do exact match if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0) { @@ -257,15 +261,19 @@ bool CDStarControl::writeModem(unsigned char *data) return false; // Is this a transmission destined for a repeater? - if (!header->isRepeater()) + if (!header->isRepeater()) { + LogMessage("D-Star, non repeater RF late entry header received"); return false; + } unsigned char callsign[DSTAR_LONG_CALLSIGN_LENGTH]; header->getRPTCall1(callsign); // Is it for us? - if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) + if (::memcmp(callsign, m_callsign, DSTAR_LONG_CALLSIGN_LENGTH) != 0) { + LogMessage("D-Star, received RF header for wrong repeater - %8.8s", callsign); return false; + } unsigned char gateway[DSTAR_LONG_CALLSIGN_LENGTH]; header->getRPTCall2(gateway); @@ -346,6 +354,8 @@ bool CDStarControl::writeModem(unsigned char *data) LogMessage("D-Star, received RF late entry from %8.8s/%4.4s to %8.8s", my1, my2, your); } + } else { + CUtils::dump("D-Star, unknown data from modem", data, DSTAR_FRAME_LENGTH_BYTES + 1U); } return true; @@ -458,7 +468,7 @@ void CDStarControl::writeNetwork() LogMessage("D-Star, received network end of transmission, %.1f seconds, %u%% packet loss, BER: %.1f%%", float(m_frames) / 50.0F, (m_lost * 100U) / m_frames, float(m_errs * 100U) / float(m_bits)); writeEndOfTransmission(); - } else { + } else if (type == TAG_DATA) { if (m_state != RS_RELAYING_NETWORK_AUDIO) return; @@ -486,6 +496,8 @@ void CDStarControl::writeNetwork() writeFile(data + 1U, length - 1U); #endif writeQueueData(data + 1U); + } else { + CUtils::dump("D-Star, unknown data from network", data, DSTAR_FRAME_LENGTH_BYTES + 1U); } } diff --git a/DStarSlowData.cpp b/DStarSlowData.cpp index e38ef6e..977d30f 100644 --- a/DStarSlowData.cpp +++ b/DStarSlowData.cpp @@ -19,6 +19,7 @@ #include "DStarSlowData.h" #include "DStarDefines.h" #include "CRC.h" +#include "Log.h" #include #include @@ -90,6 +91,8 @@ CDStarHeader* CDStarSlowData::add(const unsigned char* data) // Compare them if (::memcmp(crc, m_header + 39U, 2U) != 0) { + if (m_ptr == 45U) + LogMessage("D-Star, invalid slow data header"); ::memcpy(m_header + 39U, crc, 2U); return NULL; } diff --git a/Makefile b/Makefile index 33e9876..c127b94 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ DStarHeader.o: DStarHeader.cpp DStarHeader.h DStarDefines.h CRC.h DStarNetwork.o: DStarNetwork.cpp DStarNetwork.h Log.h UDPSocket.h RingBuffer.h Utils.h StopWatch.h DStarDefines.h Defines.h Timer.h $(CC) $(CFLAGS) -c DStarNetwork.cpp -DStarSlowData.o: DStarSlowData.cpp DStarSlowData.h DStarHeader.h DStarDefines.h CRC.h +DStarSlowData.o: DStarSlowData.cpp DStarSlowData.h DStarHeader.h DStarDefines.h CRC.h Log.h $(CC) $(CFLAGS) -c DStarSlowData.cpp EMB.o: EMB.cpp EMB.h diff --git a/Version.h b/Version.h index 3ca887b..9ce126e 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20160202"; +const char* VERSION = "20160203"; #endif