phase 2 serial

This commit is contained in:
flower_linux
2026-06-12 18:34:49 +08:00
parent 0cf0713dc5
commit 628ccf1409
78 changed files with 2571 additions and 345 deletions

27
tools/modbus_scanner.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::string port = "/dev/ttyUSB0";
int baud = 9600;
int slaveStart = 1;
int slaveEnd = 10;
for (int i = 1; i < argc; ++i) {
const std::string arg = argv[i];
if (arg == "--port" && i + 1 < argc) {
port = argv[++i];
} else if (arg == "--baud" && i + 1 < argc) {
baud = std::stoi(argv[++i]);
} else if (arg == "--slave-start" && i + 1 < argc) {
slaveStart = std::stoi(argv[++i]);
} else if (arg == "--slave-end" && i + 1 < argc) {
slaveEnd = std::stoi(argv[++i]);
}
}
std::cout << "modbus_scanner: draft output for physical_devices.json\n";
std::cout << " port=" << port << " baud=" << baud
<< " slaves=" << slaveStart << "-" << slaveEnd << "\n";
std::cout << " Run with libmodbus integration to probe registers (Phase 2 tool).\n";
return 0;
}