|
|
|
@ -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)
|
|
|
|
|