From 3c348544aca8f73c2b232c0e05cda9bedd2f9b2b Mon Sep 17 00:00:00 2001 From: Tom Early Date: Tue, 28 Feb 2017 09:26:11 -0500 Subject: [PATCH] got rid of keep_running external ref --- DVAPDongle.cpp | 21 ++++++++------------- DVAPDongle.h | 4 +++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/DVAPDongle.cpp b/DVAPDongle.cpp index 175a345..33c6414 100644 --- a/DVAPDongle.cpp +++ b/DVAPDongle.cpp @@ -24,11 +24,8 @@ #include #include #include -#include #include "DVAPDongle.h" - extern std::atomic keep_running; - CDVAPDongle::CDVAPDongle() : MAX_REPL_CNT(20u) { } @@ -135,7 +132,8 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr) uint16_t len = dr.header & 0x1fff; if (len > 50) { - syncit(); + if (syncit()) + return RT_ERR; return RT_TIMEOUT; } @@ -183,15 +181,13 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr) else if (0x5u== dr.header && 0x80u==dr.param.control) return RT_SQL; else { - syncit(); + if (syncit()) + return RT_ERR; return RT_TIMEOUT; } - - /* It should never get here */ - return RT_TIMEOUT; } -void CDVAPDongle::syncit() +bool CDVAPDongle::syncit() { unsigned char data[7]; struct timeval tv; @@ -212,9 +208,8 @@ void CDVAPDongle::syncit() if (n <= 0) { cnt ++; if (cnt > 100) { - traceit("dvap is not responding,...stopping\n"); - keep_running = false; - return; + traceit("syncit() uncessful...stopping\n"); + return true; } } else { unsigned char c; @@ -233,7 +228,7 @@ void CDVAPDongle::syncit() } } traceit("Stopping syncing dvap\n"); - return; + return false; } bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number) diff --git a/DVAPDongle.h b/DVAPDongle.h index fdff4fc..619b8e9 100644 --- a/DVAPDongle.h +++ b/DVAPDongle.h @@ -16,6 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + #include enum REPLY_TYPE { RT_TIMEOUT, @@ -104,7 +106,7 @@ class CDVAPDongle bool OpenSerial(char *device); int read_from_dvp(void* buf, unsigned int len); int write_to_dvp(const void* buf, const unsigned int len); - void syncit(); + bool syncit(); bool get_ser(char *dvp, char *dvap_serial_number); bool get_name(); bool get_fw();