xref: /openbmc/phosphor-pid-control/sysfs/sysfsread.cpp (revision 46a755fce8dc0bdd9c0c5ea09d55d3e5494f335f)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright 2017 Google Inc
3 
4 #include "sysfs/sysfsread.hpp"
5 
6 #include "interfaces.hpp"
7 
8 #include <chrono>
9 #include <cstdint>
10 #include <fstream>
11 #include <iostream>
12 
13 namespace pid_control
14 {
15 
read(void)16 ReadReturn SysFsRead::read(void)
17 {
18     int64_t value;
19     std::ifstream ifs;
20 
21     ifs.open(_path);
22     ifs >> value;
23     ifs.close();
24 
25     ReadReturn r = {static_cast<double>(value),
26                     std::chrono::high_resolution_clock::now()};
27 
28     return r;
29 }
30 
31 } // namespace pid_control
32