mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactor ip_device_reader
This commit is contained in:
parent
7fe15cbd05
commit
aedeca5c3b
2 changed files with 11 additions and 10 deletions
|
@ -20,21 +20,22 @@
|
|||
|
||||
class IpDeviceReader {
|
||||
public:
|
||||
const std::vector<std::string> devicetree_names;
|
||||
std::vector<villas::kernel::devices::IpDevice> devices;
|
||||
std::vector<villas::kernel::devices::IpDevice>
|
||||
read(std::filesystem::path devices_directory) const {
|
||||
std::vector<villas::kernel::devices::IpDevice> devices;
|
||||
|
||||
IpDeviceReader(std::filesystem::path devices_directory)
|
||||
: devicetree_names(
|
||||
villas::kernel::devices::utils::read_names_in_directory(
|
||||
devices_directory)) {
|
||||
for (auto devicetree_name : this->devicetree_names) {
|
||||
const std::vector<std::string> devicetree_names =
|
||||
villas::kernel::devices::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);
|
||||
this->devices.push_back(device);
|
||||
devices.push_back(device);
|
||||
} catch (std::runtime_error &e) {
|
||||
}
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -39,8 +39,8 @@ void PlatformCard::connectVFIOtoIps(
|
|||
// Read devices from Devicetree
|
||||
const std::filesystem::path PLATFORM_DEVICES_DIRECTORY(
|
||||
"/sys/bus/platform/devices");
|
||||
auto dtr = IpDeviceReader(PLATFORM_DEVICES_DIRECTORY);
|
||||
std::vector<IpDevice> devices = dtr.devices;
|
||||
std::vector<IpDevice> devices =
|
||||
IpDeviceReader().read(PLATFORM_DEVICES_DIRECTORY);
|
||||
|
||||
// Match devices and ips
|
||||
DeviceIpMatcher matcher(devices, configuredIps);
|
||||
|
|
Loading…
Add table
Reference in a new issue