posix_qextserialport.h 1.76 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef _POSIX_QEXTSERIALPORT_H_
#define _POSIX_QEXTSERIALPORT_H_

#include <stdio.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include "qextserialbase.h"

13
class Posix_QextSerialPort:public QextSerialBase
pixhawk's avatar
pixhawk committed
14
{
15 16 17 18 19
private:
    /*!
     * This method is a part of constructor.
     */
    void init();
pixhawk's avatar
pixhawk committed
20

21 22 23 24 25 26
protected:
    int fd;
    struct termios Posix_CommConfig;
    struct termios old_termios;
    struct timeval Posix_Timeout;
    struct timeval Posix_Copy_Timeout;
pixhawk's avatar
pixhawk committed
27

28 29
    virtual qint64 readData(char * data, qint64 maxSize);
    virtual qint64 writeData(const char * data, qint64 maxSize);
pixhawk's avatar
pixhawk committed
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
public:
    Posix_QextSerialPort(QextSerialBase::QueryMode mode);
    Posix_QextSerialPort(const Posix_QextSerialPort& s);
    Posix_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode);
    Posix_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode);
    Posix_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode);
    Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
    virtual ~Posix_QextSerialPort();

    virtual void setBaudRate(BaudRateType);
    virtual void setDataBits(DataBitsType);
    virtual void setParity(ParityType);
    virtual void setStopBits(StopBitsType);
    virtual void setFlowControl(FlowType);
    virtual void setTimeout(long);

    virtual bool open(OpenMode mode);
    virtual void close();
    virtual void flush();

    virtual qint64 size() const;
    virtual qint64 bytesAvailable() const;

    virtual void ungetChar(char c);

    virtual void translateError(ulong error);

    virtual void setDtr(bool set=true);
    virtual void setRts(bool set=true);
    virtual ulong lineStatus();
pixhawk's avatar
pixhawk committed
61 62 63 64

};

#endif