Compare commits
No commits in common. "cb8cfd6da87eca57ee735a73f5e63dcfba16f919" and "409ee7aa359cf614ec5a3d22f6dc912a02851736" have entirely different histories.
cb8cfd6da8
...
409ee7aa35
@ -1,20 +0,0 @@
|
||||
# Root cmake file sketch (might change it later)
|
||||
# Author: Unai Blazquez
|
||||
# License: GPL-3-or-later
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(azkoyen_ipc_test LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Core library
|
||||
add_library(core
|
||||
src/core/SysfsRead.cxx
|
||||
)
|
||||
|
||||
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
#tests
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
@ -1,40 +0,0 @@
|
||||
// SysfsRead.hpp
|
||||
//
|
||||
// SPDX-License-Identifier GPL-3.0-or-later
|
||||
// Author: Unai Blazquez Gomez <unaibg2000@gmail.com>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
enum class SysfsStatus
|
||||
{
|
||||
/// @brief File cannot be opened or does not exist.
|
||||
Unreachable,
|
||||
/// @brief File exists but is just empty.
|
||||
Empty,
|
||||
/// @brief File content indicates taht production is enabled (e.g. "1")
|
||||
Enabled,
|
||||
/// @brief File requests a cooldown ("error: temp too high")
|
||||
ErrorTempTooHigh,
|
||||
/// @brief File contains an UnexpectedValue; producer must not send.
|
||||
UnexpectedValue
|
||||
};
|
||||
|
||||
class SysfsReader
|
||||
{
|
||||
public:
|
||||
/// @brief Construct a SysfsReader bound to a specific input file path.
|
||||
/// @param input_path Path to the sysfs-like input file.
|
||||
explicit SysfsReader(const std::filesystem::path& input_path);
|
||||
|
||||
/// @brief Read and interpret the current status of the input file.
|
||||
///
|
||||
/// This function never throws on common I/O errors; instead it reports them
|
||||
/// via the SysfsStatus enum.
|
||||
/// @return Interpreted status of the input file
|
||||
SysfsStatus read_status() const;
|
||||
|
||||
private:
|
||||
std::filesystem::path m_path; // Path to the input file.
|
||||
};
|
||||
@ -1,5 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "SysfsRead.hpp"
|
||||
Loading…
x
Reference in New Issue
Block a user