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