#include <conexus/tty.h>
Inheritance diagram for Conexus::TTY:
This class should be used to control serial port baud rates and other aspects of serial communications.
Public Types | |
typedef boost::shared_ptr< TTY > | pointer |
typedef enum Conexus::TTY::SetOption | SetOption |
Aliases for the tty function options relating to when an option change takes effect. | |
enum | SetOption { SET_NOW = TCSANOW, SET_FLUSH = TCSAFLUSH, SET_DRAIN = TCSADRAIN } |
Aliases for the tty function options relating to when an option change takes effect. More... | |
enum | Parity { PARITY_NONE, PARITY_ODD, PARITY_EVEN } |
enum | ParityError { PARITY_ERROR_DISCARD, PARITY_ERROR_MARK, PARITY_ERROR_ZERO, PARITY_ERROR_IGNORE } |
enum | FlowControl { FLOW_NONE, FLOW_HARDWARE, FLOW_SOFTWARE, FLOW_CUSTOM } |
Public Member Functions | |
TTY (const std::string &device=std::string()) | |
Default constructor The following default characteristics are set:
| |
void | drain () |
waits until all output written to the object has been transmitted. | |
void | flush_input () |
discards data received but not read | |
void | flush_output () |
discards data written to the object but not transmitted | |
void | flush () |
discards both data written to the object but not transmitted and data received but not read | |
void | suspend_output () |
Suspends transmission of data by the object. | |
void | restart_output () |
Resumes transmission of data by the object. | |
void | suspend_input () |
Suspends reception of data by the object. | |
void | restart_input () |
Resumes reception of data by the object. | |
void | set_input_speed (unsigned speed, SetOption option=SET_NOW) |
Sets the input line speed. | |
void | set_output_speed (unsigned speed, SetOption option=SET_NOW) |
Sets the output line speed. | |
void | set_speed (unsigned speed, SetOption option=SET_NOW) |
Sets both the input and output line speeds. | |
unsigned | input_speed () |
Returns the current input line speed. | |
unsigned | output_speed () |
Returns the current output line speed. | |
void | set_parity (Parity parity, ParityError error=PARITY_ERROR_IGNORE, SetOption option=SET_NOW) |
Sets parity mode. | |
Parity | parity () |
Returns the current parity mode. | |
ParityError | parity_error () |
Returns the current parity error mode. | |
unsigned | byte_size () |
Get the current byte size in bits. | |
void | set_byte_size (unsigned size, SetOption option=SET_NOW) |
Sets the communication byte size Valid values are:
| |
unsigned | stop_bits () |
Get the number of stop bits (1 or 2). | |
void | set_stop_bits (unsigned size, SetOption option=SET_NOW) |
Sets the stop bits; only values of 1 or 2 will be processed, all others will be ignored. | |
FlowControl | flow_control () |
Returns the flow control method. | |
void | set_flow_control (FlowControl flowcontrol, SetOption option=SET_NOW) |
Sets the flow control flags according to the flow control method specified. | |
bool | carrier_detect_enabled () |
True if the hardware carrier detect (DCD) is enabled, false otherwise. | |
void | set_carrier_detect (bool enable=true, SetOption option=SET_NOW) |
Enables or disables a hardware carrier detect. | |
bool | receiver_enabled () |
True if the receive side is enabled, false otherwise. | |
void | set_receiver_enabled (bool enable=true, SetOption option=SET_NOW) |
If true the receiver will be enabled, and if false it will be disabled and no characters can be received. | |
virtual Data | read (size_t s=0) throw (read_error) |
Reads up to s bytes from the TTY. | |
virtual void | open () throw (open_error) |
virtual void | open (const std::string name, int s=READ|WRITE) throw (open_error) |
Opens the TTY in the specified mode, storing the original terminal mode, to be restored on close. | |
virtual void | close (bool force=false) throw (close_error) |
Restores the original terminal modes on the tty. | |
void | set_input_modes (tcflag_t iflag, SetOption option=SET_NOW) |
Sets TTY modes [ see termios(3) ]. | |
void | set_output_modes (tcflag_t oflag, SetOption option=SET_NOW) |
Sets TTY modes [ see termios(3) ]. | |
void | set_control_modes (tcflag_t cflag, SetOption option=SET_NOW) |
Sets TTY modes [ see termios(3) ]. | |
void | set_local_modes (tcflag_t lflag, SetOption option=SET_NOW) |
Sets TTY modes [ see termios(3) ]. | |
void | set_control_characters (int index, cc_t value, SetOption option=SET_NOW) |
Sets TTY modes [ see termios(3) ]. | |
termios | attributes () |
Gets TTY attributes [ see termios(3) ]. | |
void | inject (char data) |
Injects the character into the input queue. | |
void | inject (const char *buffer, size_t bufsize) |
Injects the input buffer into the input queue. | |
void | inject (const std::string &buffer) |
Injects the input buffer into the input queue. | |
bool | reset_on_close () |
True if the terminal will be reset to original characteristics on close. | |
void | set_reset_on_close (bool reset=true) |
Set to true if the terminal should reset to original characteristics on close. | |
sigc::signal< void > | signal_input_speed () |
sigc::signal< void > | signal_output_speed () |
sigc::signal< void > | signal_parity () |
sigc::signal< void > | signal_byte_size () |
sigc::signal< void > | signal_stop_bits () |
sigc::signal< void > | signal_flow_control () |
sigc::signal< void > | signal_carrier_detect () |
sigc::signal< void > | signal_receiver () |
virtual const std::string & | object_type () |
Static Public Member Functions | |
static TTY::pointer | create (const std::string &device=std::string()) |
Protected Member Functions | |
void | tcsetattr (SetOption option) |
speed_t | unsigned2speed (unsigned speed) |
unsigned | speed2unsigned (speed_t speed) |
Protected Attributes | |
termios m_termios | m_origtermios |
bool | m_reset_on_close |
sigc::signal< void > | m_signal_input_speed |
sigc::signal< void > | m_signal_output_speed |
sigc::signal< void > | m_signal_parity |
sigc::signal< void > | m_signal_byte_size |
sigc::signal< void > | m_signal_stop_bits |
sigc::signal< void > | m_signal_flow_control |
sigc::signal< void > | m_signal_carrier_detect |
sigc::signal< void > | m_signal_receiver |
|
|
|
|
|
|
|
|
True if the receive side is enabled, false otherwise. If false, this TTY cannot receive characters. |
|
Enables or disables a hardware carrier detect. If hardware carrier detect is enabled and this is a blocking TTY, an open will block until a DCD signal is received from the hardware (useful for modems). If this is not enabled, the TTY will behave as if the DCD is always asserted. The hardware carrier flag should usually be turned on for modems and off for local devices. |
|
Sets the flow control flags according to the flow control method specified. If FLOW_CUSTOM is specified, no change will occur. |
|
Sets the input line speed. These are generally defined in /usr/include/bits/termios.h The following is the recognized list:
|
|
Sets parity mode. Discards all parity error bytes Delivers three bytes (0xFF, 0x00 and c; where c is the error byte Delivers 0x00 when a parity error is detected Ignores all parity errors and delivers all data as is |