µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
tty.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2017-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#if defined(OS_USE_OS_APP_CONFIG_H)
13#include <cmsis-plus/os-app-config.h>
14#endif
15
17
19
20// ----------------------------------------------------------------------------
21
22#if defined(__clang__)
23#pragma clang diagnostic ignored "-Wc++98-compat"
24#endif
25
26// ----------------------------------------------------------------------------
27
28namespace os
29{
30 namespace posix
31 {
32 // ========================================================================
33
34 tty::tty (tty_impl& impl, const char* name) : char_device{ impl, name }
35 {
36 type_ |= static_cast<type_t> (type::tty);
37#if defined(OS_TRACE_POSIX_IO_TTY)
38 trace::printf ("tty::%s(\"%s\")=@%p\n", __func__, name_, this);
39#endif
40 }
41
42 tty::~tty () noexcept
43 {
44#if defined(OS_TRACE_POSIX_IO_TTY)
45 trace::printf ("tty::%s() @%p %s\n", __func__, this, name_);
46#endif
47 }
48
49 // ------------------------------------------------------------------------
50
51 inline int
52 tty::tcsendbreak (int duration)
53 {
54 return impl ().do_tcsendbreak (duration);
55 }
56
57 inline int
58 tty::tcgetattr (/* struct */ termios* ptio)
59 {
60 return impl ().do_tcgetattr (ptio);
61 }
62
63 inline int
64 tty::tcsetattr (int options, const /* struct */ termios* ptio)
65 {
66 return impl ().do_tcsetattr (options, ptio);
67 }
68
69 inline int
70 tty::tcflush (int queue_selector)
71 {
72 return impl ().do_tcflush (queue_selector);
73 }
74
75 inline int
77 {
78 return impl ().do_tcdrain ();
79 }
80
81 // ========================================================================
82
84 {
85#if defined(OS_TRACE_POSIX_IO_TTY)
86 trace::printf ("tty_impl::%s()=@%p\n", __func__, this);
87#endif
88 }
89
91 {
92#if defined(OS_TRACE_POSIX_IO_TTY)
93 trace::printf ("tty_impl::%s() @%p\n", __func__, this);
94#endif
95 }
96
97 int
99 {
100 return 1; // Yes!
101 }
102
103 // ========================================================================
104 } /* namespace posix */
105} /* namespace os */
106
107// ----------------------------------------------------------------------------
Char device class.
Definition char-device.h:52
unsigned int type_t
Definition io.h:125
virtual ~tty_impl() override
Definition tty.cpp:90
virtual int do_tcsendbreak(int duration)=0
virtual int do_tcgetattr(termios *ptio)=0
virtual int do_tcflush(int queue_selector)=0
virtual int do_isatty(void) final
Definition tty.cpp:98
virtual int do_tcsetattr(int options, const termios *ptio)=0
virtual int do_tcdrain(void)=0
virtual int tcdrain(void)
Definition tty.cpp:76
virtual int tcsendbreak(int duration)
Definition tty.cpp:52
virtual int tcgetattr(termios *ptio)
Definition tty.cpp:58
virtual int tcflush(int queue_selector)
Definition tty.cpp:70
virtual int tcsetattr(int options, const termios *ptio)
Definition tty.cpp:64
tty_impl & impl(void) const
Definition tty.h:296
virtual ~tty() noexcept override
Definition tty.cpp:42
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59
System namespace.