Convert to C++ nullptr from NULL.

This commit is contained in:
Jonathan Naylor 2025-03-14 12:13:11 +00:00
parent 43f8b2f6f0
commit cf15f42a0f
98 changed files with 1340 additions and 1340 deletions

View file

@ -475,7 +475,7 @@ CAMBEFEC::~CAMBEFEC()
unsigned int CAMBEFEC::regenerateDMR(unsigned char* bytes) const unsigned int CAMBEFEC::regenerateDMR(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
unsigned int a1 = 0U, a2 = 0U, a3 = 0U; unsigned int a1 = 0U, a2 = 0U, a3 = 0U;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;
@ -576,7 +576,7 @@ unsigned int CAMBEFEC::regenerateDMR(unsigned char* bytes) const
unsigned int CAMBEFEC::regenerateDStar(unsigned char* bytes) const unsigned int CAMBEFEC::regenerateDStar(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
unsigned int a = 0U; unsigned int a = 0U;
unsigned int b = 0U; unsigned int b = 0U;
@ -608,7 +608,7 @@ unsigned int CAMBEFEC::regenerateDStar(unsigned char* bytes) const
unsigned int CAMBEFEC::regenerateYSFDN(unsigned char* bytes) const unsigned int CAMBEFEC::regenerateYSFDN(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
unsigned int a = 0U; unsigned int a = 0U;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;
@ -659,7 +659,7 @@ unsigned int CAMBEFEC::regenerateYSFDN(unsigned char* bytes) const
unsigned int CAMBEFEC::regenerateIMBE(unsigned char* bytes) const unsigned int CAMBEFEC::regenerateIMBE(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
bool orig[144U]; bool orig[144U];
bool temp[144U]; bool temp[144U];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Jonathan Naylor, G4KLX * Copyright (C) 2020,2025 Jonathan Naylor, G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ CAX25Control::CAX25Control(CAX25Network* network, bool trace) :
m_network(network), m_network(network),
m_trace(trace), m_trace(trace),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
} }
@ -42,7 +42,7 @@ CAX25Control::~CAX25Control()
bool CAX25Control::writeModem(unsigned char *data, unsigned int len) bool CAX25Control::writeModem(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -52,7 +52,7 @@ bool CAX25Control::writeModem(unsigned char *data, unsigned int len)
CUtils::dump(1U, "AX.25 received packet", data, len); CUtils::dump(1U, "AX.25 received packet", data, len);
if (m_network == NULL) if (m_network == nullptr)
return true; return true;
return m_network->write(data, len); return m_network->write(data, len);
@ -60,9 +60,9 @@ bool CAX25Control::writeModem(unsigned char *data, unsigned int len)
unsigned int CAX25Control::readModem(unsigned char* data) unsigned int CAX25Control::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return 0U; return 0U;
if (!m_enabled) if (!m_enabled)
@ -78,7 +78,7 @@ unsigned int CAX25Control::readModem(unsigned char* data)
bool CAX25Control::openFile() bool CAX25Control::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -90,7 +90,7 @@ bool CAX25Control::openFile()
::sprintf(name, "AX25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "AX25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("AX25", 1U, 4U, m_fp); ::fwrite("AX25", 1U, 4U, m_fp);
@ -100,7 +100,7 @@ bool CAX25Control::openFile()
bool CAX25Control::writeFile(const unsigned char* data, unsigned int length) bool CAX25Control::writeFile(const unsigned char* data, unsigned int length)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(&length, 1U, sizeof(unsigned int), m_fp); ::fwrite(&length, 1U, sizeof(unsigned int), m_fp);
@ -111,9 +111,9 @@ bool CAX25Control::writeFile(const unsigned char* data, unsigned int length)
void CAX25Control::closeFile() void CAX25Control::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }
@ -124,7 +124,7 @@ void CAX25Control::enable(bool enabled)
void CAX25Control::decode(const unsigned char* data, unsigned int length) void CAX25Control::decode(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length >= 15U); assert(length >= 15U);
std::string text; std::string text;
@ -223,7 +223,7 @@ void CAX25Control::decode(const unsigned char* data, unsigned int length)
bool CAX25Control::decodeAddress(const unsigned char* data, std::string& text, bool isDigi) const bool CAX25Control::decodeAddress(const unsigned char* data, std::string& text, bool isDigi) const
{ {
assert(data != NULL); assert(data != nullptr);
for (unsigned int i = 0U; i < 6U; i++) { for (unsigned int i = 0U; i < 6U; i++) {
char c = data[i] >> 1; char c = data[i] >> 1;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 by Jonathan Naylor G4KLX * Copyright (C) 2020,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,8 +31,8 @@ const unsigned int BUFFER_LENGTH = 500U;
CAX25Network::CAX25Network(const std::string& port, unsigned int speed, bool debug) : CAX25Network::CAX25Network(const std::string& port, unsigned int speed, bool debug) :
m_serial(port, speed, false), m_serial(port, speed, false),
m_txData(NULL), m_txData(nullptr),
m_rxData(NULL), m_rxData(nullptr),
m_rxLength(0U), m_rxLength(0U),
m_rxLastChar(0U), m_rxLastChar(0U),
m_debug(debug), m_debug(debug),
@ -60,7 +60,7 @@ bool CAX25Network::open()
bool CAX25Network::write(const unsigned char* data, unsigned int length) bool CAX25Network::write(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return true; return true;
@ -98,7 +98,7 @@ bool CAX25Network::write(const unsigned char* data, unsigned int length)
unsigned int CAX25Network::read(unsigned char* data, unsigned int length) unsigned int CAX25Network::read(unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
bool complete = false; bool complete = false;

View file

@ -123,7 +123,7 @@ void CBCH::encode(const int* data, int* bb)
void CBCH::encode(unsigned char* nid) void CBCH::encode(unsigned char* nid)
{ {
assert(nid != NULL); assert(nid != nullptr);
int data[16]; int data[16];
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2012 by Ian Wraith * Copyright (C) 2012 by Ian Wraith
* Copyright (C) 2015 by Jonathan Naylor G4KLX * Copyright (C) 2015,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,8 +27,8 @@
#include <cstring> #include <cstring>
CBPTC19696::CBPTC19696() : CBPTC19696::CBPTC19696() :
m_rawData(NULL), m_rawData(nullptr),
m_deInterData(NULL) m_deInterData(nullptr)
{ {
m_rawData = new bool[196]; m_rawData = new bool[196];
m_deInterData = new bool[196]; m_deInterData = new bool[196];
@ -43,8 +43,8 @@ CBPTC19696::~CBPTC19696()
// The main decode function // The main decode function
void CBPTC19696::decode(const unsigned char* in, unsigned char* out) void CBPTC19696::decode(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Get the raw binary // Get the raw binary
decodeExtractBinary(in); decodeExtractBinary(in);
@ -62,8 +62,8 @@ void CBPTC19696::decode(const unsigned char* in, unsigned char* out)
// The main encode function // The main encode function
void CBPTC19696::encode(const unsigned char* in, unsigned char* out) void CBPTC19696::encode(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Extract Data // Extract Data
encodeExtractData(in); encodeExtractData(in);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2018,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2016,2018,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -54,7 +54,7 @@ void CCASTInfo::setIdleInt()
m_ipaddress = (char*)info; m_ipaddress = (char*)info;
delete m_network; delete m_network;
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeIPInfo(m_ipaddress); m_modem->writeIPInfo(m_ipaddress);
networkInfoInitialized = true; networkInfoInitialized = true;
@ -80,7 +80,7 @@ void CCASTInfo::setFMInt()
void CCASTInfo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) void CCASTInfo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeDStarInfo(my1, my2, your, type, reflector); m_modem->writeDStarInfo(my1, my2, your, type, reflector);
} }
@ -90,7 +90,7 @@ void CCASTInfo::clearDStarInt()
void CCASTInfo::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) void CCASTInfo::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeDMRInfo(slotNo, src, group, dst, type); m_modem->writeDMRInfo(slotNo, src, group, dst, type);
} }
@ -100,7 +100,7 @@ void CCASTInfo::clearDMRInt(unsigned int slotNo)
void CCASTInfo::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) void CCASTInfo::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeYSFInfo(source, dest, dgid, type, origin); m_modem->writeYSFInfo(source, dest, dgid, type, origin);
} }
@ -110,7 +110,7 @@ void CCASTInfo::clearFusionInt()
void CCASTInfo::writeP25Int(const char* source, bool group, unsigned int dest, const char* type) void CCASTInfo::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeP25Info(source, group, dest, type); m_modem->writeP25Info(source, group, dest, type);
} }
@ -120,7 +120,7 @@ void CCASTInfo::clearP25Int()
void CCASTInfo::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type) void CCASTInfo::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeNXDNInfo(source, group, dest, type); m_modem->writeNXDNInfo(source, group, dest, type);
} }
@ -130,7 +130,7 @@ void CCASTInfo::clearNXDNInt()
void CCASTInfo::writeM17Int(const char* source, const char* dest, const char* type) void CCASTInfo::writeM17Int(const char* source, const char* dest, const char* type)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writeM17Info(source, dest, type); m_modem->writeM17Info(source, dest, type);
} }
@ -140,7 +140,7 @@ void CCASTInfo::clearM17Int()
void CCASTInfo::writePOCSAGInt(uint32_t ric, const std::string& message) void CCASTInfo::writePOCSAGInt(uint32_t ric, const std::string& message)
{ {
if (m_modem != NULL) if (m_modem != nullptr)
m_modem->writePOCSAGInfo(ric, message); m_modem->writePOCSAGInfo(ric, message);
} }

