kandy
modem.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
|