A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
test can module responsivness after config
Geoba1c55961aa8
diff --git a/src/Controllers/CanController.cpp b/src/Controllers/CanController.cppindex 6018ac25..2b170180 100644--- a/src/Controllers/CanController.cpp+++ b/src/Controllers/CanController.cpp@@ -197,8 +197,16 @@ void CanController::handleConfig() {terminalView.println("⚠️ Requested bitrate " + std::to_string(kbps) + " kbps is not supported. Using " + std::to_string(adjusted) + " kbps instead.");}+ // Apply configurationcanService.configure(cs, sck, so, si, kbps);- terminalView.println("CAN configured.\n");++ // Test MCP2515 responsiveness+ auto probeOk = canService.probe();+ if (!probeOk) {+ terminalView.println("\n ❌ MCP2515 CAN configuration failed. Please check your wiring.\n");+ return;+ }+ terminalView.println("\n ✅ MCP2515 CAN configured.\n");}/*diff --git a/src/Services/CanService.cpp b/src/Services/CanService.cppindex c020886b..9b698563 100644--- a/src/Services/CanService.cpp+++ b/src/Services/CanService.cpp@@ -188,4 +188,39 @@ uint32_t CanService::closestSupportedBitrate(uint32_t kbps) {}return best;-}\ No newline at end of file+}++bool CanService::probe() {+ // Loopback test+ if (mcp2515.setLoopbackMode() != MCP2515::ERROR_OK) return false;++ // Prepare a test frame+ struct can_frame f{};+ f.can_id = 0x123;+ f.can_dlc = 2;+ f.data[0] = 0xAA;+ f.data[1] = 0xAA;++ // Send a test frame+ if (mcp2515.sendMessage(&f) != MCP2515::ERROR_OK) {+ mcp2515.setNormalMode();+ return false;+ }++ // Receive it back+ unsigned long t0 = millis();+ while (millis() - t0 < 20) {+ if (mcp2515.checkReceive()) {+ struct can_frame rx{};+ if (mcp2515.readMessage(&rx) == MCP2515::ERROR_OK &&+ rx.can_id == f.can_id && rx.can_dlc == f.can_dlc &&+ rx.data[0] == f.data[0] && rx.data[1] == f.data[1]) {+ mcp2515.setNormalMode();+ return true; // CAN bus OK, we received what we sent+ }+ }+ delay(1);+ }+ mcp2515.setNormalMode();+ return false;+}diff --git a/src/Services/CanService.h b/src/Services/CanService.hindex 8c91214e..3c6e0e14 100644--- a/src/Services/CanService.h+++ b/src/Services/CanService.h@@ -29,6 +29,7 @@ public:void setMask(uint32_t mask);std::string getStatus();+ bool probe();private:CAN_SPEED resolveBitrate(uint32_t kbps);