kandy Library API Documentation

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 
00040 
00041 
00042 
00043 class Modem : public QObject
00044 {
00045     Q_OBJECT
00046 public:
00047     Modem(QObject *parent = 0, const char *name = 0);
00048     virtual ~Modem();
00049 
00050     void setDevice(const QString& name);
00051 
00052     void setSpeed(int speed);
00053     void setData(int data);
00054     void setParity(char parity);
00055     void setStop(int stop);
00056 
00057     bool open();
00058     void close();
00059 
00060         bool isOpen() { return mOpen; }
00061 
00062     void flush();
00063 
00064     bool lockDevice();
00065     void unlockDevice();
00066 
00067     bool dsrOn();
00068     bool ctsOn();
00069 
00070     void writeChar(const char c);
00071     void writeLine(const char *line);
00072 
00073     void timerStart(int msec);
00074 
00075     void receiveXModem(bool crc);
00076     void abortXModem();
00077 
00078 private slots:
00079     void timerDone();
00080 
00081     void readChar(int);
00082     void readXChar(int);
00083 
00084 private:
00085   bool mOpen;
00086 
00087     void init();
00088     void xreset();
00089 
00090     uchar calcChecksum();
00091     ushort calcCRC();
00092 
00093     bool is_locked;
00094     struct termios init_tty;
00095 
00096     speed_t cspeed;
00097     tcflag_t cflag;
00098 
00099     char *fdev;
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 signals:
00113     void gotLine(const char *);
00114     void gotXBlock(const uchar *, int);
00115     void xmodemDone(bool);
00116     void timeout();
00117 
00118     void errorMessage( const QString & );
00119 };
00120 
00121 
00122 #endif // MODEM_H
KDE Logo
This file is part of the documentation for kandy Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:59 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003