Fix build: SD.h includes, enum/macro collisions (HEX/INPUT), usb_host string stub, BAUDS link
This commit is contained in:
@@ -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("]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Understand any message format and generate valid protocol messages on the fly.
|
||||
|
||||
class MessageForge : public Module {
|
||||
enum Format { HEX, JSON, PROTOBUF, CUSTOM_BINARY, XML } format = HEX;
|
||||
enum Format { FMT_HEX, JSON, PROTOBUF, CUSTOM_BINARY, XML } format = FMT_HEX;
|
||||
uint32_t messagesForged = 0;
|
||||
uint32_t payloadsInjected = 0;
|
||||
char lastMessage[128] = "00 01 02 03 04 05";
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
void craftMessage() {
|
||||
messagesForged++;
|
||||
switch (format) {
|
||||
case HEX:
|
||||
case FMT_HEX:
|
||||
strncpy(lastMessage, "48 65 6c 6c 6f 20 57 6f 72 6c 64", 127);
|
||||
say("HEX: crafted %lu byte message", (unsigned long)(messagesForged * 11));
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../core/module.h"
|
||||
#include "../core/ui.h"
|
||||
#include <Preferences.h>
|
||||
#include <SD.h>
|
||||
|
||||
// Settings: persist scan speed, voltage thresholds, SD mount, timeouts, baud list.
|
||||
// Export/import config as JSON to SD.
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#include "../core/module.h"
|
||||
#include "../core/ui.h"
|
||||
#include "../core/pins.h"
|
||||
#include <SD.h>
|
||||
|
||||
// Enhanced UART: parallel auto-baudrate detection on multiple bauds,
|
||||
// protocol sniffing (Xmodem detect), full session logging to SD.
|
||||
|
||||
class UartPlus : public Module {
|
||||
static constexpr int NBAUDS = 6;
|
||||
static constexpr long BAUDS[NBAUDS] = {9600, 19200, 38400, 57600, 115200, 230400};
|
||||
static constexpr uint32_t BAUDS[NBAUDS] = {9600, 19200, 38400, 57600, 115200, 230400};
|
||||
|
||||
HardwareSerial& port = Serial1;
|
||||
int activeBaud = 4; // 115200
|
||||
@@ -104,4 +105,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
constexpr uint32_t UartPlus::BAUDS[NBAUDS];
|
||||
|
||||
Module* makeUartPlus() { return new UartPlus(); }
|
||||
|
||||
@@ -105,11 +105,8 @@ private:
|
||||
|
||||
void readString(uint8_t idx, const char* label) {
|
||||
if (!idx) return;
|
||||
usb_transfer_t* t = nullptr;
|
||||
// Minimal control-in for a string descriptor; best-effort.
|
||||
char out[24] = {0};
|
||||
if (usb_host_get_string_descriptor(dev, idx, 0x0409, (uint8_t*)out, sizeof(out)) == ESP_OK)
|
||||
say("%s: %s", label, out);
|
||||
// String-descriptor fetch requires a full control transfer; stubbed for now.
|
||||
say("%s: idx %u", label, idx);
|
||||
}
|
||||
|
||||
void teardown() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Filter by device class, log to /logs/usb_*.log with timestamps and raw hex.
|
||||
|
||||
class UsbSniffer : public Module {
|
||||
enum FilterType { ALL_DEVICES, STORAGE, INPUT, COMM } filter = ALL_DEVICES;
|
||||
enum FilterType { FLT_ALL, FLT_STORAGE, FLT_INPUT, FLT_COMM } filter = FLT_ALL;
|
||||
bool active = false;
|
||||
uint32_t packetCount = 0;
|
||||
uint32_t dataBytes = 0;
|
||||
|
||||
Reference in New Issue
Block a user