OpenCores
URL https://opencores.org/ocsvn/bw_tiff_compression/bw_tiff_compression/trunk

Subversion Repositories bw_tiff_compression

[/] [bw_tiff_compression/] [trunk/] [client_application/] [src/] [Kernel/] [CSerialport.h] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 amulder
/*
2
 * @file     Serialport.h
3
 * @date     May 14, 2012
4
 * @author   Aart Mulder
5
 */
6
 
7
#ifndef CSERIALPORT_H
8
#define CSERIALPORT_H
9
 
10
/** @author Aart Mulder
11
 *  @version 1
12
 */
13
 
14
#include <QByteArray>
15
#include <QTime>
16
#include <QMutex>
17
#include <QQueue>
18
 
19
#include "CSerialportDevice.h"
20
 
21
class CSerialport : public CSerialportDevice
22
{
23
    Q_OBJECT
24
 
25
    enum E_CommState
26
    {
27
        S_Unknown,
28
        S_StandBy,
29
        S_WaitForData
30
    };
31
 
32
public:
33
    CSerialport();
34
    void Send(unsigned char cData);
35
    void Send(QByteArray aData);
36
    void RequestNewFrame(QString sFilename = "", QString sDir = "");
37
    bool Connect(char *sName, quint32 nBaudrate);
38
    bool Disconnect();
39
    bool IsStateStandby();
40
    bool IsStateWaitForData();
41
    int  GetBytesReceived();
42
    int  GetBytesExpected();
43
    void GetNewBytes(QByteArray *pRxData);
44
    void CancelRequest();
45
 
46
protected:
47
   void BeforeClientLoop();
48
   void ClientLoop();
49
   void AfterClientLoop();
50
   void OnDataReceived(quint8 cData);
51
   void OnDataReceived(quint8 *pData, int nSize);
52
 
53
private:
54
   unsigned int m_nBytesExpected, m_nBytesReceived, m_nImageWidth, m_nImageHeight;
55
   QByteArray m_aRxBuf;
56
   E_CommState m_oCommState;
57
   bool m_bTimeoutTimer;
58
   QTime m_oRxTimeoutTimer;
59
   int m_nTimeoutTime;
60
   QString m_sFilename;
61
   QString m_sDir;
62
   QQueue<quint8> m_aRxQForGUI;
63
   QMutex m_oRxQMutex;
64
 
65
   void handleRxByte(quint8 cData);
66
   void handleStreamComplete(QString sFilename = "", QString sDir = "");
67
 
68
private slots:
69
    void onSend(unsigned char cData);
70
    void onSend(QByteArray aData);
71
 
72
signals:
73
    void send(unsigned char cData);
74
    void send(QByteArray aData);
75
    void showErrorMessage(QString sMessage, bool bEnableBtSingleShot, bool bCheckedBtRepeat);
76
    void frameCompleted(QString sFilename);
77
 
78
};
79
 
80
#endif // CSERIALPORT_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.