#ifndef DNCOMMTHREAD_H
#define DNCOMMTHREAD_H

#include <QThread>
#include <QDateTime>
#include <QList>

class DNCommThread : public QThread
{
    Q_OBJECT
public:
    explicit DNCommThread(QObject *parent = 0,
                          quint8 id=0,
                          bool enabled=false,
                          QString path="");
    void setparam(QString path, bool enabled);
    void setCommType(quint16 type);
    quint16 chk_crcc(quint8 *d, int len);
    QByteArray comm_work(QByteArray cmd, bool needrtn);
    void ef_comm2_read();
    void chk_rtn(QByteArray Rtn);
    void set_speed(int speed);
    int set_Parity(int databits,int stopbits,int parity);
    int open_comm();
    void chk_e2(QByteArray d, uint t);
    void chk_e3(QByteArray d, uint t);
    void run();

signals:
    void log(QString txt);
public slots:

private:
    quint8 Id;
    bool Enabled;
    bool CommOpened;
    QString CommPath;
    quint16 CommType;
    bool reopen;
    int fd;
    int ef_idx;
    int noEcho0,noEcho1;
//    quint8 liveCur,deathCur;
//    QList<quint8> liveList,deathList;
};

#endif // DNCOMMTHREAD_H
