code cleanup

This commit is contained in:
2018-11-30 14:19:38 +01:00
parent db016a5f2a
commit 4dd765b341
3 changed files with 26 additions and 7 deletions

View File

@@ -8,7 +8,9 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <usb.h>
#ifdef ATMEGA
#include <usb.h>
#endif
#define USB_LED_ON 1
#define USB_LED_OFF 0
@@ -32,7 +34,9 @@ HardwareSetup::HardwareSetup() {
// //perror("ioperm");
// }
this->stop = 0;
#ifdef ATMEGA
this->handle = nullptr;
#endif
this->fd = 0;
}
void HardwareSetup::setStop() {
@@ -48,10 +52,12 @@ HardwareSetup::~HardwareSetup() {
this->stop = 1;
if (HARDWARE_VERSION == 2) {
#ifdef ATMEGA
if (this->handle) {
usb_close(this->handle);
}
this->handle = NULL;
#endif
}
else if (HARDWARE_VERSION == 3) {
// close filedescriptor
@@ -63,6 +69,7 @@ HardwareSetup::~HardwareSetup() {
}
}
}
#ifdef ATMEGA
/* Used to get descriptor strings for device identification */
int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index,
@@ -158,12 +165,14 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
}
return NULL;
}
#endif
void HardwareSetup::run() {
struct TransStruct buffer[6];
if (HARDWARE_VERSION == 2) {
#ifdef ATMEGA
int testmode = 0;
int nBytes = 0;
@@ -300,7 +309,9 @@ void HardwareSetup::run() {
}
}
}
#endif
} // end HARDWARE_VERSION 2
else if (HARDWARE_VERSION == 3) {
fd = open(PORT_PATH, O_RDONLY);