Subversion Repositories Code-Repo

Rev

Rev 364 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
352 Kevin 1
#ifndef SERIALHELPER_H
2
#define SERIALHELPER_H
3
 
4
#include "GlobalDefines.h"
5
#include <QtSerialPort>
6
 
7
#define SERIAL_NEWLINE_CHAR "\n"
8
#define SERIAL_BUFFER_SIZE	32
9
 
10
class SerialHelper : public QObject
11
{
12
        Q_OBJECT
13
    public:
14
        SerialHelper(QObject *parent = 0);
15
        ~SerialHelper();
16
 
17
        bool connected;
18
 
19
    public slots:
20
        // Inbound from SerialController
362 Kevin 21
        void QueryParameters(void);
22
        void Connect(QString port, QString speed, QString dataBits,
23
                     QString stopBits, QString parity, QString flowControl);
24
        void Disconnect(bool errored = false);
25
        void TransmitString(QString string);
26
        void TransmitByteArray(QByteArray data);
352 Kevin 27
 
28
        // Local processing of received data
362 Kevin 29
        void ProcessIncomingData(void);
30
        void ProcessError(QSerialPort::SerialPortError error);
352 Kevin 31
 
32
    signals:
33
        // Outbound to SerialController
362 Kevin 34
        void UpdateParameters(QStringList ports, QStringList speeds, QStringList dataBits,
35
                              QStringList stopBits, QStringList parity, QStringList flowControl);
36
        void ReceivedByte(QByteArray);
364 Kevin 37
        void Connected(bool);
352 Kevin 38
        void UpdateStatus(QString string);
39
 
40
    private:
41
        QSerialPort *serialPort;
42
        QStringList speeds;
43
        QStringList dataBits;
44
        QStringList stopBits;
45
        QStringList parity;
46
        QStringList flowControl;
47
 
48
        char bufferIn[SERIAL_BUFFER_SIZE];
49
        int bufferInIndex;
50
        bool bufferInOverflow;
51
        QString currString;
52
};
53
 
54
#endif // SERIALHELPER_H