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 <qobject.h>
00036 #include <qstring.h>
00037 #include <qtimer.h>
00038 #include <qsocketnotifier.h>
00039 #include <qfile.h>
00040
00041 #include "kandyprefs.h"
00042
00043
00044
00045
00046 class Modem : public QObject
00047 {
00048 Q_OBJECT
00049 public:
00050 Modem(KandyPrefs *kprefs, QObject *parent = 0, const char *name = 0);
00051 virtual ~Modem();
00052
00053 void setSpeed(int speed);
00054 void setData(int data);
00055 void setParity(char parity);
00056 void setStop(int stop);
00057
00058 bool open();
00059 void close();
00060
00061 bool isOpen() { return mOpen; }
00062
00063 void flush();
00064
00065 bool lockDevice();
00066 void unlockDevice();
00067
00068 bool dsrOn();
00069 bool ctsOn();
00070
00071 void writeChar(const char c);
00072 void writeLine(const char *line);
00073
00074 void timerStart(int msec);
00075
00076 void receiveXModem(bool crc);
00077 void abortXModem();
00078
00079 private slots:
00080 void timerDone();
00081
00082 void readChar(int);
00083 void readXChar(int);
00084
00085 private:
00086 bool mOpen;
00087
00088 void init();
00089 void xreset();
00090
00091 uchar calcChecksum();
00092 ushort calcCRC();
00093
00094 bool is_locked;
00095 struct termios init_tty;
00096
00097 speed_t cspeed;
00098 tcflag_t cflag;
00099
00100 int fd;
00101 QTimer *timer;
00102 QSocketNotifier *sn;
00103
00104 uchar buffer[1024];
00105 int bufpos;
00106
00107 int xstate;
00108 bool xcrc;
00109 uchar xblock;
00110 int xsize;
00111
00112 KandyPrefs *prefs;
00113
00114 signals:
00115 void gotLine(const char *);
00116 void gotXBlock(const uchar *, int);
00117 void xmodemDone(bool);
00118 void timeout();
00119
00120 void errorMessage( const QString & );
00121 };
00122
00123
00124 #endif // MODEM_H
|