Add more asserts to catch bugs.
This commit is contained in:
parent
14c6208ae5
commit
12fb99c00a
|
@ -16,6 +16,7 @@
|
||||||
#include "DMRCSBK.h"
|
#include "DMRCSBK.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) :
|
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) :
|
||||||
|
@ -38,6 +39,8 @@ CDMRControl::~CDMRControl()
|
||||||
|
|
||||||
bool CDMRControl::processWakeup(const unsigned char* data)
|
bool CDMRControl::processWakeup(const unsigned char* data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
// 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))
|
||||||
return false;
|
return false;
|
||||||
|
@ -65,21 +68,29 @@ bool CDMRControl::processWakeup(const unsigned char* data)
|
||||||
|
|
||||||
void CDMRControl::writeModemSlot1(unsigned char *data)
|
void CDMRControl::writeModemSlot1(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
m_slot1.writeModem(data);
|
m_slot1.writeModem(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDMRControl::writeModemSlot2(unsigned char *data)
|
void CDMRControl::writeModemSlot2(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
m_slot2.writeModem(data);
|
m_slot2.writeModem(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CDMRControl::readModemSlot1(unsigned char *data)
|
unsigned int CDMRControl::readModemSlot1(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
return m_slot2.readModem(data);
|
return m_slot2.readModem(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
const unsigned int BUFFER_LENGTH = 500U;
|
const unsigned int BUFFER_LENGTH = 500U;
|
||||||
|
|
|
@ -138,6 +138,8 @@ void CDMRLC::getData(unsigned char* bytes) const
|
||||||
|
|
||||||
void CDMRLC::getData(bool* bits) const
|
void CDMRLC::getData(bool* bits) const
|
||||||
{
|
{
|
||||||
|
assert(bits != NULL);
|
||||||
|
|
||||||
unsigned char bytes[9U];
|
unsigned char bytes[9U];
|
||||||
getData(bytes);
|
getData(bytes);
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,8 @@ 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);
|
||||||
|
|
||||||
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);
|
||||||
CUtils::byteToBitsBE(in[2U], m_rawData + 16U);
|
CUtils::byteToBitsBE(in[2U], m_rawData + 16U);
|
||||||
|
@ -131,6 +133,8 @@ 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);
|
||||||
|
|
||||||
bool bData[40U];
|
bool bData[40U];
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < 40U; i++)
|
for (unsigned int i = 0U; i < 40U; i++)
|
||||||
|
@ -156,6 +160,8 @@ void CDMRShortLC::decodeExtractData(unsigned char* data) const
|
||||||
// Extract the 36 bits of payload
|
// 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);
|
||||||
|
|
||||||
bool bData[40U];
|
bool bData[40U];
|
||||||
CUtils::byteToBitsBE(in[0U], bData + 0U);
|
CUtils::byteToBitsBE(in[0U], bData + 0U);
|
||||||
CUtils::byteToBitsBE(in[1U], bData + 8U);
|
CUtils::byteToBitsBE(in[1U], bData + 8U);
|
||||||
|
@ -208,6 +214,8 @@ void CDMRShortLC::encodeInterleave()
|
||||||
|
|
||||||
void CDMRShortLC::encodeExtractBinary(unsigned char* data)
|
void CDMRShortLC::encodeExtractBinary(unsigned char* data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
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]);
|
||||||
CUtils::bitsToByteBE(m_rawData + 16U, data[2U]);
|
CUtils::bitsToByteBE(m_rawData + 16U, data[2U]);
|
||||||
|
|
|
@ -84,6 +84,8 @@ CDMRSlot::~CDMRSlot()
|
||||||
|
|
||||||
void CDMRSlot::writeModem(unsigned char *data)
|
void CDMRSlot::writeModem(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
if (data[0U] == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
if (data[0U] == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
||||||
if (m_rfBits == 0U) m_rfBits = 1U;
|
if (m_rfBits == 0U) m_rfBits = 1U;
|
||||||
LogMessage("DMR Slot %u, RF transmission lost, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
|
LogMessage("DMR Slot %u, RF transmission lost, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));
|
||||||
|
@ -502,6 +504,8 @@ void CDMRSlot::writeModem(unsigned char *data)
|
||||||
|
|
||||||
unsigned int CDMRSlot::readModem(unsigned char* data)
|
unsigned int CDMRSlot::readModem(unsigned char* data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty())
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
|
@ -1055,6 +1059,8 @@ void CDMRSlot::clock(unsigned int ms)
|
||||||
|
|
||||||
void CDMRSlot::writeQueueRF(const unsigned char *data)
|
void CDMRSlot::writeQueueRF(const unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
if (m_netState != RS_NET_IDLE)
|
if (m_netState != RS_NET_IDLE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1115,6 +1121,8 @@ void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType)
|
||||||
|
|
||||||
void CDMRSlot::writeQueueNet(const unsigned char *data)
|
void CDMRSlot::writeQueueNet(const unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U;
|
unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U;
|
||||||
|
|
||||||
unsigned int space = m_queue.freeSpace();
|
unsigned int space = m_queue.freeSpace();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Sync.h"
|
#include "Sync.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
@ -88,6 +89,8 @@ CDStarControl::~CDStarControl()
|
||||||
|
|
||||||
bool CDStarControl::writeModem(unsigned char *data)
|
bool CDStarControl::writeModem(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
unsigned char type = data[0U];
|
unsigned char type = data[0U];
|
||||||
|
|
||||||
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
if (type == TAG_LOST && m_rfState == RS_RF_AUDIO) {
|
||||||
|
@ -343,6 +346,8 @@ bool CDStarControl::writeModem(unsigned char *data)
|
||||||
|
|
||||||
unsigned int CDStarControl::readModem(unsigned char* data)
|
unsigned int CDStarControl::readModem(unsigned char* data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty())
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
|
|
|
@ -82,51 +82,71 @@ void CDStarHeader::setUnavailable(bool on)
|
||||||
|
|
||||||
void CDStarHeader::getMyCall1(unsigned char* call1) const
|
void CDStarHeader::getMyCall1(unsigned char* call1) const
|
||||||
{
|
{
|
||||||
|
assert(call1 != NULL);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::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);
|
||||||
|
|
||||||
::memcpy(m_header + 19U, call, DSTAR_LONG_CALLSIGN_LENGTH);
|
::memcpy(m_header + 19U, call, DSTAR_LONG_CALLSIGN_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
Hamming.cpp
21
Hamming.cpp
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
||||||
|
@ -18,9 +18,14 @@
|
||||||
|
|
||||||
#include "Hamming.h"
|
#include "Hamming.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
// Hamming (15,11,3) check a boolean data array
|
// Hamming (15,11,3) check a boolean data array
|
||||||
bool CHamming::decode15113(bool* d)
|
bool CHamming::decode15113(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
// 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];
|
||||||
bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9];
|
bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9];
|
||||||
|
@ -60,6 +65,8 @@ bool CHamming::decode15113(bool* d)
|
||||||
|
|
||||||
void CHamming::encode15113(bool* d)
|
void CHamming::encode15113(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
// 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];
|
||||||
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];
|
||||||
|
@ -70,6 +77,8 @@ void CHamming::encode15113(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);
|
||||||
|
|
||||||
// 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];
|
||||||
bool c1 = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7];
|
bool c1 = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7];
|
||||||
|
@ -107,6 +116,8 @@ bool CHamming::decode1393(bool* d)
|
||||||
|
|
||||||
void CHamming::encode1393(bool* d)
|
void CHamming::encode1393(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
// 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];
|
||||||
d[10] = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7];
|
d[10] = d[0] ^ d[1] ^ d[2] ^ d[4] ^ d[6] ^ d[7];
|
||||||
|
@ -117,6 +128,8 @@ void CHamming::encode1393(bool* d)
|
||||||
// A Hamming (16,11,4) Check
|
// A Hamming (16,11,4) Check
|
||||||
bool CHamming::decode16114(bool* d)
|
bool CHamming::decode16114(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
// 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];
|
||||||
bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9];
|
bool c1 = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9];
|
||||||
|
@ -163,6 +176,8 @@ bool CHamming::decode16114(bool* d)
|
||||||
|
|
||||||
void CHamming::encode16114(bool* d)
|
void CHamming::encode16114(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8];
|
d[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];
|
||||||
d[13] = d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[7] ^ d[9] ^ d[10];
|
d[13] = d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[7] ^ d[9] ^ d[10];
|
||||||
|
@ -173,6 +188,8 @@ void CHamming::encode16114(bool* d)
|
||||||
// A Hamming (17,12,3) Check
|
// A Hamming (17,12,3) Check
|
||||||
bool CHamming::decode17123(bool* d)
|
bool CHamming::decode17123(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
// 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];
|
||||||
bool c1 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10];
|
bool c1 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10];
|
||||||
|
@ -220,6 +237,8 @@ bool CHamming::decode17123(bool* d)
|
||||||
|
|
||||||
void CHamming::encode17123(bool* d)
|
void CHamming::encode17123(bool* d)
|
||||||
{
|
{
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
d[12] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9];
|
d[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];
|
||||||
d[14] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[8] ^ d[9] ^ d[11];
|
d[14] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[8] ^ d[9] ^ d[11];
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
@ -858,6 +859,8 @@ bool CModem::setFrequency()
|
||||||
|
|
||||||
RESP_TYPE_MMDVM CModem::getResponse(unsigned char *buffer, unsigned int& length)
|
RESP_TYPE_MMDVM CModem::getResponse(unsigned char *buffer, unsigned int& length)
|
||||||
{
|
{
|
||||||
|
assert(buffer != NULL);
|
||||||
|
|
||||||
// Get the start of the frame or nothing at all
|
// Get the start of the frame or nothing at all
|
||||||
int ret = m_serial.read(buffer + 0U, 1U);
|
int ret = m_serial.read(buffer + 0U, 1U);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -65,8 +65,6 @@ bool CTFTSerial::open()
|
||||||
|
|
||||||
setRotation(ROTATION_LANDSCAPE);
|
setRotation(ROTATION_LANDSCAPE);
|
||||||
|
|
||||||
setFontSize(FONT_SMALL);
|
|
||||||
|
|
||||||
setBrightness(m_brightness);
|
setBrightness(m_brightness);
|
||||||
|
|
||||||
// Set background white
|
// Set background white
|
||||||
|
|
10
Utils.cpp
10
Utils.cpp
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX
|
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
||||||
|
@ -91,6 +91,8 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne
|
||||||
|
|
||||||
void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
|
void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
|
||||||
{
|
{
|
||||||
|
assert(bits != NULL);
|
||||||
|
|
||||||
bits[0U] = (byte & 0x80U) == 0x80U;
|
bits[0U] = (byte & 0x80U) == 0x80U;
|
||||||
bits[1U] = (byte & 0x40U) == 0x40U;
|
bits[1U] = (byte & 0x40U) == 0x40U;
|
||||||
bits[2U] = (byte & 0x20U) == 0x20U;
|
bits[2U] = (byte & 0x20U) == 0x20U;
|
||||||
|
@ -103,6 +105,8 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
|
||||||
|
|
||||||
void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
|
void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
|
||||||
{
|
{
|
||||||
|
assert(bits != NULL);
|
||||||
|
|
||||||
bits[0U] = (byte & 0x01U) == 0x01U;
|
bits[0U] = (byte & 0x01U) == 0x01U;
|
||||||
bits[1U] = (byte & 0x02U) == 0x02U;
|
bits[1U] = (byte & 0x02U) == 0x02U;
|
||||||
bits[2U] = (byte & 0x04U) == 0x04U;
|
bits[2U] = (byte & 0x04U) == 0x04U;
|
||||||
|
@ -115,6 +119,8 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
|
||||||
|
|
||||||
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
|
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
|
||||||
{
|
{
|
||||||
|
assert(bits != NULL);
|
||||||
|
|
||||||
byte = bits[0U] ? 0x80U : 0x00U;
|
byte = bits[0U] ? 0x80U : 0x00U;
|
||||||
byte |= bits[1U] ? 0x40U : 0x00U;
|
byte |= bits[1U] ? 0x40U : 0x00U;
|
||||||
byte |= bits[2U] ? 0x20U : 0x00U;
|
byte |= bits[2U] ? 0x20U : 0x00U;
|
||||||
|
@ -127,6 +133,8 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
|
||||||
|
|
||||||
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
|
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
|
||||||
{
|
{
|
||||||
|
assert(bits != NULL);
|
||||||
|
|
||||||
byte = bits[0U] ? 0x01U : 0x00U;
|
byte = bits[0U] ? 0x01U : 0x00U;
|
||||||
byte |= bits[1U] ? 0x02U : 0x00U;
|
byte |= bits[1U] ? 0x02U : 0x00U;
|
||||||
byte |= bits[2U] ? 0x04U : 0x00U;
|
byte |= bits[2U] ? 0x04U : 0x00U;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Sync.h"
|
#include "Sync.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
@ -58,6 +59,8 @@ CYSFControl::~CYSFControl()
|
||||||
|
|
||||||
bool CYSFControl::writeModem(unsigned char *data)
|
bool CYSFControl::writeModem(unsigned char *data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
unsigned char type = data[0U];
|
unsigned char type = data[0U];
|
||||||
|
|
||||||
if (type == TAG_LOST && m_state == RS_RF_AUDIO) {
|
if (type == TAG_LOST && m_state == RS_RF_AUDIO) {
|
||||||
|
@ -215,6 +218,8 @@ bool CYSFControl::writeModem(unsigned char *data)
|
||||||
|
|
||||||
unsigned int CYSFControl::readModem(unsigned char* data)
|
unsigned int CYSFControl::readModem(unsigned char* data)
|
||||||
{
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty())
|
||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue