Add raw packet output to portduino trace logging.

This commit is contained in:
Jonathan Bennett 2024-11-01 00:17:41 -05:00
parent 9cacf1e9fd
commit 954859c2aa
2 changed files with 16 additions and 9 deletions

View File

@ -11,6 +11,10 @@
#include <pb_decode.h> #include <pb_decode.h>
#include <pb_encode.h> #include <pb_encode.h>
#if ARCH_PORTDUINO
#include "PortduinoGlue.h"
#include "meshUtils.h"
#endif
void LockingArduinoHal::spiBeginTransaction() void LockingArduinoHal::spiBeginTransaction()
{ {
spiLock->lock(); spiLock->lock();
@ -390,6 +394,11 @@ void RadioLibInterface::handleReceiveInterrupt()
#endif #endif
int state = iface->readData((uint8_t *)&radioBuffer, length); int state = iface->readData((uint8_t *)&radioBuffer, length);
#if ARCH_PORTDUINO
if (settingsMap[logoutputlevel] == level_trace) {
printBytes("Raw incoming packet: ", (uint8_t *)&radioBuffer, length);
}
#endif
if (state != RADIOLIB_ERR_NONE) { if (state != RADIOLIB_ERR_NONE) {
LOG_ERROR("ignoring received packet due to error=%d", state); LOG_ERROR("ignoring received packet due to error=%d", state);
rxBad++; rxBad++;

View File

@ -61,7 +61,6 @@ char *strnstr(const char *s, const char *find, size_t slen)
void printBytes(const char *label, const uint8_t *p, size_t numbytes) void printBytes(const char *label, const uint8_t *p, size_t numbytes)
{ {
int labelSize = strlen(label); int labelSize = strlen(label);
if (labelSize < 100 && numbytes < 64) {
char *messageBuffer = new char[labelSize + (numbytes * 3) + 2]; char *messageBuffer = new char[labelSize + (numbytes * 3) + 2];
strncpy(messageBuffer, label, labelSize); strncpy(messageBuffer, label, labelSize);
for (size_t i = 0; i < numbytes; i++) for (size_t i = 0; i < numbytes; i++)
@ -69,7 +68,6 @@ void printBytes(const char *label, const uint8_t *p, size_t numbytes)
strcpy(messageBuffer + labelSize + numbytes * 3, "\n"); strcpy(messageBuffer + labelSize + numbytes * 3, "\n");
LOG_DEBUG(messageBuffer); LOG_DEBUG(messageBuffer);
delete[] messageBuffer; delete[] messageBuffer;
}
} }
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes) bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)