Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference

serialdevice.h

This is the verbatim text of the serialdevice.h include file. It is provided only for illustration; the copyright remains with Trolltech.


/**********************************************************************
** Copyright (C) 2000-2005 Trolltech AS.  All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** Licensees holding a valid license agreement from Trolltech or any of its
** authorized distributors may use this file in accordance with
** the License Agreement provided with the Licensed Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Trolltech's Commercial License Agreements.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef SERIALDEVICE_H
#define SERIALDEVICE_H


#include <qobject.h>
#include <qiodevice.h>
#include <qstring.h>


class SerialDevicePrivate;


class SerialDeviceBase : public QObject, public QIODevice
{
    Q_OBJECT
public:
    SerialDeviceBase( QObject *parent = 0, const char *name = 0 );
    ~SerialDeviceBase();

    virtual bool dtr() const = 0;
    virtual void setDtr( bool value ) = 0;
    virtual bool dsr() const = 0;
    virtual bool carrier() const = 0;
    virtual bool rts() const = 0;
    virtual void setRts( bool value ) = 0;
    virtual bool cts() const = 0;

    virtual void discard() = 0;

signals:
    void readyRead();
    void dsrChanged( bool value );
    void carrierChanged( bool value );
    void ctsChanged( bool value );
};


class SerialDevice : public SerialDeviceBase
{
    Q_OBJECT
public:
    SerialDevice( const QString& device, int rate = 38400, bool trackStatus = FALSE );
    ~SerialDevice();

    // File descriptor, for use with QSocketNotifier.
    int fd() const;

    // Override QIODevice methods.
    bool open( int mode );
    void close();
    void flush();
    uint size()	const;
    int	 readBlock( char *data, uint maxlen );
    int	 writeBlock( const char *data, uint len );
    int	 getch();
    int	 putch( int );
    int	 ungetch( int );

    // Get the baud rate.
    int rate() const;

    // Override SerialDeviceBase methods.
    bool dtr() const;
    void setDtr( bool value );
    bool dsr() const;
    bool carrier() const;
    bool rts() const;
    void setRts( bool value );
    bool cts() const;
    void discard();

    // Create and open a serial device from a "device:rate" name.
    static SerialDevice *create( const QString& name, int defaultRate=115200 );

private slots:
    void statusTimeout();

private:
    SerialDevicePrivate *d;
};


#endif // SERIALDEVICE_H


Copyright © 2005 Trolltech Trademarks
Qtopia version 2.2.0