-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialengine.cpp
More file actions
98 lines (80 loc) · 1.52 KB
/
serialengine.cpp
File metadata and controls
98 lines (80 loc) · 1.52 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "serialengine.h"
#include <QtSerialPort/QSerialPort>
#include <QObject>
serialengine::serialengine()
{
serial = new QSerialPort;
openSerialPort();
m_flowcontrol = 0;
m_rand = 200;
m_parity = 0;
m_speed_update = 100;
m_stopbits = 1;
temperature = 0;
m_ser_name = "COM4";
m_databits = 8;
m_baudrate = 115200;
buffer = (char*)malloc(sizeof(char) * 5);
int i = 5;
while(i--)
{
buffer[i] = '\0';
}
reader = new QTimer;
// reader->setSingleShot(false);
connect(reader, SIGNAL(timeout()), this, SLOT(readData()));
}
serialengine::~serialengine()
{
}
void serialengine::start()
{
reader->start(m_speed_update);
}
void serialengine::stop()
{
reader->stop();
}
int serialengine::get_temp()
{
return temperature;
}
void serialengine::set_speed(const int value)
{
stop();
m_speed_update = value;
start();
}
void serialengine::set_rand(const int value)
{
m_rand = value;
}
void serialengine::set_sername(const QString name)
{
m_ser_name = name;
}
void serialengine::set_baudrate(const int value)
{
m_baudrate = value;
}
void serialengine::set_databits(const int value)
{
m_databits = value;
}
void serialengine::set_stopBits(const int value)
{
m_databits = value;
}
void serialengine::set_parity(const int value)
{
m_parity = value;
}
void serialengine::set_flowcontrol(const int value)
{
m_flowcontrol = value;
}
void serialengine::closeSerialPort()
{
if(serial->isOpen())
serial->close();
}