diff --git a/common/include/villas/kernel/devices/ip_device_reader.hpp b/common/include/villas/kernel/devices/ip_device_reader.hpp new file mode 100644 index 000000000..c5b2085c1 --- /dev/null +++ b/common/include/villas/kernel/devices/ip_device_reader.hpp @@ -0,0 +1,38 @@ +/* Devicetree reader which parses fpga ip devices from a filesystem path + * + * Author: Pascal Bauer + * + * SPDX-FileCopyrightText: 2023-2024 Pascal Bauer + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include + +#include +#include + +class IpDeviceReader { +public: + std::vector + read(std::filesystem::path devices_directory) const { + std::vector devices; + + const std::vector devicetree_names = + villas::utils::read_names_in_directory(devices_directory); + + for (auto devicetree_name : devicetree_names) { + auto path_to_device = + devices_directory / std::filesystem::path(devicetree_name); + try { + auto device = villas::kernel::devices::IpDevice::from(path_to_device); + devices.push_back(device); + } catch (std::runtime_error &e) { + } + } + return devices; + } +}; \ No newline at end of file