summaryrefslogtreecommitdiffstats
path: root/src/serialportengine_p.h
blob: 4f122a8acaeff78851605237a2499bdbb78d9cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
    License...
*/

#ifndef SERIALPORTENGINE_P_H
#define SERIALPORTENGINE_P_H

#include "serialport.h"
#include "serialport_p.h"

QT_BEGIN_NAMESPACE

class SerialPortEngine
{
public:

#if defined (Q_OS_WINCE)
    // Only for WinCE.
    enum NotificationLockerType {
        CanReadLocker,
        CanWriteLocker,
        CanErrorLocker
    };
#endif

    virtual ~SerialPortEngine() {}

    static SerialPortEngine *create(SerialPortPrivate *parent);

    virtual bool open(const QString &location, QIODevice::OpenMode mode) = 0;
    virtual void close(const QString &location) = 0;

    virtual SerialPort::Lines lines() const = 0;

    virtual bool setDtr(bool set) = 0;
    virtual bool setRts(bool set) = 0;

    virtual bool flush() = 0;
    virtual bool reset() = 0;

    virtual bool sendBreak(int duration) = 0;
    virtual bool setBreak(bool set) = 0;

    virtual qint64 bytesAvailable() const = 0;
    virtual qint64 bytesToWrite() const = 0;

    virtual qint64 read(char *data, qint64 len) = 0;
    virtual qint64 write(const char *data, qint64 len) = 0;
    virtual bool select(int timeout,
                        bool checkRead, bool checkWrite,
                        bool *selectForRead, bool *selectForWrite) = 0;

    virtual QString toSystemLocation(const QString &port) const = 0;
    virtual QString fromSystemLocation(const QString &location) const = 0;

    virtual bool setRate(qint32 rate, SerialPort::Directions dir) = 0;
    virtual bool setDataBits(SerialPort::DataBits dataBits) = 0;
    virtual bool setParity(SerialPort::Parity parity) = 0;
    virtual bool setStopBits(SerialPort::StopBits stopBits) = 0;
    virtual bool setFlowControl(SerialPort::FlowControl flowControl) = 0;

    virtual bool setDataErrorPolicy(SerialPort::DataErrorPolicy policy) = 0;

    virtual bool isReadNotificationEnabled() const = 0;
    virtual void setReadNotificationEnabled(bool enable) = 0;
    virtual bool isWriteNotificationEnabled() const = 0;
    virtual void setWriteNotificationEnabled(bool enable) = 0;

    virtual bool processIOErrors() = 0;

#if defined (Q_OS_WINCE)
    virtual void lockNotification(NotificationLockerType type, bool uselocker) = 0;
    virtual void unlockNotification(NotificationLockerType type) = 0;
#endif

protected:
    SerialPortPrivate *m_parent;

    virtual void detectDefaultSettings() = 0;
};

QT_END_NAMESPACE

#endif // SERIALPORTENGINE_P_H