Fix build: SD.h includes, enum/macro collisions (HEX/INPUT), usb_host string stub, BAUDS link

This commit is contained in:
2026-09-24 20:24:00 -07:00
parent fd5eea5cd7
commit feae5d1066
6 changed files with 18 additions and 16 deletions

View File

@@ -2,6 +2,7 @@
#include "../core/ui.h"
#include "../core/pins.h"
#include <SPI.h>
#include <SD.h>
// CAN Bus sniffer. Listen on MCP2515 over SPI for OBD/automotive frames.
// Passive only; displays frame ID, DLC, data; logs to SD.
@@ -12,7 +13,7 @@ class CanSniff : public Module {
uint32_t fcount = 0, lastMs = 0;
uint8_t speed = 0; // 0=500k, 1=250k, 2=125k
char msg[3][40] = {{0},{0},{0}};
File log;
File logfile;
public:
const char* name() const override { return "CAN Bus"; }
@@ -23,7 +24,7 @@ public:
sdOk = SD.begin();
initMcp2515();
}
void onExit() override { running = false; if (log) log.close(); }
void onExit() override { running = false; if (logfile) logfile.close(); }
bool onKey(char c) override {
if (c == ' ') { running = !running; if (running) fcount = 0; return true; }
@@ -39,15 +40,15 @@ public:
uint32_t id = 0; uint8_t dlc = 0, data[8] = {0};
if (readFrame(id, dlc, data)) {
fcount++;
if (sdOk && !log) {
if (sdOk && !logfile) {
SD.mkdir("/logs");
log = SD.open("/logs/can.txt", FILE_APPEND);
logfile = SD.open("/logs/can.txt", FILE_APPEND);
}
if (log) log.printf("%08lX %d [", (unsigned long)id, dlc);
if (logfile) logfile.printf("%08lX %d [", (unsigned long)id, dlc);
for (int i = 0; i < dlc; i++) {
if (log) log.printf("%02X ", data[i]);
if (logfile) logfile.printf("%02X ", data[i]);
}
if (log) log.println("]");
if (logfile) logfile.println("]");
}
}