-
Notifications
You must be signed in to change notification settings - Fork 1
/
rs232.h
84 lines (70 loc) · 1.8 KB
/
rs232.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
78
79
80
81
82
83
84
/****************************************************************
* rs232.h
* Based on GrblHoming - zapmaker
*
* 15 Nov 2012
* GPL License (see LICENSE file)
* Software is provided AS-IS
****************************************************************/
#ifndef RS232_H
#define RS232_H
#include <QtGlobal>
#include <QObject>
#include <stdio.h>
#include <string.h>
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_ANDROID)
#include <termios.h>
#include "../termiosext.h"
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <Windows.h>
#else
// TODO - R - if I leave out Windows.h then Sleep is not found???
#include <Windows.h>
#include <QtGui/QWindow>
#endif
#endif
void status(const char *str, ...);
void diag(const char *str, ...);
void err(const char *str, ...);
void warn(const char *str, ...);
void info(const char *str, ...);
#include <QMessageBox>
#include <qextserialport.h>
#include <qextserialenumerator.h>
class RS232 : public QObject
{
Q_OBJECT
public:
RS232();
virtual ~RS232();
//methods
bool OpenComport(QString commPortStr, QString baudRate);
void CloseComport();
void Reset();
bool isPortOpen();
QString getDetectedLineFeed();
bool haveData();
signals:
void setTime(QString currTime);
void setGyro(QString x, QString y, QString z);
void setMotor(QString pwmOut);
void setSpeed(QString rotationCount, QString speedOfTrain, QString timeDeltaWheelTurn);
public slots:
private slots:
void onDataAvailable();
private:
QextSerialPort *port;
char detectedEOL;
QString detectedLineFeed;
int detectedLineFeedSize;
QString receivedData;
//QStringList responses;
};
#endif // RS232_H