yast2-core
|
Interface to a component via serial line. More...
#include <Y2SerialComponent.h>
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) |
![]() | |
Y2Component () | |
virtual | ~Y2Component () |
virtual Y2Namespace * | import (const char *name_space) |
virtual SCRAgent * | getSCRAgent () |
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 |
Interface to a component via serial line.
Y2SerialComponent::Y2SerialComponent | ( | string | device_name, |
long | baud_rate | ||
) |
Creates a new serial component.
References device_name, and full_name.
Y2SerialComponent::~Y2SerialComponent | ( | ) |
Cleans up
|
private |
wait with timeout (microseconds) for readability
References fd_serial.
Referenced by initializeConnection().
|
private |
close serial line if necessary and reset flag
References fd_serial.
Referenced by doActualWork(), initializeConnection(), and result().
|
virtual |
Here the client does its actual work.
arglist | YCPList of client arguments. |
user_interface | Option display server (user interface) |
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.
Defined only in the server role
Reimplemented from Y2Component.
References device_name, fd_serial, initializeConnection(), YCPElement::isNull(), receiveFromSerial(), sendToSerial(), and y2error.
|
private |
initializes the serial connection
References await_readable(), baud_rate, close_tty(), device_name, fd_serial, make_raw(), NUMSPACES, open_tty(), parser, set_fixed_line_speed(), Parser::setInput(), setup_serial_device(), TIMEOUT, timeout_seconds, and y2error.
Referenced by doActualWork(), and evaluate().
|
private |
Set raw mode 8,N,1, no parity for serial line
References device_name, fd_serial, and y2error.
Referenced by initializeConnection().
|
virtual |
|
private |
Open the given tty and return the corresponding file descriptor on success.
References device_name, fd_serial, and y2error.
Referenced by initializeConnection().
|
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().
|
virtual |
Defined only in the server role
Reimplemented from Y2Component.
References YCPTerm::add(), close_tty(), and sendToSerial().
|
private |
Send a YCPValue over the serial line
References fd_serial, and y2error.
Referenced by doActualWork(), evaluate(), and result().
|
private |
Set line speed for serial line
References device_name, fd_serial, and y2error.
Referenced by initializeConnection().
|
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.
|
private |
Setup serial device
References device_name, fd_serial, and y2error.
Referenced by initializeConnection().
|
private |
The baud rate to use
Referenced by initializeConnection().
|
private |
The name of the device to use
Referenced by evaluate(), initializeConnection(), make_raw(), open_tty(), set_fixed_line_speed(), setup_serial_device(), and Y2SerialComponent().
|
private |
file descriptor for serial connection
Referenced by await_readable(), close_tty(), evaluate(), initializeConnection(), make_raw(), open_tty(), sendToSerial(), set_fixed_line_speed(), and setup_serial_device().
|
private |
Full name of component
Referenced by name(), and Y2SerialComponent().
|
private |
Parser used to parse input
Referenced by initializeConnection(), and receiveFromSerial().
|
private |
After so many seconds cancel to try establishing the connection and to an exit(10);
Referenced by initializeConnection(), and setServerOptions().