Skip to content

Commit

Permalink
add ip device reader
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Bauer <[email protected]>
  • Loading branch information
IgnoreWarnings committed Nov 20, 2024
1 parent 6f82ce3 commit 09b5eef
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions common/include/villas/kernel/devices/ip_device_reader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Devicetree reader which parses fpga ip devices from a filesystem path
*
* Author: Pascal Bauer <[email protected]>
*
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <filesystem>
#include <stdexcept>
#include <vector>

#include <villas/kernel/devices/ip_device.hpp>
#include <villas/utils.hpp>

class IpDeviceReader {
public:
std::vector<villas::kernel::devices::IpDevice>
read(std::filesystem::path devices_directory) const {
std::vector<villas::kernel::devices::IpDevice> devices;

const std::vector<std::string> 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;
}
};

0 comments on commit 09b5eef

Please sign in to comment.