diff --git a/DMRControl.cpp b/DMRControl.cpp index 52cf8d3..3e50b9c 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -16,6 +16,7 @@ #include "DMRCSBK.h" #include "Log.h" +#include #include CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) : @@ -38,6 +39,8 @@ CDMRControl::~CDMRControl() bool CDMRControl::processWakeup(const unsigned char* data) { + assert(data != NULL); + // Wakeups always come in on slot 1 if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK)) return false; @@ -65,21 +68,29 @@ bool CDMRControl::processWakeup(const unsigned char* data) void CDMRControl::writeModemSlot1(unsigned char *data) { + assert(data != NULL); + m_slot1.writeModem(data); } void CDMRControl::writeModemSlot2(unsigned char *data) { + assert(data != NULL); + m_slot2.writeModem(data); } unsigned int CDMRControl::readModemSlot1(unsigned char *data) { + assert(data != NULL); + return m_slot1.readModem(data); } unsigned int CDMRControl::readModemSlot2(unsigned char *data) { + assert(data != NULL); + return m_slot2.readModem(data); } diff --git a/DMRIPSC.cpp b/DMRIPSC.cpp index 4c66b05..0022f2a 100644 --- a/DMRIPSC.cpp +++ b/DMRIPSC.cpp @@ -23,6 +23,7 @@ #include "Utils.h" #include "Log.h" +#include #include const unsigned int BUFFER_LENGTH = 500U; diff --git a/DMRLC.cpp b/DMRLC.cpp index acb3280..8dd897b 100644 --- a/DMRLC.cpp +++ b/DMRLC.cpp @@ -138,6 +138,8 @@ void CDMRLC::getData(unsigned char* bytes) const void CDMRLC::getData(bool* bits) const { + assert(bits != NULL); + unsigned char bytes[9U]; getData(bytes); diff --git a/DMRShortLC.cpp b/DMRShortLC.cpp index 7184066..9341db7 100644 --- a/DMRShortLC.cpp +++ b/DMRShortLC.cpp @@ -83,6 +83,8 @@ void CDMRShortLC::encode(const unsigned char* in, unsigned char* out) void CDMRShortLC::decodeExtractBinary(const unsigned char* in) { + assert(in != NULL); + CUtils::byteToBitsBE(in[0U], m_rawData + 0U); CUtils::byteToBitsBE(in[1U], m_rawData + 8U); CUtils::byteToBitsBE(in[2U], m_rawData + 16U); @@ -131,6 +133,8 @@ bool CDMRShortLC::decodeErrorCheck() // Extract the 36 bits of payload void CDMRShortLC::decodeExtractData(unsigned char* data) const { + assert(data != NULL); + bool bData[40U]; for (unsigned int i = 0U; i < 40U; i++) @@ -156,6 +160,8 @@ void CDMRShortLC::decodeExtractData(unsigned char* data) const // Extract the 36 bits of payload void CDMRShortLC::encodeExtractData(const unsigned char* in) const { + assert(in != NULL); + bool bData[40U]; CUtils::byteToBitsBE(in[0U], bData + 0U); CUtils::byteToBitsBE(in[1U], bData + 8U); @@ -208,6 +214,8 @@ void CDMRShortLC::encodeInterleave() void CDMRShortLC::encodeExtractBinary(unsigned char* data) { + assert(data != NULL); + CUtils::bitsToByteBE(m_rawData + 0U, data[0U]); CUtils::bitsToByteBE(m_rawData + 8U, data[1U]); CUtils::bitsToByteBE(m_rawData + 16U, data[2U]); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index b3b4e58..3ba7e72 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -84,6 +84,8 @@ CDMRSlot::~CDMRSlot() void CDMRSlot::writeModem(unsigned char *data) { + assert(data != NULL); + if (data[0U] == TAG_LOST && m_rfState == RS_RF_AUDIO) { if (m_rfBits == 0U) m_rfBits = 1U; LogMessage("DMR Slot %u, RF transmission lost, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); @@ -502,6 +504,8 @@ void CDMRSlot::writeModem(unsigned char *data) unsigned int CDMRSlot::readModem(unsigned char* data) { + assert(data != NULL); + if (m_queue.isEmpty()) return 0U; @@ -1055,6 +1059,8 @@ void CDMRSlot::clock(unsigned int ms) void CDMRSlot::writeQueueRF(const unsigned char *data) { + assert(data != NULL); + if (m_netState != RS_NET_IDLE) return; @@ -1115,6 +1121,8 @@ void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType) void CDMRSlot::writeQueueNet(const unsigned char *data) { + assert(data != NULL); + unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U; unsigned int space = m_queue.freeSpace(); diff --git a/DStarControl.cpp b/DStarControl.cpp index b7af2b5..9425810 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -16,6 +16,7 @@ #include "Sync.h" #include "Log.h" +#include #include #include @@ -88,6 +89,8 @@ CDStarControl::~CDStarControl() bool CDStarControl::writeModem(unsigned char *data) { + assert(data != NULL); + unsigned char type = data[0U]; if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) { @@ -343,6 +346,8 @@ bool CDStarControl::writeModem(unsigned char *data) unsigned int CDStarControl::readModem(unsigned char* data) { + assert(data != NULL); + if (m_queue.isEmpty()) return 0U; diff --git a/DStarHeader.cpp b/DStarHeader.cpp index 914dab3..ab39292 100644 --- a/DStarHeader.cpp +++ b/DStarHeader.cpp @@ -82,51 +82,71 @@ void CDStarHeader::setUnavailable(bool on) void CDStarHeader::getMyCall1(unsigned char* call1) const { + assert(call1 != NULL); + ::memcpy(call1, m_header + 27U, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::getMyCall2(unsigned char* call2) const { + assert(call2 != NULL); + ::memcpy(call2, m_header + 35U, DSTAR_SHORT_CALLSIGN_LENGTH); } void CDStarHeader::setMyCall1(const unsigned char* call1) { + assert(call1 != NULL); + ::memcpy(m_header + 27U, call1, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::setMyCall2(const unsigned char* call2) { + assert(call2 != NULL); + ::memcpy(m_header + 35U, call2, DSTAR_SHORT_CALLSIGN_LENGTH); } void CDStarHeader::getRPTCall1(unsigned char* call1) const { + assert(call1 != NULL); + ::memcpy(call1, m_header + 11U, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::getRPTCall2(unsigned char* call2) const { + assert(call2 != NULL); + ::memcpy(call2, m_header + 3U, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::setRPTCall1(const unsigned char* call1) { + assert(call1 != NULL); + ::memcpy(m_header + 11U, call1, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::setRPTCall2(const unsigned char* call2) { + assert(call2 != NULL); + ::memcpy(m_header + 3U, call2, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::getYourCall(unsigned char* call) const { + assert(call != NULL); + ::memcpy(call, m_header + 19U, DSTAR_LONG_CALLSIGN_LENGTH); } void CDStarHeader::setYourCall(const unsigned char* call) { + assert(call != NULL); + ::memcpy(m_header + 19U, call, DSTAR_LONG_CALLSIGN_LENGTH); } diff --git a/Hamming.cpp b/Hamming.cpp index d291086..6652197 100644 --- a/Hamming.cpp +++ b/Hamming.cpp @@ -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 @@ -18,9 +18,14 @@ #include "Hamming.h" +#include +#include + // Hamming (15,11,3) check a boolean data array bool CHamming::decode15113(bool* d) { + assert(d != NULL); + // Calculate the checksum this row should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9]; @@ -60,6 +65,8 @@ bool CHamming::decode15113(bool* d) void CHamming::encode15113(bool* d) { + assert(d != NULL); + // Calculate the checksum this row should have d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; d[12] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9]; @@ -70,6 +77,8 @@ void CHamming::encode15113(bool* d) // Hamming (13,9,3) check a boolean data array bool CHamming::decode1393(bool* d) { + assert(d != NULL); + // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; bool c1 = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7]; @@ -107,6 +116,8 @@ bool CHamming::decode1393(bool* d) void CHamming::encode1393(bool* d) { + assert(d != NULL); + // Calculate the checksum this column should have d[9] = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; d[10] = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7]; @@ -117,6 +128,8 @@ void CHamming::encode1393(bool* d) // A Hamming (16,11,4) Check bool CHamming::decode16114(bool* d) { + assert(d != NULL); + // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9]; @@ -163,6 +176,8 @@ bool CHamming::decode16114(bool* d) void CHamming::encode16114(bool* d) { + assert(d != NULL); + d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; d[12] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9]; d[13] = d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[7] ^ d[9] ^ d[10]; @@ -173,6 +188,8 @@ void CHamming::encode16114(bool* d) // A Hamming (17,12,3) Check bool CHamming::decode17123(bool* d) { + assert(d != NULL); + // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; bool c1 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10]; @@ -220,6 +237,8 @@ bool CHamming::decode17123(bool* d) void CHamming::encode17123(bool* d) { + assert(d != NULL); + d[12] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; d[13] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10]; d[14] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[8] ^ d[9] ^ d[11]; diff --git a/Modem.cpp b/Modem.cpp index f9f4bff..f95e5ee 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include +#include #include #include @@ -858,6 +859,8 @@ bool CModem::setFrequency() RESP_TYPE_MMDVM CModem::getResponse(unsigned char *buffer, unsigned int& length) { + assert(buffer != NULL); + // Get the start of the frame or nothing at all int ret = m_serial.read(buffer + 0U, 1U); if (ret < 0) { diff --git a/TFTSerial.cpp b/TFTSerial.cpp index 20a8ec1..be87b23 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -65,8 +65,6 @@ bool CTFTSerial::open() setRotation(ROTATION_LANDSCAPE); - setFontSize(FONT_SMALL); - setBrightness(m_brightness); // Set background white diff --git a/Utils.cpp b/Utils.cpp index 52d9063..49ded13 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX + * Copyright (C) 2009,2014,2015,2016 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 @@ -91,6 +91,8 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne void CUtils::byteToBitsBE(unsigned char byte, bool* bits) { + assert(bits != NULL); + bits[0U] = (byte & 0x80U) == 0x80U; bits[1U] = (byte & 0x40U) == 0x40U; bits[2U] = (byte & 0x20U) == 0x20U; @@ -103,6 +105,8 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits) void CUtils::byteToBitsLE(unsigned char byte, bool* bits) { + assert(bits != NULL); + bits[0U] = (byte & 0x01U) == 0x01U; bits[1U] = (byte & 0x02U) == 0x02U; bits[2U] = (byte & 0x04U) == 0x04U; @@ -115,6 +119,8 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits) void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte) { + assert(bits != NULL); + byte = bits[0U] ? 0x80U : 0x00U; byte |= bits[1U] ? 0x40U : 0x00U; byte |= bits[2U] ? 0x20U : 0x00U; @@ -127,6 +133,8 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte) void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte) { + assert(bits != NULL); + byte = bits[0U] ? 0x01U : 0x00U; byte |= bits[1U] ? 0x02U : 0x00U; byte |= bits[2U] ? 0x04U : 0x00U; diff --git a/YSFControl.cpp b/YSFControl.cpp index 61522aa..9db55ad 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -16,6 +16,7 @@ #include "Sync.h" #include "Log.h" +#include #include #include @@ -58,6 +59,8 @@ CYSFControl::~CYSFControl() bool CYSFControl::writeModem(unsigned char *data) { + assert(data != NULL); + unsigned char type = data[0U]; if (type == TAG_LOST && m_state == RS_RF_AUDIO) { @@ -215,6 +218,8 @@ bool CYSFControl::writeModem(unsigned char *data) unsigned int CYSFControl::readModem(unsigned char* data) { + assert(data != NULL); + if (m_queue.isEmpty()) return 0U;