00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file TTY_IO.h 00006 * 00007 * TTY_IO.h,v 4.29 2006/02/22 17:33:13 olli Exp 00008 * 00009 * @author Douglas C. Schmidt <schmidt@uci.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_TTY_IO_H 00014 #define ACE_TTY_IO_H 00015 00016 #include "ace/DEV_IO.h" 00017 00018 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00019 # pragma once 00020 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00021 00022 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00023 00024 /** 00025 * @class ACE_TTY_IO 00026 * 00027 * @brief Class definitions for platform specific TTY features. 00028 * 00029 * This class represents an example interface for a specific 00030 * device (a serial line). It extends the capability of the 00031 * underlying DEV_IO class by adding a control method that takes 00032 * a special structure (Serial_Params) as argument to allow a 00033 * comfortable user interface (away from that annoying termios 00034 * structure, which is very specific to UNIX). 00035 */ 00036 class ACE_Export ACE_TTY_IO : public ACE_DEV_IO 00037 { 00038 public: 00039 enum Control_Mode 00040 { 00041 SETPARAMS, ///< Set control parameters. 00042 GETPARAMS ///< Get control parameters. 00043 }; 00044 00045 struct ACE_Export Serial_Params 00046 { 00047 Serial_Params (void); 00048 00049 /** Specifies the baudrate at which the communnication port operates. */ 00050 int baudrate; 00051 /** Specifies the minimum number of bytes in input buffer before XON char 00052 is sent. Negative value indicates that default value should 00053 be used (Win32). */ 00054 int xonlim; 00055 /** Specifies the maximum number of bytes in input buffer before XOFF char 00056 is sent. Negative value indicates that default value should 00057 be used (Win32). */ 00058 int xofflim; 00059 /** Specifies the minimum number of characters for non-canonical 00060 read (POSIX). */ 00061 unsigned int readmincharacters; 00062 /** Specifies the time to wait before returning from read. Negative value 00063 means infinite timeout. */ 00064 int readtimeoutmsec; 00065 /** Enable/disable parity checking. */ 00066 bool parityenb; 00067 /** Specifies the parity mode. POSIX supports "even" and "odd" parity. 00068 Additionally Win32 supports "mark" and "space" parity modes. */ 00069 const char *paritymode; 00070 /** Enable & set CTS mode. Note that RTS & CTS are enabled/disabled 00071 together on some systems (RTS/CTS is enabled if either 00072 <code>ctsenb</code> or <code>rtsenb</code> is set). */ 00073 bool ctsenb; 00074 /** Enable & set RTS mode. Note that RTS & CTS are enabled/disabled 00075 together on some systems (RTS/CTS is enabled if either 00076 <code>ctsenb</code> or <code>rtsenb</code> is set). 00077 - 0 = Disable RTS. 00078 - 1 = Enable RTS. 00079 - 2 = Enable RTS flow-control handshaking (Win32). 00080 - 3 = Specifies that RTS line will be high if bytes are available 00081 for transmission. After transmission RTS will be low (Win32). */ 00082 int rtsenb; 00083 /** Enable/disable software flow control on input. */ 00084 bool xinenb; 00085 /** Enable/disable software flow control on output. */ 00086 bool xoutenb; 00087 /** Specifies if device is a modem (POSIX). If not set modem status 00088 lines are ignored. */ 00089 bool modem; 00090 /** Enable/disable receiver (POSIX). */ 00091 bool rcvenb; 00092 /** Controls whether DSR is disabled or enabled (Win32). */ 00093 bool dsrenb; 00094 /** Controls whether DTR is disabled or enabled. */ 00095 bool dtrdisable; 00096 /** Data bits. Valid values 5, 6, 7 and 8 data bits. 00097 Additionally Win32 supports 4 data bits. */ 00098 unsigned char databits; 00099 /** Stop bits. Valid values are 1 and 2. */ 00100 unsigned char stopbits; 00101 }; 00102 00103 /** Interface for reading/writing serial device parameters. */ 00104 int control (Control_Mode cmd, Serial_Params *arg) const; 00105 00106 #if defined (ACE_NEEDS_DEV_IO_CONVERSION) 00107 /** This is necessary to pass ACE_TTY_IO as parameter to DEV_Connector. */ 00108 operator ACE_DEV_IO &(); 00109 #endif /* ACE_NEEDS_DEV_IO_CONVERSION */ 00110 }; 00111 00112 ACE_END_VERSIONED_NAMESPACE_DECL 00113 00114 #endif /* ACE_TTY_IO_H */