-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsolei2cinterface.h
60 lines (47 loc) · 1.49 KB
/
consolei2cinterface.h
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
#ifndef CONSOLEI2CINTERFACE_H
#define CONSOLEI2CINTERFACE_H
#include <QList>
#include <QStringList>
#include <i2cportinterface.h>
#include "consoleinterface.h"
class ConsoleI2cInterface : public I2cPortInterface
{
ConsoleInterface * con;
QByteArray inputBuffer;
struct operation
{
unsigned char adr;
QByteArray data;
unsigned int size;
unsigned int time;
enum {READ,WRITE,STOP,WAIT} type;
};
QList<operation> operations;
public:
ConsoleI2cInterface();
void setConsole(ConsoleInterface * acon);
bool open();
void close();
void checkAsk(bool a);
void writeNow (unsigned char adr,QByteArray data);
QByteArray readNow (unsigned char adr,unsigned int size);
QByteArray writeReadNow (unsigned char adr,QByteArray data ,unsigned int size);
bool isOk();
void addWrite (unsigned char adr,QByteArray data);
void addRead (unsigned char adr,unsigned int size);
void addStop();
void addWait(int time);
bool preform();
int getBufferLength();
QByteArray getBuffer();
bool isAvable() {return true;}
QString name() {return "CONI2C";}
QString description() {return QObject::tr("Virtual I2C -> Console");}
QString reason() {return "";}
bool load() {return true;}
void unload() {}
virtual void setPortName(QString n) {Q_UNUSED(n);}
virtual QString getPortName() {return "";}
virtual QStringList getPortList() {return QStringList ();}
};
#endif // CONSOLEI2CINTERFACE_H