-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pascal Bauer <[email protected]>
- Loading branch information
1 parent
6f82ce3
commit 09b5eef
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |