code cleanup
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user