1#include "../include/menu_handler.h"
22 m_menu->draw_viewer_menu();
25 if (ImGui::CollapsingHeader(
"Set USB Ports", ImGuiTreeNodeFlags_DefaultOpen))
32 static std::vector<std::string> choices;
34 static int left_exo_idx_choise = 0;
35 static int right_exo_idx_choise = 0;
38 ImGui::Combo(
"Left exoskeleton", &left_exo_idx_choise,
42 ImGui::Combo(
"Right exoskeleton", &right_exo_idx_choise,
45 if (ImGui::Button(
"OK"))
62 std::vector<std::string> ports;
65 std::string usb_path(
"/dev/");
66 std::string key(
"tty");
67 for (
const auto & entry : std::filesystem::directory_iterator(usb_path))
70 std::string path_string = entry.path().string();
73 if (path_string.find(key) != std::string::npos)
75 ports.push_back(path_string);
80 std::vector<std::string> available_ports;
83 for (
size_t i = 0; i < ports.size(); i++)
85 int serial_port = open(ports.at(i).c_str(), O_RDWR);
88 if(tcgetattr(serial_port, &tty) == 0) {
89 available_ports.push_back(ports.at(i));
95 return available_ports;
std::string m_right_exoskeleton_port
Name of the right exoskeleton USB port.
std::vector< std::string > get_available_usb_ports(void)
Get available USB ports.
igl::opengl::glfw::imgui::ImGuiMenu * m_menu
ImGui menu handle pointer.
void callback(void)
Menu callback function.
bool m_ports_set
Flag that stores the state of the USB port (whether are set or not).
std::string m_left_exoskeleton_port
Name of the left exoskeleton USB port.
MenuHandler(igl::opengl::glfw::imgui::ImGuiMenu *menu)
Constructor.