oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
console.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
14#pragma once
15
16#include <ove/console.h>
17#include <ove/types.hpp>
18#include <ove/error.hpp>
19
20#ifdef CONFIG_OVE_CONSOLE
21
22namespace ove::console
23{
24
38[[nodiscard]] inline Result<void> init() noexcept
39{
40 return from_rc(ove_console_init());
41}
42
43/* Some C libraries (NuttX, glibc) define getchar/putchar as macros;
44 undefine them so the C++ inline wrappers compile cleanly. */
45#ifdef getchar
46#undef getchar
47#endif
48#ifdef putchar
49#undef putchar
50#endif
51
57inline int getchar()
58{
59 return ove_console_getchar();
60}
61
66inline void putchar(int c)
67{
68 ove_console_putchar(c);
69}
70
76inline void write(const char *data, unsigned int len)
77{
78 ove_console_write(data, len);
79}
80
81} /* namespace ove::console */
82
83#endif /* CONFIG_OVE_CONSOLE */
Strong ove::Error type, Result<T> alias, and std::error_code interop for the oveRTOS C++ binding.
Thin C++ wrappers around the oveRTOS console (serial I/O) API.
Definition console.hpp:23
void write(const char *data, unsigned int len)
Writes a buffer of bytes to the console output.
Definition console.hpp:76
int getchar()
Reads one character from the console, blocking until one is available.
Definition console.hpp:57
void putchar(int c)
Writes a single character to the console output.
Definition console.hpp:66
Result< void > init() noexcept
Initialises the console subsystem.
Definition console.hpp:38
Result< void > from_rc(int rc) noexcept
Lifts a substrate rc-code into a Result<void>.
Definition error.hpp:254
std::expected< T, Error > Result
std::expected-based result alias.
Definition error.hpp:139
Common type definitions and concepts for the C++ wrapper layer.