kandy

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 <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
KDE Home | KDE Accessibility Home | Description of Access Keys