00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: Y2SerialComponent.h 00014 00015 Author: Thomas Roelz <tom@suse.de> 00016 Maintainer: Thomas Roelz <tom@suse.de> 00017 00018 /-*/ 00019 00020 /* 00021 * Component that communicates via serial line 00022 */ 00023 00024 #ifndef Y2SerialComponent_h 00025 #define Y2SerialComponent_h 00026 00027 #include "Y2Component.h" 00028 #include <ycp/Parser.h> 00029 00033 class Y2SerialComponent : public Y2Component 00034 { 00038 string device_name; 00039 00043 long baud_rate; 00044 00048 int fd_serial; 00049 00053 string full_name; 00054 00058 Parser parser; 00059 00060 00065 int timeout_seconds; 00066 00067 public: 00068 00072 Y2SerialComponent(string device_name, long baud_rate); 00073 00077 ~Y2SerialComponent(); 00078 00082 string name() const; 00083 00087 YCPValue evaluate(const YCPValue& command); 00088 00092 void result(const YCPValue& result); 00093 00100 void setServerOptions(int argc, char **argv); 00101 00112 YCPValue doActualWork(const YCPList& arglist, Y2Component *user_interface); 00113 00114 private: 00115 00119 int open_tty(); 00120 00124 void close_tty(); 00125 00129 int setup_serial_device(); 00130 00134 int make_raw(); 00135 00139 int set_fixed_line_speed(long speed); 00140 00144 bool await_readable(long timeout); 00145 00149 bool initializeConnection(); 00150 00154 void sendToSerial(const YCPValue& v); 00155 00156 00161 YCPValue receiveFromSerial(); 00162 }; 00163 00164 #endif // Y2SerialComponent_h