feature: added possibility to change hardware interface from GUI

This commit is contained in:
2019-12-29 17:07:42 +01:00
parent 8443b12937
commit e102dab939
8 changed files with 163 additions and 9 deletions

View File

@@ -25,8 +25,8 @@
// V2 USB Atmega8
// V3 STM32F07
#define PORT_PATH "/dev/ttyACM0"
//#define PORT_PATH "/dev/pts/4"
// #define PORT_PATH "/dev/ttyACM0"
// #define PORT_PATH "/dev/pts/4"
using namespace std;
// not needed anymore -> usb
@@ -34,10 +34,16 @@ using namespace std;
// #define BASEPORT 0x378
// #define BASEPORT 0xd000
HardwareSetup::HardwareSetup() {
HardwareSetup::HardwareSetup(DataBase * db) {
// if (ioperm(BASEPORT, 3, 1)) {
// //perror("ioperm");
// }
this->db = db;
this->PORT_PATH =
this->db->getData("select interface from interface where id like 1", 1)
.at(0)
.at(0)
.toStdString();
this->stop = 0;
#ifdef ATMEGA
this->handle = nullptr;
@@ -362,12 +368,12 @@ void HardwareSetup::connectSTM32() {
close(fd);
}
usleep(10000);
fd = open(PORT_PATH, O_RDONLY);
fd = open(this->PORT_PATH.c_str(), O_RDONLY);
while (this->fd < 0) {
// wait 1 second
sleep(1);
cout << "Port can't be opened" << endl;
fd = open(PORT_PATH, O_RDONLY);
fd = open(PORT_PATH.c_str(), O_RDONLY);
if (this->stop) {
break;
}