DK
Size: a a a
DK
AF
AF
DK
FS
FS
FS
МВ
/sys/class/tty
и если папка содержит файл device
- добавляю в результатstd::vector<Device> devices;данное решение выдает ttyS* и ttyUSB*.
std::filesystem::path syspath(SYSTEM_CLASS_PATH);
std::filesystem::path dev_path(DEV_PATH);
for (auto dir: std::filesystem::directory_iterator(syspath))
{
if (dir.is_directory()) {
std::filesystem::directory_entry device_link(dir.path() / "device");
if (device_link.exists()) {
auto p = dir.path();
auto name = p.filename();
auto serial_path = dev_path / name;
std::filesystem::directory_entry serial(serial_path);
if (serial.exists()) devices.emplace_back(serial_path.string(), std::move(name));
}
}
}
return devices;
СА
FS
МВ
/sys/class/tty
и если папка содержит файл device
- добавляю в результатstd::vector<Device> devices;данное решение выдает ttyS* и ttyUSB*.
std::filesystem::path syspath(SYSTEM_CLASS_PATH);
std::filesystem::path dev_path(DEV_PATH);
for (auto dir: std::filesystem::directory_iterator(syspath))
{
if (dir.is_directory()) {
std::filesystem::directory_entry device_link(dir.path() / "device");
if (device_link.exists()) {
auto p = dir.path();
auto name = p.filename();
auto serial_path = dev_path / name;
std::filesystem::directory_entry serial(serial_path);
if (serial.exists()) devices.emplace_back(serial_path.string(), std::move(name));
}
}
}
return devices;
СА
МВ
FS
FS
МВ
q
static std::size_t nextID;
std::size_t ID;
ID = nextID++;
МВ
static std::size_t nextID;
std::size_t ID;
ID = nextID++;
МВ
static std::size_t nextID;
std::size_t ID;
ID = nextID++;
МВ