16
CRC.cpp
View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -121,7 +121,7 @@ const uint16_t CCITT16_TABLE2[] = {
bool CCRC::checkFiveBit(bool* in, unsigned int tcrc) bool CCRC::checkFiveBit(bool* in, unsigned int tcrc)
{ {
assert(in != NULL); assert(in != nullptr);
unsigned int crc; unsigned int crc;
encodeFiveBit(in, crc); encodeFiveBit(in, crc);
@ -131,7 +131,7 @@ bool CCRC::checkFiveBit(bool* in, unsigned int tcrc)
void CCRC::encodeFiveBit(const bool* in, unsigned int& tcrc) void CCRC::encodeFiveBit(const bool* in, unsigned int& tcrc)
{ {
assert(in != NULL); assert(in != nullptr);
unsigned short total = 0U; unsigned short total = 0U;
for (unsigned int i = 0U; i < 72U; i += 8U) { for (unsigned int i = 0U; i < 72U; i += 8U) {
@ -147,7 +147,7 @@ void CCRC::encodeFiveBit(const bool* in, unsigned int& tcrc)
void CCRC::addCCITT162(unsigned char *in, unsigned int length) void CCRC::addCCITT162(unsigned char *in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union {
@ -168,7 +168,7 @@ void CCRC::addCCITT162(unsigned char *in, unsigned int length)
bool CCRC::checkCCITT162(const unsigned char *in, unsigned int length) bool CCRC::checkCCITT162(const unsigned char *in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union {
@ -188,7 +188,7 @@ bool CCRC::checkCCITT162(const unsigned char *in, unsigned int length)
void CCRC::addCCITT161(unsigned char *in, unsigned int length) void CCRC::addCCITT161(unsigned char *in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union {
@ -209,7 +209,7 @@ void CCRC::addCCITT161(unsigned char *in, unsigned int length)
bool CCRC::checkCCITT161(const unsigned char *in, unsigned int length) bool CCRC::checkCCITT161(const unsigned char *in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
assert(length > 2U); assert(length > 2U);
union { union {
@ -229,7 +229,7 @@ bool CCRC::checkCCITT161(const unsigned char *in, unsigned int length)
unsigned char CCRC::crc8(const unsigned char *in, unsigned int length) unsigned char CCRC::crc8(const unsigned char *in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint8_t crc = 0U; uint8_t crc = 0U;

View file

@ -356,7 +356,7 @@ CConf::~CConf()
bool CConf::read() bool CConf::read()
{ {
FILE* fp = ::fopen(m_file.c_str(), "rt"); FILE* fp = ::fopen(m_file.c_str(), "rt");
if (fp == NULL) { if (fp == nullptr) {
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str()); ::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
return false; return false;
} }
@ -364,7 +364,7 @@ bool CConf::read()
SECTION section = SECTION::NONE; SECTION section = SECTION::NONE;
char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE];
while (::fgets(buffer, BUFFER_SIZE, fp) != NULL) { while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
if (buffer[0U] == '#') if (buffer[0U] == '#')
continue; continue;
@ -442,11 +442,11 @@ bool CConf::read()
} }
char* key = ::strtok(buffer, " \t=\r\n"); char* key = ::strtok(buffer, " \t=\r\n");
if (key == NULL) if (key == nullptr)
continue; continue;
char* value = ::strtok(NULL, "\r\n"); char* value = ::strtok(nullptr, "\r\n");
if (value == NULL) if (value == nullptr)
continue; continue;
// Remove quotes from the value // Remove quotes from the value
@ -458,7 +458,7 @@ bool CConf::read()
char *p; char *p;
// if value is not quoted, remove after # (to make comment) // if value is not quoted, remove after # (to make comment)
if ((p = strchr(value, '#')) != NULL) if ((p = strchr(value, '#')) != nullptr)
*p = '\0'; *p = '\0';
// remove trailing tab/space // remove trailing tab/space
@ -550,7 +550,7 @@ bool CConf::read()
else if (::strcmp(key, "I2CPort") == 0) else if (::strcmp(key, "I2CPort") == 0)
m_modemI2CPort = value; m_modemI2CPort = value;
else if (::strcmp(key, "I2CAddress") == 0) else if (::strcmp(key, "I2CAddress") == 0)
m_modemI2CAddress = (unsigned int)::strtoul(value, NULL, 16); m_modemI2CAddress = (unsigned int)::strtoul(value, nullptr, 16);
else if (::strcmp(key, "ModemAddress") == 0) else if (::strcmp(key, "ModemAddress") == 0)
m_modemModemAddress = value; m_modemModemAddress = value;
else if (::strcmp(key, "ModemPort") == 0) else if (::strcmp(key, "ModemPort") == 0)
@ -634,7 +634,7 @@ bool CConf::read()
m_dstarSelfOnly = ::atoi(value) == 1; m_dstarSelfOnly = ::atoi(value) == 1;
else if (::strcmp(key, "BlackList") == 0) { else if (::strcmp(key, "BlackList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
if (::strlen(p) > 0U) { if (::strlen(p) > 0U) {
for (unsigned int i = 0U; p[i] != 0; i++) for (unsigned int i = 0U; p[i] != 0; i++)
p[i] = ::toupper(p[i]); p[i] = ::toupper(p[i]);
@ -642,11 +642,11 @@ bool CConf::read()
callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' '); callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' ');
m_dstarBlackList.push_back(callsign); m_dstarBlackList.push_back(callsign);
} }
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "WhiteList") == 0) { } else if (::strcmp(key, "WhiteList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
if (::strlen(p) > 0U) { if (::strlen(p) > 0U) {
for (unsigned int i = 0U; p[i] != 0; i++) for (unsigned int i = 0U; p[i] != 0; i++)
p[i] = ::toupper(p[i]); p[i] = ::toupper(p[i]);
@ -654,7 +654,7 @@ bool CConf::read()
callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' '); callsign.resize(DSTAR_LONG_CALLSIGN_LENGTH, ' ');
m_dstarWhiteList.push_back(callsign); m_dstarWhiteList.push_back(callsign);
} }
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "AckReply") == 0) } else if (::strcmp(key, "AckReply") == 0)
m_dstarAckReply = ::atoi(value) == 1; m_dstarAckReply = ::atoi(value) == 1;
@ -692,43 +692,43 @@ bool CConf::read()
m_dmrDumpTAData = ::atoi(value) == 1; m_dmrDumpTAData = ::atoi(value) == 1;
else if (::strcmp(key, "Prefixes") == 0) { else if (::strcmp(key, "Prefixes") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int prefix = (unsigned int)::atoi(p); unsigned int prefix = (unsigned int)::atoi(p);
if (prefix > 0U && prefix <= 999U) if (prefix > 0U && prefix <= 999U)
m_dmrPrefixes.push_back(prefix); m_dmrPrefixes.push_back(prefix);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "BlackList") == 0) { } else if (::strcmp(key, "BlackList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int id = (unsigned int)::atoi(p); unsigned int id = (unsigned int)::atoi(p);
if (id > 0U) if (id > 0U)
m_dmrBlackList.push_back(id); m_dmrBlackList.push_back(id);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "WhiteList") == 0) { } else if (::strcmp(key, "WhiteList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int id = (unsigned int)::atoi(p); unsigned int id = (unsigned int)::atoi(p);
if (id > 0U) if (id > 0U)
m_dmrWhiteList.push_back(id); m_dmrWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "Slot1TGWhiteList") == 0) { } else if (::strcmp(key, "Slot1TGWhiteList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int id = (unsigned int)::atoi(p); unsigned int id = (unsigned int)::atoi(p);
if (id > 0U) if (id > 0U)
m_dmrSlot1TGWhiteList.push_back(id); m_dmrSlot1TGWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "Slot2TGWhiteList") == 0) { } else if (::strcmp(key, "Slot2TGWhiteList") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int id = (unsigned int)::atoi(p); unsigned int id = (unsigned int)::atoi(p);
if (id > 0U) if (id > 0U)
m_dmrSlot2TGWhiteList.push_back(id); m_dmrSlot2TGWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} else if (::strcmp(key, "TXHang") == 0) } else if (::strcmp(key, "TXHang") == 0)
m_dmrTXHang = (unsigned int)::atoi(value); m_dmrTXHang = (unsigned int)::atoi(value);
@ -775,7 +775,7 @@ bool CConf::read()
else if (::strcmp(key, "Id") == 0) else if (::strcmp(key, "Id") == 0)
m_p25Id = (unsigned int)::atoi(value); m_p25Id = (unsigned int)::atoi(value);
else if (::strcmp(key, "NAC") == 0) else if (::strcmp(key, "NAC") == 0)
m_p25NAC = (unsigned int)::strtoul(value, NULL, 16); m_p25NAC = (unsigned int)::strtoul(value, nullptr, 16);
else if (::strcmp(key, "OverrideUIDCheck") == 0) else if (::strcmp(key, "OverrideUIDCheck") == 0)
m_p25OverrideUID = ::atoi(value) == 1; m_p25OverrideUID = ::atoi(value) == 1;
else if (::strcmp(key, "SelfOnly") == 0) else if (::strcmp(key, "SelfOnly") == 0)
@ -1086,7 +1086,7 @@ bool CConf::read()
else if (::strcmp(key, "Columns") == 0) else if (::strcmp(key, "Columns") == 0)
m_hd44780Columns = (unsigned int)::atoi(value); m_hd44780Columns = (unsigned int)::atoi(value);
else if (::strcmp(key, "I2CAddress") == 0) else if (::strcmp(key, "I2CAddress") == 0)
m_hd44780i2cAddress = (unsigned int)::strtoul(value, NULL, 16); m_hd44780i2cAddress = (unsigned int)::strtoul(value, nullptr, 16);
else if (::strcmp(key, "PWM") == 0) else if (::strcmp(key, "PWM") == 0)
m_hd44780PWM = ::atoi(value) == 1; m_hd44780PWM = ::atoi(value) == 1;
else if (::strcmp(key, "PWMPin") == 0) else if (::strcmp(key, "PWMPin") == 0)
@ -1101,10 +1101,10 @@ bool CConf::read()
m_hd44780UTC = ::atoi(value) == 1; m_hd44780UTC = ::atoi(value) == 1;
else if (::strcmp(key, "Pins") == 0) { else if (::strcmp(key, "Pins") == 0) {
char* p = ::strtok(value, ",\r\n"); char* p = ::strtok(value, ",\r\n");
while (p != NULL) { while (p != nullptr) {
unsigned int pin = (unsigned int)::atoi(p); unsigned int pin = (unsigned int)::atoi(p);
m_hd44780Pins.push_back(pin); m_hd44780Pins.push_back(pin);
p = ::strtok(NULL, ",\r\n"); p = ::strtok(nullptr, ",\r\n");
} }
} }
} else if (section == SECTION::NEXTION) { } else if (section == SECTION::NEXTION) {
@ -1119,7 +1119,7 @@ bool CConf::read()
else if (::strcmp(key, "IdleBrightness") == 0) else if (::strcmp(key, "IdleBrightness") == 0)
m_nextionIdleBrightness = (unsigned int)::atoi(value); m_nextionIdleBrightness = (unsigned int)::atoi(value);
else if (::strcmp(key, "ScreenLayout") == 0) else if (::strcmp(key, "ScreenLayout") == 0)
m_nextionScreenLayout = (unsigned int)::strtoul(value, NULL, 0); m_nextionScreenLayout = (unsigned int)::strtoul(value, nullptr, 0);
else if (::strcmp(key, "DisplayTempInFahrenheit") == 0) else if (::strcmp(key, "DisplayTempInFahrenheit") == 0)
m_nextionTempInFahrenheit = ::atoi(value) == 1; m_nextionTempInFahrenheit = ::atoi(value) == 1;
else if (::strcmp(key, "NextionOutput") == 0) else if (::strcmp(key, "NextionOutput") == 0)

View file

@ -26,7 +26,7 @@
#include <cassert> #include <cassert>
CDMRCSBK::CDMRCSBK() : CDMRCSBK::CDMRCSBK() :
m_data(NULL), m_data(nullptr),
m_CSBKO(CSBKO::NONE), m_CSBKO(CSBKO::NONE),
m_FID(0x00U), m_FID(0x00U),
m_GI(false), m_GI(false),
@ -47,7 +47,7 @@ CDMRCSBK::~CDMRCSBK()
bool CDMRCSBK::put(const unsigned char* bytes) bool CDMRCSBK::put(const unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
CBPTC19696 bptc; CBPTC19696 bptc;
bptc.decode(bytes, m_data); bptc.decode(bytes, m_data);
@ -171,7 +171,7 @@ bool CDMRCSBK::put(const unsigned char* bytes)
void CDMRCSBK::get(unsigned char* bytes) const void CDMRCSBK::get(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
m_data[10U] ^= CSBK_CRC_MASK[0U]; m_data[10U] ^= CSBK_CRC_MASK[0U];
m_data[11U] ^= CSBK_CRC_MASK[1U]; m_data[11U] ^= CSBK_CRC_MASK[1U];

View file

@ -30,10 +30,10 @@ m_slot2(2U, timeout),
m_lookup(lookup) m_lookup(lookup)
{ {
assert(id != 0U); assert(id != 0U);
assert(modem != NULL); assert(modem != nullptr);
assert(display != NULL); assert(display != nullptr);
assert(lookup != NULL); assert(lookup != nullptr);
assert(rssi != NULL); assert(rssi != nullptr);
// Load black and white lists to DMRAccessControl // Load black and white lists to DMRAccessControl
CDMRAccessControl::init(blacklist, whitelist, slot1TGWhitelist, slot2TGWhitelist, selfOnly, prefixes, id); CDMRAccessControl::init(blacklist, whitelist, slot1TGWhitelist, slot2TGWhitelist, selfOnly, prefixes, id);
@ -47,7 +47,7 @@ CDMRControl::~CDMRControl()
bool CDMRControl::processWakeup(const unsigned char* data) bool CDMRControl::processWakeup(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
// Wakeups always come in on slot 1 // Wakeups always come in on slot 1
if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK)) if (data[0U] != TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK))
@ -78,35 +78,35 @@ bool CDMRControl::processWakeup(const unsigned char* data)
bool CDMRControl::writeModemSlot1(unsigned char *data, unsigned int len) bool CDMRControl::writeModemSlot1(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
return m_slot1.writeModem(data, len); return m_slot1.writeModem(data, len);
} }
bool CDMRControl::writeModemSlot2(unsigned char *data, unsigned int len) bool CDMRControl::writeModemSlot2(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
return m_slot2.writeModem(data, len); return m_slot2.writeModem(data, len);
} }
unsigned int CDMRControl::readModemSlot1(unsigned char *data) unsigned int CDMRControl::readModemSlot1(unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
return m_slot1.readModem(data); return m_slot1.readModem(data);
} }
unsigned int CDMRControl::readModemSlot2(unsigned char *data) unsigned int CDMRControl::readModemSlot2(unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
return m_slot2.readModem(data); return m_slot2.readModem(data);
} }
void CDMRControl::clock() void CDMRControl::clock()
{ {
if (m_network != NULL) { if (m_network != nullptr) {
CDMRData data; CDMRData data;
bool ret = m_network->read(data); bool ret = m_network->read(data);
if (ret) { if (ret) {

View file

@ -23,7 +23,7 @@
CDMRData::CDMRData(const CDMRData& data) : CDMRData::CDMRData(const CDMRData& data) :
m_slotNo(data.m_slotNo), m_slotNo(data.m_slotNo),
m_data(NULL), m_data(nullptr),
m_srcId(data.m_srcId), m_srcId(data.m_srcId),
m_dstId(data.m_dstId), m_dstId(data.m_dstId),
m_flco(data.m_flco), m_flco(data.m_flco),
@ -39,7 +39,7 @@ m_rssi(data.m_rssi)
CDMRData::CDMRData() : CDMRData::CDMRData() :
m_slotNo(1U), m_slotNo(1U),
m_data(NULL), m_data(nullptr),
m_srcId(0U), m_srcId(0U),
m_dstId(0U), m_dstId(0U),
m_flco(FLCO::GROUP), m_flco(FLCO::GROUP),
@ -170,7 +170,7 @@ void CDMRData::setRSSI(unsigned char rssi)
unsigned int CDMRData::getData(unsigned char* buffer) const unsigned int CDMRData::getData(unsigned char* buffer) const
{ {
assert(buffer != NULL); assert(buffer != nullptr);
::memcpy(buffer, m_data, DMR_FRAME_LENGTH_BYTES); ::memcpy(buffer, m_data, DMR_FRAME_LENGTH_BYTES);
@ -179,7 +179,7 @@ unsigned int CDMRData::getData(unsigned char* buffer) const
void CDMRData::setData(const unsigned char* buffer) void CDMRData::setData(const unsigned char* buffer)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
::memcpy(m_data, buffer, DMR_FRAME_LENGTH_BYTES); ::memcpy(m_data, buffer, DMR_FRAME_LENGTH_BYTES);
} }

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2012 by Ian Wraith * Copyright (C) 2012 by Ian Wraith
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2017,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@
const unsigned char UDTF_NMEA = 0x05U; const unsigned char UDTF_NMEA = 0x05U;
CDMRDataHeader::CDMRDataHeader() : CDMRDataHeader::CDMRDataHeader() :
m_data(NULL), m_data(nullptr),
m_GI(false), m_GI(false),
m_A(false), m_A(false),
m_srcId(0U), m_srcId(0U),
@ -52,7 +52,7 @@ CDMRDataHeader::~CDMRDataHeader()
bool CDMRDataHeader::put(const unsigned char* bytes) bool CDMRDataHeader::put(const unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
CBPTC19696 bptc; CBPTC19696 bptc;
bptc.decode(bytes, m_data); bptc.decode(bytes, m_data);
@ -131,7 +131,7 @@ bool CDMRDataHeader::put(const unsigned char* bytes)
void CDMRDataHeader::get(unsigned char* bytes) const void CDMRDataHeader::get(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
CBPTC19696 bptc; CBPTC19696 bptc;
bptc.encode(m_data, bytes); bptc.encode(m_data, bytes);

View file

@ -35,7 +35,7 @@ m_address(address),
m_port(port), m_port(port),
m_addr(), m_addr(),
m_addrLen(0U), m_addrLen(0U),
m_id(NULL), m_id(nullptr),
m_password(password), m_password(password),
m_duplex(duplex), m_duplex(duplex),
m_version(version), m_version(version),
@ -48,9 +48,9 @@ m_hwType(hwType),
m_status(STATUS::WAITING_CONNECT), m_status(STATUS::WAITING_CONNECT),
m_retryTimer(1000U, 10U), m_retryTimer(1000U, 10U),
m_timeoutTimer(1000U, 60U), m_timeoutTimer(1000U, 60U),
m_buffer(NULL), m_buffer(nullptr),
m_streamId(NULL), m_streamId(nullptr),
m_salt(NULL), m_salt(nullptr),
m_rxData(1000U, "DMR Network"), m_rxData(1000U, "DMR Network"),
m_options(), m_options(),
m_random(), m_random(),
@ -626,7 +626,7 @@ bool CDMRDirectNetwork::wantsBeacon()
bool CDMRDirectNetwork::write(const unsigned char* data, unsigned int length) bool CDMRDirectNetwork::write(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (m_debug) if (m_debug)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,7 +36,7 @@ CDMREMB::~CDMREMB()
void CDMREMB::putData(const unsigned char* data) void CDMREMB::putData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char DMREMB[2U]; unsigned char DMREMB[2U];
DMREMB[0U] = (data[13U] << 4) & 0xF0U; DMREMB[0U] = (data[13U] << 4) & 0xF0U;
@ -53,7 +53,7 @@ void CDMREMB::putData(const unsigned char* data)
void CDMREMB::getData(unsigned char* data) const void CDMREMB::getData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char DMREMB[2U]; unsigned char DMREMB[2U];
DMREMB[0U] = (m_colorCode << 4) & 0xF0U; DMREMB[0U] = (m_colorCode << 4) & 0xF0U;

View file

@ -27,9 +27,9 @@
#include <cstring> #include <cstring>
CDMREmbeddedData::CDMREmbeddedData() : CDMREmbeddedData::CDMREmbeddedData() :
m_raw(NULL), m_raw(nullptr),
m_state(LC_STATE::NONE), m_state(LC_STATE::NONE),
m_data(NULL), m_data(nullptr),
m_FLCO(FLCO::GROUP), m_FLCO(FLCO::GROUP),
m_valid(false) m_valid(false)
{ {
@ -46,7 +46,7 @@ CDMREmbeddedData::~CDMREmbeddedData()
// Add LC data (which may consist of 4 blocks) to the data store // Add LC data (which may consist of 4 blocks) to the data store
bool CDMREmbeddedData::addData(const unsigned char* data, unsigned char lcss) bool CDMREmbeddedData::addData(const unsigned char* data, unsigned char lcss)
{ {
assert(data != NULL); assert(data != nullptr);
bool rawData[40U]; bool rawData[40U];
CUtils::byteToBitsBE(data[14U], rawData + 0U); CUtils::byteToBitsBE(data[14U], rawData + 0U);
@ -168,7 +168,7 @@ void CDMREmbeddedData::encodeEmbeddedData()
unsigned char CDMREmbeddedData::getData(unsigned char* data, unsigned char n) const unsigned char CDMREmbeddedData::getData(unsigned char* data, unsigned char n) const
{ {
assert(data != NULL); assert(data != nullptr);
if (n >= 1U && n < 5U) { if (n >= 1U && n < 5U) {
n--; n--;
@ -277,10 +277,10 @@ void CDMREmbeddedData::decodeEmbeddedData()
CDMRLC* CDMREmbeddedData::getLC() const CDMRLC* CDMREmbeddedData::getLC() const
{ {
if (!m_valid) if (!m_valid)
return NULL; return nullptr;
if ((m_FLCO != FLCO::GROUP) && (m_FLCO != FLCO::USER_USER)) if ((m_FLCO != FLCO::GROUP) && (m_FLCO != FLCO::USER_USER))
return NULL; return nullptr;
return new CDMRLC(m_data); return new CDMRLC(m_data);
} }
@ -303,7 +303,7 @@ void CDMREmbeddedData::reset()
bool CDMREmbeddedData::getRawData(unsigned char* data) const bool CDMREmbeddedData::getRawData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_valid) if (!m_valid)
return false; return false;

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2012 by Ian Wraith * Copyright (C) 2012 by Ian Wraith
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ CDMRFullLC::~CDMRFullLC()
CDMRLC* CDMRFullLC::decode(const unsigned char* data, unsigned char type) CDMRLC* CDMRFullLC::decode(const unsigned char* data, unsigned char type)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char lcData[12U]; unsigned char lcData[12U];
m_bptc.decode(data, lcData); m_bptc.decode(data, lcData);
@ -58,18 +58,18 @@ CDMRLC* CDMRFullLC::decode(const unsigned char* data, unsigned char type)
default: default:
::LogError("Unsupported LC type - %d", int(type)); ::LogError("Unsupported LC type - %d", int(type));
return NULL; return nullptr;
} }
if (!CRS129::check(lcData)) if (!CRS129::check(lcData))
return NULL; return nullptr;
return new CDMRLC(lcData); return new CDMRLC(lcData);
} }
void CDMRFullLC::encode(const CDMRLC& lc, unsigned char* data, unsigned char type) void CDMRFullLC::encode(const CDMRLC& lc, unsigned char* data, unsigned char type)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char lcData[12U]; unsigned char lcData[12U];
lc.getData(lcData); lc.getData(lcData);

View file

@ -36,7 +36,7 @@ m_addressStr(address),
m_addr(), m_addr(),
m_addrLen(0U), m_addrLen(0U),
m_port(port), m_port(port),
m_id(NULL), m_id(nullptr),
m_duplex(duplex), m_duplex(duplex),
m_version(version), m_version(version),
m_debug(debug), m_debug(debug),
@ -45,8 +45,8 @@ m_enabled(false),
m_slot1(slot1), m_slot1(slot1),
m_slot2(slot2), m_slot2(slot2),
m_hwType(hwType), m_hwType(hwType),
m_buffer(NULL), m_buffer(nullptr),
m_streamId(NULL), m_streamId(nullptr),
m_rxData(1000U, "DMR Network"), m_rxData(1000U, "DMR Network"),
m_beacon(false), m_beacon(false),
m_random(), m_random(),
@ -434,7 +434,7 @@ bool CDMRGatewayNetwork::wantsBeacon()
bool CDMRGatewayNetwork::write(const unsigned char* data, unsigned int length) bool CDMRGatewayNetwork::write(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (m_debug) if (m_debug)

View file

@ -43,7 +43,7 @@ m_options(0U),
m_srcId(0U), m_srcId(0U),
m_dstId(0U) m_dstId(0U)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
m_PF = (bytes[0U] & 0x80U) == 0x80U; m_PF = (bytes[0U] & 0x80U) == 0x80U;
m_R = (bytes[0U] & 0x40U) == 0x40U; m_R = (bytes[0U] & 0x40U) == 0x40U;
@ -67,7 +67,7 @@ m_options(0U),
m_srcId(0U), m_srcId(0U),
m_dstId(0U) m_dstId(0U)
{ {
assert(bits != NULL); assert(bits != nullptr);
m_PF = bits[0U]; m_PF = bits[0U];
m_R = bits[1U]; m_R = bits[1U];
@ -113,7 +113,7 @@ CDMRLC::~CDMRLC()
void CDMRLC::getData(unsigned char* bytes) const void CDMRLC::getData(unsigned char* bytes) const
{ {
assert(bytes != NULL); assert(bytes != nullptr);
bytes[0U] = (unsigned char)m_FLCO; bytes[0U] = (unsigned char)m_FLCO;
@ -138,7 +138,7 @@ void CDMRLC::getData(unsigned char* bytes) const
void CDMRLC::getData(bool* bits) const void CDMRLC::getData(bool* bits) const
{ {
assert(bits != NULL); assert(bits != nullptr);
unsigned char bytes[9U]; unsigned char bytes[9U];
getData(bytes); getData(bytes);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -132,5 +132,5 @@ std::string CDMRLookup::find(unsigned int id)
bool CDMRLookup::exists(unsigned int id) bool CDMRLookup::exists(unsigned int id)
{ {
return m_table.lookup(id, NULL); return m_table.lookup(id, nullptr);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,8 +26,8 @@
#include <cstring> #include <cstring>
CDMRShortLC::CDMRShortLC() : CDMRShortLC::CDMRShortLC() :
m_rawData(NULL), m_rawData(nullptr),
m_deInterData(NULL) m_deInterData(nullptr)
{ {
m_rawData = new bool[72U]; m_rawData = new bool[72U];
m_deInterData = new bool[68U]; m_deInterData = new bool[68U];
@ -42,8 +42,8 @@ CDMRShortLC::~CDMRShortLC()
// The main decode function // The main decode function
bool CDMRShortLC::decode(const unsigned char* in, unsigned char* out) bool CDMRShortLC::decode(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Get the raw binary // Get the raw binary
decodeExtractBinary(in); decodeExtractBinary(in);
@ -65,8 +65,8 @@ bool CDMRShortLC::decode(const unsigned char* in, unsigned char* out)
// The main encode function // The main encode function
void CDMRShortLC::encode(const unsigned char* in, unsigned char* out) void CDMRShortLC::encode(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Extract Data // Extract Data
encodeExtractData(in); encodeExtractData(in);
@ -83,7 +83,7 @@ void CDMRShortLC::encode(const unsigned char* in, unsigned char* out)
void CDMRShortLC::decodeExtractBinary(const unsigned char* in) void CDMRShortLC::decodeExtractBinary(const unsigned char* in)
{ {
assert(in != NULL); assert(in != nullptr);
CUtils::byteToBitsBE(in[0U], m_rawData + 0U); CUtils::byteToBitsBE(in[0U], m_rawData + 0U);
CUtils::byteToBitsBE(in[1U], m_rawData + 8U); CUtils::byteToBitsBE(in[1U], m_rawData + 8U);
@ -133,7 +133,7 @@ bool CDMRShortLC::decodeErrorCheck()
// Extract the 36 bits of payload // Extract the 36 bits of payload
void CDMRShortLC::decodeExtractData(unsigned char* data) const void CDMRShortLC::decodeExtractData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
bool bData[40U]; bool bData[40U];
@ -160,7 +160,7 @@ void CDMRShortLC::decodeExtractData(unsigned char* data) const
// Extract the 36 bits of payload // Extract the 36 bits of payload
void CDMRShortLC::encodeExtractData(const unsigned char* in) const void CDMRShortLC::encodeExtractData(const unsigned char* in) const
{ {
assert(in != NULL); assert(in != nullptr);
bool bData[40U]; bool bData[40U];
CUtils::byteToBitsBE(in[0U], bData + 0U); CUtils::byteToBitsBE(in[0U], bData + 0U);
@ -214,7 +214,7 @@ void CDMRShortLC::encodeInterleave()
void CDMRShortLC::encodeExtractBinary(unsigned char* data) void CDMRShortLC::encodeExtractBinary(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
CUtils::bitsToByteBE(m_rawData + 0U, data[0U]); CUtils::bitsToByteBE(m_rawData + 0U, data[0U]);
CUtils::bitsToByteBE(m_rawData + 8U, data[1U]); CUtils::bitsToByteBE(m_rawData + 8U, data[1U]);

View file

@ -37,21 +37,21 @@ unsigned int CDMRSlot::m_colorCode = 0U;
bool CDMRSlot::m_embeddedLCOnly = false; bool CDMRSlot::m_embeddedLCOnly = false;
bool CDMRSlot::m_dumpTAData = true; bool CDMRSlot::m_dumpTAData = true;
CModem* CDMRSlot::m_modem = NULL; CModem* CDMRSlot::m_modem = nullptr;
IDMRNetwork* CDMRSlot::m_network = NULL; IDMRNetwork* CDMRSlot::m_network = nullptr;
CDisplay* CDMRSlot::m_display = NULL; CDisplay* CDMRSlot::m_display = nullptr;
bool CDMRSlot::m_duplex = true; bool CDMRSlot::m_duplex = true;
CDMRLookup* CDMRSlot::m_lookup = NULL; CDMRLookup* CDMRSlot::m_lookup = nullptr;
unsigned int CDMRSlot::m_hangCount = 3U * 17U; unsigned int CDMRSlot::m_hangCount = 3U * 17U;
DMR_OVCM CDMRSlot::m_ovcm = DMR_OVCM::OFF; DMR_OVCM CDMRSlot::m_ovcm = DMR_OVCM::OFF;
bool CDMRSlot::m_protect = false; bool CDMRSlot::m_protect = false;
CRSSIInterpolator* CDMRSlot::m_rssiMapper = NULL; CRSSIInterpolator* CDMRSlot::m_rssiMapper = nullptr;
unsigned int CDMRSlot::m_jitterTime = 360U; unsigned int CDMRSlot::m_jitterTime = 360U;
unsigned int CDMRSlot::m_jitterSlots = 6U; unsigned int CDMRSlot::m_jitterSlots = 6U;
unsigned char* CDMRSlot::m_idle = NULL; unsigned char* CDMRSlot::m_idle = nullptr;
FLCO CDMRSlot::m_flco1; FLCO CDMRSlot::m_flco1;
unsigned char CDMRSlot::m_id1 = 0U; unsigned char CDMRSlot::m_id1 = 0U;
@ -78,19 +78,19 @@ m_queue(5000U, "DMR Slot"),
m_rfState(RPT_RF_STATE::LISTENING), m_rfState(RPT_RF_STATE::LISTENING),
m_netState(RPT_NET_STATE::IDLE), m_netState(RPT_NET_STATE::IDLE),
m_rfEmbeddedLC(), m_rfEmbeddedLC(),
m_rfEmbeddedData(NULL), m_rfEmbeddedData(nullptr),
m_rfEmbeddedReadN(0U), m_rfEmbeddedReadN(0U),
m_rfEmbeddedWriteN(1U), m_rfEmbeddedWriteN(1U),
m_rfTalkerId(TALKER_ID_NONE), m_rfTalkerId(TALKER_ID_NONE),
m_rfTalkerAlias(slotNo), m_rfTalkerAlias(slotNo),
m_netEmbeddedLC(), m_netEmbeddedLC(),
m_netEmbeddedData(NULL), m_netEmbeddedData(nullptr),
m_netEmbeddedReadN(0U), m_netEmbeddedReadN(0U),
m_netEmbeddedWriteN(1U), m_netEmbeddedWriteN(1U),
m_netTalkerId(TALKER_ID_NONE), m_netTalkerId(TALKER_ID_NONE),
m_netTalkerAlias(slotNo), m_netTalkerAlias(slotNo),
m_rfLC(NULL), m_rfLC(nullptr),
m_netLC(NULL), m_netLC(nullptr),
m_rfSeqNo(0U), m_rfSeqNo(0U),
m_rfN(0U), m_rfN(0U),
m_lastrfN(0U), m_lastrfN(0U),
@ -111,7 +111,7 @@ m_rfErrs(0U),
m_netErrs(0U), m_netErrs(0U),
m_rfTimeout(false), m_rfTimeout(false),
m_netTimeout(false), m_netTimeout(false),
m_lastFrame(NULL), m_lastFrame(nullptr),
m_lastFrameValid(false), m_lastFrameValid(false),
m_rssi(0U), m_rssi(0U),
m_maxRSSI(0U), m_maxRSSI(0U),
@ -119,7 +119,7 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];
@ -138,7 +138,7 @@ CDMRSlot::~CDMRSlot()
bool CDMRSlot::writeModem(unsigned char *data, unsigned int len) bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -216,7 +216,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
CDMRFullLC fullLC; CDMRFullLC fullLC;
CDMRLC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); CDMRLC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER);
if (lc == NULL) if (lc == nullptr)
return false; return false;
unsigned int srcId = lc->getSrcId(); unsigned int srcId = lc->getSrcId();
@ -373,7 +373,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
else else
LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits)); LogMessage("DMR Slot %u, received RF end of voice transmission from %s to %s%s, %.1f seconds, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
m_display->writeDMRTA(m_slotNo, NULL, " "); m_display->writeDMRTA(m_slotNo, nullptr, " ");
if (m_rfTimeout) { if (m_rfTimeout) {
writeEndRF(); writeEndRF();
@ -685,12 +685,12 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
CUtils::dump(1U, text, data, 9U); CUtils::dump(1U, text, data, 9U);
logGPSPosition(data); logGPSPosition(data);
} }
if (m_network != NULL) if (m_network != nullptr)
m_network->writeRadioPosition(m_rfLC->getSrcId(), data); m_network->writeRadioPosition(m_rfLC->getSrcId(), data);
break; break;
case FLCO::TALKER_ALIAS_HEADER: case FLCO::TALKER_ALIAS_HEADER:
if (m_network != NULL) if (m_network != nullptr)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 0U, data); m_network->writeTalkerAlias(m_rfLC->getSrcId(), 0U, data);
if (!(m_rfTalkerId & TALKER_ID_HEADER)) { if (!(m_rfTalkerId & TALKER_ID_HEADER)) {
@ -709,7 +709,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
break; break;
case FLCO::TALKER_ALIAS_BLOCK1: case FLCO::TALKER_ALIAS_BLOCK1:
if (m_network != NULL) if (m_network != nullptr)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 1U, data); m_network->writeTalkerAlias(m_rfLC->getSrcId(), 1U, data);
if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) {
@ -728,7 +728,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
break; break;
case FLCO::TALKER_ALIAS_BLOCK2: case FLCO::TALKER_ALIAS_BLOCK2:
if (m_network != NULL) if (m_network != nullptr)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 2U, data); m_network->writeTalkerAlias(m_rfLC->getSrcId(), 2U, data);
if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) {
@ -747,7 +747,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
break; break;
case FLCO::TALKER_ALIAS_BLOCK3: case FLCO::TALKER_ALIAS_BLOCK3:
if (m_network != NULL) if (m_network != nullptr)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 3U, data); m_network->writeTalkerAlias(m_rfLC->getSrcId(), 3U, data);
if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) { if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) {
@ -817,7 +817,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_rfEmbeddedLC.addData(data + 2U, emb.getLCSS()); m_rfEmbeddedLC.addData(data + 2U, emb.getLCSS());
CDMRLC* lc = m_rfEmbeddedLC.getLC(); CDMRLC* lc = m_rfEmbeddedLC.getLC();
if (lc != NULL) { if (lc != nullptr) {
unsigned int srcId = lc->getSrcId(); unsigned int srcId = lc->getSrcId();
unsigned int dstId = lc->getDstId(); unsigned int dstId = lc->getDstId();
FLCO flco = lc->getFLCO(); FLCO flco = lc->getFLCO();
@ -954,7 +954,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
unsigned int CDMRSlot::readModem(unsigned char* data) unsigned int CDMRSlot::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -1010,7 +1010,7 @@ void CDMRSlot::writeEndRF(bool writeEnd)
m_rfN = 0U; m_rfN = 0U;
delete m_rfLC; delete m_rfLC;
m_rfLC = NULL; m_rfLC = nullptr;
} }
void CDMRSlot::writeEndNet(bool writeEnd) void CDMRSlot::writeEndNet(bool writeEnd)
@ -1063,7 +1063,7 @@ void CDMRSlot::writeEndNet(bool writeEnd)
m_netN = 0U; m_netN = 0U;
delete m_netLC; delete m_netLC;
m_netLC = NULL; m_netLC = nullptr;
#if defined(DUMP_DMR) #if defined(DUMP_DMR)
closeFile(); closeFile();
@ -1091,7 +1091,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
CDMRFullLC fullLC; CDMRFullLC fullLC;
CDMRLC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); CDMRLC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER);
if (lc == NULL) { if (lc == nullptr) {
LogMessage("DMR Slot %u, bad LC received from the network, replacing", m_slotNo); LogMessage("DMR Slot %u, bad LC received from the network, replacing", m_slotNo);
lc = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); lc = new CDMRLC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId());
} }
@ -1314,7 +1314,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// We've received the voice header and terminator haven't we? // We've received the voice header and terminator haven't we?
m_netFrames += 2U; m_netFrames += 2U;
LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits)); LogMessage("DMR Slot %u, received network end of voice transmission from %s to %s%s, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, src.c_str(), flco == FLCO::GROUP ? "TG " : "", dst.c_str(), float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));
m_display->writeDMRTA(m_slotNo, NULL, " "); m_display->writeDMRTA(m_slotNo, nullptr, " ");
writeEndNet(); writeEndNet();
} else if (dataType == DT_DATA_HEADER) { } else if (dataType == DT_DATA_HEADER) {
if (m_netState == RPT_NET_STATE::DATA) if (m_netState == RPT_NET_STATE::DATA)
@ -1910,7 +1910,7 @@ void CDMRSlot::clock()
void CDMRSlot::writeQueueRF(const unsigned char *data) void CDMRSlot::writeQueueRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -1929,12 +1929,12 @@ void CDMRSlot::writeQueueRF(const unsigned char *data)
void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType, FLCO flco, unsigned int srcId, unsigned int dstId, unsigned char errors) void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType, FLCO flco, unsigned int srcId, unsigned int dstId, unsigned char errors)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
if (m_network == NULL) if (m_network == nullptr)
return; return;
CDMRData dmrData; CDMRData dmrData;
@ -1957,15 +1957,15 @@ void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType,
void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType, unsigned char errors) void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType, unsigned char errors)
{ {
assert(data != NULL); assert(data != nullptr);
assert(m_rfLC != NULL); assert(m_rfLC != nullptr);
writeNetworkRF(data, dataType, m_rfLC->getFLCO(), m_rfLC->getSrcId(), m_rfLC->getDstId(), errors); writeNetworkRF(data, dataType, m_rfLC->getFLCO(), m_rfLC->getSrcId(), m_rfLC->getDstId(), errors);
} }
void CDMRSlot::writeQueueNet(const unsigned char *data) void CDMRSlot::writeQueueNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U; unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U;
@ -1981,10 +1981,10 @@ void CDMRSlot::writeQueueNet(const unsigned char *data)
void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM ovcm, bool protect) void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData, unsigned int callHang, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssiMapper, unsigned int jitter, DMR_OVCM ovcm, bool protect)
{ {
assert(modem != NULL); assert(modem != nullptr);
assert(display != NULL); assert(display != nullptr);
assert(lookup != NULL); assert(lookup != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
m_colorCode = colorCode; m_colorCode = colorCode;
m_embeddedLCOnly = embeddedLCOnly; m_embeddedLCOnly = embeddedLCOnly;
@ -2017,7 +2017,7 @@ void CDMRSlot::init(unsigned int colorCode, bool embeddedLCOnly, bool dumpTAData
void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, ACTIVITY_TYPE type) void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, ACTIVITY_TYPE type)
{ {
assert(m_modem != NULL); assert(m_modem != nullptr);
switch (slotNo) { switch (slotNo) {
case 1U: case 1U:
@ -2111,7 +2111,7 @@ void CDMRSlot::setShortLC(unsigned int slotNo, unsigned int id, FLCO flco, ACTIV
bool CDMRSlot::openFile() bool CDMRSlot::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -2123,7 +2123,7 @@ bool CDMRSlot::openFile()
::sprintf(name, "DMR_%u_%04d%02d%02d_%02d%02d%02d.ambe", m_slotNo, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "DMR_%u_%04d%02d%02d_%02d%02d%02d.ambe", m_slotNo, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("DMR", 1U, 3U, m_fp); ::fwrite("DMR", 1U, 3U, m_fp);
@ -2133,7 +2133,7 @@ bool CDMRSlot::openFile()
bool CDMRSlot::writeFile(const unsigned char* data) bool CDMRSlot::writeFile(const unsigned char* data)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, DMR_FRAME_LENGTH_BYTES + 2U, m_fp); ::fwrite(data, 1U, DMR_FRAME_LENGTH_BYTES + 2U, m_fp);
@ -2143,15 +2143,15 @@ bool CDMRSlot::writeFile(const unsigned char* data)
void CDMRSlot::closeFile() void CDMRSlot::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }
bool CDMRSlot::insertSilence(const unsigned char* data, unsigned char seqNo) bool CDMRSlot::insertSilence(const unsigned char* data, unsigned char seqNo)
{ {
assert(data != NULL); assert(data != nullptr);
// Do not send duplicate // Do not send duplicate
if (seqNo == m_netN) if (seqNo == m_netN)
@ -2251,7 +2251,7 @@ void CDMRSlot::enable(bool enabled)
m_rfN = 0U; m_rfN = 0U;
delete m_rfLC; delete m_rfLC;
m_rfLC = NULL; m_rfLC = nullptr;
// Reset the networking section // Reset the networking section
m_netState = RPT_NET_STATE::IDLE; m_netState = RPT_NET_STATE::IDLE;
@ -2272,7 +2272,7 @@ void CDMRSlot::enable(bool enabled)
m_netN = 0U; m_netN = 0U;
delete m_netLC; delete m_netLC;
m_netLC = NULL; m_netLC = nullptr;
} }
m_enabled = enabled; m_enabled = enabled;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -35,7 +35,7 @@ CDMRSlotType::~CDMRSlotType()
void CDMRSlotType::putData(const unsigned char* data) void CDMRSlotType::putData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char DMRSlotType[3U]; unsigned char DMRSlotType[3U];
DMRSlotType[0U] = (data[12U] << 2) & 0xFCU; DMRSlotType[0U] = (data[12U] << 2) & 0xFCU;
@ -55,7 +55,7 @@ void CDMRSlotType::putData(const unsigned char* data)
void CDMRSlotType::getData(unsigned char* data) const void CDMRSlotType::getData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char DMRSlotType[3U]; unsigned char DMRSlotType[3U];
DMRSlotType[0U] = (m_colorCode << 4) & 0xF0U; DMRSlotType[0U] = (m_colorCode << 4) & 0xF0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2017,2018,2023 Jonathan Naylor, G4KLX * Copyright (C) 2015,2016,2017,2018,2023,2025 Jonathan Naylor, G4KLX
* Copyright (C) 2018 by Shawn Chain, BG5HHP * Copyright (C) 2018 by Shawn Chain, BG5HHP
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,7 +31,7 @@ CDMRTA::~CDMRTA()
bool CDMRTA::add(unsigned int blockId, const unsigned char* data, unsigned int len) bool CDMRTA::add(unsigned int blockId, const unsigned char* data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (blockId > 3U) { if (blockId > 3U) {
// invalid block id // invalid block id

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor, G4KLX * Copyright (C) 2016,2025 by Jonathan Naylor, G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -49,8 +49,8 @@ CDMRTrellis::~CDMRTrellis()
bool CDMRTrellis::decode(const unsigned char* data, unsigned char* payload) bool CDMRTrellis::decode(const unsigned char* data, unsigned char* payload)
{ {
assert(data != NULL); assert(data != nullptr);
assert(payload != NULL); assert(payload != nullptr);
signed char dibits[98U]; signed char dibits[98U];
deinterleave(data, dibits); deinterleave(data, dibits);
@ -83,8 +83,8 @@ bool CDMRTrellis::decode(const unsigned char* data, unsigned char* payload)
void CDMRTrellis::encode(const unsigned char* payload, unsigned char* data) void CDMRTrellis::encode(const unsigned char* payload, unsigned char* data)
{ {
assert(payload != NULL); assert(payload != nullptr);
assert(data != NULL); assert(data != nullptr);
unsigned char tribits[49U]; unsigned char tribits[49U];
bitsToTribits(payload, tribits); bitsToTribits(payload, tribits);

View file

@ -38,8 +38,8 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)
// #define DUMP_DSTAR // #define DUMP_DSTAR
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) : CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, bool ackReply, unsigned int ackTime, DSTAR_ACK ackMessage, bool errorReply, const std::vector<std::string>& blackList, const std::vector<std::string>& whiteList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL), m_callsign(nullptr),
m_gateway(NULL), m_gateway(nullptr),
m_selfOnly(selfOnly), m_selfOnly(selfOnly),
m_ackReply(ackReply), m_ackReply(ackReply),
m_ackMessage(ackMessage), m_ackMessage(ackMessage),
@ -76,7 +76,7 @@ m_rfBits(1U),
m_netBits(1U), m_netBits(1U),
m_rfErrs(0U), m_rfErrs(0U),
m_netErrs(0U), m_netErrs(0U),
m_lastFrame(NULL), m_lastFrame(nullptr),
m_lastFrameValid(false), m_lastFrameValid(false),
m_rssiMapper(rssiMapper), m_rssiMapper(rssiMapper),
m_rssi(0U), m_rssi(0U),
@ -85,10 +85,10 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
m_callsign = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; m_callsign = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH];
m_gateway = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; m_gateway = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH];
@ -122,7 +122,7 @@ CDStarControl::~CDStarControl()
bool CDStarControl::writeModem(unsigned char *data, unsigned int len) bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -152,7 +152,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (m_errorReply) if (m_errorReply)
m_errTimer.start(); m_errTimer.start();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -315,7 +315,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (m_errorReply) if (m_errorReply)
m_errTimer.start(); m_errTimer.start();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -409,7 +409,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
m_display->writeDStarRSSI(m_rssi); m_display->writeDStarRSSI(m_rssi);
unsigned int errors = 0U; unsigned int errors = 0U;
if (::memcmp(data + 1U, DSTAR_NULL_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) == 0) { if (::memcmp(data + 1U, DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) == 0) {
LogDebug("D-Star, audio sequence no. %u, null audio", m_rfN); LogDebug("D-Star, audio sequence no. %u, null audio", m_rfN);
} else { } else {
errors = m_fec.regenerateDStar(data + 1U); errors = m_fec.regenerateDStar(data + 1U);
@ -423,7 +423,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (m_rfN != 0U) { if (m_rfN != 0U) {
const unsigned char* text = m_rfSlowData.addText(data + 1U, m_rfN); const unsigned char* text = m_rfSlowData.addText(data + 1U, m_rfN);
if (text != NULL) if (text != nullptr)
LogMessage("D-Star, RF slow data text = \"%s\"", text); LogMessage("D-Star, RF slow data text = \"%s\"", text);
} }
@ -446,7 +446,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
return false; return false;
} else { } else {
CDStarHeader* header = m_rfSlowData.addHeader(data + 1U, m_rfN); CDStarHeader* header = m_rfSlowData.addHeader(data + 1U, m_rfN);
if (header == NULL) { if (header == nullptr) {
m_rfN = (m_rfN + 1U) % 21U; m_rfN = (m_rfN + 1U) % 21U;
return false; return false;
} }
@ -546,7 +546,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
} }
unsigned int errors = 0U; unsigned int errors = 0U;
if (::memcmp(data + 1U, DSTAR_NULL_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) == 0) { if (::memcmp(data + 1U, DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) == 0) {
LogDebug("D-Star, audio sequence no. %u, null audio", m_rfN); LogDebug("D-Star, audio sequence no. %u, null audio", m_rfN);
} else { } else {
errors = m_fec.regenerateDStar(data + 1U); errors = m_fec.regenerateDStar(data + 1U);
@ -585,7 +585,7 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
unsigned int CDStarControl::readModem(unsigned char* data) unsigned int CDStarControl::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -609,7 +609,7 @@ void CDStarControl::writeEndRF()
m_ackTimer.start(); m_ackTimer.start();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
} }
@ -626,7 +626,7 @@ void CDStarControl::writeEndNet()
m_networkWatchdog.stop(); m_networkWatchdog.stop();
m_packetTimer.stop(); m_packetTimer.stop();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
#if defined(DUMP_DSTAR) #if defined(DUMP_DSTAR)
@ -636,7 +636,7 @@ void CDStarControl::writeEndNet()
void CDStarControl::writeNetwork() void CDStarControl::writeNetwork()
{ {
assert(m_network != NULL); assert(m_network != nullptr);
unsigned char data[DSTAR_HEADER_LENGTH_BYTES + 2U]; unsigned char data[DSTAR_HEADER_LENGTH_BYTES + 2U];
unsigned int length = m_network->read(data, DSTAR_HEADER_LENGTH_BYTES + 2U); unsigned int length = m_network->read(data, DSTAR_HEADER_LENGTH_BYTES + 2U);
@ -760,7 +760,7 @@ void CDStarControl::writeNetwork()
unsigned char n = data[1U]; unsigned char n = data[1U];
unsigned int errors = 0U; unsigned int errors = 0U;
if (::memcmp(data + 2U, DSTAR_NULL_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) != 0) { if (::memcmp(data + 2U, DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED, DSTAR_VOICE_FRAME_LENGTH_BYTES) != 0) {
errors = m_fec.regenerateDStar(data + 2U); errors = m_fec.regenerateDStar(data + 2U);
blankDTMF(data + 2U); blankDTMF(data + 2U);
} }
@ -783,7 +783,7 @@ void CDStarControl::writeNetwork()
m_netSlowData.start(); m_netSlowData.start();
} else { } else {
const unsigned char* text = m_netSlowData.addText(data + 2U, m_netN); const unsigned char* text = m_netSlowData.addText(data + 2U, m_netN);
if (text != NULL) if (text != nullptr)
LogMessage("D-Star, network slow data text = \"%s\"", text); LogMessage("D-Star, network slow data text = \"%s\"", text);
} }
@ -837,7 +837,7 @@ void CDStarControl::clock()
unsigned int ms = m_interval.elapsed(); unsigned int ms = m_interval.elapsed();
m_interval.start(); m_interval.start();
if (m_network != NULL) if (m_network != nullptr)
writeNetwork(); writeNetwork();
m_ackTimer.clock(ms); m_ackTimer.clock(ms);
@ -892,7 +892,7 @@ void CDStarControl::clock()
void CDStarControl::writeQueueHeaderRF(const unsigned char *data) void CDStarControl::writeQueueHeaderRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -915,7 +915,7 @@ void CDStarControl::writeQueueHeaderRF(const unsigned char *data)
void CDStarControl::writeQueueDataRF(const unsigned char *data) void CDStarControl::writeQueueDataRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -960,7 +960,7 @@ void CDStarControl::writeQueueEOTRF()
void CDStarControl::writeQueueHeaderNet(const unsigned char *data) void CDStarControl::writeQueueHeaderNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return; return;
@ -980,7 +980,7 @@ void CDStarControl::writeQueueHeaderNet(const unsigned char *data)
void CDStarControl::writeQueueDataNet(const unsigned char *data) void CDStarControl::writeQueueDataNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return; return;
@ -1019,9 +1019,9 @@ void CDStarControl::writeQueueEOTNet()
void CDStarControl::writeNetworkHeaderRF(const unsigned char* data) void CDStarControl::writeNetworkHeaderRF(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return; return;
// Don't send to the network if the timeout has expired // Don't send to the network if the timeout has expired
@ -1033,9 +1033,9 @@ void CDStarControl::writeNetworkHeaderRF(const unsigned char* data)
void CDStarControl::writeNetworkDataRF(const unsigned char* data, unsigned int errors, bool end) void CDStarControl::writeNetworkDataRF(const unsigned char* data, unsigned int errors, bool end)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return; return;
// Don't send to the network if the timeout has expired // Don't send to the network if the timeout has expired
@ -1047,7 +1047,7 @@ void CDStarControl::writeNetworkDataRF(const unsigned char* data, unsigned int e
bool CDStarControl::openFile() bool CDStarControl::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -1059,7 +1059,7 @@ bool CDStarControl::openFile()
::sprintf(name, "DStar_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "DStar_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("DSTAR", 1U, 4U, m_fp); ::fwrite("DSTAR", 1U, 4U, m_fp);
@ -1069,7 +1069,7 @@ bool CDStarControl::openFile()
bool CDStarControl::writeFile(const unsigned char* data, unsigned int length) bool CDStarControl::writeFile(const unsigned char* data, unsigned int length)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, length, m_fp); ::fwrite(data, 1U, length, m_fp);
@ -1079,15 +1079,15 @@ bool CDStarControl::writeFile(const unsigned char* data, unsigned int length)
void CDStarControl::closeFile() void CDStarControl::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }
bool CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo) bool CDStarControl::insertSilence(const unsigned char* data, unsigned char seqNo)
{ {
assert(data != NULL); assert(data != nullptr);
// Check to see if we have any spaces to fill? // Check to see if we have any spaces to fill?
unsigned int oldSeqNo = (m_netN + 1U) % 21U; unsigned int oldSeqNo = (m_netN + 1U) % 21U;
@ -1122,19 +1122,19 @@ void CDStarControl::insertSilence(unsigned int count)
for (unsigned int i = 0U; i < count; i++) { for (unsigned int i = 0U; i < count; i++) {
if (i < 3U && m_lastFrameValid) { if (i < 3U && m_lastFrameValid) {
if (n == 0U) { if (n == 0U) {
::memcpy(m_lastFrame + DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U, DSTAR_NULL_SLOW_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES); ::memcpy(m_lastFrame + DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U, DSTAR_nullptr_SLOW_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES);
writeQueueDataNet(m_lastFrame); writeQueueDataNet(m_lastFrame);
} else { } else {
::memcpy(m_lastFrame + DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U, DSTAR_NULL_SLOW_DATA_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES); ::memcpy(m_lastFrame + DSTAR_VOICE_FRAME_LENGTH_BYTES + 1U, DSTAR_nullptr_SLOW_DATA_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES);
writeQueueDataNet(m_lastFrame); writeQueueDataNet(m_lastFrame);
} }
} else { } else {
m_lastFrameValid = false; m_lastFrameValid = false;
if (n == 0U) if (n == 0U)
writeQueueDataNet(DSTAR_NULL_FRAME_SYNC_BYTES); writeQueueDataNet(DSTAR_nullptr_FRAME_SYNC_BYTES);
else else
writeQueueDataNet(DSTAR_NULL_FRAME_DATA_BYTES); writeQueueDataNet(DSTAR_nullptr_FRAME_DATA_BYTES);
} }
m_netN = n; m_netN = n;
@ -1148,7 +1148,7 @@ void CDStarControl::insertSilence(unsigned int count)
void CDStarControl::blankDTMF(unsigned char* data) const void CDStarControl::blankDTMF(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
// DTMF begins with these byte values // DTMF begins with these byte values
if ((data[0] & DSTAR_DTMF_MASK[0]) == DSTAR_DTMF_SIG[0] && (data[1] & DSTAR_DTMF_MASK[1]) == DSTAR_DTMF_SIG[1] && if ((data[0] & DSTAR_DTMF_MASK[0]) == DSTAR_DTMF_SIG[0] && (data[1] & DSTAR_DTMF_MASK[1]) == DSTAR_DTMF_SIG[1] &&
@ -1156,7 +1156,7 @@ void CDStarControl::blankDTMF(unsigned char* data) const
(data[4] & DSTAR_DTMF_MASK[4]) == DSTAR_DTMF_SIG[4] && (data[5] & DSTAR_DTMF_MASK[5]) == DSTAR_DTMF_SIG[5] && (data[4] & DSTAR_DTMF_MASK[4]) == DSTAR_DTMF_SIG[4] && (data[5] & DSTAR_DTMF_MASK[5]) == DSTAR_DTMF_SIG[5] &&
(data[6] & DSTAR_DTMF_MASK[6]) == DSTAR_DTMF_SIG[6] && (data[7] & DSTAR_DTMF_MASK[7]) == DSTAR_DTMF_SIG[7] && (data[6] & DSTAR_DTMF_MASK[6]) == DSTAR_DTMF_SIG[6] && (data[7] & DSTAR_DTMF_MASK[7]) == DSTAR_DTMF_SIG[7] &&
(data[8] & DSTAR_DTMF_MASK[8]) == DSTAR_DTMF_SIG[8]) (data[8] & DSTAR_DTMF_MASK[8]) == DSTAR_DTMF_SIG[8])
::memcpy(data, DSTAR_NULL_AMBE_DATA_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES); ::memcpy(data, DSTAR_nullptr_AMBE_DATA_BYTES, DSTAR_VOICE_FRAME_LENGTH_BYTES);
} }
void CDStarControl::sendAck() void CDStarControl::sendAck()
@ -1182,11 +1182,11 @@ void CDStarControl::sendAck()
writeQueueHeaderRF(data); writeQueueHeaderRF(data);
writeQueueDataRF(DSTAR_NULL_FRAME_SYNC_BYTES); writeQueueDataRF(DSTAR_nullptr_FRAME_SYNC_BYTES);
LINK_STATUS status = LINK_STATUS::NONE; LINK_STATUS status = LINK_STATUS::NONE;
unsigned char reflector[DSTAR_LONG_CALLSIGN_LENGTH]; unsigned char reflector[DSTAR_LONG_CALLSIGN_LENGTH];
if (m_network != NULL) if (m_network != nullptr)
m_network->getStatus(status, reflector); m_network->getStatus(status, reflector);
char text[40U]; char text[40U];
@ -1219,7 +1219,7 @@ void CDStarControl::sendAck()
m_rfSlowData.setText(text); m_rfSlowData.setText(text);
::memcpy(data, DSTAR_NULL_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U); ::memcpy(data, DSTAR_nullptr_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U);
for (unsigned int i = 0U; i < 19U; i++) { for (unsigned int i = 0U; i < 19U; i++) {
m_rfSlowData.getSlowData(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES); m_rfSlowData.getSlowData(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES);
@ -1247,11 +1247,11 @@ void CDStarControl::sendError()
writeQueueHeaderRF(data); writeQueueHeaderRF(data);
writeQueueDataRF(DSTAR_NULL_FRAME_SYNC_BYTES); writeQueueDataRF(DSTAR_nullptr_FRAME_SYNC_BYTES);
LINK_STATUS status = LINK_STATUS::NONE; LINK_STATUS status = LINK_STATUS::NONE;
unsigned char reflector[DSTAR_LONG_CALLSIGN_LENGTH]; unsigned char reflector[DSTAR_LONG_CALLSIGN_LENGTH];
if (m_network != NULL) if (m_network != nullptr)
m_network->getStatus(status, reflector); m_network->getStatus(status, reflector);
char text[40U]; char text[40U];
@ -1284,7 +1284,7 @@ void CDStarControl::sendError()
m_rfSlowData.setText(text); m_rfSlowData.setText(text);
::memcpy(data, DSTAR_NULL_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U); ::memcpy(data, DSTAR_nullptr_FRAME_DATA_BYTES, DSTAR_FRAME_LENGTH_BYTES + 1U);
for (unsigned int i = 0U; i < 19U; i++) { for (unsigned int i = 0U; i < 19U; i++) {
m_rfSlowData.getSlowData(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES); m_rfSlowData.getSlowData(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES);

View file

@ -27,16 +27,16 @@ const unsigned int DSTAR_FRAME_LENGTH_BYTES = 12U;
const unsigned char DSTAR_END_PATTERN_BYTES[] = { TAG_EOT, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A }; const unsigned char DSTAR_END_PATTERN_BYTES[] = { TAG_EOT, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A };
const unsigned int DSTAR_END_PATTERN_LENGTH_BYTES = 6U; const unsigned int DSTAR_END_PATTERN_LENGTH_BYTES = 6U;
const unsigned char DSTAR_NULL_AMBE_DATA_BYTES[] = { 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8 }; const unsigned char DSTAR_nullptr_AMBE_DATA_BYTES[] = { 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8 };
// DSTAR_NULL_AMBE_DATA_BYTES_SCRAMBLED is DSTAR_NULL_AMBE_DATA_BYTES XORed with DSTAR_SCRAMBLER_BYTES. // DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED is DSTAR_nullptr_AMBE_DATA_BYTES XORed with DSTAR_SCRAMBLER_BYTES.
const unsigned char DSTAR_NULL_AMBE_DATA_BYTES_SCRAMBLED[] = { 0xEEU, 0xC2U, 0xA1U, 0xC8U, 0x42U, 0x6EU, 0x52U, 0x51U, 0xC3U }; const unsigned char DSTAR_nullptr_AMBE_DATA_BYTES_SCRAMBLED[] = { 0xEEU, 0xC2U, 0xA1U, 0xC8U, 0x42U, 0x6EU, 0x52U, 0x51U, 0xC3U };
const unsigned char DSTAR_NULL_SLOW_SYNC_BYTES[] = { 0x55, 0x2D, 0x16 }; const unsigned char DSTAR_nullptr_SLOW_SYNC_BYTES[] = { 0x55, 0x2D, 0x16 };
// Note that these are already scrambled, 0x66 0x66 0x66 otherwise // Note that these are already scrambled, 0x66 0x66 0x66 otherwise
const unsigned char DSTAR_NULL_SLOW_DATA_BYTES[] = { 0x16, 0x29, 0xF5 }; const unsigned char DSTAR_nullptr_SLOW_DATA_BYTES[] = { 0x16, 0x29, 0xF5 };
const unsigned char DSTAR_NULL_FRAME_SYNC_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16 }; const unsigned char DSTAR_nullptr_FRAME_SYNC_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16 };
const unsigned char DSTAR_NULL_FRAME_DATA_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x16, 0x29, 0xF5 }; const unsigned char DSTAR_nullptr_FRAME_DATA_BYTES[] = { TAG_DATA, 0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x16, 0x29, 0xF5 };
const unsigned int DSTAR_VOICE_FRAME_LENGTH_BYTES = 9U; const unsigned int DSTAR_VOICE_FRAME_LENGTH_BYTES = 9U;
const unsigned int DSTAR_DATA_FRAME_LENGTH_BYTES = 3U; const unsigned int DSTAR_DATA_FRAME_LENGTH_BYTES = 3U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,9 +25,9 @@
#include <cstring> #include <cstring>
CDStarHeader::CDStarHeader(const unsigned char* header) : CDStarHeader::CDStarHeader(const unsigned char* header) :
m_header(NULL) m_header(nullptr)
{ {
assert(header != NULL); assert(header != nullptr);
m_header = new unsigned char[DSTAR_HEADER_LENGTH_BYTES]; m_header = new unsigned char[DSTAR_HEADER_LENGTH_BYTES];
@ -35,7 +35,7 @@ m_header(NULL)
} }
CDStarHeader::CDStarHeader() : CDStarHeader::CDStarHeader() :
m_header(NULL) m_header(nullptr)
{ {
m_header = new unsigned char[DSTAR_HEADER_LENGTH_BYTES]; m_header = new unsigned char[DSTAR_HEADER_LENGTH_BYTES];
@ -87,77 +87,77 @@ void CDStarHeader::setUnavailable(bool on)
void CDStarHeader::getMyCall1(unsigned char* call1) const void CDStarHeader::getMyCall1(unsigned char* call1) const
{ {
assert(call1 != NULL); assert(call1 != nullptr);
::memcpy(call1, m_header + 27U, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(call1, m_header + 27U, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::getMyCall2(unsigned char* call2) const void CDStarHeader::getMyCall2(unsigned char* call2) const
{ {
assert(call2 != NULL); assert(call2 != nullptr);
::memcpy(call2, m_header + 35U, DSTAR_SHORT_CALLSIGN_LENGTH); ::memcpy(call2, m_header + 35U, DSTAR_SHORT_CALLSIGN_LENGTH);
} }
void CDStarHeader::setMyCall1(const unsigned char* call1) void CDStarHeader::setMyCall1(const unsigned char* call1)
{ {
assert(call1 != NULL); assert(call1 != nullptr);
::memcpy(m_header + 27U, call1, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(m_header + 27U, call1, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::setMyCall2(const unsigned char* call2) void CDStarHeader::setMyCall2(const unsigned char* call2)
{ {
assert(call2 != NULL); assert(call2 != nullptr);
::memcpy(m_header + 35U, call2, DSTAR_SHORT_CALLSIGN_LENGTH); ::memcpy(m_header + 35U, call2, DSTAR_SHORT_CALLSIGN_LENGTH);
} }
void CDStarHeader::getRPTCall1(unsigned char* call1) const void CDStarHeader::getRPTCall1(unsigned char* call1) const
{ {
assert(call1 != NULL); assert(call1 != nullptr);
::memcpy(call1, m_header + 11U, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(call1, m_header + 11U, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::getRPTCall2(unsigned char* call2) const void CDStarHeader::getRPTCall2(unsigned char* call2) const
{ {
assert(call2 != NULL); assert(call2 != nullptr);
::memcpy(call2, m_header + 3U, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(call2, m_header + 3U, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::setRPTCall1(const unsigned char* call1) void CDStarHeader::setRPTCall1(const unsigned char* call1)
{ {
assert(call1 != NULL); assert(call1 != nullptr);
::memcpy(m_header + 11U, call1, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(m_header + 11U, call1, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::setRPTCall2(const unsigned char* call2) void CDStarHeader::setRPTCall2(const unsigned char* call2)
{ {
assert(call2 != NULL); assert(call2 != nullptr);
::memcpy(m_header + 3U, call2, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(m_header + 3U, call2, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::getYourCall(unsigned char* call) const void CDStarHeader::getYourCall(unsigned char* call) const
{ {
assert(call != NULL); assert(call != nullptr);
::memcpy(call, m_header + 19U, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(call, m_header + 19U, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::setYourCall(const unsigned char* call) void CDStarHeader::setYourCall(const unsigned char* call)
{ {
assert(call != NULL); assert(call != nullptr);
::memcpy(m_header + 19U, call, DSTAR_LONG_CALLSIGN_LENGTH); ::memcpy(m_header + 19U, call, DSTAR_LONG_CALLSIGN_LENGTH);
} }
void CDStarHeader::get(unsigned char* header) const void CDStarHeader::get(unsigned char* header) const
{ {
assert(header != NULL); assert(header != nullptr);
::memcpy(header, m_header, DSTAR_HEADER_LENGTH_BYTES); ::memcpy(header, m_header, DSTAR_HEADER_LENGTH_BYTES);

View file

@ -44,7 +44,7 @@ m_inId(0U),
m_buffer(1000U, "D-Star Network"), m_buffer(1000U, "D-Star Network"),
m_pollTimer(1000U, 60U), m_pollTimer(1000U, 60U),
m_linkStatus(LINK_STATUS::NONE), m_linkStatus(LINK_STATUS::NONE),
m_linkReflector(NULL), m_linkReflector(nullptr),
m_random() m_random()
{ {
if (CUDPSocket::lookup(gatewayAddress, gatewayPort, m_addr, m_addrLen) != 0) if (CUDPSocket::lookup(gatewayAddress, gatewayPort, m_addr, m_addrLen) != 0)
@ -79,7 +79,7 @@ bool CDStarNetwork::open()
bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length, bool busy) bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length, bool busy)
{ {
assert(header != NULL); assert(header != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
@ -117,7 +117,7 @@ bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length
bool CDStarNetwork::writeData(const unsigned char* data, unsigned int length, unsigned int errors, bool end, bool busy) bool CDStarNetwork::writeData(const unsigned char* data, unsigned int length, unsigned int errors, bool end, bool busy)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[30U]; unsigned char buffer[30U];
@ -155,7 +155,7 @@ bool CDStarNetwork::writeData(const unsigned char* data, unsigned int length, un
bool CDStarNetwork::writePoll(const char* text) bool CDStarNetwork::writePoll(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
unsigned char buffer[40U]; unsigned char buffer[40U];
@ -285,7 +285,7 @@ void CDStarNetwork::clock(unsigned int ms)
unsigned int CDStarNetwork::read(unsigned char* data, unsigned int length) unsigned int CDStarNetwork::read(unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return 0U; return 0U;
@ -340,7 +340,7 @@ void CDStarNetwork::enable(bool enabled)
void CDStarNetwork::getStatus(LINK_STATUS& status, unsigned char* reflector) void CDStarNetwork::getStatus(LINK_STATUS& status, unsigned char* reflector)
{ {
assert(reflector != NULL); assert(reflector != nullptr);
status = m_linkStatus; status = m_linkStatus;

View file

@ -27,10 +27,10 @@
#include <cstring> #include <cstring>
CDStarSlowData::CDStarSlowData() : CDStarSlowData::CDStarSlowData() :
m_header(NULL), m_header(nullptr),
m_ptr(0U), m_ptr(0U),
m_buffer(NULL), m_buffer(nullptr),
m_text(NULL), m_text(nullptr),
m_textPtr(0U), m_textPtr(0U),
m_textBits(0x00U), m_textBits(0x00U),
m_type(0x00U), m_type(0x00U),
@ -50,7 +50,7 @@ CDStarSlowData::~CDStarSlowData()
void CDStarSlowData::peakSlowData(const unsigned char* data, unsigned int n) void CDStarSlowData::peakSlowData(const unsigned char* data, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
if ((n % 2U) == 0U) { if ((n % 2U) == 0U) {
m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U]; m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U];
@ -62,7 +62,7 @@ void CDStarSlowData::peakSlowData(const unsigned char* data, unsigned int n)
CDStarHeader* CDStarSlowData::addHeader(const unsigned char* data, unsigned int n) CDStarHeader* CDStarSlowData::addHeader(const unsigned char* data, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
if ((n % 2U) == 0U) { if ((n % 2U) == 0U) {
m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U]; m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U];
@ -78,10 +78,10 @@ CDStarHeader* CDStarSlowData::addHeader(const unsigned char* data, unsigned int
} }
if ((m_buffer[0U] & DSTAR_SLOW_DATA_TYPE_MASK) != DSTAR_SLOW_DATA_TYPE_HEADER) if ((m_buffer[0U] & DSTAR_SLOW_DATA_TYPE_MASK) != DSTAR_SLOW_DATA_TYPE_HEADER)
return NULL; return nullptr;
if (m_ptr >= 45U) if (m_ptr >= 45U)
return NULL; return nullptr;
::memcpy(m_header + m_ptr, m_buffer + 1U, 5U); ::memcpy(m_header + m_ptr, m_buffer + 1U, 5U);
m_ptr += 5U; m_ptr += 5U;
@ -99,7 +99,7 @@ CDStarHeader* CDStarSlowData::addHeader(const unsigned char* data, unsigned int
if (!ret) { if (!ret) {
if (m_ptr == 45U) if (m_ptr == 45U)
LogMessage("D-Star, invalid slow data header"); LogMessage("D-Star, invalid slow data header");
return NULL; return nullptr;
} }
return new CDStarHeader(m_header); return new CDStarHeader(m_header);
@ -107,7 +107,7 @@ CDStarHeader* CDStarSlowData::addHeader(const unsigned char* data, unsigned int
const unsigned char* CDStarSlowData::addText(const unsigned char* data, unsigned int n) const unsigned char* CDStarSlowData::addText(const unsigned char* data, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
if ((n % 2U) == 0U) { if ((n % 2U) == 0U) {
m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U]; m_type = data[9U] ^ DSTAR_SCRAMBLER_BYTES[0U];
@ -161,11 +161,11 @@ const unsigned char* CDStarSlowData::addText(const unsigned char* data, unsigned
m_textBits |= 0x08U; m_textBits |= 0x08U;
break; break;
default: default:
return NULL; return nullptr;
} }
if (m_textBits != 0x0FU) if (m_textBits != 0x0FU)
return NULL; return nullptr;
CUtils::dump(1U, "D-Star slow data text", m_text, 20U); CUtils::dump(1U, "D-Star slow data text", m_text, 20U);
@ -194,7 +194,7 @@ void CDStarSlowData::reset()
void CDStarSlowData::setText(const char* text) void CDStarSlowData::setText(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
m_text[0U] = DSTAR_SLOW_DATA_TYPE_TEXT | 0U; m_text[0U] = DSTAR_SLOW_DATA_TYPE_TEXT | 0U;
m_text[1U] = text[0U]; m_text[1U] = text[0U];
@ -230,7 +230,7 @@ void CDStarSlowData::setText(const char* text)
void CDStarSlowData::getSlowData(unsigned char* data) void CDStarSlowData::getSlowData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_textPtr < 24U) { if (m_textPtr < 24U) {
data[0U] = m_text[m_textPtr++] ^ DSTAR_SCRAMBLER_BYTES[0U]; data[0U] = m_text[m_textPtr++] ^ DSTAR_SCRAMBLER_BYTES[0U];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2018,2020,2021,2023,2024 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018,2020,2021,2023,2024,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -78,7 +78,7 @@ void CDisplay::setLockout()
void CDisplay::setError(const char* text) void CDisplay::setError(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
m_timer1.stop(); m_timer1.stop();
m_timer2.stop(); m_timer2.stop();
@ -113,11 +113,11 @@ void CDisplay::setFM()
void CDisplay::writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) void CDisplay::writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
assert(my1 != NULL); assert(my1 != nullptr);
assert(my2 != NULL); assert(my2 != nullptr);
assert(your != NULL); assert(your != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(reflector != NULL); assert(reflector != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -149,7 +149,7 @@ void CDisplay::clearDStar()
void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
if (slotNo == 1U) { if (slotNo == 1U) {
m_timer1.start(); m_timer1.start();
@ -163,7 +163,7 @@ void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group,
void CDisplay::writeDMR(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type) void CDisplay::writeDMR(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
if (slotNo == 1U) { if (slotNo == 1U) {
m_timer1.start(); m_timer1.start();
@ -229,10 +229,10 @@ void CDisplay::clearDMR(unsigned int slotNo)
void CDisplay::writeFusion(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) void CDisplay::writeFusion(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(origin != NULL); assert(origin != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -264,8 +264,8 @@ void CDisplay::clearFusion()
void CDisplay::writeP25(const char* source, bool group, unsigned int dest, const char* type) void CDisplay::writeP25(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -297,8 +297,8 @@ void CDisplay::clearP25()
void CDisplay::writeNXDN(const char* source, bool group, unsigned int dest, const char* type) void CDisplay::writeNXDN(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -308,7 +308,7 @@ void CDisplay::writeNXDN(const char* source, bool group, unsigned int dest, cons
void CDisplay::writeNXDN(const class CUserDBentry& source, bool group, unsigned int dest, const char* type) void CDisplay::writeNXDN(const class CUserDBentry& source, bool group, unsigned int dest, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -341,9 +341,9 @@ void CDisplay::clearNXDN()
void CDisplay::writeM17(const char* source, const char* dest, const char* type) void CDisplay::writeM17(const char* source, const char* dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
m_timer1.start(); m_timer1.start();
m_mode1 = MODE_IDLE; m_mode1 = MODE_IDLE;
@ -543,7 +543,7 @@ int CDisplay::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsig
/* Factory method extracted from MMDVMHost.cpp - BG5HHP */ /* Factory method extracted from MMDVMHost.cpp - BG5HHP */
CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem) CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
{ {
CDisplay *display = NULL; CDisplay *display = nullptr;
std::string type = conf.getDisplay(); std::string type = conf.getDisplay();
unsigned int dmrid = conf.getDMRId(); unsigned int dmrid = conf.getDMRId();
@ -560,7 +560,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
LogInfo(" Brightness: %u", brightness); LogInfo(" Brightness: %u", brightness);
LogInfo(" Screen Layout: %u", screenLayout); LogInfo(" Screen Layout: %u", screenLayout);
ISerialPort* serial = NULL; ISerialPort* serial = nullptr;
if (port == "modem") if (port == "modem")
serial = new IModemSerialPort(modem); serial = new IModemSerialPort(modem);
else else
@ -605,7 +605,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
} }
if (port == "modem") { if (port == "modem") {
CUDPSocket* socket = NULL; CUDPSocket* socket = nullptr;
struct sockaddr_storage addr; struct sockaddr_storage addr;
unsigned int addrLength = 0U; unsigned int addrLength = 0U;
@ -622,12 +622,12 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CModem* modem)
bool ret = socket->open(addr); bool ret = socket->open(addr);
if (!ret) { if (!ret) {
delete socket; delete socket;
socket = NULL; socket = nullptr;
} }
} }
} }
if (socket == NULL) { if (socket == nullptr) {
ISerialPort* serial = new IModemSerialPort(modem); ISerialPort* serial = new IModemSerialPort(modem);
display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF); display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF);
} else { } else {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,11 +39,11 @@ m_preEmphasisOn(preEmphasisOn),
m_deEmphasisOn(deEmphasisOn), m_deEmphasisOn(deEmphasisOn),
m_enabled(false), m_enabled(false),
m_incomingRFAudio(1600U, "Incoming RF FM Audio"), m_incomingRFAudio(1600U, "Incoming RF FM Audio"),
m_preEmphasis(NULL), m_preEmphasis(nullptr),
m_deEmphasis(NULL), m_deEmphasis(nullptr),
m_filterStage1(NULL), m_filterStage1(nullptr),
m_filterStage2(NULL), m_filterStage2(nullptr),
m_filterStage3(NULL) m_filterStage3(nullptr)
{ {
assert(txAudioGain > 0.0F); assert(txAudioGain > 0.0F);
assert(rxAudioGain > 0.0F); assert(rxAudioGain > 0.0F);
@ -69,10 +69,10 @@ CFMControl::~CFMControl()
bool CFMControl::writeModem(const unsigned char* data, unsigned int length) bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (m_network == NULL) if (m_network == nullptr)
return true; return true;
if (data[0U] == TAG_HEADER) if (data[0U] == TAG_HEADER)
@ -124,7 +124,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
#if defined(DUMP_RF_AUDIO) #if defined(DUMP_RF_AUDIO)
FILE * audiofile = fopen("./audiodump.bin", "ab"); FILE * audiofile = fopen("./audiodump.bin", "ab");
if (audiofile != NULL) { if (audiofile != nullptr) {
fwrite(out, sizeof(float), nOut, audiofile); fwrite(out, sizeof(float), nOut, audiofile);
fclose(audiofile); fclose(audiofile);
} }
@ -137,10 +137,10 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length)
unsigned int CFMControl::readModem(unsigned char* data, unsigned int space) unsigned int CFMControl::readModem(unsigned char* data, unsigned int space)
{ {
assert(data != NULL); assert(data != nullptr);
assert(space > 0U); assert(space > 0U);
if (m_network == NULL) if (m_network == nullptr)
return 0U; return 0U;
if (space > 240U) // 160 samples 12-bit if (space > 240U) // 160 samples 12-bit

View file

@ -46,10 +46,10 @@ m_enabled(false),
m_buffer(2000U, "FM Network"), m_buffer(2000U, "FM Network"),
m_seqNo(0U), m_seqNo(0U),
#if defined(HAS_SRC) #if defined(HAS_SRC)
m_resampler(NULL), m_resampler(nullptr),
#endif #endif
m_error(0), m_error(0),
m_fp(NULL) m_fp(nullptr)
{ {
assert(!callsign.empty()); assert(!callsign.empty());
assert(gatewayPort > 0U); assert(gatewayPort > 0U);
@ -93,7 +93,7 @@ bool CFMNetwork::open()
if (m_protocol == FM_NETWORK_PROTOCOL::RAW) { if (m_protocol == FM_NETWORK_PROTOCOL::RAW) {
if (!m_squelchFile.empty()) { if (!m_squelchFile.empty()) {
m_fp = ::fopen(m_squelchFile.c_str(), "wb"); m_fp = ::fopen(m_squelchFile.c_str(), "wb");
if (m_fp == NULL) { if (m_fp == nullptr) {
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
LogError("Cannot open the squelch file: %s, errno=%d", m_squelchFile.c_str(), errno); LogError("Cannot open the squelch file: %s, errno=%d", m_squelchFile.c_str(), errno);
#else #else
@ -116,7 +116,7 @@ bool CFMNetwork::open()
bool CFMNetwork::writeData(const float* data, unsigned int nSamples) bool CFMNetwork::writeData(const float* data, unsigned int nSamples)
{ {
assert(data != NULL); assert(data != nullptr);
assert(nSamples > 0U); assert(nSamples > 0U);
if (m_protocol == FM_NETWORK_PROTOCOL::USRP) if (m_protocol == FM_NETWORK_PROTOCOL::USRP)
@ -129,7 +129,7 @@ bool CFMNetwork::writeData(const float* data, unsigned int nSamples)
bool CFMNetwork::writeUSRPData(const float* data, unsigned int nSamples) bool CFMNetwork::writeUSRPData(const float* data, unsigned int nSamples)
{ {
assert(data != NULL); assert(data != nullptr);
assert(nSamples > 0U); assert(nSamples > 0U);
if (m_seqNo == 0U) { if (m_seqNo == 0U) {
@ -203,7 +203,7 @@ bool CFMNetwork::writeUSRPData(const float* data, unsigned int nSamples)
bool CFMNetwork::writeRawData(const float* in, unsigned int nIn) bool CFMNetwork::writeRawData(const float* in, unsigned int nIn)
{ {
assert(in != NULL); assert(in != nullptr);
assert(nIn > 0U); assert(nIn > 0U);
if (m_seqNo == 0U) { if (m_seqNo == 0U) {
@ -338,7 +338,7 @@ bool CFMNetwork::writeRawEnd()
{ {
m_seqNo = 0U; m_seqNo = 0U;
if (m_fp != NULL) { if (m_fp != nullptr) {
size_t n = ::fwrite("Z", 1, 1, m_fp); size_t n = ::fwrite("Z", 1, 1, m_fp);
if (n != 1) { if (n != 1) {
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
@ -407,7 +407,7 @@ void CFMNetwork::clock(unsigned int ms)
unsigned int CFMNetwork::readData(float* out, unsigned int nOut) unsigned int CFMNetwork::readData(float* out, unsigned int nOut)
{ {
assert(out != NULL); assert(out != nullptr);
assert(nOut > 0U); assert(nOut > 0U);
unsigned int bytes = m_buffer.dataSize() / sizeof(unsigned short); unsigned int bytes = m_buffer.dataSize() / sizeof(unsigned short);
@ -474,9 +474,9 @@ void CFMNetwork::close()
{ {
m_socket.close(); m_socket.close();
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
LogMessage("Closing FM network connection"); LogMessage("Closing FM network connection");
@ -591,7 +591,7 @@ bool CFMNetwork::writeUSRPStart()
bool CFMNetwork::writeRawStart() bool CFMNetwork::writeRawStart()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
size_t n = ::fwrite("O", 1, 1, m_fp); size_t n = ::fwrite("O", 1, 1, m_fp);
if (n != 1) { if (n != 1) {
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -237,7 +237,7 @@ unsigned int CGolay2087::getSyndrome1987(unsigned int pattern)
unsigned char CGolay2087::decode(const unsigned char* data) unsigned char CGolay2087::decode(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int code = (data[0U] << 11) + (data[1U] << 3) + (data[2U] >> 5); unsigned int code = (data[0U] << 11) + (data[1U] << 3) + (data[2U] >> 5);
unsigned int syndrome = getSyndrome1987(code); unsigned int syndrome = getSyndrome1987(code);
@ -251,7 +251,7 @@ unsigned char CGolay2087::decode(const unsigned char* data)
void CGolay2087::encode(unsigned char* data) void CGolay2087::encode(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int value = data[0U]; unsigned int value = data[0U];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2010,2016,2021 by Jonathan Naylor G4KLX * Copyright (C) 2010,2016,2021,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2002 by Robert H. Morelos-Zaragoza. All rights reserved. * Copyright (C) 2002 by Robert H. Morelos-Zaragoza. All rights reserved.
*/ */
@ -1106,7 +1106,7 @@ bool CGolay24128::decode24128(unsigned int in, unsigned int& out)
bool CGolay24128::decode24128(unsigned char* in, unsigned int& out) bool CGolay24128::decode24128(unsigned char* in, unsigned int& out)
{ {
assert(in != NULL); assert(in != nullptr);
unsigned int code = (in[0U] << 16) | (in[1U] << 8) | (in[2U] << 0); unsigned int code = (in[0U] << 16) | (in[1U] << 8) | (in[2U] << 0);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,7 +24,7 @@
// Hamming (15,11,3) check a boolean data array // Hamming (15,11,3) check a boolean data array
bool CHamming::decode15113_1(bool* d) bool CHamming::decode15113_1(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the parity it should have // Calculate the parity it should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6]; bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6];
@ -66,7 +66,7 @@ bool CHamming::decode15113_1(bool* d)
void CHamming::encode15113_1(bool* d) void CHamming::encode15113_1(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this row should have // Calculate the checksum this row should have
d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6]; d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6];
@ -78,7 +78,7 @@ void CHamming::encode15113_1(bool* d)
// Hamming (15,11,3) check a boolean data array // Hamming (15,11,3) check a boolean data array
bool CHamming::decode15113_2(bool* d) bool CHamming::decode15113_2(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this row should have // Calculate the checksum this row should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8];
@ -119,7 +119,7 @@ bool CHamming::decode15113_2(bool* d)
void CHamming::encode15113_2(bool* d) void CHamming::encode15113_2(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this row should have // Calculate the checksum this row should have
d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8];
@ -131,7 +131,7 @@ void CHamming::encode15113_2(bool* d)
// Hamming (13,9,3) check a boolean data array // Hamming (13,9,3) check a boolean data array
bool CHamming::decode1393(bool* d) bool CHamming::decode1393(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
bool c0 = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; bool c0 = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6];
@ -170,7 +170,7 @@ bool CHamming::decode1393(bool* d)
void CHamming::encode1393(bool* d) void CHamming::encode1393(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
d[9] = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; d[9] = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6];
@ -182,7 +182,7 @@ void CHamming::encode1393(bool* d)
// Hamming (10,6,3) check a boolean data array // Hamming (10,6,3) check a boolean data array
bool CHamming::decode1063(bool* d) bool CHamming::decode1063(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[5]; bool c0 = d[0] ^ d[1] ^ d[2] ^ d[5];
@ -218,7 +218,7 @@ bool CHamming::decode1063(bool* d)
void CHamming::encode1063(bool* d) void CHamming::encode1063(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
d[6] = d[0] ^ d[1] ^ d[2] ^ d[5]; d[6] = d[0] ^ d[1] ^ d[2] ^ d[5];
@ -230,7 +230,7 @@ void CHamming::encode1063(bool* d)
// A Hamming (16,11,4) Check // A Hamming (16,11,4) Check
bool CHamming::decode16114(bool* d) bool CHamming::decode16114(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8];
@ -278,7 +278,7 @@ bool CHamming::decode16114(bool* d)
void CHamming::encode16114(bool* d) void CHamming::encode16114(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; 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[12] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9];
@ -290,7 +290,7 @@ void CHamming::encode16114(bool* d)
// A Hamming (17,12,3) Check // A Hamming (17,12,3) Check
bool CHamming::decode17123(bool* d) bool CHamming::decode17123(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
// Calculate the checksum this column should have // Calculate the checksum this column should have
bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9];
@ -339,7 +339,7 @@ bool CHamming::decode17123(bool* d)
void CHamming::encode17123(bool* d) void CHamming::encode17123(bool* d)
{ {
assert(d != NULL); assert(d != nullptr);
d[12] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; 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[13] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10];

View file

@ -151,7 +151,7 @@ bool CLCDproc::open()
/* Lookup the client address (random port - need to specify manual port from ini file) */ /* Lookup the client address (random port - need to specify manual port from ini file) */
hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE; hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE;
hints.ai_family = serverAddress.ss_family; hints.ai_family = serverAddress.ss_family;
err = getaddrinfo(NULL, localPort.c_str(), &hints, &res); err = getaddrinfo(nullptr, localPort.c_str(), &hints, &res);
if (err) { if (err) {
LogError("LCDproc, cannot lookup client"); LogError("LCDproc, cannot lookup client");
return false; return false;
@ -204,7 +204,7 @@ void CLCDproc::setIdleInt()
void CLCDproc::setErrorInt(const char* text) void CLCDproc::setErrorInt(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -280,11 +280,11 @@ void CLCDproc::setFMInt()
void CLCDproc::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) void CLCDproc::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
assert(my1 != NULL); assert(my1 != nullptr);
assert(my2 != NULL); assert(my2 != nullptr);
assert(your != NULL); assert(your != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(reflector != NULL); assert(reflector != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -341,7 +341,7 @@ void CLCDproc::clearDStarInt()
void CLCDproc::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) void CLCDproc::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
if (!m_dmr) { if (!m_dmr) {
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -435,10 +435,10 @@ void CLCDproc::clearDMRInt(unsigned int slotNo)
void CLCDproc::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) void CLCDproc::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(origin != NULL); assert(origin != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -481,8 +481,8 @@ void CLCDproc::clearFusionInt()
void CLCDproc::writeP25Int(const char* source, bool group, unsigned int dest, const char* type) void CLCDproc::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -526,8 +526,8 @@ void CLCDproc::clearP25Int()
void CLCDproc::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type) void CLCDproc::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -569,9 +569,9 @@ void CLCDproc::clearNXDNInt()
void CLCDproc::writeM17Int(const char* source, const char* dest, const char* type) void CLCDproc::writeM17Int(const char* source, const char* dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
m_clockDisplayTimer.stop(); // Stop the clock display m_clockDisplayTimer.stop(); // Stop the clock display
@ -675,7 +675,7 @@ void CLCDproc::clockInt(unsigned int ms)
* exceptfds = we are not waiting for exception fds * exceptfds = we are not waiting for exception fds
*/ */
if (select(int(m_socketfd) + 1, &m_readfds, NULL, NULL, &m_timeout) == -1) { if (select(int(m_socketfd) + 1, &m_readfds, nullptr, nullptr, &m_timeout) == -1) {
LogError("LCDproc, error on select"); LogError("LCDproc, error on select");
return; return;
} }
@ -798,7 +798,7 @@ int CLCDproc::socketPrintf(int fd, const char *format, ...)
m_timeout.tv_sec = 0; m_timeout.tv_sec = 0;
m_timeout.tv_usec = 0; m_timeout.tv_usec = 0;
if (select(int(m_socketfd) + 1, NULL, &m_writefds, NULL, &m_timeout) == -1) if (select(int(m_socketfd) + 1, nullptr, &m_writefds, nullptr, &m_timeout) == -1)
LogError("LCDproc, error on select"); LogError("LCDproc, error on select");
if (FD_ISSET(m_socketfd, &m_writefds)) { if (FD_ISSET(m_socketfd, &m_writefds)) {

18
Log.cpp
View file

@ -37,7 +37,7 @@ static std::string m_filePath;
static std::string m_fileRoot; static std::string m_fileRoot;
static bool m_fileRotate = true; static bool m_fileRotate = true;
static FILE* m_fpLog = NULL; static FILE* m_fpLog = nullptr;
static bool m_daemon = false; static bool m_daemon = false;
static unsigned int m_displayLevel = 2U; static unsigned int m_displayLevel = 2U;
@ -59,10 +59,10 @@ static bool logOpenRotate()
struct tm* tm = ::gmtime(&now); struct tm* tm = ::gmtime(&now);
if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) { if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) {
if (m_fpLog != NULL) if (m_fpLog != nullptr)
return true; return true;
} else { } else {
if (m_fpLog != NULL) if (m_fpLog != nullptr)
::fclose(m_fpLog); ::fclose(m_fpLog);
} }
@ -73,7 +73,7 @@ static bool logOpenRotate()
::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); ::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
#endif #endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) { if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true; status = true;
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
@ -94,7 +94,7 @@ static bool logOpenNoRotate()
if (m_fileLevel == 0U) if (m_fileLevel == 0U)
return true; return true;
if (m_fpLog != NULL) if (m_fpLog != nullptr)
return true; return true;
char filename[200U]; char filename[200U];
@ -104,7 +104,7 @@ static bool logOpenNoRotate()
::sprintf(filename, "%s/%s.log", m_filePath.c_str(), m_fileRoot.c_str()); ::sprintf(filename, "%s/%s.log", m_filePath.c_str(), m_fileRoot.c_str());
#endif #endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) { if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true; status = true;
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
@ -141,13 +141,13 @@ bool LogInitialise(bool daemon, const std::string& filePath, const std::string&
void LogFinalise() void LogFinalise()
{ {
if (m_fpLog != NULL) if (m_fpLog != nullptr)
::fclose(m_fpLog); ::fclose(m_fpLog);
} }
void Log(unsigned int level, const char* fmt, ...) void Log(unsigned int level, const char* fmt, ...)
{ {
assert(fmt != NULL); assert(fmt != nullptr);
char buffer[501U]; char buffer[501U];
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
@ -157,7 +157,7 @@ void Log(unsigned int level, const char* fmt, ...)
::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); ::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
#else #else
struct timeval now; struct timeval now;
::gettimeofday(&now, NULL); ::gettimeofday(&now, nullptr);
struct tm* tm = ::gmtime(&now.tv_sec); struct tm* tm = ::gmtime(&now.tv_sec);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ const uint16_t CRC16_TABLE[] = {0x0000U, 0x5935U, 0xB26AU, 0xEB5FU, 0x3DE1U, 0x6
bool CM17CRC::checkCRC16(const unsigned char* in, unsigned int nBytes) bool CM17CRC::checkCRC16(const unsigned char* in, unsigned int nBytes)
{ {
assert(in != NULL); assert(in != nullptr);
assert(nBytes > 2U); assert(nBytes > 2U);
uint16_t crc = createCRC16(in, nBytes - 2U); uint16_t crc = createCRC16(in, nBytes - 2U);
@ -62,7 +62,7 @@ bool CM17CRC::checkCRC16(const unsigned char* in, unsigned int nBytes)
void CM17CRC::encodeCRC16(unsigned char* in, unsigned int nBytes) void CM17CRC::encodeCRC16(unsigned char* in, unsigned int nBytes)
{ {
assert(in != NULL); assert(in != nullptr);
assert(nBytes > 2U); assert(nBytes > 2U);
uint16_t crc = createCRC16(in, nBytes - 2U); uint16_t crc = createCRC16(in, nBytes - 2U);
@ -73,7 +73,7 @@ void CM17CRC::encodeCRC16(unsigned char* in, unsigned int nBytes)
uint16_t CM17CRC::createCRC16(const unsigned char* in, unsigned int nBytes) uint16_t CM17CRC::createCRC16(const unsigned char* in, unsigned int nBytes)
{ {
assert(in != NULL); assert(in != nullptr);
uint16_t crc = 0xFFFFU; uint16_t crc = 0xFFFFU;

View file

@ -88,8 +88,8 @@ m_netLSF(),
m_netLSFn(0U), m_netLSFn(0U),
m_rfTextBits(0x00U), m_rfTextBits(0x00U),
m_netTextBits(0x00U), m_netTextBits(0x00U),
m_rfText(NULL), m_rfText(nullptr),
m_netText(NULL), m_netText(nullptr),
m_rssiMapper(rssiMapper), m_rssiMapper(rssiMapper),
m_rssi(0U), m_rssi(0U),
m_maxRSSI(0U), m_maxRSSI(0U),
@ -97,10 +97,10 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
m_rfText = new char[4U * M17_META_LENGTH_BYTES]; m_rfText = new char[4U * M17_META_LENGTH_BYTES];
m_netText = new char[4U * M17_META_LENGTH_BYTES]; m_netText = new char[4U * M17_META_LENGTH_BYTES];
@ -114,7 +114,7 @@ CM17Control::~CM17Control()
bool CM17Control::writeModem(unsigned char* data, unsigned int len) bool CM17Control::writeModem(unsigned char* data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -395,7 +395,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
writeQueueRF(rfData); writeQueueRF(rfData);
} }
if (m_network != NULL && m_rfTimeoutTimer.isRunning() && !m_rfTimeoutTimer.hasExpired()) { if (m_network != nullptr && m_rfTimeoutTimer.isRunning() && !m_rfTimeoutTimer.hasExpired()) {
unsigned char netData[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES]; unsigned char netData[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES];
m_rfCurrentNetLSF.getNetwork(netData + 0U); m_rfCurrentNetLSF.getNetwork(netData + 0U);
@ -436,7 +436,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
writeQueueRF(rfData); writeQueueRF(rfData);
} }
if (m_network != NULL && m_rfTimeoutTimer.isRunning() && !m_rfTimeoutTimer.hasExpired()) { if (m_network != nullptr && m_rfTimeoutTimer.isRunning() && !m_rfTimeoutTimer.hasExpired()) {
unsigned char netData[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES]; unsigned char netData[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES];
m_rfCurrentNetLSF.getNetwork(netData + 0U); m_rfCurrentNetLSF.getNetwork(netData + 0U);
@ -475,7 +475,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
unsigned int CM17Control::readModem(unsigned char* data) unsigned int CM17Control::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -505,7 +505,7 @@ void CM17Control::writeEndRF()
if (m_netState == RPT_NET_STATE::IDLE) { if (m_netState == RPT_NET_STATE::IDLE) {
m_display->clearM17(); m_display->clearM17();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -528,7 +528,7 @@ void CM17Control::writeEndNet()
m_display->clearM17(); m_display->clearM17();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -835,7 +835,7 @@ void CM17Control::createRFLSF(bool addCallsign)
void CM17Control::clock(unsigned int ms) void CM17Control::clock(unsigned int ms)
{ {
if (m_network != NULL) if (m_network != nullptr)
writeNetwork(); writeNetwork();
m_rfTimeoutTimer.clock(ms); m_rfTimeoutTimer.clock(ms);
@ -853,7 +853,7 @@ void CM17Control::clock(unsigned int ms)
void CM17Control::writeQueueRF(const unsigned char *data) void CM17Control::writeQueueRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -876,7 +876,7 @@ void CM17Control::writeQueueRF(const unsigned char *data)
void CM17Control::writeQueueNet(const unsigned char *data) void CM17Control::writeQueueNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return; return;
@ -896,8 +896,8 @@ void CM17Control::writeQueueNet(const unsigned char *data)
void CM17Control::interleaver(const unsigned char* in, unsigned char* out) const void CM17Control::interleaver(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
for (unsigned int i = 0U; i < (M17_FRAME_LENGTH_BITS - M17_SYNC_LENGTH_BITS); i++) { for (unsigned int i = 0U; i < (M17_FRAME_LENGTH_BITS - M17_SYNC_LENGTH_BITS); i++) {
unsigned int n1 = i + M17_SYNC_LENGTH_BITS; unsigned int n1 = i + M17_SYNC_LENGTH_BITS;
@ -909,8 +909,8 @@ void CM17Control::interleaver(const unsigned char* in, unsigned char* out) const
void CM17Control::decorrelator(const unsigned char* in, unsigned char* out) const void CM17Control::decorrelator(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
for (unsigned int i = M17_SYNC_LENGTH_BYTES; i < M17_FRAME_LENGTH_BYTES; i++) { for (unsigned int i = M17_SYNC_LENGTH_BYTES; i < M17_FRAME_LENGTH_BYTES; i++) {
out[i] = in[i] ^ SCRAMBLER[i]; out[i] = in[i] ^ SCRAMBLER[i];
@ -926,7 +926,7 @@ bool CM17Control::checkCallsign(const std::string& callsign) const
bool CM17Control::openFile() bool CM17Control::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -938,7 +938,7 @@ bool CM17Control::openFile()
::sprintf(name, "M17_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "M17_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("M17", 1U, 3U, m_fp); ::fwrite("M17", 1U, 3U, m_fp);
@ -948,7 +948,7 @@ bool CM17Control::openFile()
bool CM17Control::writeFile(const unsigned char* data) bool CM17Control::writeFile(const unsigned char* data)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, M17_FRAME_LENGTH_BYTES, m_fp); ::fwrite(data, 1U, M17_FRAME_LENGTH_BYTES, m_fp);
@ -958,9 +958,9 @@ bool CM17Control::writeFile(const unsigned char* data)
void CM17Control::closeFile() void CM17Control::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -53,12 +53,12 @@ const uint32_t M = 4U;
const unsigned int K = 5U; const unsigned int K = 5U;
CM17Convolution::CM17Convolution() : CM17Convolution::CM17Convolution() :
m_metrics1(NULL), m_metrics1(nullptr),
m_metrics2(NULL), m_metrics2(nullptr),
m_oldMetrics(NULL), m_oldMetrics(nullptr),
m_newMetrics(NULL), m_newMetrics(nullptr),
m_decisions(NULL), m_decisions(nullptr),
m_dp(NULL) m_dp(nullptr)
{ {
m_metrics1 = new uint16_t[20U]; m_metrics1 = new uint16_t[20U];
m_metrics2 = new uint16_t[20U]; m_metrics2 = new uint16_t[20U];
@ -74,8 +74,8 @@ CM17Convolution::~CM17Convolution()
void CM17Convolution::encodeLinkSetup(const unsigned char* in, unsigned char* out) const void CM17Convolution::encodeLinkSetup(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
unsigned char temp1[31U]; unsigned char temp1[31U];
::memset(temp1, 0x00U, 31U); ::memset(temp1, 0x00U, 31U);
@ -99,8 +99,8 @@ void CM17Convolution::encodeLinkSetup(const unsigned char* in, unsigned char* ou
void CM17Convolution::encodeData(const unsigned char* in, unsigned char* out) const void CM17Convolution::encodeData(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
unsigned char temp1[19U]; unsigned char temp1[19U];
::memset(temp1, 0x00U, 19U); ::memset(temp1, 0x00U, 19U);
@ -124,8 +124,8 @@ void CM17Convolution::encodeData(const unsigned char* in, unsigned char* out) co
unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned char* out) unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
uint8_t temp[500U]; uint8_t temp[500U];
::memset(temp, 0x00U, 500U); ::memset(temp, 0x00U, 500U);
@ -157,8 +157,8 @@ unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned
unsigned int CM17Convolution::decodeData(const unsigned char* in, unsigned char* out) unsigned int CM17Convolution::decodeData(const unsigned char* in, unsigned char* out)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
uint8_t temp[300U]; uint8_t temp[300U];
::memset(temp, 0x00U, 300U); ::memset(temp, 0x00U, 300U);
@ -231,7 +231,7 @@ void CM17Convolution::decode(uint8_t s0, uint8_t s1)
unsigned int CM17Convolution::chainback(unsigned char* out, unsigned int nBits) unsigned int CM17Convolution::chainback(unsigned char* out, unsigned int nBits)
{ {
assert(out != NULL); assert(out != nullptr);
uint32_t state = 0U; uint32_t state = 0U;
@ -257,8 +257,8 @@ unsigned int CM17Convolution::chainback(unsigned char* out, unsigned int nBits)
void CM17Convolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const void CM17Convolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
assert(nBits > 0U); assert(nBits > 0U);
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U; uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -49,7 +49,7 @@ const unsigned int M17_LICH_FRAGMENT_FEC_LENGTH_BYTES = M17_LICH_FRAGMENT_FEC_LE
const unsigned int M17_PAYLOAD_LENGTH_BITS = 128U; const unsigned int M17_PAYLOAD_LENGTH_BITS = 128U;
const unsigned int M17_PAYLOAD_LENGTH_BYTES = M17_PAYLOAD_LENGTH_BITS / 8U; const unsigned int M17_PAYLOAD_LENGTH_BYTES = M17_PAYLOAD_LENGTH_BITS / 8U;
const unsigned char M17_NULL_NONCE[] = {0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U}; const unsigned char M17_nullptr_NONCE[] = {0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U};
const unsigned int M17_META_LENGTH_BITS = 112U; const unsigned int M17_META_LENGTH_BITS = 112U;
const unsigned int M17_META_LENGTH_BYTES = M17_META_LENGTH_BITS / 8U; const unsigned int M17_META_LENGTH_BYTES = M17_META_LENGTH_BITS / 8U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2023,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
#include <cstring> #include <cstring>
CM17LSF::CM17LSF(const CM17LSF& lsf) : CM17LSF::CM17LSF(const CM17LSF& lsf) :
m_lsf(NULL), m_lsf(nullptr),
m_valid(lsf.m_valid) m_valid(lsf.m_valid)
{ {
m_lsf = new unsigned char[M17_LSF_LENGTH_BYTES]; m_lsf = new unsigned char[M17_LSF_LENGTH_BYTES];
@ -34,7 +34,7 @@ m_valid(lsf.m_valid)
} }
CM17LSF::CM17LSF() : CM17LSF::CM17LSF() :
m_lsf(NULL), m_lsf(nullptr),
m_valid(false) m_valid(false)
{ {
m_lsf = new unsigned char[M17_LSF_LENGTH_BYTES]; m_lsf = new unsigned char[M17_LSF_LENGTH_BYTES];
@ -49,14 +49,14 @@ CM17LSF::~CM17LSF()
void CM17LSF::getNetwork(unsigned char* data) const void CM17LSF::getNetwork(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_lsf, M17_LSF_LENGTH_BYTES); ::memcpy(data, m_lsf, M17_LSF_LENGTH_BYTES);
} }
void CM17LSF::setNetwork(const unsigned char* data) void CM17LSF::setNetwork(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_lsf, data, M17_LSF_LENGTH_BYTES); ::memcpy(m_lsf, data, M17_LSF_LENGTH_BYTES);
@ -149,14 +149,14 @@ void CM17LSF::setCAN(unsigned char can)
void CM17LSF::getMeta(unsigned char* data) const void CM17LSF::getMeta(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_lsf + 14U, M17_META_LENGTH_BYTES); ::memcpy(data, m_lsf + 14U, M17_META_LENGTH_BYTES);
} }
void CM17LSF::setMeta(const unsigned char* data) void CM17LSF::setMeta(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_lsf + 14U, data, M17_META_LENGTH_BYTES); ::memcpy(m_lsf + 14U, data, M17_META_LENGTH_BYTES);
} }
@ -175,7 +175,7 @@ bool CM17LSF::isValid() const
void CM17LSF::getLinkSetup(unsigned char* data) const void CM17LSF::getLinkSetup(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_lsf, M17_LSF_LENGTH_BYTES); ::memcpy(data, m_lsf, M17_LSF_LENGTH_BYTES);
@ -184,7 +184,7 @@ void CM17LSF::getLinkSetup(unsigned char* data) const
void CM17LSF::setLinkSetup(const unsigned char* data) void CM17LSF::setLinkSetup(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_lsf, data, M17_LSF_LENGTH_BYTES); ::memcpy(m_lsf, data, M17_LSF_LENGTH_BYTES);
@ -193,7 +193,7 @@ void CM17LSF::setLinkSetup(const unsigned char* data)
void CM17LSF::getFragment(unsigned char* data, unsigned int n) const void CM17LSF::getFragment(unsigned char* data, unsigned int n) const
{ {
assert(data != NULL); assert(data != nullptr);
CM17CRC::encodeCRC16(m_lsf, M17_LSF_LENGTH_BYTES); CM17CRC::encodeCRC16(m_lsf, M17_LSF_LENGTH_BYTES);
@ -202,7 +202,7 @@ void CM17LSF::getFragment(unsigned char* data, unsigned int n) const
void CM17LSF::setFragment(const unsigned char* data, unsigned int n) void CM17LSF::setFragment(const unsigned char* data, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_lsf + (n * M17_LSF_FRAGMENT_LENGTH_BYTES), data, M17_LSF_FRAGMENT_LENGTH_BYTES); ::memcpy(m_lsf + (n * M17_LSF_FRAGMENT_LENGTH_BYTES), data, M17_LSF_FRAGMENT_LENGTH_BYTES);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2023,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -79,7 +79,7 @@ bool CM17Network::write(const unsigned char* data)
if (m_addrLen == 0U) if (m_addrLen == 0U)
return false; return false;
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[100U]; unsigned char buffer[100U];
@ -160,7 +160,7 @@ void CM17Network::clock(unsigned int ms)
bool CM17Network::read(unsigned char* data) bool CM17Network::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return false; return false;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021,2024 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2024,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
void CM17Utils::encodeCallsign(const std::string& callsign, unsigned char* encoded) void CM17Utils::encodeCallsign(const std::string& callsign, unsigned char* encoded)
{ {
assert(encoded != NULL); assert(encoded != nullptr);
if (callsign == "ALL" || callsign == "ALL ") { if (callsign == "ALL" || callsign == "ALL ") {
encoded[0U] = 0xFFU; encoded[0U] = 0xFFU;
@ -71,7 +71,7 @@ void CM17Utils::encodeCallsign(const std::string& callsign, unsigned char* encod
void CM17Utils::decodeCallsign(const unsigned char* encoded, std::string& callsign) void CM17Utils::decodeCallsign(const unsigned char* encoded, std::string& callsign)
{ {
assert(encoded != NULL); assert(encoded != nullptr);
callsign.clear(); callsign.clear();
@ -105,7 +105,7 @@ void CM17Utils::decodeCallsign(const unsigned char* encoded, std::string& callsi
void CM17Utils::splitFragmentLICH(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4) void CM17Utils::splitFragmentLICH(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4)
{ {
assert(data != NULL); assert(data != nullptr);
frag1 = frag2 = frag3 = frag4 = 0x00U; frag1 = frag2 = frag3 = frag4 = 0x00U;
@ -141,7 +141,7 @@ void CM17Utils::splitFragmentLICH(const unsigned char* data, unsigned int& frag1
void CM17Utils::splitFragmentLICHFEC(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4) void CM17Utils::splitFragmentLICHFEC(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4)
{ {
assert(data != NULL); assert(data != nullptr);
frag1 = frag2 = frag3 = frag4 = 0x00U; frag1 = frag2 = frag3 = frag4 = 0x00U;
@ -177,7 +177,7 @@ void CM17Utils::splitFragmentLICHFEC(const unsigned char* data, unsigned int& fr
void CM17Utils::combineFragmentLICH(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data) void CM17Utils::combineFragmentLICH(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int offset = 0U; unsigned int offset = 0U;
unsigned int MASK = 0x800U; unsigned int MASK = 0x800U;
@ -207,7 +207,7 @@ void CM17Utils::combineFragmentLICH(unsigned int frag1, unsigned int frag2, unsi
void CM17Utils::combineFragmentLICHFEC(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data) void CM17Utils::combineFragmentLICHFEC(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int offset = 0U; unsigned int offset = 0U;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;

File diff suppressed because it is too large Load diff

154
Modem.cpp
View file

@ -165,8 +165,8 @@ m_fmEnabled(false),
m_ax25Enabled(false), m_ax25Enabled(false),
m_rxDCOffset(0), m_rxDCOffset(0),
m_txDCOffset(0), m_txDCOffset(0),
m_port(NULL), m_port(nullptr),
m_buffer(NULL), m_buffer(nullptr),
m_length(0U), m_length(0U),
m_offset(0U), m_offset(0U),
m_state(SERIAL_STATE::START), m_state(SERIAL_STATE::START),
@ -267,7 +267,7 @@ CModem::~CModem()
void CModem::setPort(IModemPort* port) void CModem::setPort(IModemPort* port)
{ {
assert(port != NULL); assert(port != nullptr);
m_port = port; m_port = port;
} }
@ -363,7 +363,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} else { } else {
/* Stopping the inactivity timer here when a firmware version has been /* Stopping the inactivity timer here when a firmware version has been
@ -375,7 +375,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
@ -383,7 +383,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
@ -392,7 +392,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
@ -400,7 +400,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
@ -408,7 +408,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
@ -417,7 +417,7 @@ bool CModem::open()
if (!ret) { if (!ret) {
m_port->close(); m_port->close();
delete m_port; delete m_port;
m_port = NULL; m_port = nullptr;
return false; return false;
} }
} }
@ -433,7 +433,7 @@ bool CModem::open()
void CModem::clock(unsigned int ms) void CModem::clock(unsigned int ms)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
// Poll the modem status every 250ms // Poll the modem status every 250ms
m_statusTimer.clock(ms); m_statusTimer.clock(ms);
@ -1154,7 +1154,7 @@ void CModem::clock(unsigned int ms)
void CModem::close() void CModem::close()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
::LogMessage("Closing the MMDVM"); ::LogMessage("Closing the MMDVM");
@ -1163,7 +1163,7 @@ void CModem::close()
unsigned int CModem::readDStarData(unsigned char* data) unsigned int CModem::readDStarData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxDStarData.isEmpty()) if (m_rxDStarData.isEmpty())
return 0U; return 0U;
@ -1177,7 +1177,7 @@ unsigned int CModem::readDStarData(unsigned char* data)
unsigned int CModem::readDMRData1(unsigned char* data) unsigned int CModem::readDMRData1(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxDMRData1.isEmpty()) if (m_rxDMRData1.isEmpty())
return 0U; return 0U;
@ -1191,7 +1191,7 @@ unsigned int CModem::readDMRData1(unsigned char* data)
unsigned int CModem::readDMRData2(unsigned char* data) unsigned int CModem::readDMRData2(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxDMRData2.isEmpty()) if (m_rxDMRData2.isEmpty())
return 0U; return 0U;
@ -1205,7 +1205,7 @@ unsigned int CModem::readDMRData2(unsigned char* data)
unsigned int CModem::readYSFData(unsigned char* data) unsigned int CModem::readYSFData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxYSFData.isEmpty()) if (m_rxYSFData.isEmpty())
return 0U; return 0U;
@ -1219,7 +1219,7 @@ unsigned int CModem::readYSFData(unsigned char* data)
unsigned int CModem::readP25Data(unsigned char* data) unsigned int CModem::readP25Data(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxP25Data.isEmpty()) if (m_rxP25Data.isEmpty())
return 0U; return 0U;
@ -1233,7 +1233,7 @@ unsigned int CModem::readP25Data(unsigned char* data)
unsigned int CModem::readNXDNData(unsigned char* data) unsigned int CModem::readNXDNData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxNXDNData.isEmpty()) if (m_rxNXDNData.isEmpty())
return 0U; return 0U;
@ -1247,7 +1247,7 @@ unsigned int CModem::readNXDNData(unsigned char* data)
unsigned int CModem::readM17Data(unsigned char* data) unsigned int CModem::readM17Data(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxM17Data.isEmpty()) if (m_rxM17Data.isEmpty())
return 0U; return 0U;
@ -1261,7 +1261,7 @@ unsigned int CModem::readM17Data(unsigned char* data)
unsigned int CModem::readFMData(unsigned char* data) unsigned int CModem::readFMData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxFMData.isEmpty()) if (m_rxFMData.isEmpty())
return 0U; return 0U;
@ -1275,7 +1275,7 @@ unsigned int CModem::readFMData(unsigned char* data)
unsigned int CModem::readAX25Data(unsigned char* data) unsigned int CModem::readAX25Data(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxAX25Data.isEmpty()) if (m_rxAX25Data.isEmpty())
return 0U; return 0U;
@ -1289,7 +1289,7 @@ unsigned int CModem::readAX25Data(unsigned char* data)
unsigned int CModem::readTransparentData(unsigned char* data) unsigned int CModem::readTransparentData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rxTransparentData.isEmpty()) if (m_rxTransparentData.isEmpty())
return 0U; return 0U;
@ -1303,7 +1303,7 @@ unsigned int CModem::readTransparentData(unsigned char* data)
unsigned int CModem::readSerial(unsigned char* data, unsigned int length) unsigned int CModem::readSerial(unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned int n = 0U; unsigned int n = 0U;
@ -1324,7 +1324,7 @@ bool CModem::hasDStarSpace() const
bool CModem::writeDStarData(const unsigned char* data, unsigned int length) bool CModem::writeDStarData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[50U]; unsigned char buffer[50U];
@ -1372,7 +1372,7 @@ bool CModem::hasDMRSpace2() const
bool CModem::writeDMRData1(const unsigned char* data, unsigned int length) bool CModem::writeDMRData1(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (data[0U] != TAG_DATA && data[0U] != TAG_EOT) if (data[0U] != TAG_DATA && data[0U] != TAG_EOT)
@ -1395,7 +1395,7 @@ bool CModem::writeDMRData1(const unsigned char* data, unsigned int length)
bool CModem::writeDMRData2(const unsigned char* data, unsigned int length) bool CModem::writeDMRData2(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (data[0U] != TAG_DATA && data[0U] != TAG_EOT) if (data[0U] != TAG_DATA && data[0U] != TAG_EOT)
@ -1425,7 +1425,7 @@ bool CModem::hasYSFSpace() const
bool CModem::writeYSFData(const unsigned char* data, unsigned int length) bool CModem::writeYSFData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (data[0U] != TAG_DATA && data[0U] != TAG_EOT) if (data[0U] != TAG_DATA && data[0U] != TAG_EOT)
@ -1455,7 +1455,7 @@ bool CModem::hasP25Space() const
bool CModem::writeP25Data(const unsigned char* data, unsigned int length) bool CModem::writeP25Data(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (data[0U] != TAG_HEADER && data[0U] != TAG_DATA && data[0U] != TAG_EOT) if (data[0U] != TAG_HEADER && data[0U] != TAG_DATA && data[0U] != TAG_EOT)
@ -1485,7 +1485,7 @@ bool CModem::hasNXDNSpace() const
bool CModem::writeNXDNData(const unsigned char* data, unsigned int length) bool CModem::writeNXDNData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
if (data[0U] != TAG_DATA && data[0U] != TAG_EOT) if (data[0U] != TAG_DATA && data[0U] != TAG_EOT)
@ -1515,7 +1515,7 @@ bool CModem::hasM17Space() const
bool CModem::writeM17Data(const unsigned char* data, unsigned int length) bool CModem::writeM17Data(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[130U]; unsigned char buffer[130U];
@ -1556,7 +1556,7 @@ bool CModem::hasPOCSAGSpace() const
bool CModem::writePOCSAGData(const unsigned char* data, unsigned int length) bool CModem::writePOCSAGData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[130U]; unsigned char buffer[130U];
@ -1581,7 +1581,7 @@ unsigned int CModem::getFMSpace() const
bool CModem::writeFMData(const unsigned char* data, unsigned int length) bool CModem::writeFMData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[500U]; unsigned char buffer[500U];
@ -1617,7 +1617,7 @@ bool CModem::hasAX25Space() const
bool CModem::writeAX25Data(const unsigned char* data, unsigned int length) bool CModem::writeAX25Data(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[500U]; unsigned char buffer[500U];
@ -1646,7 +1646,7 @@ bool CModem::writeAX25Data(const unsigned char* data, unsigned int length)
bool CModem::writeTransparentData(const unsigned char* data, unsigned int length) bool CModem::writeTransparentData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[250U]; unsigned char buffer[250U];
@ -1680,12 +1680,12 @@ bool CModem::writeTransparentData(const unsigned char* data, unsigned int length
bool CModem::writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) bool CModem::writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(my1 != NULL); assert(my1 != nullptr);
assert(my2 != NULL); assert(my2 != nullptr);
assert(your != NULL); assert(your != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(reflector != NULL); assert(reflector != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
@ -1709,8 +1709,8 @@ bool CModem::writeDStarInfo(const char* my1, const char* my2, const char* your,
bool CModem::writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dest, const char* type) bool CModem::writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dest, const char* type)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(type != NULL); assert(type != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
@ -1735,11 +1735,11 @@ bool CModem::writeDMRInfo(unsigned int slotNo, const std::string& src, bool grou
bool CModem::writeYSFInfo(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) bool CModem::writeYSFInfo(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(origin != NULL); assert(origin != nullptr);
unsigned char buffer[40U]; unsigned char buffer[40U];
@ -1763,9 +1763,9 @@ bool CModem::writeYSFInfo(const char* source, const char* dest, unsigned char dg
bool CModem::writeP25Info(const char* source, bool group, unsigned int dest, const char* type) bool CModem::writeP25Info(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
unsigned char buffer[40U]; unsigned char buffer[40U];
@ -1788,9 +1788,9 @@ bool CModem::writeP25Info(const char* source, bool group, unsigned int dest, con
bool CModem::writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type) bool CModem::writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
unsigned char buffer[40U]; unsigned char buffer[40U];
@ -1813,10 +1813,10 @@ bool CModem::writeNXDNInfo(const char* source, bool group, unsigned int dest, co
bool CModem::writeM17Info(const char* source, const char* dest, const char* type) bool CModem::writeM17Info(const char* source, const char* dest, const char* type)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
unsigned char buffer[40U]; unsigned char buffer[40U];
@ -1837,7 +1837,7 @@ bool CModem::writeM17Info(const char* source, const char* dest, const char* type
bool CModem::writePOCSAGInfo(unsigned int ric, const std::string& message) bool CModem::writePOCSAGInfo(unsigned int ric, const std::string& message)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
size_t length = message.size(); size_t length = message.size();
@ -1860,7 +1860,7 @@ bool CModem::writePOCSAGInfo(unsigned int ric, const std::string& message)
bool CModem::writeIPInfo(const std::string& address) bool CModem::writeIPInfo(const std::string& address)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
size_t length = address.size(); size_t length = address.size();
@ -1881,8 +1881,8 @@ bool CModem::writeIPInfo(const std::string& address)
bool CModem::writeSerial(const unsigned char* data, unsigned int length) bool CModem::writeSerial(const unsigned char* data, unsigned int length)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char buffer[255U]; unsigned char buffer[255U];
@ -1972,7 +1972,7 @@ unsigned int CModem::getVersion() const
bool CModem::readVersion() bool CModem::readVersion()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
CThread::sleep(2000U); // 2s CThread::sleep(2000U); // 2s
@ -2091,7 +2091,7 @@ bool CModem::readVersion()
bool CModem::readStatus() bool CModem::readStatus()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[3U]; unsigned char buffer[3U];
@ -2118,7 +2118,7 @@ bool CModem::writeConfig()
bool CModem::setConfig1() bool CModem::setConfig1()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[30U]; unsigned char buffer[30U];
@ -2233,7 +2233,7 @@ bool CModem::setConfig1()
bool CModem::setConfig2() bool CModem::setConfig2()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
@ -2359,7 +2359,7 @@ bool CModem::setConfig2()
bool CModem::setFrequency() bool CModem::setFrequency()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[20U]; unsigned char buffer[20U];
unsigned char len; unsigned char len;
@ -2432,7 +2432,7 @@ bool CModem::setFrequency()
RESP_TYPE_MMDVM CModem::getResponse() RESP_TYPE_MMDVM CModem::getResponse()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
if (m_state == SERIAL_STATE::START) { if (m_state == SERIAL_STATE::START) {
// Get the start of the frame or nothing at all // Get the start of the frame or nothing at all
@ -2544,7 +2544,7 @@ unsigned char CModem::getMode() const
bool CModem::setMode(unsigned char mode) bool CModem::setMode(unsigned char mode)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[4U]; unsigned char buffer[4U];
@ -2560,7 +2560,7 @@ bool CModem::setMode(unsigned char mode)
bool CModem::sendCWId(const std::string& callsign) bool CModem::sendCWId(const std::string& callsign)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned int length = (unsigned int)callsign.length(); unsigned int length = (unsigned int)callsign.length();
if (length > 200U) if (length > 200U)
@ -2582,7 +2582,7 @@ bool CModem::sendCWId(const std::string& callsign)
bool CModem::writeDMRStart(bool tx) bool CModem::writeDMRStart(bool tx)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
if (tx && m_tx) if (tx && m_tx)
return true; return true;
@ -2603,7 +2603,7 @@ bool CModem::writeDMRStart(bool tx)
bool CModem::writeDMRAbort(unsigned int slotNo) bool CModem::writeDMRAbort(unsigned int slotNo)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
if (slotNo == 1U) if (slotNo == 1U)
m_txDMRData1.clear(); m_txDMRData1.clear();
@ -2624,8 +2624,8 @@ bool CModem::writeDMRAbort(unsigned int slotNo)
bool CModem::writeDMRShortLC(const unsigned char* lc) bool CModem::writeDMRShortLC(const unsigned char* lc)
{ {
assert(m_port != NULL); assert(m_port != nullptr);
assert(lc != NULL); assert(lc != nullptr);
unsigned char buffer[12U]; unsigned char buffer[12U];
@ -2706,7 +2706,7 @@ void CModem::setFMExtParams(const std::string& ack, unsigned int audioBoost)
bool CModem::setFMCallsignParams() bool CModem::setFMCallsignParams()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[80U]; unsigned char buffer[80U];
unsigned char len = 10U + (unsigned char)m_fmCallsign.size(); unsigned char len = 10U + (unsigned char)m_fmCallsign.size();
@ -2767,7 +2767,7 @@ bool CModem::setFMCallsignParams()
bool CModem::setFMAckParams() bool CModem::setFMAckParams()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[80U]; unsigned char buffer[80U];
unsigned char len = 8U + (unsigned char)m_fmRfAck.size(); unsigned char len = 8U + (unsigned char)m_fmRfAck.size();
@ -2819,7 +2819,7 @@ bool CModem::setFMAckParams()
bool CModem::setFMMiscParams() bool CModem::setFMMiscParams()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[20U]; unsigned char buffer[20U];
@ -2888,7 +2888,7 @@ bool CModem::setFMMiscParams()
bool CModem::setFMExtParams() bool CModem::setFMExtParams()
{ {
assert(m_port != NULL); assert(m_port != nullptr);
unsigned char buffer[80U]; unsigned char buffer[80U];
unsigned char len = 7U + (unsigned char)m_fmExtAck.size(); unsigned char len = 7U + (unsigned char)m_fmExtAck.size();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2016,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,7 +24,7 @@
IModemSerialPort::IModemSerialPort(CModem* modem) : IModemSerialPort::IModemSerialPort(CModem* modem) :
m_modem(modem) m_modem(modem)
{ {
assert(modem != NULL); assert(modem != nullptr);
} }
IModemSerialPort::~IModemSerialPort() IModemSerialPort::~IModemSerialPort()
@ -38,7 +38,7 @@ bool IModemSerialPort::open()
int IModemSerialPort::write(const unsigned char* data, unsigned int length) int IModemSerialPort::write(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
bool ret = m_modem->writeSerial(data, length); bool ret = m_modem->writeSerial(data, length);
@ -48,7 +48,7 @@ int IModemSerialPort::write(const unsigned char* data, unsigned int length)
int IModemSerialPort::read(unsigned char* data, unsigned int length) int IModemSerialPort::read(unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
assert(length > 0U); assert(length > 0U);
return m_modem->readSerial(data, length); return m_modem->readSerial(data, length);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
CMutex::CMutex() : CMutex::CMutex() :
m_handle() m_handle()
{ {
m_handle = ::CreateMutex(NULL, FALSE, NULL); m_handle = ::CreateMutex(nullptr, FALSE, nullptr);
} }
CMutex::~CMutex() CMutex::~CMutex()

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -457,8 +457,8 @@ CNXDNAudio::~CNXDNAudio()
void CNXDNAudio::decode(const unsigned char* in, unsigned char* out) const void CNXDNAudio::decode(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
decode(in + 0U, out, 0U); decode(in + 0U, out, 0U);
decode(in + 9U, out, 49U); decode(in + 9U, out, 49U);
@ -466,8 +466,8 @@ void CNXDNAudio::decode(const unsigned char* in, unsigned char* out) const
void CNXDNAudio::encode(const unsigned char* in, unsigned char* out) const void CNXDNAudio::encode(const unsigned char* in, unsigned char* out) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
encode(in, out + 0U, 0U); encode(in, out + 0U, 0U);
encode(in, out + 9U, 49U); encode(in, out + 9U, 49U);
@ -475,8 +475,8 @@ void CNXDNAudio::encode(const unsigned char* in, unsigned char* out) const
void CNXDNAudio::decode(const unsigned char* in, unsigned char* out, unsigned int offset) const void CNXDNAudio::decode(const unsigned char* in, unsigned char* out, unsigned int offset) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
unsigned int a = 0U; unsigned int a = 0U;
unsigned int MASK = 0x800000U; unsigned int MASK = 0x800000U;
@ -525,8 +525,8 @@ void CNXDNAudio::decode(const unsigned char* in, unsigned char* out, unsigned in
void CNXDNAudio::encode(const unsigned char* in, unsigned char* out, unsigned int offset) const void CNXDNAudio::encode(const unsigned char* in, unsigned char* out, unsigned int offset) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
unsigned int aOrig = 0U; unsigned int aOrig = 0U;
unsigned int bOrig = 0U; unsigned int bOrig = 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@ const uint8_t BIT_MASK_TABLE1[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0
bool CNXDNCRC::checkCRC6(const unsigned char* in, unsigned int length) bool CNXDNCRC::checkCRC6(const unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint8_t crc = createCRC6(in, length); uint8_t crc = createCRC6(in, length);
@ -45,7 +45,7 @@ bool CNXDNCRC::checkCRC6(const unsigned char* in, unsigned int length)
void CNXDNCRC::encodeCRC6(unsigned char* in, unsigned int length) void CNXDNCRC::encodeCRC6(unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint8_t crc[1U]; uint8_t crc[1U];
crc[0U] = createCRC6(in, length); crc[0U] = createCRC6(in, length);
@ -59,7 +59,7 @@ void CNXDNCRC::encodeCRC6(unsigned char* in, unsigned int length)
bool CNXDNCRC::checkCRC12(const unsigned char* in, unsigned int length) bool CNXDNCRC::checkCRC12(const unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint16_t crc = createCRC12(in, length); uint16_t crc = createCRC12(in, length);
uint8_t temp1[2U]; uint8_t temp1[2U];
@ -80,7 +80,7 @@ bool CNXDNCRC::checkCRC12(const unsigned char* in, unsigned int length)
void CNXDNCRC::encodeCRC12(unsigned char* in, unsigned int length) void CNXDNCRC::encodeCRC12(unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint16_t crc = createCRC12(in, length); uint16_t crc = createCRC12(in, length);
@ -97,7 +97,7 @@ void CNXDNCRC::encodeCRC12(unsigned char* in, unsigned int length)
bool CNXDNCRC::checkCRC15(const unsigned char* in, unsigned int length) bool CNXDNCRC::checkCRC15(const unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint16_t crc = createCRC15(in, length); uint16_t crc = createCRC15(in, length);
uint8_t temp1[2U]; uint8_t temp1[2U];
@ -118,7 +118,7 @@ bool CNXDNCRC::checkCRC15(const unsigned char* in, unsigned int length)
void CNXDNCRC::encodeCRC15(unsigned char* in, unsigned int length) void CNXDNCRC::encodeCRC15(unsigned char* in, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
uint16_t crc = createCRC15(in, length); uint16_t crc = createCRC15(in, length);

View file

@ -72,11 +72,11 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
assert(lookup != NULL); assert(lookup != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
} }
CNXDNControl::~CNXDNControl() CNXDNControl::~CNXDNControl()
@ -85,7 +85,7 @@ CNXDNControl::~CNXDNControl()
bool CNXDNControl::writeModem(unsigned char *data, unsigned int len) bool CNXDNControl::writeModem(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -684,7 +684,7 @@ bool CNXDNControl::processData(unsigned char option, unsigned char *data)
unsigned int CNXDNControl::readModem(unsigned char* data) unsigned int CNXDNControl::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -709,7 +709,7 @@ void CNXDNControl::writeEndRF()
if (m_netState == RPT_NET_STATE::IDLE) { if (m_netState == RPT_NET_STATE::IDLE) {
m_display->clearNXDN(); m_display->clearNXDN();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -731,7 +731,7 @@ void CNXDNControl::writeEndNet()
m_display->clearNXDN(); m_display->clearNXDN();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -986,7 +986,7 @@ void CNXDNControl::writeNetwork()
void CNXDNControl::clock(unsigned int ms) void CNXDNControl::clock(unsigned int ms)
{ {
if (m_network != NULL) if (m_network != nullptr)
writeNetwork(); writeNetwork();
m_rfTimeoutTimer.clock(ms); m_rfTimeoutTimer.clock(ms);
@ -1004,7 +1004,7 @@ void CNXDNControl::clock(unsigned int ms)
void CNXDNControl::writeQueueRF(const unsigned char *data) void CNXDNControl::writeQueueRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -1027,7 +1027,7 @@ void CNXDNControl::writeQueueRF(const unsigned char *data)
void CNXDNControl::writeQueueNet(const unsigned char *data) void CNXDNControl::writeQueueNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return; return;
@ -1047,9 +1047,9 @@ void CNXDNControl::writeQueueNet(const unsigned char *data)
void CNXDNControl::writeNetwork(const unsigned char *data, NXDN_NETWORK_MESSAGE_TYPE type) void CNXDNControl::writeNetwork(const unsigned char *data, NXDN_NETWORK_MESSAGE_TYPE type)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return; return;
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired()) if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired())
@ -1060,7 +1060,7 @@ void CNXDNControl::writeNetwork(const unsigned char *data, NXDN_NETWORK_MESSAGE_
void CNXDNControl::scrambler(unsigned char* data) const void CNXDNControl::scrambler(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
for (unsigned int i = 0U; i < NXDN_FRAME_LENGTH_BYTES; i++) for (unsigned int i = 0U; i < NXDN_FRAME_LENGTH_BYTES; i++)
data[i] ^= SCRAMBLER[i]; data[i] ^= SCRAMBLER[i];
@ -1068,7 +1068,7 @@ void CNXDNControl::scrambler(unsigned char* data) const
bool CNXDNControl::openFile() bool CNXDNControl::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -1080,7 +1080,7 @@ bool CNXDNControl::openFile()
::sprintf(name, "NXDN_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "NXDN_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("NXDN", 1U, 4U, m_fp); ::fwrite("NXDN", 1U, 4U, m_fp);
@ -1090,7 +1090,7 @@ bool CNXDNControl::openFile()
bool CNXDNControl::writeFile(const unsigned char* data) bool CNXDNControl::writeFile(const unsigned char* data)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, NXDN_FRAME_LENGTH_BYTES, m_fp); ::fwrite(data, 1U, NXDN_FRAME_LENGTH_BYTES, m_fp);
@ -1100,9 +1100,9 @@ bool CNXDNControl::writeFile(const unsigned char* data)
void CNXDNControl::closeFile() void CNXDNControl::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2016,2018,2021 by Jonathan Naylor G4KLX * Copyright (C) 2009-2016,2018,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -37,12 +37,12 @@ const uint32_t M = 4U;
const unsigned int K = 5U; const unsigned int K = 5U;
CNXDNConvolution::CNXDNConvolution() : CNXDNConvolution::CNXDNConvolution() :
m_metrics1(NULL), m_metrics1(nullptr),
m_metrics2(NULL), m_metrics2(nullptr),
m_oldMetrics(NULL), m_oldMetrics(nullptr),
m_newMetrics(NULL), m_newMetrics(nullptr),
m_decisions(NULL), m_decisions(nullptr),
m_dp(NULL) m_dp(nullptr)
{ {
m_metrics1 = new uint16_t[20U]; m_metrics1 = new uint16_t[20U];
m_metrics2 = new uint16_t[20U]; m_metrics2 = new uint16_t[20U];
@ -99,7 +99,7 @@ void CNXDNConvolution::decode(uint8_t s0, uint8_t s1)
unsigned int CNXDNConvolution::chainback(unsigned char* out, unsigned int nBits) unsigned int CNXDNConvolution::chainback(unsigned char* out, unsigned int nBits)
{ {
assert(out != NULL); assert(out != nullptr);
uint32_t state = 0U; uint32_t state = 0U;
@ -125,8 +125,8 @@ unsigned int CNXDNConvolution::chainback(unsigned char* out, unsigned int nBits)
void CNXDNConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const void CNXDNConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
assert(nBits > 0U); assert(nBits > 0U);
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U; uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -49,14 +49,14 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CNXDNFACCH1::CNXDNFACCH1(const CNXDNFACCH1& facch1) : CNXDNFACCH1::CNXDNFACCH1(const CNXDNFACCH1& facch1) :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[10U + 2U]; m_data = new unsigned char[10U + 2U];
::memcpy(m_data, facch1.m_data, 10U + 2U); ::memcpy(m_data, facch1.m_data, 10U + 2U);
} }
CNXDNFACCH1::CNXDNFACCH1() : CNXDNFACCH1::CNXDNFACCH1() :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[10U + 2U]; m_data = new unsigned char[10U + 2U];
} }
@ -68,7 +68,7 @@ CNXDNFACCH1::~CNXDNFACCH1()
bool CNXDNFACCH1::decode(const unsigned char* data, unsigned int offset) bool CNXDNFACCH1::decode(const unsigned char* data, unsigned int offset)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[18U]; unsigned char temp1[18U];
@ -114,7 +114,7 @@ bool CNXDNFACCH1::decode(const unsigned char* data, unsigned int offset)
void CNXDNFACCH1::encode(unsigned char* data, unsigned int offset) const void CNXDNFACCH1::encode(unsigned char* data, unsigned int offset) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[12U]; unsigned char temp1[12U];
::memset(temp1, 0x00U, 12U); ::memset(temp1, 0x00U, 12U);
@ -150,14 +150,14 @@ void CNXDNFACCH1::encode(unsigned char* data, unsigned int offset) const
void CNXDNFACCH1::getData(unsigned char* data) const void CNXDNFACCH1::getData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_data, 10U); ::memcpy(data, m_data, 10U);
} }
void CNXDNFACCH1::getRaw(unsigned char* data) const void CNXDNFACCH1::getRaw(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memset(data, 0x00U, 12U); ::memset(data, 0x00U, 12U);
::memcpy(data, m_data, 10U); ::memcpy(data, m_data, 10U);
@ -167,14 +167,14 @@ void CNXDNFACCH1::getRaw(unsigned char* data) const
void CNXDNFACCH1::setData(const unsigned char* data) void CNXDNFACCH1::setData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_data, data, 10U); ::memcpy(m_data, data, 10U);
} }
void CNXDNFACCH1::setRaw(const unsigned char* data) void CNXDNFACCH1::setRaw(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_data, data, 12U); ::memcpy(m_data, data, 12U);
} }

View file

@ -61,7 +61,7 @@ bool CNXDNIcomNetwork::open()
bool CNXDNIcomNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type) bool CNXDNIcomNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[110U]; unsigned char buffer[110U];
::memset(buffer, 0x00U, 110U); ::memset(buffer, 0x00U, 110U);
@ -139,7 +139,7 @@ void CNXDNIcomNetwork::clock(unsigned int ms)
bool CNXDNIcomNetwork::read(unsigned char* data) bool CNXDNIcomNetwork::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return false; return false;

View file

@ -46,7 +46,7 @@ m_seen1(false),
m_seen2(false), m_seen2(false),
m_seen3(false), m_seen3(false),
m_seen4(false), m_seen4(false),
m_sacch(NULL), m_sacch(nullptr),
m_sessionId(1U), m_sessionId(1U),
m_seqNo(0U), m_seqNo(0U),
m_ssrc(0U), m_ssrc(0U),
@ -107,7 +107,7 @@ bool CNXDNKenwoodNetwork::open()
bool CNXDNKenwoodNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type) bool CNXDNKenwoodNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type)
{ {
assert(data != NULL); assert(data != nullptr);
switch (type) { switch (type) {
case NXDN_NETWORK_MESSAGE_TYPE::VOICE_HEADER: // Voice header or trailer case NXDN_NETWORK_MESSAGE_TYPE::VOICE_HEADER: // Voice header or trailer
@ -127,7 +127,7 @@ bool CNXDNKenwoodNetwork::write(const unsigned char* data, NXDN_NETWORK_MESSAGE_
bool CNXDNKenwoodNetwork::processIcomVoiceHeader(const unsigned char* inData) bool CNXDNKenwoodNetwork::processIcomVoiceHeader(const unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[30U]; unsigned char outData[30U];
::memset(outData, 0x00U, 30U); ::memset(outData, 0x00U, 30U);
@ -171,7 +171,7 @@ bool CNXDNKenwoodNetwork::processIcomVoiceHeader(const unsigned char* inData)
bool CNXDNKenwoodNetwork::processIcomVoiceData(const unsigned char* inData) bool CNXDNKenwoodNetwork::processIcomVoiceData(const unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[40U], temp[10U]; unsigned char outData[40U], temp[10U];
::memset(outData, 0x00U, 40U); ::memset(outData, 0x00U, 40U);
@ -251,7 +251,7 @@ bool CNXDNKenwoodNetwork::processIcomVoiceData(const unsigned char* inData)
bool CNXDNKenwoodNetwork::processIcomDataHeader(const unsigned char* inData) bool CNXDNKenwoodNetwork::processIcomDataHeader(const unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[30U]; unsigned char outData[30U];
::memset(outData, 0x00U, 30U); ::memset(outData, 0x00U, 30U);
@ -295,7 +295,7 @@ bool CNXDNKenwoodNetwork::processIcomDataHeader(const unsigned char* inData)
bool CNXDNKenwoodNetwork::processIcomDataData(const unsigned char* inData) bool CNXDNKenwoodNetwork::processIcomDataData(const unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[40U]; unsigned char outData[40U];
::memset(outData, 0x00U, 40U); ::memset(outData, 0x00U, 40U);
@ -328,7 +328,7 @@ bool CNXDNKenwoodNetwork::processIcomDataData(const unsigned char* inData)
bool CNXDNKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
::memset(buffer, 0x00U, 50U); ::memset(buffer, 0x00U, 50U);
@ -375,7 +375,7 @@ bool CNXDNKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data)
bool CNXDNKenwoodNetwork::writeRTPVoiceTrailer(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPVoiceTrailer(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
::memset(buffer, 0x00U, 50U); ::memset(buffer, 0x00U, 50U);
@ -421,7 +421,7 @@ bool CNXDNKenwoodNetwork::writeRTPVoiceTrailer(const unsigned char* data)
bool CNXDNKenwoodNetwork::writeRTPVoiceData(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPVoiceData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[60U]; unsigned char buffer[60U];
::memset(buffer, 0x00U, 60U); ::memset(buffer, 0x00U, 60U);
@ -467,7 +467,7 @@ bool CNXDNKenwoodNetwork::writeRTPVoiceData(const unsigned char* data)
bool CNXDNKenwoodNetwork::writeRTPDataHeader(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPDataHeader(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
::memset(buffer, 0x00U, 50U); ::memset(buffer, 0x00U, 50U);
@ -509,7 +509,7 @@ bool CNXDNKenwoodNetwork::writeRTPDataHeader(const unsigned char* data)
bool CNXDNKenwoodNetwork::writeRTPDataTrailer(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPDataTrailer(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
::memset(buffer, 0x00U, 50U); ::memset(buffer, 0x00U, 50U);
@ -551,7 +551,7 @@ bool CNXDNKenwoodNetwork::writeRTPDataTrailer(const unsigned char* data)
bool CNXDNKenwoodNetwork::writeRTPDataData(const unsigned char* data) bool CNXDNKenwoodNetwork::writeRTPDataData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[50U]; unsigned char buffer[50U];
::memset(buffer, 0x00U, 50U); ::memset(buffer, 0x00U, 50U);
@ -605,7 +605,7 @@ bool CNXDNKenwoodNetwork::writeRTCPStart()
m_startUSecs = st.wMilliseconds * 1000U; m_startUSecs = st.wMilliseconds * 1000U;
#else #else
struct timeval tod; struct timeval tod;
::gettimeofday(&tod, NULL); ::gettimeofday(&tod, nullptr);
m_startSecs = tod.tv_sec; m_startSecs = tod.tv_sec;
m_startUSecs = tod.tv_usec; m_startUSecs = tod.tv_usec;
@ -738,7 +738,7 @@ bool CNXDNKenwoodNetwork::writeRTCPHang()
bool CNXDNKenwoodNetwork::read(unsigned char* data) bool CNXDNKenwoodNetwork::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char dummy[BUFFER_LENGTH]; unsigned char dummy[BUFFER_LENGTH];
readRTCP(dummy); readRTCP(dummy);
@ -764,7 +764,7 @@ bool CNXDNKenwoodNetwork::read(unsigned char* data)
unsigned int CNXDNKenwoodNetwork::readRTP(unsigned char* data) unsigned int CNXDNKenwoodNetwork::readRTP(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[BUFFER_LENGTH]; unsigned char buffer[BUFFER_LENGTH];
@ -792,7 +792,7 @@ unsigned int CNXDNKenwoodNetwork::readRTP(unsigned char* data)
unsigned int CNXDNKenwoodNetwork::readRTCP(unsigned char* data) unsigned int CNXDNKenwoodNetwork::readRTCP(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[BUFFER_LENGTH]; unsigned char buffer[BUFFER_LENGTH];
@ -868,7 +868,7 @@ void CNXDNKenwoodNetwork::clock(unsigned int ms)
bool CNXDNKenwoodNetwork::processKenwoodVoiceHeader(unsigned char* inData) bool CNXDNKenwoodNetwork::processKenwoodVoiceHeader(unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[50U], temp[20U]; unsigned char outData[50U], temp[20U];
::memset(outData, 0x00U, 50U); ::memset(outData, 0x00U, 50U);
@ -925,7 +925,7 @@ bool CNXDNKenwoodNetwork::processKenwoodVoiceHeader(unsigned char* inData)
bool CNXDNKenwoodNetwork::processKenwoodVoiceData(unsigned char* inData) bool CNXDNKenwoodNetwork::processKenwoodVoiceData(unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char outData[50U], temp[20U]; unsigned char outData[50U], temp[20U];
::memset(outData, 0x00U, 50U); ::memset(outData, 0x00U, 50U);
@ -1088,7 +1088,7 @@ unsigned long CNXDNKenwoodNetwork::getTimeStamp() const
timeStamp += ms * 80U; timeStamp += ms * 80U;
#else #else
struct timeval tod; struct timeval tod;
::gettimeofday(&tod, NULL); ::gettimeofday(&tod, nullptr);
unsigned int ss = tod.tv_sec; unsigned int ss = tod.tv_sec;
unsigned int ms = tod.tv_usec / 1000U; unsigned int ms = tod.tv_usec / 1000U;
@ -1102,7 +1102,7 @@ unsigned long CNXDNKenwoodNetwork::getTimeStamp() const
bool CNXDNKenwoodNetwork::processKenwoodVoiceLateEntry(unsigned char* inData) bool CNXDNKenwoodNetwork::processKenwoodVoiceLateEntry(unsigned char* inData)
{ {
assert(inData != NULL); assert(inData != nullptr);
unsigned char sacch[4U]; unsigned char sacch[4U];
sacch[0U] = inData[12U]; sacch[0U] = inData[12U];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,14 +29,14 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CNXDNLICH::CNXDNLICH(const CNXDNLICH& lich) : CNXDNLICH::CNXDNLICH(const CNXDNLICH& lich) :
m_lich(NULL) m_lich(nullptr)
{ {
m_lich = new unsigned char[1U]; m_lich = new unsigned char[1U];
m_lich[0U] = lich.m_lich[0U]; m_lich[0U] = lich.m_lich[0U];
} }
CNXDNLICH::CNXDNLICH() : CNXDNLICH::CNXDNLICH() :
m_lich(NULL) m_lich(nullptr)
{ {
m_lich = new unsigned char[1U]; m_lich = new unsigned char[1U];
} }
@ -48,7 +48,7 @@ CNXDNLICH::~CNXDNLICH()
bool CNXDNLICH::decode(const unsigned char* bytes) bool CNXDNLICH::decode(const unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
unsigned int offset = NXDN_FSW_LENGTH_BITS; unsigned int offset = NXDN_FSW_LENGTH_BITS;
for (unsigned int i = 0U; i < (NXDN_LICH_LENGTH_BITS / 2U); i++, offset += 2U) { for (unsigned int i = 0U; i < (NXDN_LICH_LENGTH_BITS / 2U); i++, offset += 2U) {
@ -64,7 +64,7 @@ bool CNXDNLICH::decode(const unsigned char* bytes)
void CNXDNLICH::encode(unsigned char* bytes) void CNXDNLICH::encode(unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
bool parity = getParity(); bool parity = getParity();
if (parity) if (parity)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,14 +29,14 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CNXDNLayer3::CNXDNLayer3(const CNXDNLayer3& layer3) : CNXDNLayer3::CNXDNLayer3(const CNXDNLayer3& layer3) :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[22U]; m_data = new unsigned char[22U];
::memcpy(m_data, layer3.m_data, 22U); ::memcpy(m_data, layer3.m_data, 22U);
} }
CNXDNLayer3::CNXDNLayer3() : CNXDNLayer3::CNXDNLayer3() :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[22U]; m_data = new unsigned char[22U];
::memset(m_data, 0x00U, 22U); ::memset(m_data, 0x00U, 22U);
@ -49,7 +49,7 @@ CNXDNLayer3::~CNXDNLayer3()
void CNXDNLayer3::decode(const unsigned char* bytes, unsigned int length, unsigned int offset) void CNXDNLayer3::decode(const unsigned char* bytes, unsigned int length, unsigned int offset)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
for (unsigned int i = 0U; i < length; i++, offset++) { for (unsigned int i = 0U; i < length; i++, offset++) {
bool b = READ_BIT1(bytes, i); bool b = READ_BIT1(bytes, i);
@ -59,7 +59,7 @@ void CNXDNLayer3::decode(const unsigned char* bytes, unsigned int length, unsign
void CNXDNLayer3::encode(unsigned char* bytes, unsigned int length, unsigned int offset) void CNXDNLayer3::encode(unsigned char* bytes, unsigned int length, unsigned int offset)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
for (unsigned int i = 0U; i < length; i++, offset++) { for (unsigned int i = 0U; i < length; i++, offset++) {
bool b = READ_BIT1(m_data, offset); bool b = READ_BIT1(m_data, offset);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2018,2021 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -132,5 +132,5 @@ std::string CNXDNLookup::find(unsigned int id)
bool CNXDNLookup::exists(unsigned int id) bool CNXDNLookup::exists(unsigned int id)
{ {
return m_table.lookup(id, NULL); return m_table.lookup(id, nullptr);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -42,14 +42,14 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CNXDNSACCH::CNXDNSACCH(const CNXDNSACCH& sacch) : CNXDNSACCH::CNXDNSACCH(const CNXDNSACCH& sacch) :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[5U]; m_data = new unsigned char[5U];
::memcpy(m_data, sacch.m_data, 5U); ::memcpy(m_data, sacch.m_data, 5U);
} }
CNXDNSACCH::CNXDNSACCH() : CNXDNSACCH::CNXDNSACCH() :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[5U]; m_data = new unsigned char[5U];
} }
@ -61,7 +61,7 @@ CNXDNSACCH::~CNXDNSACCH()
bool CNXDNSACCH::decode(const unsigned char* data) bool CNXDNSACCH::decode(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[8U]; unsigned char temp1[8U];
@ -107,7 +107,7 @@ bool CNXDNSACCH::decode(const unsigned char* data)
void CNXDNSACCH::encode(unsigned char* data) const void CNXDNSACCH::encode(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[5U]; unsigned char temp1[5U];
::memset(temp1, 0x00U, 5U); ::memset(temp1, 0x00U, 5U);
@ -157,7 +157,7 @@ unsigned char CNXDNSACCH::getStructure() const
void CNXDNSACCH::getData(unsigned char* data) const void CNXDNSACCH::getData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int offset = 8U; unsigned int offset = 8U;
for (unsigned int i = 0U; i < 18U; i++, offset++) { for (unsigned int i = 0U; i < 18U; i++, offset++) {
@ -168,7 +168,7 @@ void CNXDNSACCH::getData(unsigned char* data) const
void CNXDNSACCH::getRaw(unsigned char* data) const void CNXDNSACCH::getRaw(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_data, 4U); ::memcpy(data, m_data, 4U);
@ -189,7 +189,7 @@ void CNXDNSACCH::setStructure(unsigned char structure)
void CNXDNSACCH::setData(const unsigned char* data) void CNXDNSACCH::setData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int offset = 8U; unsigned int offset = 8U;
for (unsigned int i = 0U; i < 18U; i++, offset++) { for (unsigned int i = 0U; i < 18U; i++, offset++) {
@ -200,7 +200,7 @@ void CNXDNSACCH::setData(const unsigned char* data)
void CNXDNSACCH::setRaw(const unsigned char* data) void CNXDNSACCH::setRaw(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_data, data, 4U); ::memcpy(m_data, data, 4U);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018 by Jonathan Naylor G4KLX * Copyright (C) 2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -70,14 +70,14 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CNXDNUDCH::CNXDNUDCH(const CNXDNUDCH& udch) : CNXDNUDCH::CNXDNUDCH(const CNXDNUDCH& udch) :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[23U + 3U]; m_data = new unsigned char[23U + 3U];
::memcpy(m_data, udch.m_data, 23U + 3U); ::memcpy(m_data, udch.m_data, 23U + 3U);
} }
CNXDNUDCH::CNXDNUDCH() : CNXDNUDCH::CNXDNUDCH() :
m_data(NULL) m_data(nullptr)
{ {
m_data = new unsigned char[23U + 3U]; m_data = new unsigned char[23U + 3U];
} }
@ -89,7 +89,7 @@ CNXDNUDCH::~CNXDNUDCH()
bool CNXDNUDCH::decode(const unsigned char* data) bool CNXDNUDCH::decode(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[44U]; unsigned char temp1[44U];
@ -135,7 +135,7 @@ bool CNXDNUDCH::decode(const unsigned char* data)
void CNXDNUDCH::encode(unsigned char* data) const void CNXDNUDCH::encode(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char temp1[25U]; unsigned char temp1[25U];
::memset(temp1, 0x00U, 25U); ::memset(temp1, 0x00U, 25U);
@ -176,14 +176,14 @@ unsigned char CNXDNUDCH::getRAN() const
void CNXDNUDCH::getData(unsigned char* data) const void CNXDNUDCH::getData(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, m_data + 1U, 22U); ::memcpy(data, m_data + 1U, 22U);
} }
void CNXDNUDCH::getRaw(unsigned char* data) const void CNXDNUDCH::getRaw(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
::memset(data, 0x00U, 25U); ::memset(data, 0x00U, 25U);
::memcpy(data, m_data, 23U); ::memcpy(data, m_data, 23U);
@ -196,14 +196,14 @@ void CNXDNUDCH::setRAN(unsigned char ran)
void CNXDNUDCH::setData(const unsigned char* data) void CNXDNUDCH::setData(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_data + 1U, data, 22U); ::memcpy(m_data + 1U, data, 22U);
} }
void CNXDNUDCH::setRaw(const unsigned char* data) void CNXDNUDCH::setRaw(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(m_data, data, 25U); ::memcpy(m_data, data, 25U);
} }

View file

@ -69,11 +69,11 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
::strcpy((char*)info, "(address unknown)"); ::strcpy((char*)info, "(address unknown)");
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__) #if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
char* dflt = NULL; char* dflt = nullptr;
#if defined(__linux__) #if defined(__linux__)
FILE* fp = ::fopen("/proc/net/route" , "r"); // IPv4 routing FILE* fp = ::fopen("/proc/net/route" , "r"); // IPv4 routing
if (fp == NULL) { if (fp == nullptr) {
LogError("Unabled to open /proc/route"); LogError("Unabled to open /proc/route");
return; return;
} }
@ -81,9 +81,9 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
char line[100U]; char line[100U];
while (::fgets(line, 100U, fp)) { while (::fgets(line, 100U, fp)) {
char* p1 = strtok(line , " \t"); char* p1 = strtok(line , " \t");
char* p2 = strtok(NULL , " \t"); char* p2 = strtok(nullptr , " \t");
if (p1 != NULL && p2 != NULL) { if (p1 != nullptr && p2 != nullptr) {
if (::strcmp(p2, "00000000") == 0) { if (::strcmp(p2, "00000000") == 0) {
dflt = p1; dflt = p1;
break; break;
@ -109,13 +109,13 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
size_t size; size_t size;
char ifname[IF_NAMESIZE] = {}; char ifname[IF_NAMESIZE] = {};
if (::sysctl(mib, cnt, NULL, &size, NULL, 0) == -1 || size <= 0) { if (::sysctl(mib, cnt, nullptr, &size, nullptr, 0) == -1 || size <= 0) {
LogError("Unable to estimate routing table size"); LogError("Unable to estimate routing table size");
return; return;
} }
char *buf = new char[size]; char *buf = new char[size];
if (::sysctl(mib, cnt, buf, &size, NULL, 0) == -1) { if (::sysctl(mib, cnt, buf, &size, nullptr, 0) == -1) {
LogError("Unable to get routing table"); LogError("Unable to get routing table");
delete[] buf; delete[] buf;
return; return;
@ -141,7 +141,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
if (::strlen(ifname)) if (::strlen(ifname))
dflt = ifname; dflt = ifname;
#endif #endif
if (dflt == NULL) { if (dflt == nullptr) {
LogError("Unable to find the default route"); LogError("Unable to find the default route");
return; return;
} }
@ -158,14 +158,14 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
} }
unsigned int ifnr = 0U; unsigned int ifnr = 0U;
for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { for (struct ifaddrs* ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL) if (ifa->ifa_addr == nullptr)
continue; continue;
int family = ifa->ifa_addr->sa_family; int family = ifa->ifa_addr->sa_family;
if (family == AF_INET || family == AF_INET6) { if (family == AF_INET || family == AF_INET6) {
char host[NI_MAXHOST]; char host[NI_MAXHOST];
int s = ::getnameinfo(ifa->ifa_addr, family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); int s = ::getnameinfo(ifa->ifa_addr, family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6), host, NI_MAXHOST, nullptr, 0, NI_NUMERICHOST);
if (s != 0) { if (s != 0) {
LogError("getnameinfo() failed: %s\n", gai_strerror(s)); LogError("getnameinfo() failed: %s\n", gai_strerror(s));
continue; continue;
@ -190,7 +190,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
for (unsigned int n = 0U; n < ifnr; n++) { for (unsigned int n = 0U; n < ifnr; n++) {
char* p = ::strchr(interfacelist[n], '%'); char* p = ::strchr(interfacelist[n], '%');
if (p != NULL) if (p != nullptr)
*p = 0; *p = 0;
if (::strstr(interfacelist[n], dflt) != 0) { if (::strstr(interfacelist[n], dflt) != 0) {
@ -202,7 +202,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
LogInfo(" IP to show: %s", info); LogInfo(" IP to show: %s", info);
#elif defined(_WIN32) || defined(_WIN64) #elif defined(_WIN32) || defined(_WIN64)
PMIB_IPFORWARDTABLE pIpForwardTable = (MIB_IPFORWARDTABLE *)::malloc(sizeof(MIB_IPFORWARDTABLE)); PMIB_IPFORWARDTABLE pIpForwardTable = (MIB_IPFORWARDTABLE *)::malloc(sizeof(MIB_IPFORWARDTABLE));
if (pIpForwardTable == NULL) { if (pIpForwardTable == nullptr) {
LogError("Error allocating memory"); LogError("Error allocating memory");
return; return;
} }
@ -211,7 +211,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
if (::GetIpForwardTable(pIpForwardTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { if (::GetIpForwardTable(pIpForwardTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
::free(pIpForwardTable); ::free(pIpForwardTable);
pIpForwardTable = (MIB_IPFORWARDTABLE *)::malloc(dwSize); pIpForwardTable = (MIB_IPFORWARDTABLE *)::malloc(dwSize);
if (pIpForwardTable == NULL) { if (pIpForwardTable == nullptr) {
LogError("Error allocating memory"); LogError("Error allocating memory");
return; return;
} }
@ -242,7 +242,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
::free(pIpForwardTable); ::free(pIpForwardTable);
PIP_ADAPTER_INFO pAdapterInfo = (IP_ADAPTER_INFO *)::malloc(sizeof(IP_ADAPTER_INFO)); PIP_ADAPTER_INFO pAdapterInfo = (IP_ADAPTER_INFO *)::malloc(sizeof(IP_ADAPTER_INFO));
if (pAdapterInfo == NULL) { if (pAdapterInfo == nullptr) {
LogError("Error allocating memory"); LogError("Error allocating memory");
return; return;
} }
@ -251,7 +251,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
if (::GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) { if (::GetAdaptersInfo(pAdapterInfo, &buflen) == ERROR_BUFFER_OVERFLOW) {
::free(pAdapterInfo); ::free(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *)::malloc(buflen); pAdapterInfo = (IP_ADAPTER_INFO *)::malloc(buflen);
if (pAdapterInfo == NULL) { if (pAdapterInfo == nullptr) {
LogError("Error allocating memory"); LogError("Error allocating memory");
return; return;
} }
@ -264,7 +264,7 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
} }
PIP_ADAPTER_INFO pAdapter = pAdapterInfo; PIP_ADAPTER_INFO pAdapter = pAdapterInfo;
while (pAdapter != NULL) { while (pAdapter != nullptr) {
LogInfo(" IP : %s", pAdapter->IpAddressList.IpAddress.String); LogInfo(" IP : %s", pAdapter->IpAddressList.IpAddress.String);
if (pAdapter->Index == ifnr) if (pAdapter->Index == ifnr)
::strcpy((char*)info, pAdapter->IpAddressList.IpAddress.String); ::strcpy((char*)info, pAdapter->IpAddressList.IpAddress.String);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2018,2020,2023,2024 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2018,2020,2023,2024,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -79,9 +79,9 @@ m_socket(socket),
m_addr(addr), m_addr(addr),
m_addrLength(addrLength) m_addrLength(addrLength)
{ {
assert(serial != NULL); assert(serial != nullptr);
assert(brightness >= 0U && brightness <= 100U); assert(brightness >= 0U && brightness <= 100U);
assert(socket != NULL); assert(socket != nullptr);
assert(addrLength > 0U); assert(addrLength > 0U);
static const unsigned int feature_set[] = { static const unsigned int feature_set[] = {
@ -128,11 +128,11 @@ m_rxFrequency(rxFrequency),
m_fl_txFrequency(0.0F), m_fl_txFrequency(0.0F),
m_fl_rxFrequency(0.0F), m_fl_rxFrequency(0.0F),
m_displayTempInF(displayTempInF), m_displayTempInF(displayTempInF),
m_socket(NULL), m_socket(nullptr),
m_addr(), m_addr(),
m_addrLength(0U) m_addrLength(0U)
{ {
assert(serial != NULL); assert(serial != nullptr);
assert(brightness >= 0U && brightness <= 100U); assert(brightness >= 0U && brightness <= 100U);
static const unsigned int feature_set[] = { static const unsigned int feature_set[] = {
@ -218,7 +218,7 @@ void CNextion::setIdleInt()
// CPU temperature // CPU temperature
FILE* fp = ::fopen("/sys/class/thermal/thermal_zone0/temp", "rt"); FILE* fp = ::fopen("/sys/class/thermal/thermal_zone0/temp", "rt");
if (fp != NULL) { if (fp != nullptr) {
double val = 0.0; double val = 0.0;
int n = ::fscanf(fp, "%lf", &val); int n = ::fscanf(fp, "%lf", &val);
::fclose(fp); ::fclose(fp);
@ -253,7 +253,7 @@ void CNextion::setIdleInt()
void CNextion::setErrorInt(const char* text) void CNextion::setErrorInt(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
sendCommand("page MMDVM"); sendCommand("page MMDVM");
sendCommandAction(1U); sendCommandAction(1U);
@ -339,11 +339,11 @@ void CNextion::setFMInt()
void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
assert(my1 != NULL); assert(my1 != nullptr);
assert(my2 != NULL); assert(my2 != nullptr);
assert(your != NULL); assert(your != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(reflector != NULL); assert(reflector != nullptr);
if (m_mode != MODE_DSTAR) { if (m_mode != MODE_DSTAR) {
sendCommand("page DStar"); sendCommand("page DStar");
@ -421,7 +421,7 @@ void CNextion::clearDStarInt()
void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_DMR) { if (m_mode != MODE_DMR) {
sendCommand("page DMR"); sendCommand("page DMR");
@ -658,10 +658,10 @@ void CNextion::clearDMRInt(unsigned int slotNo)
void CNextion::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) void CNextion::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(origin != NULL); assert(origin != nullptr);
if (m_mode != MODE_YSF) { if (m_mode != MODE_YSF) {
sendCommand("page YSF"); sendCommand("page YSF");
@ -740,8 +740,8 @@ void CNextion::clearFusionInt()
void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, const char* type) void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_P25) { if (m_mode != MODE_P25) {
sendCommand("page P25"); sendCommand("page P25");
@ -812,8 +812,8 @@ void CNextion::clearP25Int()
void CNextion::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type) void CNextion::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_NXDN) { if (m_mode != MODE_NXDN) {
sendCommand("page NXDN"); sendCommand("page NXDN");
@ -884,9 +884,9 @@ void CNextion::clearNXDNInt()
void CNextion::writeM17Int(const char* source, const char* dest, const char* type) void CNextion::writeM17Int(const char* source, const char* dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_M17) { if (m_mode != MODE_M17) {
sendCommand("page M17"); sendCommand("page M17");
@ -1025,7 +1025,7 @@ void CNextion::clockInt(unsigned int ms)
m_clockDisplayTimer.start(); // restart the clock display timer m_clockDisplayTimer.start(); // restart the clock display timer
} }
if (m_socket != NULL) { if (m_socket != nullptr) {
unsigned char buffer[200U]; unsigned char buffer[200U];
int len = m_serial->read(buffer, 200U); int len = m_serial->read(buffer, 200U);
@ -1039,7 +1039,7 @@ void CNextion::close()
m_serial->close(); m_serial->close();
delete m_serial; delete m_serial;
if (m_socket != NULL) { if (m_socket != nullptr) {
m_socket->close(); m_socket->close();
delete m_socket; delete m_socket;
} }
@ -1059,7 +1059,7 @@ void CNextion::sendCommandAction(unsigned int status)
void CNextion::sendCommand(const char* command) void CNextion::sendCommand(const char* command)
{ {
assert(command != NULL); assert(command != nullptr);
m_serial->write((unsigned char*)command, (unsigned int)::strlen(command)); m_serial->write((unsigned char*)command, (unsigned int)::strlen(command));
m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U); m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * Copyright (C) 2016,2018,2020,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#if !defined(NULLDISPLAY_H) #if !defined(nullptrDISPLAY_H)
#define NULLDISPLAY_H #define nullptrDISPLAY_H
#include "Display.h" #include "Display.h"

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ CP25Audio::~CP25Audio()
unsigned int CP25Audio::process(unsigned char* data) unsigned int CP25Audio::process(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int errs = 0U; unsigned int errs = 0U;
@ -95,8 +95,8 @@ unsigned int CP25Audio::process(unsigned char* data)
void CP25Audio::decode(const unsigned char* data, unsigned char* imbe, unsigned int n) void CP25Audio::decode(const unsigned char* data, unsigned char* imbe, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
assert(imbe != NULL); assert(imbe != nullptr);
unsigned char temp[18U]; unsigned char temp[18U];
@ -204,8 +204,8 @@ void CP25Audio::decode(const unsigned char* data, unsigned char* imbe, unsigned
void CP25Audio::encode(unsigned char* data, const unsigned char* imbe, unsigned int n) void CP25Audio::encode(unsigned char* data, const unsigned char* imbe, unsigned int n)
{ {
assert(data != NULL); assert(data != nullptr);
assert(imbe != NULL); assert(imbe != nullptr);
bool bTemp[144U]; bool bTemp[144U];
bool* bit = bTemp; bool* bit = bTemp;

View file

@ -70,11 +70,11 @@ m_rfData(),
m_netData(), m_netData(),
m_rfLSD(), m_rfLSD(),
m_netLSD(), m_netLSD(),
m_netLDU1(NULL), m_netLDU1(nullptr),
m_netLDU2(NULL), m_netLDU2(nullptr),
m_lastIMBE(NULL), m_lastIMBE(nullptr),
m_rfLDU(NULL), m_rfLDU(nullptr),
m_rfPDU(NULL), m_rfPDU(nullptr),
m_rfPDUCount(0U), m_rfPDUCount(0U),
m_rfPDUBits(0U), m_rfPDUBits(0U),
m_rssiMapper(rssiMapper), m_rssiMapper(rssiMapper),
@ -84,11 +84,11 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
assert(lookup != NULL); assert(lookup != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
m_netLDU1 = new unsigned char[9U * 25U]; m_netLDU1 = new unsigned char[9U * 25U];
m_netLDU2 = new unsigned char[9U * 25U]; m_netLDU2 = new unsigned char[9U * 25U];
@ -97,7 +97,7 @@ m_fp(NULL)
::memset(m_netLDU2, 0x00U, 9U * 25U); ::memset(m_netLDU2, 0x00U, 9U * 25U);
m_lastIMBE = new unsigned char[11U]; m_lastIMBE = new unsigned char[11U];
::memcpy(m_lastIMBE, P25_NULL_IMBE, 11U); ::memcpy(m_lastIMBE, P25_nullptr_IMBE, 11U);
m_rfLDU = new unsigned char[P25_LDU_FRAME_LENGTH_BYTES]; m_rfLDU = new unsigned char[P25_LDU_FRAME_LENGTH_BYTES];
::memset(m_rfLDU, 0x00U, P25_LDU_FRAME_LENGTH_BYTES); ::memset(m_rfLDU, 0x00U, P25_LDU_FRAME_LENGTH_BYTES);
@ -117,7 +117,7 @@ CP25Control::~CP25Control()
bool CP25Control::writeModem(unsigned char* data, unsigned int len) bool CP25Control::writeModem(unsigned char* data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -633,7 +633,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
unsigned int CP25Control::readModem(unsigned char* data) unsigned int CP25Control::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -650,7 +650,7 @@ void CP25Control::writeNetwork()
{ {
unsigned char data[100U]; unsigned char data[100U];
if (m_network == NULL) if (m_network == nullptr)
return; return;
unsigned int length = m_network->read(data, 100U); unsigned int length = m_network->read(data, 100U);
@ -756,7 +756,7 @@ void CP25Control::writeNetwork()
void CP25Control::clock(unsigned int ms) void CP25Control::clock(unsigned int ms)
{ {
if (m_network != NULL) if (m_network != nullptr)
writeNetwork(); writeNetwork();
m_rfTimeout.clock(ms); m_rfTimeout.clock(ms);
@ -778,7 +778,7 @@ void CP25Control::clock(unsigned int ms)
void CP25Control::writeQueueRF(const unsigned char* data, unsigned int length) void CP25Control::writeQueueRF(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_rfTimeout.isRunning() && m_rfTimeout.hasExpired()) if (m_rfTimeout.isRunning() && m_rfTimeout.hasExpired())
return; return;
@ -797,7 +797,7 @@ void CP25Control::writeQueueRF(const unsigned char* data, unsigned int length)
void CP25Control::writeQueueNet(const unsigned char* data, unsigned int length) void CP25Control::writeQueueNet(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeout.isRunning() && m_netTimeout.hasExpired()) if (m_netTimeout.isRunning() && m_netTimeout.hasExpired())
return; return;
@ -816,9 +816,9 @@ void CP25Control::writeQueueNet(const unsigned char* data, unsigned int length)
void CP25Control::writeNetwork(const unsigned char *data, unsigned char type, bool end) void CP25Control::writeNetwork(const unsigned char *data, unsigned char type, bool end)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return; return;
if (m_rfTimeout.isRunning() && m_rfTimeout.hasExpired()) if (m_rfTimeout.isRunning() && m_rfTimeout.hasExpired())
@ -839,7 +839,7 @@ void CP25Control::writeNetwork(const unsigned char *data, unsigned char type, bo
void CP25Control::setBusyBits(unsigned char* data, unsigned int ssOffset, bool b1, bool b2) void CP25Control::setBusyBits(unsigned char* data, unsigned int ssOffset, bool b1, bool b2)
{ {
assert(data != NULL); assert(data != nullptr);
WRITE_BIT(data, ssOffset, b1); WRITE_BIT(data, ssOffset, b1);
WRITE_BIT(data, ssOffset + 1U, b2); WRITE_BIT(data, ssOffset + 1U, b2);
@ -847,7 +847,7 @@ void CP25Control::setBusyBits(unsigned char* data, unsigned int ssOffset, bool b
void CP25Control::addBusyBits(unsigned char* data, unsigned int length, bool b1, bool b2) void CP25Control::addBusyBits(unsigned char* data, unsigned int length, bool b1, bool b2)
{ {
assert(data != NULL); assert(data != nullptr);
for (unsigned int ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += P25_INCREMENT) { for (unsigned int ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += P25_INCREMENT) {
unsigned int ss1Pos = ss0Pos + 1U; unsigned int ss1Pos = ss0Pos + 1U;
@ -1198,7 +1198,7 @@ void CP25Control::createNetTerminator()
bool CP25Control::openFile() bool CP25Control::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -1210,7 +1210,7 @@ bool CP25Control::openFile()
::sprintf(name, "P25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "P25_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("P25", 1U, 3U, m_fp); ::fwrite("P25", 1U, 3U, m_fp);
@ -1220,7 +1220,7 @@ bool CP25Control::openFile()
bool CP25Control::writeFile(const unsigned char* data, unsigned char length) bool CP25Control::writeFile(const unsigned char* data, unsigned char length)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(&length, 1U, 1U, m_fp); ::fwrite(&length, 1U, 1U, m_fp);
@ -1232,9 +1232,9 @@ bool CP25Control::writeFile(const unsigned char* data, unsigned char length)
void CP25Control::closeFile() void CP25Control::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2023,2024 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2023,2024,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com> N2PLL * Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com> N2PLL
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -36,7 +36,7 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
#define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CP25Data::CP25Data() : CP25Data::CP25Data() :
m_mi(NULL), m_mi(nullptr),
m_mfId(0U), m_mfId(0U),
m_algId(P25_ALGO_UNENCRYPT), m_algId(P25_ALGO_UNENCRYPT),
m_kId(0U), m_kId(0U),
@ -77,7 +77,7 @@ CP25Data& CP25Data::operator=(const CP25Data& data)
bool CP25Data::decodeHeader(const unsigned char* data) bool CP25Data::decodeHeader(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
// deinterleave // deinterleave
unsigned char rs[81U]; unsigned char rs[81U];
@ -116,8 +116,8 @@ bool CP25Data::decodeHeader(const unsigned char* data)
void CP25Data::encodeHeader(unsigned char* data) void CP25Data::encodeHeader(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
assert(m_mi != NULL); assert(m_mi != nullptr);
unsigned char rs[81U]; unsigned char rs[81U];
::memset(rs, 0x00U, 81U); ::memset(rs, 0x00U, 81U);
@ -147,7 +147,7 @@ void CP25Data::encodeHeader(unsigned char* data)
bool CP25Data::decodeLDU1(const unsigned char* data) bool CP25Data::decodeLDU1(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char rs[18U]; unsigned char rs[18U];
@ -204,7 +204,7 @@ bool CP25Data::decodeLDU1(const unsigned char* data)
void CP25Data::encodeLDU1(unsigned char* data) void CP25Data::encodeLDU1(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char rs[18U]; unsigned char rs[18U];
::memset(rs, 0x00U, 18U); ::memset(rs, 0x00U, 18U);
@ -258,7 +258,7 @@ void CP25Data::encodeLDU1(unsigned char* data)
bool CP25Data::decodeLDU2(const unsigned char* data) bool CP25Data::decodeLDU2(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char rs[18U]; unsigned char rs[18U];
@ -310,8 +310,8 @@ bool CP25Data::decodeLDU2(const unsigned char* data)
void CP25Data::encodeLDU2(unsigned char* data) void CP25Data::encodeLDU2(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
assert(m_mi != NULL); assert(m_mi != nullptr);
unsigned char rs[18U]; unsigned char rs[18U];
::memset(rs, 0x00U, 18U); ::memset(rs, 0x00U, 18U);
@ -349,7 +349,7 @@ void CP25Data::encodeLDU2(unsigned char* data)
bool CP25Data::decodeTSDU(const unsigned char* data) bool CP25Data::decodeTSDU(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
// deinterleave // deinterleave
unsigned char tsbk[12U]; unsigned char tsbk[12U];
@ -404,7 +404,7 @@ bool CP25Data::decodeTSDU(const unsigned char* data)
void CP25Data::encodeTSDU(unsigned char* data) void CP25Data::encodeTSDU(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char tsbk[12U]; unsigned char tsbk[12U];
::memset(tsbk, 0x00U, 12U); ::memset(tsbk, 0x00U, 12U);
@ -459,14 +459,14 @@ void CP25Data::encodeTSDU(unsigned char* data)
void CP25Data::setMI(const unsigned char* mi) void CP25Data::setMI(const unsigned char* mi)
{ {
assert(mi != NULL); assert(mi != nullptr);
::memcpy(m_mi, mi, P25_MI_LENGTH_BYTES); ::memcpy(m_mi, mi, P25_MI_LENGTH_BYTES);
} }
void CP25Data::getMI(unsigned char* mi) const void CP25Data::getMI(unsigned char* mi) const
{ {
assert(mi != NULL); assert(mi != nullptr);
::memcpy(mi, m_mi, P25_MI_LENGTH_BYTES); ::memcpy(mi, m_mi, P25_MI_LENGTH_BYTES);
} }

View file

@ -75,6 +75,6 @@ const unsigned char P25_DUID_LDU2 = 0x0AU;
const unsigned char P25_DUID_PDU = 0x0CU; const unsigned char P25_DUID_PDU = 0x0CU;
const unsigned char P25_DUID_TERM_LC = 0x0FU; const unsigned char P25_DUID_TERM_LC = 0x0FU;
const unsigned char P25_NULL_IMBE[] = {0x04U, 0x0CU, 0xFDU, 0x7BU, 0xFBU, 0x7DU, 0xF2U, 0x7BU, 0x3DU, 0x9EU, 0x45U}; const unsigned char P25_nullptr_IMBE[] = {0x04U, 0x0CU, 0xFDU, 0x7BU, 0xFBU, 0x7DU, 0xF2U, 0x7BU, 0x3DU, 0x9EU, 0x45U};
#endif #endif

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -54,7 +54,7 @@ CP25LowSpeedData::~CP25LowSpeedData()
void CP25LowSpeedData::process(unsigned char* data) void CP25LowSpeedData::process(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char lsd[4U]; unsigned char lsd[4U];
CP25Utils::decode(data, lsd, 1546U, 1578U); CP25Utils::decode(data, lsd, 1546U, 1578U);
@ -93,7 +93,7 @@ void CP25LowSpeedData::process(unsigned char* data)
void CP25LowSpeedData::encode(unsigned char* data) const void CP25LowSpeedData::encode(unsigned char* data) const
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char lsd[4U]; unsigned char lsd[4U];
lsd[0U] = m_lsd1; lsd[0U] = m_lsd1;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX * Copyright (C) 2016,2018,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com> * Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -29,13 +29,13 @@ const unsigned int MAX_NID_ERRS = 5U;
CP25NID::CP25NID(unsigned int nac) : CP25NID::CP25NID(unsigned int nac) :
m_duid(0U), m_duid(0U),
m_hdr(NULL), m_hdr(nullptr),
m_ldu1(NULL), m_ldu1(nullptr),
m_ldu2(NULL), m_ldu2(nullptr),
m_termlc(NULL), m_termlc(nullptr),
m_term(NULL), m_term(nullptr),
m_tsdu(NULL), m_tsdu(nullptr),
m_pdu(NULL) m_pdu(nullptr)
{ {
CBCH bch; CBCH bch;
@ -102,7 +102,7 @@ CP25NID::~CP25NID()
bool CP25NID::decode(const unsigned char* data) bool CP25NID::decode(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char nid[P25_NID_LENGTH_BYTES]; unsigned char nid[P25_NID_LENGTH_BYTES];
CP25Utils::decode(data, nid, 48U, 114U); CP25Utils::decode(data, nid, 48U, 114U);
@ -154,7 +154,7 @@ bool CP25NID::decode(const unsigned char* data)
void CP25NID::encode(unsigned char* data, unsigned char duid) const void CP25NID::encode(unsigned char* data, unsigned char duid) const
{ {
assert(data != NULL); assert(data != nullptr);
switch (duid) { switch (duid) {
case P25_DUID_HEADER: case P25_DUID_HEADER:

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2014,2016,2019,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2009-2014,2016,2019,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -118,7 +118,7 @@ bool CP25Network::open()
bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, const CP25LowSpeedData& lsd, bool end) bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control, const CP25LowSpeedData& lsd, bool end)
{ {
assert(ldu1 != NULL); assert(ldu1 != nullptr);
unsigned char buffer[22U]; unsigned char buffer[22U];
@ -247,7 +247,7 @@ bool CP25Network::writeLDU1(const unsigned char* ldu1, const CP25Data& control,
bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, const CP25LowSpeedData& lsd, bool end) bool CP25Network::writeLDU2(const unsigned char* ldu2, const CP25Data& control, const CP25LowSpeedData& lsd, bool end)
{ {
assert(ldu2 != NULL); assert(ldu2 != nullptr);
unsigned char buffer[22U]; unsigned char buffer[22U];
@ -409,7 +409,7 @@ void CP25Network::clock(unsigned int ms)
unsigned int CP25Network::read(unsigned char* data, unsigned int length) unsigned int CP25Network::read(unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return 0U; return 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2018,2024 by Jonathan Naylor, G4KLX * Copyright (C) 2016,2018,2024,2025 by Jonathan Naylor, G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -54,8 +54,8 @@ CP25Trellis::~CP25Trellis()
bool CP25Trellis::decode34(const unsigned char* data, unsigned char* payload) bool CP25Trellis::decode34(const unsigned char* data, unsigned char* payload)
{ {
assert(data != NULL); assert(data != nullptr);
assert(payload != NULL); assert(payload != nullptr);
signed char dibits[98U]; signed char dibits[98U];
deinterleave(data, dibits); deinterleave(data, dibits);
@ -88,8 +88,8 @@ bool CP25Trellis::decode34(const unsigned char* data, unsigned char* payload)
void CP25Trellis::encode34(const unsigned char* payload, unsigned char* data) void CP25Trellis::encode34(const unsigned char* payload, unsigned char* data)
{ {
assert(payload != NULL); assert(payload != nullptr);
assert(data != NULL); assert(data != nullptr);
unsigned char tribits[49U]; unsigned char tribits[49U];
bitsToTribits(payload, tribits); bitsToTribits(payload, tribits);
@ -113,8 +113,8 @@ void CP25Trellis::encode34(const unsigned char* payload, unsigned char* data)
bool CP25Trellis::decode12(const unsigned char* data, unsigned char* payload) bool CP25Trellis::decode12(const unsigned char* data, unsigned char* payload)
{ {
assert(data != NULL); assert(data != nullptr);
assert(payload != NULL); assert(payload != nullptr);
signed char dibits[98U]; signed char dibits[98U];
deinterleave(data, dibits); deinterleave(data, dibits);
@ -147,8 +147,8 @@ bool CP25Trellis::decode12(const unsigned char* data, unsigned char* payload)
void CP25Trellis::encode12(const unsigned char* payload, unsigned char* data) void CP25Trellis::encode12(const unsigned char* payload, unsigned char* data)
{ {
assert(payload != NULL); assert(payload != nullptr);
assert(data != NULL); assert(data != nullptr);
unsigned char bits[49U]; unsigned char bits[49U];
bitsToDibits(payload, bits); bitsToDibits(payload, bits);

View file

@ -29,8 +29,8 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
unsigned int CP25Utils::decode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop) unsigned int CP25Utils::decode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Move the SSx positions to the range needed // Move the SSx positions to the range needed
unsigned int ss0Pos = P25_SS0_START; unsigned int ss0Pos = P25_SS0_START;
@ -59,8 +59,8 @@ unsigned int CP25Utils::decode(const unsigned char* in, unsigned char* out, unsi
unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop) unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Move the SSx positions to the range needed // Move the SSx positions to the range needed
unsigned int ss0Pos = P25_SS0_START; unsigned int ss0Pos = P25_SS0_START;
@ -89,8 +89,8 @@ unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsi
unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsigned int length) unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsigned int length)
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
// Move the SSx positions to the range needed // Move the SSx positions to the range needed
unsigned int ss0Pos = P25_SS0_START; unsigned int ss0Pos = P25_SS0_START;
@ -116,8 +116,8 @@ unsigned int CP25Utils::encode(const unsigned char* in, unsigned char* out, unsi
unsigned int CP25Utils::compare(const unsigned char* data1, const unsigned char* data2, unsigned int length) unsigned int CP25Utils::compare(const unsigned char* data1, const unsigned char* data2, unsigned int length)
{ {
assert(data1 != NULL); assert(data1 != nullptr);
assert(data2 != NULL); assert(data2 != nullptr);
unsigned int errs = 0U; unsigned int errs = 0U;
for (unsigned int i = 0U; i < length; i++) { for (unsigned int i = 0U; i < length; i++) {

View file

@ -70,9 +70,9 @@ m_ric(0U),
m_data(), m_data(),
m_state(POCSAG_STATE::NONE), m_state(POCSAG_STATE::NONE),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
} }
CPOCSAGControl::~CPOCSAGControl() CPOCSAGControl::~CPOCSAGControl()
@ -87,7 +87,7 @@ CPOCSAGControl::~CPOCSAGControl()
unsigned int CPOCSAGControl::readModem(unsigned char* data) unsigned int CPOCSAGControl::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -194,7 +194,7 @@ void CPOCSAGControl::sendPageAlert2(unsigned int ric, const std::string& text)
bool CPOCSAGControl::readNetwork() bool CPOCSAGControl::readNetwork()
{ {
if (m_network == NULL) if (m_network == nullptr)
return true; return true;
unsigned char data[300U]; unsigned char data[300U];
@ -431,7 +431,7 @@ void CPOCSAGControl::packNumeric(const std::string& text, std::deque<uint32_t>&
for (std::string::const_iterator it = text.cbegin(); it != text.cend(); ++it) { for (std::string::const_iterator it = text.cbegin(); it != text.cend(); ++it) {
char c = *it; char c = *it;
const BCD* bcd = NULL; const BCD* bcd = nullptr;
for (unsigned int i = 0U; BCD_VALUES[i].m_c != 0; i++) { for (unsigned int i = 0U; BCD_VALUES[i].m_c != 0; i++) {
if (BCD_VALUES[i].m_c == c) { if (BCD_VALUES[i].m_c == c) {
bcd = BCD_VALUES + i; bcd = BCD_VALUES + i;
@ -439,7 +439,7 @@ void CPOCSAGControl::packNumeric(const std::string& text, std::deque<uint32_t>&
} }
} }
if (bcd != NULL) { if (bcd != nullptr) {
word |= bcd->m_bcd[n]; word |= bcd->m_bcd[n];
n++; n++;
@ -520,7 +520,7 @@ void CPOCSAGControl::writeQueue()
bool CPOCSAGControl::openFile() bool CPOCSAGControl::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -532,7 +532,7 @@ bool CPOCSAGControl::openFile()
::sprintf(name, "POCSAG_%04d%02d%02d_%02d%02d%02d.dat", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "POCSAG_%04d%02d%02d_%02d%02d%02d.dat", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("POCSAG", 1U, 6U, m_fp); ::fwrite("POCSAG", 1U, 6U, m_fp);
@ -542,7 +542,7 @@ bool CPOCSAGControl::openFile()
bool CPOCSAGControl::writeFile(const unsigned char* data) bool CPOCSAGControl::writeFile(const unsigned char* data)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, POCSAG_FRAME_LENGTH_BYTES, m_fp); ::fwrite(data, 1U, POCSAG_FRAME_LENGTH_BYTES, m_fp);
@ -552,9 +552,9 @@ bool CPOCSAGControl::writeFile(const unsigned char* data)
void CPOCSAGControl::closeFile() void CPOCSAGControl::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018,2019,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2018,2019,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -88,7 +88,7 @@ void CPOCSAGNetwork::clock(unsigned int ms)
unsigned int CPOCSAGNetwork::read(unsigned char* data) unsigned int CPOCSAGNetwork::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return 0U; return 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -55,7 +55,7 @@ bool CPseudoTTYController::open()
int slavefd; int slavefd;
char slave[300]; char slave[300];
int result = ::openpty(&m_fd, &slavefd, slave, NULL, NULL); int result = ::openpty(&m_fd, &slavefd, slave, nullptr, nullptr);
if (result < 0) { if (result < 0) {
LogError("Cannot open the pseudo tty - errno : %d", errno); LogError("Cannot open the pseudo tty - errno : %d", errno);
return false; return false;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -92,7 +92,7 @@ unsigned int CQR1676::getSyndrome1576(unsigned int pattern)
// Compute the EMB against a precomputed list of correct words // Compute the EMB against a precomputed list of correct words
void CQR1676::encode(unsigned char* data) void CQR1676::encode(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int value = (data[0U] >> 1) & 0x7FU; unsigned int value = (data[0U] >> 1) & 0x7FU;
unsigned int cksum = ENCODING_TABLE_1676[value]; unsigned int cksum = ENCODING_TABLE_1676[value];
@ -103,7 +103,7 @@ void CQR1676::encode(unsigned char* data)
unsigned char CQR1676::decode(const unsigned char* data) unsigned char CQR1676::decode(const unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned int code = (data[0U] << 7) + (data[1U] >> 1); unsigned int code = (data[0U] << 7) + (data[1U] >> 1);
unsigned int syndrome = getSyndrome1576(code); unsigned int syndrome = getSyndrome1576(code);

10
RS.h
View file

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 2014 Hard Consulting Corporation * Copyright (C) 2014 Hard Consulting Corporation
* Copyright (C) 2023 Bryan Biedenkapp, N2PLL * Copyright (C) 2023 Bryan Biedenkapp, N2PLL
* Copyright (C) 2024 Jonathan Naylor, G4KLX * Copyright (C) 2024,2025 Jonathan Naylor, G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1044,16 +1044,16 @@
TYP cor = alpha_to[modnn(index_of[num1] + index_of[num2] + NN - index_of[den])]; TYP cor = alpha_to[modnn(index_of[num1] + index_of[num2] + NN - index_of[den])];
// Store the error correction pattern, if a correction buffer is available // Store the error correction pattern, if a correction buffer is available
if (corr != NULL) if (corr != nullptr)
corr[j] = cor; corr[j] = cor;
// If a data/parity buffer is given and the error is inside the message or // If a data/parity buffer is given and the error is inside the message or
// parity data, correct it // parity data, correct it
if (loc[j] < (NN - NROOTS)) { if (loc[j] < (NN - NROOTS)) {
if (data != NULL) if (data != nullptr)
data[loc[j] - pad] ^= cor; data[loc[j] - pad] ^= cor;
} else if (loc[j] < NN) { } else if (loc[j] < NN) {
if (parity != NULL) if (parity != nullptr)
parity[loc[j] - (NN - NROOTS)] ^= cor; parity[loc[j] - (NN - NROOTS)] ^= cor;
} }
} }
@ -1082,7 +1082,7 @@
LogDebug(LOG_HOST, "%s", ss.str().c_str()); LogDebug(LOG_HOST, "%s", ss.str().c_str());
} }
#endif #endif
if (eras_pos != NULL) { if (eras_pos != nullptr) {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
eras_pos[i] = loc[i] - pad; eras_pos[i] = loc[i] - pad;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 by Jonathan Naylor G4KLX * Copyright (C) 2015,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -101,8 +101,8 @@ static unsigned char gmult(unsigned char a, unsigned char b)
*/ */
void CRS129::encode(const unsigned char* msg, unsigned int nbytes, unsigned char* parity) void CRS129::encode(const unsigned char* msg, unsigned int nbytes, unsigned char* parity)
{ {
assert(msg != NULL); assert(msg != nullptr);
assert(parity != NULL); assert(parity != nullptr);
for (unsigned int i = 0U; i < NPAR + 1U; i++) for (unsigned int i = 0U; i < NPAR + 1U; i++)
parity[i] = 0x00U; parity[i] = 0x00U;
@ -120,7 +120,7 @@ void CRS129::encode(const unsigned char* msg, unsigned int nbytes, unsigned char
// Reed-Solomon (12,9) check // Reed-Solomon (12,9) check
bool CRS129::check(const unsigned char* in) bool CRS129::check(const unsigned char* in)
{ {
assert(in != NULL); assert(in != nullptr);
unsigned char parity[4U]; unsigned char parity[4U];
encode(in, 9U, parity); encode(in, 9U, parity);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2024 by Jonathan Naylor G4KLX * Copyright (C) 2016,2024,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2018,2023 by Bryan Biedenkapp <gatekeep@gmail.com> N2PLL * Copyright (C) 2018,2023 by Bryan Biedenkapp <gatekeep@gmail.com> N2PLL
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -163,7 +163,7 @@ CRS634717::~CRS634717()
bool CRS634717::decode241213(unsigned char* data) bool CRS634717::decode241213(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
std::vector<unsigned char> codeword(63, 0); std::vector<unsigned char> codeword(63, 0);
@ -185,7 +185,7 @@ bool CRS634717::decode241213(unsigned char* data)
void CRS634717::encode241213(unsigned char* data) void CRS634717::encode241213(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char codeword[24U]; unsigned char codeword[24U];
@ -206,7 +206,7 @@ void CRS634717::encode241213(unsigned char* data)
bool CRS634717::decode24169(unsigned char* data) bool CRS634717::decode24169(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
std::vector<unsigned char> codeword(63, 0); std::vector<unsigned char> codeword(63, 0);
@ -228,7 +228,7 @@ bool CRS634717::decode24169(unsigned char* data)
void CRS634717::encode24169(unsigned char* data) void CRS634717::encode24169(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char codeword[24U]; unsigned char codeword[24U];
@ -249,7 +249,7 @@ void CRS634717::encode24169(unsigned char* data)
bool CRS634717::decode362017(unsigned char* data) bool CRS634717::decode362017(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
std::vector<unsigned char> codeword(63, 0); std::vector<unsigned char> codeword(63, 0);
@ -271,7 +271,7 @@ bool CRS634717::decode362017(unsigned char* data)
void CRS634717::encode362017(unsigned char* data) void CRS634717::encode362017(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char codeword[36U]; unsigned char codeword[36U];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 by Jonathan Naylor G4KLX * Copyright (C) 2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -38,20 +38,20 @@ CRSSIInterpolator::~CRSSIInterpolator()
bool CRSSIInterpolator::load(const std::string& filename) bool CRSSIInterpolator::load(const std::string& filename)
{ {
FILE* fp = ::fopen(filename.c_str(), "rt"); FILE* fp = ::fopen(filename.c_str(), "rt");
if (fp == NULL) { if (fp == nullptr) {
LogWarning("Cannot open the RSSI data file - %s", filename.c_str()); LogWarning("Cannot open the RSSI data file - %s", filename.c_str());
return false; return false;
} }
char buffer[100U]; char buffer[100U];
while (::fgets(buffer, 100, fp) != NULL) { while (::fgets(buffer, 100, fp) != nullptr) {
if (buffer[0U] == '#') if (buffer[0U] == '#')
continue; continue;
char* p1 = ::strtok(buffer, " \t\r\n"); char* p1 = ::strtok(buffer, " \t\r\n");
char* p2 = ::strtok(NULL, " \t\r\n"); char* p2 = ::strtok(nullptr, " \t\r\n");
if (p1 != NULL && p2 != NULL) { if (p1 != nullptr && p2 != nullptr) {
uint16_t raw = uint16_t(::atoi(p1)); uint16_t raw = uint16_t(::atoi(p1));
int rssi = ::atoi(p2); int rssi = ::atoi(p2);
m_map.insert(std::pair<uint16_t, int>(raw, rssi)); m_map.insert(std::pair<uint16_t, int>(raw, rssi));

View file

@ -80,9 +80,9 @@ REMOTE_COMMAND CRemoteControl::getCommand()
// Parse the original command into a vector of strings. // Parse the original command into a vector of strings.
char* b = buffer; char* b = buffer;
char* p = NULL; char* p = nullptr;
while ((p = ::strtok(b, " ")) != NULL) { while ((p = ::strtok(b, " ")) != nullptr) {
b = NULL; b = nullptr;
m_args.push_back(std::string(p)); m_args.push_back(std::string(p));
} }
@ -163,7 +163,7 @@ REMOTE_COMMAND CRemoteControl::getCommand()
// Reload command is in the form of "reload" // Reload command is in the form of "reload"
m_command = REMOTE_COMMAND::RELOAD; m_command = REMOTE_COMMAND::RELOAD;
} else if (m_args.at(0U) == "status") { } else if (m_args.at(0U) == "status") {
if (m_host != NULL) { if (m_host != nullptr) {
m_host->buildNetworkStatusString(replyStr); m_host->buildNetworkStatusString(replyStr);
} else { } else {
replyStr = "KO"; replyStr = "KO";
@ -171,7 +171,7 @@ REMOTE_COMMAND CRemoteControl::getCommand()
m_command = REMOTE_COMMAND::CONNECTION_STATUS; m_command = REMOTE_COMMAND::CONNECTION_STATUS;
} else if (m_args.at(0U) == "hosts") { } else if (m_args.at(0U) == "hosts") {
if (m_host != NULL) { if (m_host != nullptr) {
m_host->buildNetworkHostsString(replyStr); m_host->buildNetworkHostsString(replyStr);
} else { } else {
replyStr = "KO"; replyStr = "KO";

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2006-2009,2012,2013,2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2006-2009,2012,2013,2015,2016,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -30,12 +30,12 @@ public:
CRingBuffer(unsigned int length, const char* name) : CRingBuffer(unsigned int length, const char* name) :
m_length(length), m_length(length),
m_name(name), m_name(name),
m_buffer(NULL), m_buffer(nullptr),
m_iPtr(0U), m_iPtr(0U),
m_oPtr(0U) m_oPtr(0U)
{ {
assert(length > 0U); assert(length > 0U);
assert(name != NULL); assert(name != nullptr);
m_buffer = new T[length]; m_buffer = new T[length];

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2005,2006,2008 Free Software Foundation, Inc. * Copyright (C) 2005,2006,2008 Free Software Foundation, Inc.
* Copyright (C) 2011,2015 by Jonathan Naylor G4KLX * Copyright (C) 2011,2015,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -46,10 +46,10 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
must be called before using hash in the call to sha256_hash must be called before using hash in the call to sha256_hash
*/ */
CSHA256::CSHA256() : CSHA256::CSHA256() :
m_state(NULL), m_state(nullptr),
m_total(NULL), m_total(nullptr),
m_buflen(0U), m_buflen(0U),
m_buffer(NULL) m_buffer(nullptr)
{ {
m_state = new uint32_t[8U]; m_state = new uint32_t[8U];
m_total = new uint32_t[2U]; m_total = new uint32_t[2U];
@ -85,7 +85,7 @@ void CSHA256::init()
* (uint32_t *) cp = v */ * (uint32_t *) cp = v */
static inline void set_uint32(unsigned char* cp, uint32_t v) static inline void set_uint32(unsigned char* cp, uint32_t v)
{ {
assert(cp != NULL); assert(cp != nullptr);
::memcpy(cp, &v, sizeof v); ::memcpy(cp, &v, sizeof v);
} }
@ -94,7 +94,7 @@ static inline void set_uint32(unsigned char* cp, uint32_t v)
must be in little endian byte order. */ must be in little endian byte order. */
unsigned char* CSHA256::read(unsigned char* resbuf) unsigned char* CSHA256::read(unsigned char* resbuf)
{ {
assert(resbuf != NULL); assert(resbuf != nullptr);
for (unsigned int i = 0U; i < 8U; i++) for (unsigned int i = 0U; i < 8U; i++)
set_uint32(resbuf + i * sizeof(m_state[0]), SWAP(m_state[i])); set_uint32(resbuf + i * sizeof(m_state[0]), SWAP(m_state[i]));
@ -129,7 +129,7 @@ void CSHA256::conclude()
unsigned char* CSHA256::finish(unsigned char* resbuf) unsigned char* CSHA256::finish(unsigned char* resbuf)
{ {
assert(resbuf != NULL); assert(resbuf != nullptr);
conclude(); conclude();
@ -142,8 +142,8 @@ unsigned char* CSHA256::finish(unsigned char* resbuf)
digest. */ digest. */
unsigned char* CSHA256::buffer(const unsigned char* buffer, unsigned int len, unsigned char* resblock) unsigned char* CSHA256::buffer(const unsigned char* buffer, unsigned int len, unsigned char* resblock)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(resblock != NULL); assert(resblock != nullptr);
/* Initialize the computation context. */ /* Initialize the computation context. */
init(); init();
@ -157,7 +157,7 @@ unsigned char* CSHA256::buffer(const unsigned char* buffer, unsigned int len, un
void CSHA256::processBytes(const unsigned char* buffer, unsigned int len) void CSHA256::processBytes(const unsigned char* buffer, unsigned int len)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
/* When we already have some bits in our internal buffer concatenate /* When we already have some bits in our internal buffer concatenate
both inputs first. */ both inputs first. */
@ -252,7 +252,7 @@ static const uint32_t roundConstants[64] = {
void CSHA256::processBlock(const unsigned char* buffer, unsigned int len) void CSHA256::processBlock(const unsigned char* buffer, unsigned int len)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
const uint32_t* words = (uint32_t*)buffer; const uint32_t* words = (uint32_t*)buffer;
unsigned int nwords = len / sizeof(uint32_t); unsigned int nwords = len / sizeof(uint32_t);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2018,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -77,7 +77,7 @@ CStopWatch::~CStopWatch()
unsigned long long CStopWatch::time() const unsigned long long CStopWatch::time() const
{ {
struct timeval now; struct timeval now;
::gettimeofday(&now, NULL); ::gettimeofday(&now, nullptr);
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL; return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2018,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2018,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,14 +32,14 @@
void CSync::addDStarSync(unsigned char* data) void CSync::addDStarSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES); ::memcpy(data + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES);
} }
void CSync::addDMRDataSync(unsigned char* data, bool duplex) void CSync::addDMRDataSync(unsigned char* data, bool duplex)
{ {
assert(data != NULL); assert(data != nullptr);
if (duplex) { if (duplex) {
for (unsigned int i = 0U; i < 7U; i++) for (unsigned int i = 0U; i < 7U; i++)
@ -52,7 +52,7 @@ void CSync::addDMRDataSync(unsigned char* data, bool duplex)
void CSync::addDMRAudioSync(unsigned char* data, bool duplex) void CSync::addDMRAudioSync(unsigned char* data, bool duplex)
{ {
assert(data != NULL); assert(data != nullptr);
if (duplex) { if (duplex) {
for (unsigned int i = 0U; i < 7U; i++) for (unsigned int i = 0U; i < 7U; i++)
@ -65,21 +65,21 @@ void CSync::addDMRAudioSync(unsigned char* data, bool duplex)
void CSync::addYSFSync(unsigned char* data) void CSync::addYSFSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, YSF_SYNC_BYTES, YSF_SYNC_LENGTH_BYTES); ::memcpy(data, YSF_SYNC_BYTES, YSF_SYNC_LENGTH_BYTES);
} }
void CSync::addP25Sync(unsigned char* data) void CSync::addP25Sync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, P25_SYNC_BYTES, P25_SYNC_LENGTH_BYTES); ::memcpy(data, P25_SYNC_BYTES, P25_SYNC_LENGTH_BYTES);
} }
void CSync::addNXDNSync(unsigned char* data) void CSync::addNXDNSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
for (unsigned int i = 0U; i < NXDN_FSW_BYTES_LENGTH; i++) for (unsigned int i = 0U; i < NXDN_FSW_BYTES_LENGTH; i++)
data[i] = (data[i] & ~NXDN_FSW_BYTES_MASK[i]) | NXDN_FSW_BYTES[i]; data[i] = (data[i] & ~NXDN_FSW_BYTES_MASK[i]) | NXDN_FSW_BYTES[i];
@ -87,21 +87,21 @@ void CSync::addNXDNSync(unsigned char* data)
void CSync::addM17LinkSetupSync(unsigned char* data) void CSync::addM17LinkSetupSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, M17_LINK_SETUP_SYNC_BYTES, M17_SYNC_LENGTH_BYTES); ::memcpy(data, M17_LINK_SETUP_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
} }
void CSync::addM17StreamSync(unsigned char* data) void CSync::addM17StreamSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, M17_STREAM_SYNC_BYTES, M17_SYNC_LENGTH_BYTES); ::memcpy(data, M17_STREAM_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
} }
void CSync::addM17EOTSync(unsigned char* data) void CSync::addM17EOTSync(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
::memcpy(data, M17_EOT_SYNC_BYTES, M17_SYNC_LENGTH_BYTES); ::memcpy(data, M17_EOT_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
} }

View file

@ -116,11 +116,11 @@ m_duplex(duplex),
//m_duplex(true), // uncomment to force duplex display for testing! //m_duplex(true), // uncomment to force duplex display for testing!
m_refresh(false), m_refresh(false),
m_refreshTimer(1000U, 0U, REFRESH_PERIOD), m_refreshTimer(1000U, 0U, REFRESH_PERIOD),
m_lineBuf(NULL), m_lineBuf(nullptr),
m_temp(), m_temp(),
m_screenLayout(screenLayout) m_screenLayout(screenLayout)
{ {
assert(serial != NULL); assert(serial != nullptr);
assert(brightness >= 0U && brightness <= 255U); assert(brightness >= 0U && brightness <= 255U);
} }
@ -161,7 +161,7 @@ void CTFTSurenoo::setIdleInt()
void CTFTSurenoo::setErrorInt(const char* text) void CTFTSurenoo::setErrorInt(const char* text)
{ {
assert(text != NULL); assert(text != nullptr);
setModeLine(STR_MMDVM); setModeLine(STR_MMDVM);
setStatusLine(statusLineNo(0), text); setStatusLine(statusLineNo(0), text);
@ -201,11 +201,11 @@ void CTFTSurenoo::setFMInt()
void CTFTSurenoo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) void CTFTSurenoo::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
{ {
assert(my1 != NULL); assert(my1 != nullptr);
assert(my2 != NULL); assert(my2 != nullptr);
assert(your != NULL); assert(your != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(reflector != NULL); assert(reflector != nullptr);
setModeLine(STR_MMDVM); setModeLine(STR_MMDVM);
@ -233,7 +233,7 @@ void CTFTSurenoo::clearDStarInt()
void CTFTSurenoo::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) void CTFTSurenoo::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_DMR) { if (m_mode != MODE_DMR) {
setModeLine(STR_DMR); setModeLine(STR_DMR);
@ -257,7 +257,7 @@ void CTFTSurenoo::writeDMRInt(unsigned int slotNo, const std::string& src, bool
int CTFTSurenoo::writeDMRIntEx(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type) int CTFTSurenoo::writeDMRIntEx(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
// duplex mode is not supported // duplex mode is not supported
if (m_duplex) if (m_duplex)
@ -290,10 +290,10 @@ void CTFTSurenoo::clearDMRInt(unsigned int slotNo)
void CTFTSurenoo::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) void CTFTSurenoo::writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
assert(origin != NULL); assert(origin != nullptr);
setModeLine(STR_YSF); setModeLine(STR_YSF);
@ -319,8 +319,8 @@ void CTFTSurenoo::clearFusionInt()
void CTFTSurenoo::writeP25Int(const char* source, bool group, unsigned int dest, const char* type) void CTFTSurenoo::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
setModeLine(STR_P25); setModeLine(STR_P25);
@ -340,8 +340,8 @@ void CTFTSurenoo::clearP25Int()
void CTFTSurenoo::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type) void CTFTSurenoo::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_NXDN) if (m_mode != MODE_NXDN)
setModeLine(STR_NXDN); setModeLine(STR_NXDN);
@ -357,7 +357,7 @@ void CTFTSurenoo::writeNXDNInt(const char* source, bool group, unsigned int dest
int CTFTSurenoo::writeNXDNIntEx(const CUserDBentry& source, bool group, unsigned int dest, const char* type) int CTFTSurenoo::writeNXDNIntEx(const CUserDBentry& source, bool group, unsigned int dest, const char* type)
{ {
assert(type != NULL); assert(type != nullptr);
setModeLine(STR_NXDN); setModeLine(STR_NXDN);
setStatusLine(statusLineNo(2), (source.get(keyFIRST_NAME) + " " + source.get(keyLAST_NAME)).c_str()); setStatusLine(statusLineNo(2), (source.get(keyFIRST_NAME) + " " + source.get(keyLAST_NAME)).c_str());
@ -377,9 +377,9 @@ void CTFTSurenoo::clearNXDNInt()
void CTFTSurenoo::writeM17Int(const char* source, const char* dest, const char* type) void CTFTSurenoo::writeM17Int(const char* source, const char* dest, const char* type)
{ {
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(type != NULL); assert(type != nullptr);
if (m_mode != MODE_M17) if (m_mode != MODE_M17)
setModeLine(STR_M17); setModeLine(STR_M17);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2020,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,9 +31,9 @@ CThread::~CThread()
bool CThread::run() bool CThread::run()
{ {
m_handle = ::CreateThread(NULL, 0, &helper, this, 0, NULL); m_handle = ::CreateThread(nullptr, 0, &helper, this, 0, nullptr);
return m_handle != NULL; return m_handle != nullptr;
} }
@ -74,13 +74,13 @@ CThread::~CThread()
bool CThread::run() bool CThread::run()
{ {
return ::pthread_create(&m_thread, NULL, helper, this) == 0; return ::pthread_create(&m_thread, nullptr, helper, this) == 0;
} }
void CThread::wait() void CThread::wait()
{ {
::pthread_join(m_thread, NULL); ::pthread_join(m_thread, nullptr);
} }
@ -90,7 +90,7 @@ void* CThread::helper(void* arg)
p->entry(); p->entry();
return NULL; return nullptr;
} }
void CThread::sleep(unsigned int ms) void CThread::sleep(unsigned int ms)
@ -100,7 +100,7 @@ void CThread::sleep(unsigned int ms)
ts.tv_sec = ms / 1000U; ts.tv_sec = ms / 1000U;
ts.tv_nsec = (ms % 1000U) * 1000000U; ts.tv_nsec = (ms % 1000U) * 1000000U;
::nanosleep(&ts, NULL); ::nanosleep(&ts, nullptr);
} }
#endif #endif

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2019,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2002-2004,2007-2011,2013,2014-2017,2019,2020,2021,2025 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -68,7 +68,7 @@ bool CUARTController::open()
std::string baseName = m_device.substr(4U); // Convert "\\.\COM10" to "COM10" std::string baseName = m_device.substr(4U); // Convert "\\.\COM10" to "COM10"
m_handle = ::CreateFileA(m_device.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); m_handle = ::CreateFileA(m_device.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (m_handle == INVALID_HANDLE_VALUE) { if (m_handle == INVALID_HANDLE_VALUE) {
LogError("Cannot open device - %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot open device - %s, err=%04lx", m_device.c_str(), ::GetLastError());
return false; return false;
@ -77,7 +77,7 @@ bool CUARTController::open()
DCB dcb; DCB dcb;
if (::GetCommState(m_handle, &dcb) == 0) { if (::GetCommState(m_handle, &dcb) == 0) {
LogError("Cannot get the attributes for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot get the attributes for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
@ -97,7 +97,7 @@ bool CUARTController::open()
if (::SetCommState(m_handle, &dcb) == 0) { if (::SetCommState(m_handle, &dcb) == 0) {
LogError("Cannot set the attributes for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot set the attributes for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
@ -105,7 +105,7 @@ bool CUARTController::open()
COMMTIMEOUTS timeouts; COMMTIMEOUTS timeouts;
if (!::GetCommTimeouts(m_handle, &timeouts)) { if (!::GetCommTimeouts(m_handle, &timeouts)) {
LogError("Cannot get the timeouts for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot get the timeouts for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
@ -116,26 +116,26 @@ bool CUARTController::open()
if (!::SetCommTimeouts(m_handle, &timeouts)) { if (!::SetCommTimeouts(m_handle, &timeouts)) {
LogError("Cannot set the timeouts for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot set the timeouts for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
if (::EscapeCommFunction(m_handle, CLRDTR) == 0) { if (::EscapeCommFunction(m_handle, CLRDTR) == 0) {
LogError("Cannot clear DTR for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot clear DTR for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
if (::EscapeCommFunction(m_handle, m_assertRTS ? SETRTS : CLRRTS) == 0) { if (::EscapeCommFunction(m_handle, m_assertRTS ? SETRTS : CLRRTS) == 0) {
LogError("Cannot set/clear RTS for %s, err=%04lx", m_device.c_str(), ::GetLastError()); LogError("Cannot set/clear RTS for %s, err=%04lx", m_device.c_str(), ::GetLastError());
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
::CloseHandle(m_handle); ::CloseHandle(m_handle);
return false; return false;
} }
::ClearCommError(m_handle, &errCode, NULL); ::ClearCommError(m_handle, &errCode, nullptr);
return true; return true;
} }
@ -143,7 +143,7 @@ bool CUARTController::open()
int CUARTController::read(unsigned char* buffer, unsigned int length) int CUARTController::read(unsigned char* buffer, unsigned int length)
{ {
assert(m_handle != INVALID_HANDLE_VALUE); assert(m_handle != INVALID_HANDLE_VALUE);
assert(buffer != NULL); assert(buffer != nullptr);
unsigned int ptr = 0U; unsigned int ptr = 0U;
@ -165,7 +165,7 @@ int CUARTController::read(unsigned char* buffer, unsigned int length)
int CUARTController::readNonblock(unsigned char* buffer, unsigned int length) int CUARTController::readNonblock(unsigned char* buffer, unsigned int length)
{ {
assert(m_handle != INVALID_HANDLE_VALUE); assert(m_handle != INVALID_HANDLE_VALUE);
assert(buffer != NULL); assert(buffer != nullptr);
if (length == 0U) if (length == 0U)
return 0; return 0;
@ -185,7 +185,7 @@ int CUARTController::readNonblock(unsigned char* buffer, unsigned int length)
readLength = length; readLength = length;
DWORD bytes = 0UL; DWORD bytes = 0UL;
BOOL ret = ::ReadFile(m_handle, buffer, readLength, &bytes, NULL); BOOL ret = ::ReadFile(m_handle, buffer, readLength, &bytes, nullptr);
if (!ret) { if (!ret) {
LogError("Error from ReadFile for %s: %04lx", m_device.c_str(), ::GetLastError()); LogError("Error from ReadFile for %s: %04lx", m_device.c_str(), ::GetLastError());
return -1; return -1;
@ -197,7 +197,7 @@ int CUARTController::readNonblock(unsigned char* buffer, unsigned int length)
int CUARTController::write(const unsigned char* buffer, unsigned int length) int CUARTController::write(const unsigned char* buffer, unsigned int length)
{ {
assert(m_handle != INVALID_HANDLE_VALUE); assert(m_handle != INVALID_HANDLE_VALUE);
assert(buffer != NULL); assert(buffer != nullptr);
if (length == 0U) if (length == 0U)
return 0; return 0;
@ -206,7 +206,7 @@ int CUARTController::write(const unsigned char* buffer, unsigned int length)
while (ptr < length) { while (ptr < length) {
DWORD bytes = 0UL; DWORD bytes = 0UL;
BOOL ret = ::WriteFile(m_handle, buffer + ptr, length - ptr, &bytes, NULL); BOOL ret = ::WriteFile(m_handle, buffer + ptr, length - ptr, &bytes, nullptr);
if (!ret) { if (!ret) {
LogError("Error from WriteFile for %s: %04lx", m_device.c_str(), ::GetLastError()); LogError("Error from WriteFile for %s: %04lx", m_device.c_str(), ::GetLastError());
return -1; return -1;
@ -414,7 +414,7 @@ int CUARTController::setNonblock(bool nonblock)
int CUARTController::read(unsigned char* buffer, unsigned int length) int CUARTController::read(unsigned char* buffer, unsigned int length)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(m_fd != -1); assert(m_fd != -1);
if (length == 0U) if (length == 0U)
@ -431,11 +431,11 @@ int CUARTController::read(unsigned char* buffer, unsigned int length)
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
n = ::select(m_fd + 1, &fds, NULL, NULL, &tv); n = ::select(m_fd + 1, &fds, nullptr, nullptr, &tv);
if (n == 0) if (n == 0)
return 0; return 0;
} else { } else {
n = ::select(m_fd + 1, &fds, NULL, NULL, NULL); n = ::select(m_fd + 1, &fds, nullptr, nullptr, nullptr);
} }
if (n < 0) { if (n < 0) {
@ -470,7 +470,7 @@ bool CUARTController::canWrite(){
timeo.tv_sec = 0; timeo.tv_sec = 0;
timeo.tv_usec = 0; timeo.tv_usec = 0;
int rc = ::select(m_fd + 1, NULL, &wset, NULL, &timeo); int rc = ::select(m_fd + 1, nullptr, &wset, nullptr, &timeo);
if (rc > 0 && FD_ISSET(m_fd, &wset)) if (rc > 0 && FD_ISSET(m_fd, &wset))
return true; return true;
@ -482,7 +482,7 @@ bool CUARTController::canWrite(){
int CUARTController::write(const unsigned char* buffer, unsigned int length) int CUARTController::write(const unsigned char* buffer, unsigned int length)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(m_fd != -1); assert(m_fd != -1);
if (length == 0U) if (length == 0U)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021 by Jonathan Naylor G4KLX * Copyright (C) 2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -54,7 +54,7 @@ bool CUDPController::open()
int CUDPController::read(unsigned char* buffer, unsigned int length) int CUDPController::read(unsigned char* buffer, unsigned int length)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(length > 0U); assert(length > 0U);
unsigned char data[BUFFER_LENGTH]; unsigned char data[BUFFER_LENGTH];
@ -85,7 +85,7 @@ int CUDPController::read(unsigned char* buffer, unsigned int length)
int CUDPController::write(const unsigned char* buffer, unsigned int length) int CUDPController::write(const unsigned char* buffer, unsigned int length)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(length > 0U); assert(length > 0U);
return m_socket.write(buffer, length, m_addr, m_addrLen) ? int(length) : -1; return m_socket.write(buffer, length, m_addr, m_addrLen) ? int(length) : -1;

View file

@ -94,7 +94,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockadd
/* Port is always digits, no needs to lookup service */ /* Port is always digits, no needs to lookup service */
hints.ai_flags |= AI_NUMERICSERV; hints.ai_flags |= AI_NUMERICSERV;
int err = ::getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res); int err = ::getaddrinfo(hostname.empty() ? nullptr : hostname.c_str(), portstr.c_str(), &hints, &res);
if (err != 0) { if (err != 0) {
sockaddr_in* paddr = (sockaddr_in*)&addr; sockaddr_in* paddr = (sockaddr_in*)&addr;
::memset(paddr, 0x00U, address_length = sizeof(sockaddr_in)); ::memset(paddr, 0x00U, address_length = sizeof(sockaddr_in));
@ -233,7 +233,7 @@ bool CUDPSocket::open()
int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &addressLength) int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &addressLength)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(length > 0U); assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
@ -301,7 +301,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int addressLength) bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int addressLength)
{ {
assert(buffer != NULL); assert(buffer != nullptr);
assert(length > 0U); assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
assert(m_fd != INVALID_SOCKET); assert(m_fd != INVALID_SOCKET);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 by SASANO Takayoshi JG1UAA * Copyright (C) 2020,2025 by SASANO Takayoshi JG1UAA
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@ bool CUserDB::lookup(unsigned int id, class CUserDBentry *entry)
m_mutex.lock(); m_mutex.lock();
try { try {
if (entry != NULL) if (entry != nullptr)
*entry = m_table.at(id); *entry = m_table.at(id);
else else
(void)m_table.at(id); (void)m_table.at(id);
@ -59,7 +59,7 @@ bool CUserDB::load(std::string const& filename)
LogInfo("Loading ID lookup table from %s", filename.c_str()); LogInfo("Loading ID lookup table from %s", filename.c_str());
FILE* fp = ::fopen(filename.c_str(), "rt"); FILE* fp = ::fopen(filename.c_str(), "rt");
if (fp == NULL) { if (fp == nullptr) {
LogWarning("Cannot open ID lookup file - %s", filename.c_str()); LogWarning("Cannot open ID lookup file - %s", filename.c_str());
return false; return false;
} }
@ -71,7 +71,7 @@ bool CUserDB::load(std::string const& filename)
// set index for entries // set index for entries
char buffer[256U]; char buffer[256U];
if (::fgets(buffer, sizeof(buffer), fp) == NULL) { if (::fgets(buffer, sizeof(buffer), fp) == nullptr) {
LogWarning("ID lookup file has no entry - %s", filename.c_str()); LogWarning("ID lookup file has no entry - %s", filename.c_str());
m_mutex.unlock(); m_mutex.unlock();
::fclose(fp); ::fclose(fp);
@ -86,7 +86,7 @@ bool CUserDB::load(std::string const& filename)
::rewind(fp); ::rewind(fp);
} }
while (::fgets(buffer, sizeof(buffer), fp) != NULL) { while (::fgets(buffer, sizeof(buffer), fp) != nullptr) {
if (buffer[0U] != '#') if (buffer[0U] != '#')
parse(buffer, index); parse(buffer, index);
} }
@ -109,7 +109,7 @@ bool CUserDB::makeindex(char* buf, std::unordered_map<std::string, int>& index)
// Remove the old index // Remove the old index
index.clear(); index.clear();
for (i = 0, p1 = tokenize(buf, &p2); p1 != NULL; for (i = 0, p1 = tokenize(buf, &p2); p1 != nullptr;
i++, p1 = tokenize(p2, &p2)) { i++, p1 = tokenize(p2, &p2)) {
// create [column keyword] - [column number] table // create [column keyword] - [column number] table
@ -133,7 +133,7 @@ void CUserDB::parse(char* buf, std::unordered_map<std::string, int>& index)
std::unordered_map<std::string, char*> ptr; std::unordered_map<std::string, char*> ptr;
unsigned int id; unsigned int id;
for (i = 0, p1 = tokenize(buf, &p2); p1 != NULL; for (i = 0, p1 = tokenize(buf, &p2); p1 != nullptr;
i++, p1 = tokenize(p2, &p2)) { i++, p1 = tokenize(p2, &p2)) {
for (auto it = index.begin(); it != index.end(); it++) { for (auto it = index.begin(); it != index.end(); it++) {
@ -175,10 +175,10 @@ void CUserDB::toupper_string(char* str)
char* CUserDB::tokenize(char* str, char** next) char* CUserDB::tokenize(char* str, char** next)
{ {
if (*str == '\0') if (*str == '\0')
return NULL; return nullptr;
char* p = ::strpbrk(str, ",\t\r\n"); char* p = ::strpbrk(str, ",\t\r\n");
if (p == NULL) { if (p == nullptr) {
*next = str + ::strlen(str); *next = str + ::strlen(str);
} else { } else {
*p = '\0'; *p = '\0';

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009,2014,2015,2016,2021 Jonathan Naylor, G4KLX * Copyright (C) 2009,2014,2015,2016,2021,2025 Jonathan Naylor, G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,14 +19,14 @@
void CUtils::dump(const std::string& title, const unsigned char* data, unsigned int length) void CUtils::dump(const std::string& title, const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
dump(2U, title, data, length); dump(2U, title, data, length);
} }
void CUtils::dump(int level, const std::string& title, const unsigned char* data, unsigned int length) void CUtils::dump(int level, const std::string& title, const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != nullptr);
::Log(level, "%s", title.c_str()); ::Log(level, "%s", title.c_str());
@ -72,14 +72,14 @@ void CUtils::dump(int level, const std::string& title, const unsigned char* data
void CUtils::dump(const std::string& title, const bool* bits, unsigned int length) void CUtils::dump(const std::string& title, const bool* bits, unsigned int length)
{ {
assert(bits != NULL); assert(bits != nullptr);
dump(2U, title, bits, length); dump(2U, title, bits, length);
} }
void CUtils::dump(int level, const std::string& title, const bool* bits, unsigned int length) void CUtils::dump(int level, const std::string& title, const bool* bits, unsigned int length)
{ {
assert(bits != NULL); assert(bits != nullptr);
unsigned char bytes[100U]; unsigned char bytes[100U];
unsigned int nBytes = 0U; unsigned int nBytes = 0U;
@ -91,7 +91,7 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne
void CUtils::byteToBitsBE(unsigned char byte, bool* bits) void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
{ {
assert(bits != NULL); assert(bits != nullptr);
bits[0U] = (byte & 0x80U) == 0x80U; bits[0U] = (byte & 0x80U) == 0x80U;
bits[1U] = (byte & 0x40U) == 0x40U; bits[1U] = (byte & 0x40U) == 0x40U;
@ -105,7 +105,7 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
void CUtils::byteToBitsLE(unsigned char byte, bool* bits) void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
{ {
assert(bits != NULL); assert(bits != nullptr);
bits[0U] = (byte & 0x01U) == 0x01U; bits[0U] = (byte & 0x01U) == 0x01U;
bits[1U] = (byte & 0x02U) == 0x02U; bits[1U] = (byte & 0x02U) == 0x02U;
@ -119,7 +119,7 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte) void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
{ {
assert(bits != NULL); assert(bits != nullptr);
byte = bits[0U] ? 0x80U : 0x00U; byte = bits[0U] ? 0x80U : 0x00U;
byte |= bits[1U] ? 0x40U : 0x00U; byte |= bits[1U] ? 0x40U : 0x00U;
@ -133,7 +133,7 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte) void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
{ {
assert(bits != NULL); assert(bits != nullptr);
byte = bits[0U] ? 0x01U : 0x00U; byte = bits[0U] ? 0x01U : 0x00U;
byte |= bits[1U] ? 0x02U : 0x00U; byte |= bits[1U] ? 0x02U : 0x00U;

View file

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20250313"; const char* VERSION = "20250314";
#endif #endif

View file

@ -24,8 +24,8 @@
// #define DUMP_YSF // #define DUMP_YSF
CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) : CYSFControl::CYSFControl(const std::string& callsign, bool selfOnly, CYSFNetwork* network, CDisplay* display, unsigned int timeout, bool duplex, bool lowDeviation, bool remoteGateway, CRSSIInterpolator* rssiMapper) :
m_callsign(NULL), m_callsign(nullptr),
m_selfCallsign(NULL), m_selfCallsign(nullptr),
m_selfOnly(selfOnly), m_selfOnly(selfOnly),
m_network(network), m_network(network),
m_display(display), m_display(display),
@ -47,10 +47,10 @@ m_rfErrs(0U),
m_rfBits(1U), m_rfBits(1U),
m_netErrs(0U), m_netErrs(0U),
m_netBits(1U), m_netBits(1U),
m_rfSource(NULL), m_rfSource(nullptr),
m_rfDest(NULL), m_rfDest(nullptr),
m_netSource(NULL), m_netSource(nullptr),
m_netDest(NULL), m_netDest(nullptr),
m_lastFICH(), m_lastFICH(),
m_netN(0U), m_netN(0U),
m_rfPayload(), m_rfPayload(),
@ -62,10 +62,10 @@ m_minRSSI(0U),
m_aveRSSI(0U), m_aveRSSI(0U),
m_rssiCount(0U), m_rssiCount(0U),
m_enabled(true), m_enabled(true),
m_fp(NULL) m_fp(nullptr)
{ {
assert(display != NULL); assert(display != nullptr);
assert(rssiMapper != NULL); assert(rssiMapper != nullptr);
m_rfPayload.setUplink(callsign); m_rfPayload.setUplink(callsign);
m_rfPayload.setDownlink(callsign); m_rfPayload.setDownlink(callsign);
@ -100,7 +100,7 @@ CYSFControl::~CYSFControl()
bool CYSFControl::writeModem(unsigned char *data, unsigned int len) bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
{ {
assert(data != NULL); assert(data != nullptr);
if (!m_enabled) if (!m_enabled)
return false; return false;
@ -118,8 +118,8 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len)
if ((type == TAG_LOST) && (m_rfState == RPT_RF_STATE::REJECTED)) { if ((type == TAG_LOST) && (m_rfState == RPT_RF_STATE::REJECTED)) {
m_rfPayload.reset(); m_rfPayload.reset();
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
m_rfState = RPT_RF_STATE::LISTENING; m_rfState = RPT_RF_STATE::LISTENING;
return false; return false;
} }
@ -289,8 +289,8 @@ bool CYSFControl::processVWData(bool valid, unsigned char *data)
} else if (valid && (fi == YSF_FI_TERMINATOR)) { } else if (valid && (fi == YSF_FI_TERMINATOR)) {
if (m_rfState == RPT_RF_STATE::REJECTED) { if (m_rfState == RPT_RF_STATE::REJECTED) {
m_rfPayload.reset(); m_rfPayload.reset();
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
m_rfState = RPT_RF_STATE::LISTENING; m_rfState = RPT_RF_STATE::LISTENING;
} else if (m_rfState == RPT_RF_STATE::AUDIO) { } else if (m_rfState == RPT_RF_STATE::AUDIO) {
m_rfPayload.processHeaderData(data + 2U); m_rfPayload.processHeaderData(data + 2U);
@ -458,8 +458,8 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
} else if (valid && (fi == YSF_FI_TERMINATOR)) { } else if (valid && (fi == YSF_FI_TERMINATOR)) {
if (m_rfState == RPT_RF_STATE::REJECTED) { if (m_rfState == RPT_RF_STATE::REJECTED) {
m_rfPayload.reset(); m_rfPayload.reset();
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
m_rfState = RPT_RF_STATE::LISTENING; m_rfState = RPT_RF_STATE::LISTENING;
} else if (m_rfState == RPT_RF_STATE::AUDIO) { } else if (m_rfState == RPT_RF_STATE::AUDIO) {
m_rfPayload.processHeaderData(data + 2U); m_rfPayload.processHeaderData(data + 2U);
@ -590,7 +590,7 @@ bool CYSFControl::processDNData(bool valid, unsigned char *data)
m_rfSource = m_rfPayload.getSource(); m_rfSource = m_rfPayload.getSource();
if (m_rfSource == NULL || m_rfDest == NULL) if (m_rfSource == nullptr || m_rfDest == nullptr)
return false; return false;
if (m_selfOnly) { if (m_selfOnly) {
@ -756,8 +756,8 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
} else if (valid && fi == YSF_FI_TERMINATOR) { } else if (valid && fi == YSF_FI_TERMINATOR) {
if (m_rfState == RPT_RF_STATE::REJECTED) { if (m_rfState == RPT_RF_STATE::REJECTED) {
m_rfPayload.reset(); m_rfPayload.reset();
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
m_rfState = RPT_RF_STATE::LISTENING; m_rfState = RPT_RF_STATE::LISTENING;
} else if (m_rfState == RPT_RF_STATE::DATA) { } else if (m_rfState == RPT_RF_STATE::DATA) {
m_rfPayload.processHeaderData(data + 2U); m_rfPayload.processHeaderData(data + 2U);
@ -842,7 +842,7 @@ bool CYSFControl::processFRData(bool valid, unsigned char *data)
unsigned int CYSFControl::readModem(unsigned char* data) unsigned int CYSFControl::readModem(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_queue.isEmpty()) if (m_queue.isEmpty())
return 0U; return 0U;
@ -863,13 +863,13 @@ void CYSFControl::writeEndRF()
m_rfPayload.reset(); m_rfPayload.reset();
// These variables are free'd by YSFPayload // These variables are free'd by YSFPayload
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
if (m_netState == RPT_NET_STATE::IDLE) { if (m_netState == RPT_NET_STATE::IDLE) {
m_display->clearFusion(); m_display->clearFusion();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -890,7 +890,7 @@ void CYSFControl::writeEndNet()
m_display->clearFusion(); m_display->clearFusion();
if (m_network != NULL) if (m_network != nullptr)
m_network->reset(); m_network->reset();
} }
@ -1054,7 +1054,7 @@ void CYSFControl::writeNetwork()
void CYSFControl::clock(unsigned int ms) void CYSFControl::clock(unsigned int ms)
{ {
if (m_network != NULL) if (m_network != nullptr)
writeNetwork(); writeNetwork();
m_rfTimeoutTimer.clock(ms); m_rfTimeoutTimer.clock(ms);
@ -1072,7 +1072,7 @@ void CYSFControl::clock(unsigned int ms)
void CYSFControl::writeQueueRF(const unsigned char *data) void CYSFControl::writeQueueRF(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netState != RPT_NET_STATE::IDLE) if (m_netState != RPT_NET_STATE::IDLE)
return; return;
@ -1095,7 +1095,7 @@ void CYSFControl::writeQueueRF(const unsigned char *data)
void CYSFControl::writeQueueNet(const unsigned char *data) void CYSFControl::writeQueueNet(const unsigned char *data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired()) if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return; return;
@ -1115,9 +1115,9 @@ void CYSFControl::writeQueueNet(const unsigned char *data)
void CYSFControl::writeNetwork(const unsigned char *data, unsigned int count) void CYSFControl::writeNetwork(const unsigned char *data, unsigned int count)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_network == NULL) if (m_network == nullptr)
return; return;
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired()) if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired())
@ -1128,7 +1128,7 @@ void CYSFControl::writeNetwork(const unsigned char *data, unsigned int count)
bool CYSFControl::openFile() bool CYSFControl::openFile()
{ {
if (m_fp != NULL) if (m_fp != nullptr)
return true; return true;
time_t t; time_t t;
@ -1140,7 +1140,7 @@ bool CYSFControl::openFile()
::sprintf(name, "YSF_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); ::sprintf(name, "YSF_%04d%02d%02d_%02d%02d%02d.ambe", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
m_fp = ::fopen(name, "wb"); m_fp = ::fopen(name, "wb");
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite("YSF", 1U, 3U, m_fp); ::fwrite("YSF", 1U, 3U, m_fp);
@ -1150,7 +1150,7 @@ bool CYSFControl::openFile()
bool CYSFControl::writeFile(const unsigned char* data) bool CYSFControl::writeFile(const unsigned char* data)
{ {
if (m_fp == NULL) if (m_fp == nullptr)
return false; return false;
::fwrite(data, 1U, YSF_FRAME_LENGTH_BYTES, m_fp); ::fwrite(data, 1U, YSF_FRAME_LENGTH_BYTES, m_fp);
@ -1160,9 +1160,9 @@ bool CYSFControl::writeFile(const unsigned char* data)
void CYSFControl::closeFile() void CYSFControl::closeFile()
{ {
if (m_fp != NULL) { if (m_fp != nullptr) {
::fclose(m_fp); ::fclose(m_fp);
m_fp = NULL; m_fp = nullptr;
} }
} }
@ -1173,18 +1173,18 @@ bool CYSFControl::checkCallsign(const unsigned char* callsign) const
void CYSFControl::processNetCallsigns(const unsigned char* data, unsigned char dgid) void CYSFControl::processNetCallsigns(const unsigned char* data, unsigned char dgid)
{ {
assert(data != NULL); assert(data != nullptr);
if (::memcmp(m_netSource, " ", 10U) == 0 || ::memcmp(m_netDest, " ", 10U) == 0) { if (::memcmp(m_netSource, " ", 10U) == 0 || ::memcmp(m_netDest, " ", 10U) == 0) {
if (::memcmp(m_netSource, " ", YSF_CALLSIGN_LENGTH) == 0) { if (::memcmp(m_netSource, " ", YSF_CALLSIGN_LENGTH) == 0) {
unsigned char* source = m_netPayload.getSource(); unsigned char* source = m_netPayload.getSource();
if (source != NULL) if (source != nullptr)
::memcpy(m_netSource, source, YSF_CALLSIGN_LENGTH); ::memcpy(m_netSource, source, YSF_CALLSIGN_LENGTH);
} }
if (::memcmp(m_netDest, " ", YSF_CALLSIGN_LENGTH) == 0) { if (::memcmp(m_netDest, " ", YSF_CALLSIGN_LENGTH) == 0) {
unsigned char* dest = m_netPayload.getDest(); unsigned char* dest = m_netPayload.getDest();
if (dest != NULL) if (dest != nullptr)
::memcpy(m_netDest, dest, YSF_CALLSIGN_LENGTH); ::memcpy(m_netDest, dest, YSF_CALLSIGN_LENGTH);
} }
@ -1212,8 +1212,8 @@ void CYSFControl::enable(bool enabled)
m_rfPayload.reset(); m_rfPayload.reset();
// These variables are free'd by YSFPayload // These variables are free'd by YSFPayload
m_rfSource = NULL; m_rfSource = nullptr;
m_rfDest = NULL; m_rfDest = nullptr;
// Reset the networking section // Reset the networking section
m_netState = RPT_NET_STATE::IDLE; m_netState = RPT_NET_STATE::IDLE;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2016,2021 by Jonathan Naylor G4KLX * Copyright (C) 2009-2016,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,12 +36,12 @@ const uint32_t M = 2U;
const unsigned int K = 5U; const unsigned int K = 5U;
CYSFConvolution::CYSFConvolution() : CYSFConvolution::CYSFConvolution() :
m_metrics1(NULL), m_metrics1(nullptr),
m_metrics2(NULL), m_metrics2(nullptr),
m_oldMetrics(NULL), m_oldMetrics(nullptr),
m_newMetrics(NULL), m_newMetrics(nullptr),
m_decisions(NULL), m_decisions(nullptr),
m_dp(NULL) m_dp(nullptr)
{ {
m_metrics1 = new uint16_t[20U]; m_metrics1 = new uint16_t[20U];
m_metrics2 = new uint16_t[20U]; m_metrics2 = new uint16_t[20U];
@ -98,7 +98,7 @@ void CYSFConvolution::decode(uint8_t s0, uint8_t s1)
unsigned int CYSFConvolution::chainback(unsigned char* out, unsigned int nBits) unsigned int CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
{ {
assert(out != NULL); assert(out != nullptr);
uint32_t state = 0U; uint32_t state = 0U;
@ -124,8 +124,8 @@ unsigned int CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const
{ {
assert(in != NULL); assert(in != nullptr);
assert(out != NULL); assert(out != nullptr);
assert(nBits > 0U); assert(nBits > 0U);
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U; uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2019,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2016,2017,2019,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -55,7 +55,7 @@ const unsigned int INTERLEAVE_TABLE[] = {
38U, 78U, 118U, 158U, 198U}; 38U, 78U, 118U, 158U, 198U};
CYSFFICH::CYSFFICH(const CYSFFICH& fich) : CYSFFICH::CYSFFICH(const CYSFFICH& fich) :
m_fich(NULL) m_fich(nullptr)
{ {
m_fich = new unsigned char[6U]; m_fich = new unsigned char[6U];
@ -63,7 +63,7 @@ m_fich(NULL)
} }
CYSFFICH::CYSFFICH() : CYSFFICH::CYSFFICH() :
m_fich(NULL) m_fich(nullptr)
{ {
m_fich = new unsigned char[6U]; m_fich = new unsigned char[6U];
@ -77,7 +77,7 @@ CYSFFICH::~CYSFFICH()
bool CYSFFICH::decode(const unsigned char* bytes) bool CYSFFICH::decode(const unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
// Skip the sync bytes // Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES; bytes += YSF_SYNC_LENGTH_BYTES;
@ -120,7 +120,7 @@ bool CYSFFICH::decode(const unsigned char* bytes)
void CYSFFICH::encode(unsigned char* bytes) void CYSFFICH::encode(unsigned char* bytes)
{ {
assert(bytes != NULL); assert(bytes != nullptr);
// Skip the sync bytes // Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES; bytes += YSF_SYNC_LENGTH_BYTES;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009-2014,2016,2019,2020,2021 by Jonathan Naylor G4KLX * Copyright (C) 2009-2014,2016,2019,2020,2021,2025 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -37,7 +37,7 @@ m_debug(debug),
m_enabled(false), m_enabled(false),
m_buffer(1000U, "YSF Network"), m_buffer(1000U, "YSF Network"),
m_pollTimer(1000U, 5U), m_pollTimer(1000U, 5U),
m_tag(NULL) m_tag(nullptr)
{ {
m_callsign = callsign; m_callsign = callsign;
m_callsign.resize(YSF_CALLSIGN_LENGTH, ' '); m_callsign.resize(YSF_CALLSIGN_LENGTH, ' ');
@ -70,7 +70,7 @@ bool CYSFNetwork::open()
bool CYSFNetwork::write(const unsigned char* src, const unsigned char* dest, const unsigned char* data, unsigned int count, bool end) bool CYSFNetwork::write(const unsigned char* src, const unsigned char* dest, const unsigned char* data, unsigned int count, bool end)
{ {
assert(data != NULL); assert(data != nullptr);
unsigned char buffer[200U]; unsigned char buffer[200U];
@ -82,12 +82,12 @@ bool CYSFNetwork::write(const unsigned char* src, const unsigned char* dest, con
for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++) for (unsigned int i = 0U; i < YSF_CALLSIGN_LENGTH; i++)
buffer[i + 4U] = m_callsign.at(i); buffer[i + 4U] = m_callsign.at(i);
if (src != NULL) if (src != nullptr)
::memcpy(buffer + 14U, src, YSF_CALLSIGN_LENGTH); ::memcpy(buffer + 14U, src, YSF_CALLSIGN_LENGTH);
else else
::memset(buffer + 14U, ' ', YSF_CALLSIGN_LENGTH); ::memset(buffer + 14U, ' ', YSF_CALLSIGN_LENGTH);
if (dest != NULL) if (dest != nullptr)
::memcpy(buffer + 24U, dest, YSF_CALLSIGN_LENGTH); ::memcpy(buffer + 24U, dest, YSF_CALLSIGN_LENGTH);
else else
::memset(buffer + 24U, ' ', YSF_CALLSIGN_LENGTH); ::memset(buffer + 24U, ' ', YSF_CALLSIGN_LENGTH);
@ -168,7 +168,7 @@ void CYSFNetwork::clock(unsigned int ms)
unsigned int CYSFNetwork::read(unsigned char* data) unsigned int CYSFNetwork::read(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
if (m_buffer.isEmpty()) if (m_buffer.isEmpty())
return 0U; return 0U;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2017,2020 Jonathan Naylor, G4KLX * Copyright (C) 2016,2017,2020,2025 Jonathan Naylor, G4KLX
* Copyright (C) 2016 Mathias Weyland, HB9FRV * Copyright (C) 2016 Mathias Weyland, HB9FRV
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -84,10 +84,10 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7]) #define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
CYSFPayload::CYSFPayload() : CYSFPayload::CYSFPayload() :
m_uplink(NULL), m_uplink(nullptr),
m_downlink(NULL), m_downlink(nullptr),
m_source(NULL), m_source(nullptr),
m_dest(NULL), m_dest(nullptr),
m_fec() m_fec()
{ {
} }
@ -102,7 +102,7 @@ CYSFPayload::~CYSFPayload()
bool CYSFPayload::processHeaderData(unsigned char* data) bool CYSFPayload::processHeaderData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -136,12 +136,12 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
if (m_dest == NULL) { if (m_dest == nullptr) {
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH]; m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH); ::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH);
} }
if (m_source == NULL) { if (m_source == nullptr) {
m_source = new unsigned char[YSF_CALLSIGN_LENGTH]; m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH); ::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
} }
@ -206,10 +206,10 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
output[i] ^= WHITENING_DATA[i]; output[i] ^= WHITENING_DATA[i];
if (m_downlink != NULL) if (m_downlink != nullptr)
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH); ::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
if (m_uplink != NULL) if (m_uplink != nullptr)
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH); ::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
for (unsigned int i = 0U; i < 20U; i++) for (unsigned int i = 0U; i < 20U; i++)
@ -251,7 +251,7 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
unsigned int CYSFPayload::processVDMode1Audio(unsigned char* data) unsigned int CYSFPayload::processVDMode1Audio(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -268,7 +268,7 @@ unsigned int CYSFPayload::processVDMode1Audio(unsigned char* data)
bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool gateway) bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool gateway)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -304,12 +304,12 @@ bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool
switch (fn) { switch (fn) {
case 0U: case 0U:
if (m_dest == NULL) { if (m_dest == nullptr) {
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH]; m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH); ::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH);
} }
if (m_source == NULL) { if (m_source == nullptr) {
m_source = new unsigned char[YSF_CALLSIGN_LENGTH]; m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH); ::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
} }
@ -317,10 +317,10 @@ bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool
break; break;
case 1U: case 1U:
if (m_downlink != NULL && !gateway) if (m_downlink != nullptr && !gateway)
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH); ::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
if (m_uplink != NULL && !gateway) if (m_uplink != nullptr && !gateway)
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH); ::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
break; break;
@ -388,7 +388,7 @@ bool CYSFPayload::processVDMode1Data(unsigned char* data, unsigned char fn, bool
unsigned int CYSFPayload::processVDMode2Audio(unsigned char* data) unsigned int CYSFPayload::processVDMode2Audio(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -466,7 +466,7 @@ unsigned int CYSFPayload::processVDMode2Audio(unsigned char* data)
bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn, bool gateway) bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn, bool gateway)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -502,26 +502,26 @@ bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn, bool
switch (fn) { switch (fn) {
case 0U: case 0U:
if (m_dest == NULL) { if (m_dest == nullptr) {
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH]; m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_dest, output, YSF_CALLSIGN_LENGTH); ::memcpy(m_dest, output, YSF_CALLSIGN_LENGTH);
} }
break; break;
case 1U: case 1U:
if (m_source == NULL) { if (m_source == nullptr) {
m_source = new unsigned char[YSF_CALLSIGN_LENGTH]; m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_source, output, YSF_CALLSIGN_LENGTH); ::memcpy(m_source, output, YSF_CALLSIGN_LENGTH);
} }
break; break;
case 2U: case 2U:
if (m_downlink != NULL && !gateway) if (m_downlink != nullptr && !gateway)
::memcpy(output, m_downlink, YSF_CALLSIGN_LENGTH); ::memcpy(output, m_downlink, YSF_CALLSIGN_LENGTH);
break; break;
case 3U: case 3U:
if (m_uplink != NULL && !gateway) if (m_uplink != nullptr && !gateway)
::memcpy(output, m_uplink, YSF_CALLSIGN_LENGTH); ::memcpy(output, m_uplink, YSF_CALLSIGN_LENGTH);
break; break;
@ -576,7 +576,7 @@ bool CYSFPayload::processVDMode2Data(unsigned char* data, unsigned char fn, bool
bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, bool gateway) bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, bool gateway)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -614,12 +614,12 @@ bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, b
case 0U: case 0U:
// CUtils::dump(1U, "FR Mode Data, CSD1", output, 20U); // CUtils::dump(1U, "FR Mode Data, CSD1", output, 20U);
if (m_dest == NULL) { if (m_dest == nullptr) {
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH]; m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH); ::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH);
} }
if (m_source == NULL) { if (m_source == nullptr) {
m_source = new unsigned char[YSF_CALLSIGN_LENGTH]; m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH); ::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
} }
@ -722,10 +722,10 @@ bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, b
case 0U: case 0U:
// CUtils::dump(1U, "FR Mode Data, CSD2", output, 20U); // CUtils::dump(1U, "FR Mode Data, CSD2", output, 20U);
if (m_downlink != NULL && !gateway) if (m_downlink != nullptr && !gateway)
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH); ::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
if (m_uplink != NULL && !gateway) if (m_uplink != nullptr && !gateway)
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH); ::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
break; break;
@ -801,7 +801,7 @@ bool CYSFPayload::processDataFRModeData(unsigned char* data, unsigned char fn, b
unsigned int CYSFPayload::processVoiceFRModeAudio2(unsigned char* data) unsigned int CYSFPayload::processVoiceFRModeAudio2(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -815,7 +815,7 @@ unsigned int CYSFPayload::processVoiceFRModeAudio2(unsigned char* data)
unsigned int CYSFPayload::processVoiceFRModeAudio5(unsigned char* data) unsigned int CYSFPayload::processVoiceFRModeAudio5(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -832,7 +832,7 @@ unsigned int CYSFPayload::processVoiceFRModeAudio5(unsigned char* data)
bool CYSFPayload::processVoiceFRModeData(unsigned char* data) bool CYSFPayload::processVoiceFRModeData(unsigned char* data)
{ {
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -888,9 +888,9 @@ bool CYSFPayload::processVoiceFRModeData(unsigned char* data)
void CYSFPayload::writeHeader(unsigned char* data, const unsigned char* csd1, const unsigned char* csd2) void CYSFPayload::writeHeader(unsigned char* data, const unsigned char* csd1, const unsigned char* csd2)
{ {
assert(data != NULL); assert(data != nullptr);
assert(csd1 != NULL); assert(csd1 != nullptr);
assert(csd2 != NULL); assert(csd2 != nullptr);
writeDataFRModeData1(csd1, data); writeDataFRModeData1(csd1, data);
@ -899,8 +899,8 @@ void CYSFPayload::writeHeader(unsigned char* data, const unsigned char* csd1, co
void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* data) void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* data)
{ {
assert(dt != NULL); assert(dt != nullptr);
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -943,8 +943,8 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data) void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data)
{ {
assert(dt != NULL); assert(dt != nullptr);
assert(data != NULL); assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES; data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -1022,6 +1022,6 @@ void CYSFPayload::reset()
delete[] m_source; delete[] m_source;
delete[] m_dest; delete[] m_dest;
m_source = NULL; m_source = nullptr;
m_dest = NULL; m_dest = nullptr;
} }