blob: a0e07797e18605c8b930382a88cddb01f5bc6631 [file] [log] [blame]
Alexander Hansen46a755f2025-10-27 16:31:08 +01001// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright 2017 Google Inc
Patrick Venture863b9242018-03-08 08:29:23 -08003
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07004#include "sysfs/sysfsread.hpp"
5
Ed Tanousf8b6e552025-06-27 13:27:50 -07006#include "interfaces.hpp"
7
Patrick Venture863b9242018-03-08 08:29:23 -08008#include <chrono>
Ed Tanousf8b6e552025-06-27 13:27:50 -07009#include <cstdint>
Patrick Venture863b9242018-03-08 08:29:23 -080010#include <fstream>
11#include <iostream>
12
Patrick Venturea0764872020-08-08 07:48:43 -070013namespace pid_control
14{
15
Patrick Venture863b9242018-03-08 08:29:23 -080016ReadReturn SysFsRead::read(void)
17{
18 int64_t value;
19 std::ifstream ifs;
20
21 ifs.open(_path);
22 ifs >> value;
23 ifs.close();
24
Patrick Venture1df9e872020-10-08 15:35:01 -070025 ReadReturn r = {static_cast<double>(value),
26 std::chrono::high_resolution_clock::now()};
Patrick Venture863b9242018-03-08 08:29:23 -080027
28 return r;
29}
Patrick Venturea0764872020-08-08 07:48:43 -070030
31} // namespace pid_control