#include <tty.h>
Public Types | |
typedef ConexusPointer< TTY > | pointer |
Public Member Functions | |
CONEXUS_ENDPOINT_GENERIC_CREATE () | |
virtual | ~TTY () |
virtual void | drain () |
waits until all output written to the object has been transmitted. | |
virtual void | flush_input () |
discards data received but not read | |
virtual void | flush_output () |
discards data written to the object but not transmitted | |
virtual void | flush () |
discards both data written to the object but not transmitted and data received but not read | |
virtual void | suspend_output () |
Suspends transmission of data by the object. | |
virtual void | restart_output () |
Resumes transmission of data by the object. | |
virtual void | suspend_input () |
Suspends reception of data by the object. | |
virtual 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 | is_carrier_detect_enabled () |
True if the hardware carrier detect (DCD) is enabled, false otherwise. | |
void | enable_carrier_detect (bool enable=true, SetOption option=SET_NOW) |
Enables or disables a hardware carrier detect. | |
bool | is_receiver_enabled () |
True if the receive side is enabled, false otherwise. | |
void | enable_receiver (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 void | open () throw ( open_exception ) |
virtual void | open (const std::string &name, ReadWrite mode=READ_WRITE_UNCHANGED) throw ( open_exception ) |
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_exception ) |
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) ]. | |
struct 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 | is_reset_on_close_enabled () |
True if the terminal will be reset to original characteristics on close. | |
void | enable_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_changed () |
sigc::signal< void > & | signal_output_speed_changed () |
sigc::signal< void > & | signal_parity_changed () |
sigc::signal< void > & | signal_byte_size_changed () |
sigc::signal< void > & | signal_stop_bits_changed () |
sigc::signal< void > & | signal_flow_control_changed () |
sigc::signal< void > & | signal_carrier_detect_changed () |
sigc::signal< void > & | signal_receiver_changed () |
virtual size_t | input_available () throw () |
Static Public Member Functions | |
static TTY::pointer | create (const std::string &device=std::string(), ReadWrite rwmode=READ_WRITE) |
Protected Member Functions | |
TTY (const std::string &device=std::string(), ReadWrite rwmode=READ_WRITE) | |
Default constructor The following default characteristics are set:
| |
void | tcsetattr (SetOption option) |
speed_t | unsigned2speed (unsigned speed) |
unsigned | speed2unsigned (speed_t speed) |
Protected Attributes | |
struct termios m_termios | m_origtermios |
bool | m_reset_on_close |
sigc::signal< void > | m_signal_input_speed_changed |
sigc::signal< void > | m_signal_output_speed_changed |
sigc::signal< void > | m_signal_parity_changed |
sigc::signal< void > | m_signal_byte_size_changed |
sigc::signal< void > | m_signal_stop_bits_changed |
sigc::signal< void > | m_signal_flow_control_changed |
sigc::signal< void > | m_signal_carrier_detect_changed |
sigc::signal< void > | m_signal_receiver_changed |
Related Functions | |
(Note that these are not member functions.) | |
enum | TOS { TOS_LOWDELAY = IPTOS_LOWDELAY, TOS_THROUGHPUT = IPTOS_THROUGHPUT, TOS_RELIABILITY = IPTOS_RELIABILITY, TOS_LOWCOST = IPTOS_LOWCOST } |
enum | SetOption { SET_NOW = TCSANOW, SET_FLUSH = TCSAFLUSH, SET_DRAIN = TCSADRAIN } |
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 } |
This class should be used to control serial port baud rates and other aspects of serial communications.
typedef ConexusPointer<TTY> Conexus::TTY::pointer |
Conexus::TTY::TTY | ( | const std::string & | device = std::string() , |
|
ReadWrite | rwmode = READ_WRITE | |||
) | [protected] |
Default constructor The following default characteristics are set:
Referenced by create().
Conexus::TTY::~TTY | ( | ) | [virtual] |
References Conexus::FileDescriptor::m_fd, m_origtermios, and tcsetattr().
struct termios Conexus::TTY::attributes | ( | ) | [read] |
Gets TTY attributes [ see termios(3) ].
unsigned Conexus::TTY::byte_size | ( | ) | [virtual] |
void Conexus::TTY::close | ( | bool | force = false |
) | throw ( close_exception ) [virtual] |
Restores the original terminal modes on the tty.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::close().
Conexus::TTY::CONEXUS_ENDPOINT_GENERIC_CREATE | ( | ) |
Reimplemented from Conexus::Serial.
TTY::pointer Conexus::TTY::create | ( | const std::string & | device = std::string() , |
|
ReadWrite | rwmode = READ_WRITE | |||
) | [static] |
void Conexus::TTY::drain | ( | ) | [virtual] |
waits until all output written to the object has been transmitted.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::enable_carrier_detect | ( | bool | enable = true , |
|
SetOption | option = SET_NOW | |||
) | [virtual] |
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.
Implements Conexus::TTYInterface.
References m_signal_carrier_detect_changed, and tcsetattr().
void Conexus::TTY::enable_receiver | ( | bool | enable = true , |
|
SetOption | option = SET_NOW | |||
) | [virtual] |
If true the receiver will be enabled, and if false it will be disabled and no characters can be received.
Implements Conexus::TTYInterface.
References m_signal_receiver_changed, and tcsetattr().
void Conexus::TTY::enable_reset_on_close | ( | bool | reset = true |
) | [virtual] |
Set to true if the terminal should reset to original characteristics on close.
Implements Conexus::TTYInterface.
References m_reset_on_close.
FlowControl Conexus::TTY::flow_control | ( | ) | [virtual] |
Returns the flow control method.
Implements Conexus::TTYInterface.
References Conexus::FLOW_CUSTOM, Conexus::FLOW_HARDWARE, Conexus::FLOW_NONE, and Conexus::FLOW_SOFTWARE.
void Conexus::TTY::flush | ( | ) | [virtual] |
discards both data written to the object but not transmitted and data received but not read
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::flush_input | ( | ) | [virtual] |
discards data received but not read
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::flush_output | ( | ) | [virtual] |
discards data written to the object but not transmitted
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::inject | ( | const std::string & | buffer | ) | [virtual] |
Injects the input buffer into the input queue.
Implements Conexus::TTYInterface.
References inject().
void Conexus::TTY::inject | ( | const char * | buffer, | |
size_t | bufsize | |||
) |
void Conexus::TTY::inject | ( | char | data | ) |
Injects the character into the input queue.
References Conexus::FileDescriptor::m_fd.
Referenced by inject().
size_t Conexus::TTY::input_available | ( | ) | throw () [virtual] |
unsigned Conexus::TTY::input_speed | ( | ) | [virtual] |
Returns the current input line speed.
Implements Conexus::TTYInterface.
References speed2unsigned().
bool Conexus::TTY::is_carrier_detect_enabled | ( | ) | [virtual] |
True if the hardware carrier detect (DCD) is enabled, false otherwise.
Implements Conexus::TTYInterface.
bool Conexus::TTY::is_receiver_enabled | ( | ) | [virtual] |
True if the receive side is enabled, false otherwise.
If false, this TTY cannot receive characters.
Implements Conexus::TTYInterface.
bool Conexus::TTY::is_reset_on_close_enabled | ( | ) | [virtual] |
True if the terminal will be reset to original characteristics on close.
Implements Conexus::TTYInterface.
References m_reset_on_close.
void Conexus::TTY::open | ( | const std::string & | name, | |
ReadWrite | mode = READ_WRITE_UNCHANGED | |||
) | throw ( open_exception ) [virtual] |
Opens the TTY in the specified mode, storing the original terminal mode, to be restored on close.
Reimplemented from Conexus::Serial.
References Conexus::Serial::open(), and Conexus::SET_NOW.
void Conexus::TTY::open | ( | ) | throw ( open_exception ) [virtual] |
Reimplemented from Conexus::Serial.
unsigned Conexus::TTY::output_speed | ( | ) | [virtual] |
Returns the current output line speed.
Implements Conexus::TTYInterface.
References speed2unsigned().
Parity Conexus::TTY::parity | ( | ) | [virtual] |
Returns the current parity mode.
Implements Conexus::TTYInterface.
References Conexus::PARITY_EVEN, Conexus::PARITY_NONE, and Conexus::PARITY_ODD.
ParityError Conexus::TTY::parity_error | ( | ) | [virtual] |
Returns the current parity error mode.
Implements Conexus::TTYInterface.
References Conexus::PARITY_ERROR_DISCARD, Conexus::PARITY_ERROR_IGNORE, Conexus::PARITY_ERROR_MARK, and Conexus::PARITY_ERROR_ZERO.
void Conexus::TTY::restart_input | ( | ) | [virtual] |
Resumes reception of data by the object.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::restart_output | ( | ) | [virtual] |
Resumes transmission of data by the object.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::set_byte_size | ( | unsigned | size, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets the communication byte size Valid values are:
Implements Conexus::TTYInterface.
References m_signal_byte_size_changed, and tcsetattr().
void Conexus::TTY::set_control_characters | ( | int | index, | |
cc_t | value, | |||
SetOption | option = SET_NOW | |||
) |
void Conexus::TTY::set_control_modes | ( | tcflag_t | cflag, | |
SetOption | option = SET_NOW | |||
) |
Sets TTY modes [ see termios(3) ].
References m_signal_byte_size_changed, m_signal_carrier_detect_changed, m_signal_flow_control_changed, m_signal_parity_changed, m_signal_receiver_changed, m_signal_stop_bits_changed, and tcsetattr().
void Conexus::TTY::set_flow_control | ( | FlowControl | flowcontrol, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets the flow control flags according to the flow control method specified.
If FLOW_CUSTOM is specified, no change will occur.
Implements Conexus::TTYInterface.
References Conexus::FLOW_CUSTOM, Conexus::FLOW_HARDWARE, Conexus::FLOW_NONE, Conexus::FLOW_SOFTWARE, m_signal_flow_control_changed, and tcsetattr().
void Conexus::TTY::set_input_modes | ( | tcflag_t | iflag, | |
SetOption | option = SET_NOW | |||
) |
Sets TTY modes [ see termios(3) ].
References m_signal_flow_control_changed, m_signal_input_speed_changed, m_signal_parity_changed, and tcsetattr().
void Conexus::TTY::set_input_speed | ( | unsigned | speed, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets the input line speed.
These are generally defined in /usr/include/bits/termios.h The following is the recognized list:
Implements Conexus::TTYInterface.
References m_signal_input_speed_changed, tcsetattr(), and unsigned2speed().
void Conexus::TTY::set_local_modes | ( | tcflag_t | lflag, | |
SetOption | option = SET_NOW | |||
) |
void Conexus::TTY::set_output_modes | ( | tcflag_t | oflag, | |
SetOption | option = SET_NOW | |||
) |
void Conexus::TTY::set_output_speed | ( | unsigned | speed, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets the output line speed.
Implements Conexus::TTYInterface.
References m_signal_output_speed_changed, tcsetattr(), and unsigned2speed().
void Conexus::TTY::set_parity | ( | Parity | parity, | |
ParityError | error = PARITY_ERROR_IGNORE , |
|||
SetOption | option = SET_NOW | |||
) | [virtual] |
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
Implements Conexus::TTYInterface.
References m_signal_parity_changed, Conexus::PARITY_ERROR_DISCARD, Conexus::PARITY_ERROR_IGNORE, Conexus::PARITY_ERROR_MARK, Conexus::PARITY_ERROR_ZERO, Conexus::PARITY_NONE, Conexus::PARITY_ODD, and tcsetattr().
void Conexus::TTY::set_speed | ( | unsigned | speed, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets both the input and output line speeds.
Implements Conexus::TTYInterface.
References m_signal_input_speed_changed, m_signal_output_speed_changed, tcsetattr(), and unsigned2speed().
void Conexus::TTY::set_stop_bits | ( | unsigned | size, | |
SetOption | option = SET_NOW | |||
) | [virtual] |
Sets the stop bits; only values of 1 or 2 will be processed, all others will be ignored.
Implements Conexus::TTYInterface.
References m_signal_stop_bits_changed, and tcsetattr().
sigc::signal< void > & Conexus::TTY::signal_byte_size_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_carrier_detect_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_flow_control_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_input_speed_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_output_speed_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_parity_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_receiver_changed | ( | ) | [virtual] |
sigc::signal< void > & Conexus::TTY::signal_stop_bits_changed | ( | ) | [virtual] |
unsigned Conexus::TTY::speed2unsigned | ( | speed_t | speed | ) | [protected] |
Referenced by input_speed(), and output_speed().
unsigned Conexus::TTY::stop_bits | ( | ) | [virtual] |
void Conexus::TTY::suspend_input | ( | ) | [virtual] |
Suspends reception of data by the object.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::suspend_output | ( | ) | [virtual] |
Suspends transmission of data by the object.
Implements Conexus::TTYInterface.
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::tcsetattr | ( | SetOption | option | ) | [protected] |
References Conexus::Endpoint::is_open(), and Conexus::FileDescriptor::m_fd.
Referenced by enable_carrier_detect(), enable_receiver(), set_byte_size(), set_control_characters(), set_control_modes(), set_flow_control(), set_input_modes(), set_input_speed(), set_local_modes(), set_output_modes(), set_output_speed(), set_parity(), set_speed(), set_stop_bits(), and ~TTY().
speed_t Conexus::TTY::unsigned2speed | ( | unsigned | speed | ) | [protected] |
Referenced by set_input_speed(), set_output_speed(), and set_speed().
enum FlowControl [related] |
enum Parity [related] |
enum ParityError [related] |
enum SetOption [related] |
Aliases for the tty function options relating to when an option change takes effect.
enum TOS [related] |
struct termios m_termios Conexus::TTY::m_origtermios [read, protected] |
Referenced by ~TTY().
bool Conexus::TTY::m_reset_on_close [protected] |
Referenced by enable_reset_on_close(), and is_reset_on_close_enabled().
sigc::signal<void> Conexus::TTY::m_signal_byte_size_changed [protected] |
Referenced by set_byte_size(), set_control_modes(), and signal_byte_size_changed().
sigc::signal<void> Conexus::TTY::m_signal_carrier_detect_changed [protected] |
Referenced by enable_carrier_detect(), set_control_modes(), and signal_carrier_detect_changed().
sigc::signal<void> Conexus::TTY::m_signal_flow_control_changed [protected] |
Referenced by set_control_modes(), set_flow_control(), set_input_modes(), and signal_flow_control_changed().
sigc::signal<void> Conexus::TTY::m_signal_input_speed_changed [protected] |
Referenced by set_input_modes(), set_input_speed(), set_speed(), and signal_input_speed_changed().
sigc::signal<void> Conexus::TTY::m_signal_output_speed_changed [protected] |
Referenced by set_output_modes(), set_output_speed(), set_speed(), and signal_output_speed_changed().
sigc::signal<void> Conexus::TTY::m_signal_parity_changed [protected] |
Referenced by set_control_modes(), set_input_modes(), set_parity(), and signal_parity_changed().
sigc::signal<void> Conexus::TTY::m_signal_receiver_changed [protected] |
Referenced by enable_receiver(), set_control_modes(), and signal_receiver_changed().
sigc::signal<void> Conexus::TTY::m_signal_stop_bits_changed [protected] |
Referenced by set_control_modes(), set_stop_bits(), and signal_stop_bits_changed().