/
setstickerfuse.cpp
46 lines (39 loc) · 1.23 KB
/
setstickerfuse.cpp
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
#include <QString>
#include <QProcess>
#include "setstickerfuse.h"
SetStickerFuse::SetStickerFuse(int num, QString fuse, int value,
QString config, QString part)
: stickerNum(num), fuseValue(value), fuseName(fuse),
configFile(config), partName(part)
{
name = "Set sticker fuse";
}
void SetStickerFuse::runTest()
{
QProcess avrdude;
emit testMessage(testName(), infoMessage, stickerNum,
QString("Setting fuse ") + fuseName
+ " to 0x" + QString::number(fuseValue, 16));
selectSticker(stickerNum);
avrdude.start("./avrdude", QStringList()
<< "-C" << configFile
<< "-c" << "linuxgpio"
<< "-P" << "linuxgpio"
<< "-p" << partName
<< "-U" << (QString()
+ fuseName + ":w:0x" + QString::number(fuseValue, 16) + ":m")
);
if (!avrdude.waitForStarted()) {
testError("Unable to start avrdude");
return;
}
avrdude.closeWriteChannel();
if (!avrdude.waitForFinished()) {
testError("avrdude never finished");
return;
}
if (avrdude.exitCode()) {
testError(QString("avrdude returned an error: ") + avrdude.readAll());
return;
}
}