#include <tty.h>
Public Types | |
typedef ConexusPointer< TTY > | pointer |
Public Member Functions | |
CONEXUS_ENDPOINT_GENERIC_CREATE () | |
virtual | ~TTY () |
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 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 | 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 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 |
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 |
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 | ( | ) |
Get the current byte size in bits.
bool Conexus::TTY::carrier_detect_enabled | ( | ) |
True if the hardware carrier detect (DCD) is enabled, false otherwise.
void Conexus::TTY::close | ( | bool | force = false |
) | throw ( close_exception ) [virtual] |
Restores the original terminal modes on the tty.
Reimplemented from Conexus::FileDescriptor.
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 | ( | ) |
waits until all output written to the object has been transmitted.
References Conexus::FileDescriptor::m_fd.
FlowControl Conexus::TTY::flow_control | ( | ) |
Returns the flow control method.
References Conexus::FLOW_CUSTOM, Conexus::FLOW_HARDWARE, Conexus::FLOW_NONE, and Conexus::FLOW_SOFTWARE.
void Conexus::TTY::flush | ( | ) |
discards both data written to the object but not transmitted and data received but not read
References Conexus::FileDescriptor::m_fd.
void Conexus::TTY::flush_input | ( | ) |
void Conexus::TTY::flush_output | ( | ) |
void Conexus::TTY::inject | ( | const std::string & | buffer | ) |
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 | ( | ) |
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 | ( | ) |
Parity Conexus::TTY::parity | ( | ) |
Returns the current parity mode.
References Conexus::PARITY_EVEN, Conexus::PARITY_NONE, and Conexus::PARITY_ODD.
ParityError Conexus::TTY::parity_error | ( | ) |
Returns the current parity error mode.
References Conexus::PARITY_ERROR_DISCARD, Conexus::PARITY_ERROR_IGNORE, Conexus::PARITY_ERROR_MARK, and Conexus::PARITY_ERROR_ZERO.
bool Conexus::TTY::receiver_enabled | ( | ) |
True if the receive side is enabled, false otherwise.
If false, this TTY cannot receive characters.
bool Conexus::TTY::reset_on_close | ( | ) |
True if the terminal will be reset to original characteristics on close.
References m_reset_on_close.
void Conexus::TTY::restart_input | ( | ) |
void Conexus::TTY::restart_output | ( | ) |
void Conexus::TTY::set_byte_size | ( | unsigned | size, | |
SetOption | option = SET_NOW | |||
) |
Sets the communication byte size Valid values are:
References m_signal_byte_size, and tcsetattr().
void Conexus::TTY::set_carrier_detect | ( | bool | enable = true , |
|
SetOption | option = SET_NOW | |||
) |
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.
References m_signal_carrier_detect, 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, m_signal_carrier_detect, m_signal_flow_control, m_signal_parity, m_signal_receiver, m_signal_stop_bits, and tcsetattr().
void Conexus::TTY::set_flow_control | ( | FlowControl | flowcontrol, | |
SetOption | option = SET_NOW | |||
) |
Sets the flow control flags according to the flow control method specified.
If FLOW_CUSTOM is specified, no change will occur.
References Conexus::FLOW_CUSTOM, Conexus::FLOW_HARDWARE, Conexus::FLOW_NONE, Conexus::FLOW_SOFTWARE, m_signal_flow_control, 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, m_signal_input_speed, m_signal_parity, and tcsetattr().
void Conexus::TTY::set_input_speed | ( | unsigned | speed, | |
SetOption | option = SET_NOW | |||
) |
Sets the input line speed.
These are generally defined in /usr/include/bits/termios.h The following is the recognized list:
References m_signal_input_speed, 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 | |||
) |
void Conexus::TTY::set_parity | ( | Parity | parity, | |
ParityError | error = PARITY_ERROR_IGNORE , |
|||
SetOption | option = SET_NOW | |||
) |
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
References m_signal_parity, 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_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.
References m_signal_receiver, and tcsetattr().
void Conexus::TTY::set_reset_on_close | ( | bool | reset = true |
) |
Set to true if the terminal should reset to original characteristics on close.
References m_reset_on_close.
void Conexus::TTY::set_speed | ( | unsigned | speed, | |
SetOption | option = SET_NOW | |||
) |
Sets both the input and output line speeds.
References m_signal_input_speed, m_signal_output_speed, tcsetattr(), and unsigned2speed().
void Conexus::TTY::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.
References m_signal_stop_bits, and tcsetattr().
sigc::signal< void > Conexus::TTY::signal_byte_size | ( | ) |
References m_signal_byte_size.
sigc::signal< void > Conexus::TTY::signal_carrier_detect | ( | ) |
References m_signal_carrier_detect.
sigc::signal< void > Conexus::TTY::signal_flow_control | ( | ) |
References m_signal_flow_control.
sigc::signal< void > Conexus::TTY::signal_input_speed | ( | ) |
References m_signal_input_speed.
sigc::signal< void > Conexus::TTY::signal_output_speed | ( | ) |
References m_signal_output_speed.
sigc::signal< void > Conexus::TTY::signal_parity | ( | ) |
References m_signal_parity.
sigc::signal< void > Conexus::TTY::signal_receiver | ( | ) |
References m_signal_receiver.
sigc::signal< void > Conexus::TTY::signal_stop_bits | ( | ) |
References m_signal_stop_bits.
unsigned Conexus::TTY::speed2unsigned | ( | speed_t | speed | ) | [protected] |
Referenced by input_speed(), and output_speed().
unsigned Conexus::TTY::stop_bits | ( | ) |
Get the number of stop bits (1 or 2).
void Conexus::TTY::suspend_input | ( | ) |
void Conexus::TTY::suspend_output | ( | ) |
void Conexus::TTY::tcsetattr | ( | SetOption | option | ) | [protected] |
References Conexus::Endpoint::is_open(), and Conexus::FileDescriptor::m_fd.
Referenced by set_byte_size(), set_carrier_detect(), 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_receiver_enabled(), 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 reset_on_close(), and set_reset_on_close().
sigc::signal<void> Conexus::TTY::m_signal_byte_size [protected] |
Referenced by set_byte_size(), set_control_modes(), and signal_byte_size().
sigc::signal<void> Conexus::TTY::m_signal_carrier_detect [protected] |
Referenced by set_carrier_detect(), set_control_modes(), and signal_carrier_detect().
sigc::signal<void> Conexus::TTY::m_signal_flow_control [protected] |
Referenced by set_control_modes(), set_flow_control(), set_input_modes(), and signal_flow_control().
sigc::signal<void> Conexus::TTY::m_signal_input_speed [protected] |
Referenced by set_input_modes(), set_input_speed(), set_speed(), and signal_input_speed().
sigc::signal<void> Conexus::TTY::m_signal_output_speed [protected] |
Referenced by set_output_modes(), set_output_speed(), set_speed(), and signal_output_speed().
sigc::signal<void> Conexus::TTY::m_signal_parity [protected] |
Referenced by set_control_modes(), set_input_modes(), set_parity(), and signal_parity().
sigc::signal<void> Conexus::TTY::m_signal_receiver [protected] |
Referenced by set_control_modes(), set_receiver_enabled(), and signal_receiver().
sigc::signal<void> Conexus::TTY::m_signal_stop_bits [protected] |
Referenced by set_control_modes(), set_stop_bits(), and signal_stop_bits().