-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialport-win32.h
executable file
·77 lines (65 loc) · 1.87 KB
/
serialport-win32.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef SERIALPORTWIN32_H
#define SERIALPORTWIN32_H
#include "serialport.h"
class StandardSerialPortBackend : public AbstractSerialPortBackend
{
Q_OBJECT
public:
StandardSerialPortBackend(QObject *parent = 0);
~StandardSerialPortBackend();
static QString defaultPortName();
bool open();
bool isOpen();
void close();
void cancel();
int speedByte();
QByteArray readCommandFrame();
QByteArray readDataFrame(uint size, bool verbose = true);
bool writeDataFrame(const QByteArray &data);
bool writeCommandAck();
bool writeCommandNak();
bool writeDataAck();
bool writeDataNak();
bool writeComplete();
bool writeError();
bool setSpeed(int speed);
bool writeRawFrame(const QByteArray &data);
private:
bool mCanceled;
bool mHighSpeed;
void *mHandle, *mCancelHandle;
int mSpeed;
int mMethod;
bool setNormalSpeed();
bool setHighSpeed();
int speed();
quint8 sioChecksum(const QByteArray &data, uint size);
QByteArray readRawFrame(uint size, bool verbose = true);
QString lastErrorMessage();
};
/* Dummy AtariSIO backend */
class AtariSioBackend : public AbstractSerialPortBackend
{
Q_OBJECT
public:
static QString defaultPortName();
AtariSioBackend(QObject *parent = 0);
~AtariSioBackend();
bool open();
bool isOpen();
void close();
void cancel();
int speedByte();
QByteArray readCommandFrame();
QByteArray readDataFrame(uint size, bool verbose = true);
bool writeDataFrame(const QByteArray &data);
bool writeCommandAck();
bool writeCommandNak();
bool writeDataAck();
bool writeDataNak();
bool writeComplete();
bool writeError();
bool setSpeed(int speed);
bool writeRawFrame(const QByteArray &data);
};
#endif // SERIALPORTWIN32_H