-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
39 lines (35 loc) · 963 Bytes
/
main.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
#include <QCoreApplication>
#include <QTextStream>
#include <QFile>
#include <QDebug>
#include <iostream>
//#include <fstream>
//#include <cstdlib>
using namespace std;
bool writeToFile(const QString &filename, const QString &fileContent);
int main(int argc, char *argv[])
{
if (argc != 3) {
cerr << "Program take 2 parameters: Send2Device <device> <message>\n";
return -1;
}
if (writeToFile((QString) argv[1], (QString) argv[2])) {
cout << "Message " << argv[2] << " to " << argv[1] << " sended\n";
return 0;
} else {
cerr << "Failed to open device file\n";
return -1;
}
}
bool writeToFile(const QString &filename, const QString &fileContent)
{
QFile gpioFile(filename);
if (gpioFile.open(QIODevice::WriteOnly)) {
QTextStream gpioStream(&gpioFile);
gpioStream << fileContent;
gpioFile.close();
return true;
} else {
return false;
}
}