Compare commits

..

3 Commits

Author SHA1 Message Date
cb8cfd6da8 I forgot about the CMakeFile 2026-03-10 17:08:09 +01:00
159d55c2a2 feat: declared skeleton of sysfsRead.hpp 2026-03-10 17:02:34 +01:00
fabcf5a146 feat: declared enum class 2026-03-10 17:00:50 +01:00
3 changed files with 65 additions and 0 deletions

20
CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
# 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)

40
include/SysfsRead.hpp Normal file
View File

@ -0,0 +1,40 @@
// 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.
};

View File

@ -0,0 +1,5 @@
#include <gtest/gtest.h>
#include <fstream>
#include "SysfsRead.hpp"