Subversion Repositories Code-Repo

Rev

Rev 345 | Blame | Last modification | View Log | RSS feed

#ifndef SERIALCONTROLLER_H
#define SERIALCONTROLLER_H

#include "GlobalDefines.h"
#include <QtSerialPort>

#define SERIAL_NEWLINE_CHAR "\n"
#define SERIAL_BUFFER_SIZE      32

class SerialController : public QObject
{
        Q_OBJECT
    public:
        SerialController(QObject *parent = 0);
        ~SerialController();

        bool connected;

    public slots:
        void Serial_QueryParameters(void);
        void Serial_Connect(QString port, QString speed, QString dataBits,
                            QString stopBits, QString parity, QString flowControl);
        void Serial_Disconnect(void);
        void Serial_TransmitString(QString string);
        void Serial_ProcessIncomingData(void);

    signals:
        void Serial_UpdateParameters(QStringList ports, QStringList speeds, QStringList dataBits,
                                     QStringList stopBits, QStringList parity, QStringList flowControl);
        void Serial_ReceivedString(QString string);
        void Serial_Connected(void);
        void Serial_Disconnected(void);

    private:
        QSerialPort *serialPort;
        QStringList speeds;
        QStringList dataBits;
        QStringList stopBits;
        QStringList parity;
        QStringList flowControl;

        char bufferIn[SERIAL_BUFFER_SIZE];
        int bufferInIndex;
        bool bufferInOverflow;
        QString currString;
};

#endif // SERIALCONTROLLER_H