diff options
author | Julian Oes <julian@oes.ch> | 2014-06-09 07:48:50 +0200 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2014-06-09 07:48:50 +0200 |
commit | d8f77a2b396b651410c7f28cfad84c6f8288925c (patch) | |
tree | b5fff2eff1b1522a7757ef33ca405640e70f3e4c /src/drivers/gps/ubx.cpp | |
parent | 13b6dffb2e719219ffccccd6681d36e695165aa5 (diff) | |
parent | 497b89165972b7c4836fcb8bc0da681d8e67fb32 (diff) | |
download | px4-firmware-d8f77a2b396b651410c7f28cfad84c6f8288925c.tar.gz px4-firmware-d8f77a2b396b651410c7f28cfad84c6f8288925c.tar.bz2 px4-firmware-d8f77a2b396b651410c7f28cfad84c6f8288925c.zip |
Merge remote-tracking branch 'px4/master' into navigator_rewrite
Conflicts:
src/modules/position_estimator_inav/position_estimator_inav_main.c
Diffstat (limited to 'src/drivers/gps/ubx.cpp')
-rw-r--r-- | src/drivers/gps/ubx.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/drivers/gps/ubx.cpp b/src/drivers/gps/ubx.cpp index 6820fb73d..404607571 100644 --- a/src/drivers/gps/ubx.cpp +++ b/src/drivers/gps/ubx.cpp @@ -69,6 +69,9 @@ UBX::UBX(const int &fd, struct vehicle_gps_position_s *gps_position) : _gps_position(gps_position), _configured(false), _waiting_for_ack(false), + _got_posllh(false), + _got_velned(false), + _got_timeutc(false), _disable_cmd_last(0) { decode_init(); @@ -275,9 +278,10 @@ UBX::receive(unsigned timeout) bool handled = false; while (true) { + bool ready_to_return = _configured ? (_got_posllh && _got_velned && _got_timeutc) : handled; /* poll for new data, wait for only UBX_PACKET_TIMEOUT (2ms) if something already received */ - int ret = poll(fds, sizeof(fds) / sizeof(fds[0]), handled ? UBX_PACKET_TIMEOUT : timeout); + int ret = poll(fds, sizeof(fds) / sizeof(fds[0]), ready_to_return ? UBX_PACKET_TIMEOUT : timeout); if (ret < 0) { /* something went wrong when polling */ @@ -286,7 +290,10 @@ UBX::receive(unsigned timeout) } else if (ret == 0) { /* return success after short delay after receiving a packet or timeout after long delay */ - if (handled) { + if (ready_to_return) { + _got_posllh = false; + _got_velned = false; + _got_timeutc = false; return 1; } else { @@ -438,6 +445,7 @@ UBX::handle_message() _rate_count_lat_lon++; + _got_posllh = true; ret = 1; break; } @@ -482,6 +490,7 @@ UBX::handle_message() _gps_position->time_gps_usec += (uint64_t)(packet->time_nanoseconds * 1e-3f); _gps_position->timestamp_time = hrt_absolute_time(); + _got_timeutc = true; ret = 1; break; } @@ -557,6 +566,7 @@ UBX::handle_message() _rate_count_vel++; + _got_velned = true; ret = 1; break; } |