added missing gps code
This commit is contained in:
parent
a99e72d7ae
commit
583934990e
@ -38,7 +38,7 @@
|
||||
|
||||
#define XTRA_BLOCK_SIZE 400
|
||||
#define DISABLE_CLEANUP 1 // fully shutting down the GPS is temporarily disabled
|
||||
#define ENABLE_NMEA 0
|
||||
#define ENABLE_NMEA 1
|
||||
|
||||
#define MEASUREMENT_PRECISION 10.0f // in meters
|
||||
#define DUMP_DATA 0
|
||||
@ -448,11 +448,11 @@ nmea_reader_parse( NmeaReader* r )
|
||||
Token tok;
|
||||
int report_nmea = 0;
|
||||
|
||||
#if DUMP_DATA & 0
|
||||
#if DUMP_DATA
|
||||
D("Received: %.*s", r->pos, r->in);
|
||||
#endif
|
||||
if (r->pos < 9) {
|
||||
#if DUMP_DATA & 0
|
||||
#if DUMP_DATA
|
||||
D("Too short. discarded.");
|
||||
#endif
|
||||
return;
|
||||
@ -484,7 +484,7 @@ nmea_reader_parse( NmeaReader* r )
|
||||
// Satellites in View
|
||||
Token tok_num_svs = nmea_tokenizer_get(tzer, 3);
|
||||
int num_svs = str2int(tok_num_svs.p, tok_num_svs.end);
|
||||
report_nmea = 1;
|
||||
//report_nmea = 1;
|
||||
|
||||
if (num_svs > 0) {
|
||||
Token tok_total_sentences= nmea_tokenizer_get(tzer, 1);
|
||||
@ -607,7 +607,7 @@ nmea_reader_parse( NmeaReader* r )
|
||||
|
||||
} else {
|
||||
tok.p -= 2;
|
||||
#if DUMP_DATA & 0
|
||||
#if DUMP_DATA
|
||||
D("unknown sentence '%.*s", tok.end-tok.p, tok.p);
|
||||
#endif
|
||||
}
|
||||
@ -894,16 +894,24 @@ static void* gps_state_thread( void* arg ) {
|
||||
} else if (fd == gps_fd) {
|
||||
char buf[512];
|
||||
int nn, ret;
|
||||
//D("gps fd event");
|
||||
#if DUMP_DATA
|
||||
D("gps fd event");
|
||||
#endif
|
||||
do {
|
||||
ret = read( fd, buf, sizeof(buf) );
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
|
||||
if (ret > 0) {
|
||||
for (nn = 0; nn < ret; nn++)
|
||||
for (nn = 0; nn < ret; nn++) {
|
||||
nmea_reader_addc( reader, buf[nn] );
|
||||
#if DUMP_DATA & 0
|
||||
D("%2d, nmea_reader_addc() is called", nn+1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//D("gps fd event end");
|
||||
#if DUMP_DATA
|
||||
D("gps fd event end");
|
||||
#endif
|
||||
} else {
|
||||
LOGE("epoll_wait() returned unkown fd %d ?", fd);
|
||||
}
|
||||
@ -924,7 +932,7 @@ static void gps_state_init( GpsState* state ) {
|
||||
#if ENABLE_NMEA
|
||||
state->fd = open("/dev/smd27", O_RDONLY);
|
||||
#else
|
||||
state->fd;
|
||||
state->fd = -1;
|
||||
#endif
|
||||
|
||||
if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
|
||||
@ -1022,6 +1030,14 @@ static int gps_xtra_inject_xtra_data(char* data, int length) {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void xtra_download_request() {
|
||||
D("%s() is called", __FUNCTION__);
|
||||
GpsState* state = _gps_state;
|
||||
//Should be made thread safe...
|
||||
if(state->xtra_callbacks.download_request_cb)
|
||||
state->xtra_callbacks.download_request_cb();
|
||||
}
|
||||
|
||||
static const GpsXtraInterface sGpsXtraInterface = {
|
||||
gps_xtra_init,
|
||||
gps_xtra_inject_xtra_data,
|
||||
|
Loading…
Reference in New Issue
Block a user