conexus logo

tty.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the conexus library.                             *
00006  *                                                                         *
00007  *   The conexus library is free software; you can redistribute it and/or  *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The conexus library is distributed in the hope that it will be        *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
00018  ***************************************************************************/
00019 #ifndef CONEXUSTTY_H
00020 #define CONEXUSTTY_H
00021 
00022 #include <conexus/serial.h>
00023 
00024 #include <termios.h>
00025 #include <unistd.h>
00026 
00032 namespace Conexus
00033 {
00034 
00044   class TTY : public Serial
00045   {
00046     protected:
00047 
00059       TTY( const std::string& device = std::string(), ReadWrite rwmode = READ_WRITE );
00060 
00061     public:
00062 
00063       typedef ConexusPointer<TTY> pointer;
00064 
00065       CONEXUS_ENDPOINT_GENERIC_CREATE();
00066 
00067       static TTY::pointer create( const std::string& device = std::string(), ReadWrite rwmode = READ_WRITE );
00068 
00069       virtual ~TTY();
00070 
00074       void drain();
00075 
00079       void flush_input();
00080 
00084       void flush_output();
00085 
00090       void flush();
00091 
00095       void suspend_output();
00096 
00100       void restart_output();
00101 
00105       void suspend_input();
00106 
00110       void restart_input();
00111 
00149       void set_input_speed( unsigned speed, SetOption option = SET_NOW );
00150 
00152       void set_output_speed( unsigned speed, SetOption option = SET_NOW );
00153 
00155       void set_speed( unsigned speed, SetOption option = SET_NOW );
00156 
00158       unsigned input_speed();
00159 
00161       unsigned output_speed();
00162 
00164       void set_parity( Parity parity, ParityError error = PARITY_ERROR_IGNORE, SetOption option = SET_NOW );
00165 
00167       Parity parity();
00168 
00170       ParityError parity_error();
00171 
00173       unsigned byte_size();
00174 
00184       void set_byte_size( unsigned size, SetOption option = SET_NOW );
00185 
00187       unsigned stop_bits();
00188 
00190       void set_stop_bits( unsigned size, SetOption option = SET_NOW );
00191 
00193       FlowControl flow_control();
00194 
00199       void set_flow_control( FlowControl flowcontrol, SetOption option = SET_NOW );
00200 
00202       bool carrier_detect_enabled();
00203 
00212       void set_carrier_detect( bool enable = true, SetOption option = SET_NOW );
00213 
00218       bool receiver_enabled();
00219 
00224       void set_receiver_enabled( bool enable = true, SetOption option = SET_NOW );
00225 
00226       virtual void open() throw ( open_exception );
00227 
00229       virtual void open( const std::string& name, ReadWrite mode = READ_WRITE_UNCHANGED ) throw ( open_exception );
00230 
00232       virtual void close( bool force = false ) throw ( close_exception );
00233 
00237       void set_input_modes( tcflag_t iflag, SetOption option = SET_NOW );
00238 
00242       void set_output_modes( tcflag_t oflag, SetOption option = SET_NOW );
00243 
00247       void set_control_modes( tcflag_t cflag, SetOption option = SET_NOW );
00248 
00252       void set_local_modes( tcflag_t lflag, SetOption option = SET_NOW );
00253 
00257       void set_control_characters( int index, cc_t value, SetOption option = SET_NOW );
00258 
00262       struct termios attributes();
00263 
00267       void inject( char data );
00268 
00272       void inject( const char* buffer, size_t bufsize );
00273 
00277       void inject( const std::string& buffer );
00278 
00280       bool reset_on_close();
00281 
00283       void set_reset_on_close( bool reset = true );
00284 
00285       sigc::signal<void> signal_input_speed();
00286       sigc::signal<void> signal_output_speed();
00287       sigc::signal<void> signal_parity();
00288       sigc::signal<void> signal_byte_size();
00289       sigc::signal<void> signal_stop_bits();
00290       sigc::signal<void> signal_flow_control();
00291       sigc::signal<void> signal_carrier_detect();
00292       sigc::signal<void> signal_receiver();
00293 
00294       virtual size_t input_available() throw();
00295 
00296     protected:
00297       struct termios m_termios, m_origtermios;
00298       bool m_reset_on_close;
00299 
00300       sigc::signal<void> m_signal_input_speed;
00301       sigc::signal<void> m_signal_output_speed;
00302       sigc::signal<void> m_signal_parity;
00303       sigc::signal<void> m_signal_byte_size;
00304       sigc::signal<void> m_signal_stop_bits;
00305       sigc::signal<void> m_signal_flow_control;
00306       sigc::signal<void> m_signal_carrier_detect;
00307       sigc::signal<void> m_signal_receiver;
00308 
00309       void tcsetattr( SetOption option );
00310 
00311       speed_t unsigned2speed( unsigned speed );
00312       unsigned speed2unsigned( speed_t speed );
00313 
00314   };
00315 
00316 }
00317 
00318 #endif

Generated on Tue Jun 9 10:01:56 2009 for conexus by doxygen 1.5.7.1