diff options
Diffstat (limited to 'gui/stmdsp.cpp')
-rw-r--r-- | gui/stmdsp.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gui/stmdsp.cpp b/gui/stmdsp.cpp new file mode 100644 index 0000000..267bebc --- /dev/null +++ b/gui/stmdsp.cpp @@ -0,0 +1,31 @@ +#include "stmdsp.hpp" + +#include <chrono> +#include <filesystem> +#include <thread> + +using namespace std::chrono_literals; + +namespace stmdsp +{ + void scanner::scan() + { + std::string path ("/dev/ttyACM0"); + + for (unsigned int i = 0; i < 10; i++) { + path.back() = '0' + i; + if (std::filesystem::exists(path)) { + if (device dev (path); dev.open()) { + dev.write("i", 1); + std::this_thread::sleep_for(1s); + char buf[7]; + if (dev.read(buf, 6) == 6) { + buf[6] = '\0'; + if (std::string(buf) == "stmdsp") + m_devices.emplace(std::move(dev)); + } + } + } + } + } +} |