summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/io_serial.h
blob: f8b04e2b45e0d542b1dd91aa50e28be11bb9fe4e (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
#ifndef OPIE_IO_SERIAL
#define OPIE_IO_SERIAL

#include <qsocketnotifier.h>
#include "io_layer.h"

/* Default values to be used if the profile information is incomplete */
#define SERIAL_DEFAULT_DEVICE       "/dev/ttyS0"
#define SERIAL_DEFAULT_BAUD         9600
#define SERIAL_DEFAULT_PARITY       0
#define SERIAL_DEFAULT_DBITS        8
#define SERIAL_DEFAULT_SBITS        1
#define SERIAL_DEFAULT_FLOW         0

/* IOSerial implements a RS232 IO Layer */

class IOSerial : public IOLayer {
    Q_OBJECT
public:
    enum Parity {
        ParityNone = 0,
        ParityEven,
        ParityOdd,
        ParitySpace,
        ParityMark
    };

    enum Flow {
        FlowHW = 0x01,
        FlowSW = 0x02
    };

    IOSerial(const Profile &);
    ~IOSerial();

    virtual QString identifier() const;
    virtual QString name() const;
    int rawIO() const;
    void closeRawIO (int fd );
    virtual QBitArray supports() const;
    virtual bool isConnected();

/*signals:
    void received(const QByteArray &);
    void error(int, const QString &);
*/
public slots:
    virtual void send(const QByteArray &);
    virtual bool open();
    virtual void close();
    virtual void reload(const Profile &);
protected:
    int baud(int baud) const;
    void internDetach();
    void internAttach();
protected slots:
    void dataArrived();
    void errorOccured();
protected:
    QSocketNotifier *m_read;
    QSocketNotifier *m_error;
    QString          m_device;
    int              m_baud;
    int              m_parity;
    int              m_dbits;
    int              m_sbits;
    int              m_flow;
    int              m_fd;
    bool             m_connected;

};

#endif /* OPIE_IO_SERIAL */