modem.h
00001 /* 00002 KMLOCfg 00003 00004 A utility to configure the ELSA MicroLink(tm) Office modem. 00005 00006 Copyright (C) 2000 Oliver Gantz <Oliver.Gantz@epost.de> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 00022 ------ 00023 ELSA and MicroLink are trademarks of ELSA AG, Aachen. 00024 */ 00025 00026 #ifndef MODEM_H 00027 #define MODEM_H 00028 00029 #ifdef HAVE_CONFIG_H 00030 #include "config.h" 00031 #endif 00032 00033 #include <termios.h> 00034 00035 #include <tqobject.h> 00036 #include <tqstring.h> 00037 #include <tqtimer.h> 00038 #include <tqsocketnotifier.h> 00039 #include <tqfile.h> 00040 00041 #include "kandyprefs.h" 00042 00043 00044 00045 00046 class Modem : public TQObject 00047 { 00048 Q_OBJECT 00049 TQ_OBJECT 00050 public: 00051 Modem(KandyPrefs *kprefs, TQObject *parent = 0, const char *name = 0); 00052 virtual ~Modem(); 00053 00054 void setSpeed(int speed); 00055 void setData(int data); 00056 void setParity(char parity); 00057 void setStop(int stop); 00058 00059 bool open(); 00060 void close(); 00061 00062 bool isOpen() { return mOpen; } 00063 00064 void flush(); 00065 00066 bool lockDevice(); 00067 void unlockDevice(); 00068 00069 bool dsrOn(); 00070 bool ctsOn(); 00071 00072 void writeChar(const char c); 00073 void writeLine(const char *line); 00074 00075 void timerStart(int msec); 00076 00077 void receiveXModem(bool crc); 00078 void abortXModem(); 00079 00080 private slots: 00081 void timerDone(); 00082 00083 void readChar(int); 00084 void readXChar(int); 00085 00086 private: 00087 bool mOpen; 00088 00089 void init(); 00090 void xreset(); 00091 00092 uchar calcChecksum(); 00093 ushort calcCRC(); 00094 00095 bool is_locked; 00096 struct termios init_tty; 00097 00098 speed_t cspeed; 00099 tcflag_t cflag; 00100 00101 int fd; 00102 TQTimer *timer; 00103 TQSocketNotifier *sn; 00104 00105 uchar buffer[1024]; 00106 int bufpos; 00107 00108 int xstate; 00109 bool xcrc; 00110 uchar xblock; 00111 int xsize; 00112 00113 KandyPrefs *prefs; 00114 00115 signals: 00116 void gotLine(const char *); 00117 void gotXBlock(const uchar *, int); 00118 void xmodemDone(bool); 00119 void timeout(); 00120 00121 void errorMessage( const TQString & ); 00122 }; 00123 00124 00125 #endif // MODEM_H