summaryrefslogtreecommitdiff
path: root/ace/TTY_IO.h
blob: e716aebe741c41d53c87a27a0b776fb321f3d5b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    TTY_IO.h
 *
 *  $Id$
 *
 *  @author Douglas C. Schmidt <schmidt@uci.edu>
 */
//=============================================================================


#ifndef ACE_TTY_IO_H
#define ACE_TTY_IO_H

#include "ace/OS.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/DEV_Addr.h"
#include "ace/DEV_Connector.h"
#include "ace/DEV_IO.h"

/**
 * @class ACE_TTY_IO
 *
 * @brief Class definitions for platform specific TTY features.
 *
 * This class represents an example interface for a specific
 * device (a serial line) It extends the capability of the
 * underlying DEV_IO class by adding a control method that takes
 * a special structure (Serial_Params) as argument to allow a
 * comfortable user interface (away from that annoying termios
 * structure, which is very specific to UNIX).
 */
class ACE_Export ACE_TTY_IO : public ACE_DEV_IO
{
public:
  enum Control_Mode
  {
    /// Set control parameters.
    SETPARAMS,
    /// Get control parameters.
    GETPARAMS
  };

  struct Serial_Params
  {
    // Common params
    int baudrate;
    int parityenb;
    const char *paritymode;
    int databits;
    int stopbits;
    int readtimeoutmsec;
    int ctsenb;  // CTS & RTS are the same under unix
    int rtsenb;  // enable & set rts mode (win32)
    int xinenb;  // enable xon/xoff  reception
    int xoutenb;  // enable xon/xoff transmission

    // Posix - unix variant
    int modem;
    int rcvenb;

    //Win32
    int xonlim;  // min bytes in input buffer before xon
    int xofflim; // max bytes in input buffer before xoff
  };

  /// Interface for reading/writing serial device parameters.
  int control (Control_Mode cmd,
               Serial_Params *arg) const;

#if defined (ACE_NEEDS_DEV_IO_CONVERSION)
  /// This is necessary to pass ACE_TTY_IO as parameter to DEV_Connector.
  operator ACE_DEV_IO &();
#endif /* ACE_NEEDS_DEV_IO_CONVERSION */
};

#endif /* ACE_TTY_IO_H */