got rid of keep_running external ref

pull/1/head
Tom Early 9 years ago
parent f6efa6080c
commit 3c348544ac

@ -24,11 +24,8 @@
#include <termios.h> #include <termios.h>
#include <time.h> #include <time.h>
#include <sys/file.h> #include <sys/file.h>
#include <atomic>
#include "DVAPDongle.h" #include "DVAPDongle.h"
extern std::atomic<bool> keep_running;
CDVAPDongle::CDVAPDongle() : MAX_REPL_CNT(20u) CDVAPDongle::CDVAPDongle() : MAX_REPL_CNT(20u)
{ {
} }
@ -135,7 +132,8 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr)
uint16_t len = dr.header & 0x1fff; uint16_t len = dr.header & 0x1fff;
if (len > 50) { if (len > 50) {
syncit(); if (syncit())
return RT_ERR;
return RT_TIMEOUT; return RT_TIMEOUT;
} }
@ -183,15 +181,13 @@ REPLY_TYPE CDVAPDongle::GetReply(SDVAP_REGISTER &dr)
else if (0x5u== dr.header && 0x80u==dr.param.control) else if (0x5u== dr.header && 0x80u==dr.param.control)
return RT_SQL; return RT_SQL;
else { else {
syncit(); if (syncit())
return RT_ERR;
return RT_TIMEOUT; return RT_TIMEOUT;
} }
/* It should never get here */
return RT_TIMEOUT;
} }
void CDVAPDongle::syncit() bool CDVAPDongle::syncit()
{ {
unsigned char data[7]; unsigned char data[7];
struct timeval tv; struct timeval tv;
@ -212,9 +208,8 @@ void CDVAPDongle::syncit()
if (n <= 0) { if (n <= 0) {
cnt ++; cnt ++;
if (cnt > 100) { if (cnt > 100) {
traceit("dvap is not responding,...stopping\n"); traceit("syncit() uncessful...stopping\n");
keep_running = false; return true;
return;
} }
} else { } else {
unsigned char c; unsigned char c;
@ -233,7 +228,7 @@ void CDVAPDongle::syncit()
} }
} }
traceit("Stopping syncing dvap\n"); traceit("Stopping syncing dvap\n");
return; return false;
} }
bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number) bool CDVAPDongle::get_ser(char *dvp, char *dvap_serial_number)

@ -17,6 +17,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <stdint.h>
enum REPLY_TYPE { enum REPLY_TYPE {
RT_TIMEOUT, RT_TIMEOUT,
RT_ERR, RT_ERR,
@ -104,7 +106,7 @@ class CDVAPDongle
bool OpenSerial(char *device); bool OpenSerial(char *device);
int read_from_dvp(void* buf, unsigned int len); int read_from_dvp(void* buf, unsigned int len);
int write_to_dvp(const void* buf, const 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_ser(char *dvp, char *dvap_serial_number);
bool get_name(); bool get_name();
bool get_fw(); bool get_fw();

Loading…
Cancel
Save

Powered by TurnKey Linux.