yast2-core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Y2SerialComponent Class Reference

Interface to a component via serial line. More...

#include <Y2SerialComponent.h>

Inheritance diagram for Y2SerialComponent:
Y2Component

Public Member Functions

 Y2SerialComponent (string device_name, long baud_rate)
 
 ~Y2SerialComponent ()
 
string name () const
 
YCPValue evaluate (const YCPValue &command)
 
void result (const YCPValue &result)
 
void setServerOptions (int argc, char **argv)
 
YCPValue doActualWork (const YCPList &arglist, Y2Component *user_interface)
 
- Public Member Functions inherited from Y2Component
 Y2Component ()
 
virtual ~Y2Component ()
 
virtual Y2Namespaceimport (const char *name_space)
 
virtual SCRAgentgetSCRAgent ()
 
virtual bool remote () const
 

Private Member Functions

int open_tty ()
 
void close_tty ()
 
int setup_serial_device ()
 
int make_raw ()
 
int set_fixed_line_speed (long speed)
 
bool await_readable (long timeout)
 
bool initializeConnection ()
 
void sendToSerial (const YCPValue &v)
 
YCPValue receiveFromSerial ()
 

Private Attributes

string device_name
 
long baud_rate
 
int fd_serial
 
string full_name
 
Parser parser
 
int timeout_seconds
 

Detailed Description

Interface to a component via serial line.

Constructor & Destructor Documentation

Y2SerialComponent::Y2SerialComponent ( string  device_name,
long  baud_rate 
)

Creates a new serial component.

References device_name, and full_name.

Y2SerialComponent::~Y2SerialComponent ( )

Cleans up

Member Function Documentation

bool Y2SerialComponent::await_readable ( long  timeout)
private

wait with timeout (microseconds) for readability

References fd_serial.

Referenced by initializeConnection().

void Y2SerialComponent::close_tty ( )
private

close serial line if necessary and reset flag

References fd_serial.

Referenced by doActualWork(), initializeConnection(), and result().

YCPValue Y2SerialComponent::doActualWork ( const YCPList arglist,
Y2Component user_interface 
)
virtual

Here the client does its actual work.

Parameters
arglistYCPList of client arguments.
user_interfaceOption display server (user interface)
Returns
The result value (exit code) of the called client. The result code has not yet been sent to the display server. Destroy it after use.

This method is only defined, if the component is a client.

Reimplemented from Y2Component.

References close_tty(), Y2Component::evaluate(), initializeConnection(), receiveFromSerial(), sendToSerial(), YCPList::size(), and y2warning.

YCPValue Y2SerialComponent::evaluate ( const YCPValue command)
virtual

Defined only in the server role

Reimplemented from Y2Component.

References device_name, fd_serial, initializeConnection(), YCPElement::isNull(), receiveFromSerial(), sendToSerial(), and y2error.

bool Y2SerialComponent::initializeConnection ( )
private
int Y2SerialComponent::make_raw ( )
private

Set raw mode 8,N,1, no parity for serial line

References device_name, fd_serial, and y2error.

Referenced by initializeConnection().

string Y2SerialComponent::name ( ) const
virtual

Returns the name of the component.

Implements Y2Component.

References full_name.

int Y2SerialComponent::open_tty ( )
private

Open the given tty and return the corresponding file descriptor on success.

References device_name, fd_serial, and y2error.

Referenced by initializeConnection().

YCPValue Y2SerialComponent::receiveFromSerial ( )
private

Reads one YCP value from the serial line. Return 0 if none could be read.

References Parser::parse(), and parser.

Referenced by doActualWork(), and evaluate().

void Y2SerialComponent::result ( const YCPValue result)
virtual

Defined only in the server role

Reimplemented from Y2Component.

References YCPTerm::add(), close_tty(), and sendToSerial().

void Y2SerialComponent::sendToSerial ( const YCPValue v)
private

Send a YCPValue over the serial line

References fd_serial, and y2error.

Referenced by doActualWork(), evaluate(), and result().

int Y2SerialComponent::set_fixed_line_speed ( long  speed)
private

Set line speed for serial line

References device_name, fd_serial, and y2error.

Referenced by initializeConnection().

void Y2SerialComponent::setServerOptions ( int  argc,
char **  argv 
)
virtual

Sets the commandline options of the server. Server options for the cat server are simply ignored.

This method is only defined, if the component is a server.

Reimplemented from Y2Component.

References timeout_seconds, y2milestone, and y2warning.

int Y2SerialComponent::setup_serial_device ( )
private

Setup serial device

References device_name, fd_serial, and y2error.

Referenced by initializeConnection().

Member Data Documentation

long Y2SerialComponent::baud_rate
private

The baud rate to use

Referenced by initializeConnection().

string Y2SerialComponent::device_name
private
int Y2SerialComponent::fd_serial
private
string Y2SerialComponent::full_name
private

Full name of component

Referenced by name(), and Y2SerialComponent().

Parser Y2SerialComponent::parser
private

Parser used to parse input

Referenced by initializeConnection(), and receiveFromSerial().

int Y2SerialComponent::timeout_seconds
private

After so many seconds cancel to try establishing the connection and to an exit(10);

Referenced by initializeConnection(), and setServerOptions().


The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.8.11