Portduino logging enhancements (#3121)

* Portduino logging enhancements

* Extra debugging for SPI device
This commit is contained in:
Jonathan Bennett 2024-01-22 01:27:06 -06:00 committed by GitHub
parent 062c646814
commit 6b5101ec67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 15 deletions

View File

@ -95,3 +95,8 @@ Touchscreen:
Input: Input:
# KeyboardDevice: /dev/input/event0 # KeyboardDevice: /dev/input/event0
###
Logging:
# DebugMode: true

View File

@ -10,6 +10,10 @@
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
/** /**
* A printer that doesn't go anywhere * A printer that doesn't go anywhere
*/ */
@ -68,6 +72,10 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg)
size_t RedirectablePrint::log(const char *logLevel, const char *format, ...) size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
{ {
#ifdef ARCH_PORTDUINO
if (!settingsMap[debugmode] && strcmp(logLevel, "DEBUG") == 0)
return 0;
#endif
if (moduleConfig.serial.override_console_serial_port && strcmp(logLevel, "DEBUG") == 0) { if (moduleConfig.serial.override_console_serial_port && strcmp(logLevel, "DEBUG") == 0) {
return 0; return 0;
} }

View File

@ -717,6 +717,7 @@ void setup()
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
if (settingsMap[use_sx1262]) { if (settingsMap[use_sx1262]) {
if (!rIf) { if (!rIf) {
LOG_DEBUG("Attempting to activate sx1262 radio on SPI port %s\n", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]); settingsMap[busy]);
@ -730,6 +731,7 @@ void setup()
} }
} else if (settingsMap[use_rf95]) { } else if (settingsMap[use_rf95]) {
if (!rIf) { if (!rIf) {
LOG_DEBUG("Attempting to activate rf95 radio on SPI port %s\n", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]); settingsMap[busy]);
@ -744,6 +746,7 @@ void setup()
} }
} else if (settingsMap[use_sx1280]) { } else if (settingsMap[use_sx1280]) {
if (!rIf) { if (!rIf) {
LOG_DEBUG("Attempting to activate sx1280 radio on SPI port %s\n", settingsStrings[spidev].c_str());
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]); settingsMap[busy]);

View File

@ -81,6 +81,7 @@ void portduinoSetup()
YAML::Node yamlConfig; YAML::Node yamlConfig;
if (configPath != nullptr) { if (configPath != nullptr) {
std::cout << "Using " << configPath << " as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile(configPath); yamlConfig = YAML::LoadFile(configPath);
} catch (YAML::Exception e) { } catch (YAML::Exception e) {
@ -88,6 +89,7 @@ void portduinoSetup()
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if (access("config.yaml", R_OK) == 0) { } else if (access("config.yaml", R_OK) == 0) {
std::cout << "Using local config.yaml as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile("config.yaml"); yamlConfig = YAML::LoadFile("config.yaml");
} catch (YAML::Exception e) { } catch (YAML::Exception e) {
@ -95,6 +97,7 @@ void portduinoSetup()
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if (access("/etc/meshtasticd/config.yaml", R_OK) == 0) { } else if (access("/etc/meshtasticd/config.yaml", R_OK) == 0) {
std::cout << "Using /etc/meshtasticd/config.yaml as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml"); yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml");
} catch (YAML::Exception e) { } catch (YAML::Exception e) {
@ -105,24 +108,13 @@ void portduinoSetup()
std::cout << "No 'config.yaml' found, running simulated." << std::endl; std::cout << "No 'config.yaml' found, running simulated." << std::endl;
// Set the random seed equal to TCPPort to have a different seed per instance // Set the random seed equal to TCPPort to have a different seed per instance
randomSeed(TCPPort); randomSeed(TCPPort);
/* Aren't all pins defaulted to simulated?
auto fakeBusy = new SimGPIOPin(SX126X_BUSY, "fakeBusy");
fakeBusy->writePin(LOW);
fakeBusy->setSilent(true);
gpioBind(fakeBusy);
auto cs = new SimGPIOPin(SX126X_CS, "fakeLoraCS");
cs->setSilent(true);
gpioBind(cs);
gpioBind(new SimGPIOPin(SX126X_RESET, "fakeLoraReset"));
gpioBind(new SimGPIOPin(LORA_DIO1, "fakeLoraIrq"));
*/
return; return;
} }
try { try {
if (yamlConfig["Logging"]) {
settingsMap[debugmode] = yamlConfig["Logging"]["DebugMode"].as<bool>(false);
}
if (yamlConfig["Lora"]) { if (yamlConfig["Lora"]) {
settingsMap[use_sx1262] = false; settingsMap[use_sx1262] = false;
settingsMap[use_rf95] = false; settingsMap[use_rf95] = false;

View File

@ -31,7 +31,8 @@ enum configNames {
displayOffsetX, displayOffsetX,
displayOffsetY, displayOffsetY,
displayInvert, displayInvert,
keyboardDevice keyboardDevice,
debugmode
}; };
enum { no_screen, st7789, st7735, st7735s }; enum { no_screen, st7789, st7735, st7735s };
enum { no_touchscreen, xpt2046 }; enum { no_touchscreen, xpt2046 };