Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

control pin range for dio (0-48)

Geoe300548080e2
diff --git a/src/Controllers/DioController.cpp b/src/Controllers/DioController.cpp
index cf6a4836..cf860b12 100644
--- a/src/Controllers/DioController.cpp
+++ b/src/Controllers/DioController.cpp
@@ -447,9 +447,21 @@ void DioController::handleHelp() {
bool DioController::isPinAllowed(uint8_t pin, const std::string& context) {
const auto& protectedPins = state.getProtectedPins();
+
if (std::find(protectedPins.begin(), protectedPins.end(), pin) != protectedPins.end()) {
terminalView.println("DIO " + context + ": Pin " + std::to_string(pin) + " is protected and cannot be used.");
return false;
}
+
+ if (pin > 48 /* max pin for S3 */) {
+ terminalView.println("DIO " + context + ": Pin " + std::to_string(pin) + " is out of range (0-48).");
+ return false;
+ }
+
+ if (pin < 0) {
+ terminalView.println("DIO " + context + ": Pin " + std::to_string(pin) + " is invalid.");
+ return false;
+ }
+
return true;
}
\ No newline at end of file