Allow for hex dumps of modem data by the host.

This commit is contained in:
Jonathan Naylor 2021-04-11 18:15:19 +01:00
parent 1ad20fd4a0
commit 6ffb68450c
3 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2021 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,6 +27,7 @@
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
#define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d))
#define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e))
#define DEBUG_DUMP(a,b) serial.writeDebugDump((a),(b))
#endif

View File

@ -94,6 +94,7 @@ const uint8_t MMDVM_DEBUG2 = 0xF2U;
const uint8_t MMDVM_DEBUG3 = 0xF3U;
const uint8_t MMDVM_DEBUG4 = 0xF4U;
const uint8_t MMDVM_DEBUG5 = 0xF5U;
const uint8_t MMDVM_DEBUG_DUMP = 0xFAU;
#if EXTERNAL_OSC == 12000000
#define TCXO "12.0000 MHz"
@ -2049,3 +2050,29 @@ void CSerialPort::writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n
writeInt(1U, reply, count, true);
}
void CSerialPort::writeDebugDump(const uint8_t* data, uint16_t length)
{
uint8_t reply[512U];
reply[0U] = MMDVM_FRAME_START;
if (length > 252U) {
reply[1U] = 0U;
reply[2U] = (length + 4U) - 255U;
reply[3U] = MMDVM_DEBUG_DUMP;
for (uint8_t i = 0U; i < length; i++)
reply[i + 4U] = data[i];
writeInt(1U, reply, length + 4U);
} else {
reply[1U] = length + 3U;
reply[2U] = MMDVM_DEBUG_DUMP;
for (uint8_t i = 0U; i < length; i++)
reply[i + 3U] = data[i];
writeInt(1U, reply, length + 3U);
}
}

View File

@ -97,6 +97,7 @@ public:
void writeDebug(const char* text, int16_t n1, int16_t n2);
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3);
void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4);
void writeDebugDump(const uint8_t* data, uint16_t length);
private:
uint8_t m_buffer[512U];