mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 21:03:34 +08:00
gps: make the driver compile and run on QURT
This commit is contained in:
+23
-23
@@ -12,9 +12,13 @@
|
||||
#include <uORB/topics/vehicle_gps_position.h>
|
||||
#include <uORB/topics/satellite_info.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <px4_time.h>
|
||||
#include <px4_defines.h>
|
||||
#ifdef __PX4_QURT
|
||||
#include <dspal_time.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
|
||||
ASHTECH::ASHTECH(const int &fd, struct vehicle_gps_position_s *gps_position, struct satellite_info_s *satellite_info):
|
||||
_fd(fd),
|
||||
@@ -99,6 +103,9 @@ int ASHTECH::handle_message(int len)
|
||||
timeinfo.tm_hour = ashtech_hour;
|
||||
timeinfo.tm_min = ashtech_minute;
|
||||
timeinfo.tm_sec = int(ashtech_sec);
|
||||
|
||||
// TODO: this functionality is not available on the Snapdragon yet
|
||||
#ifndef __PX4_QURT
|
||||
time_t epoch = mktime(&timeinfo);
|
||||
|
||||
if (epoch > GPS_EPOCH_SECS) {
|
||||
@@ -112,7 +119,7 @@ int ASHTECH::handle_message(int len)
|
||||
ts.tv_sec = epoch;
|
||||
ts.tv_nsec = usecs * 1000;
|
||||
|
||||
if (clock_settime(CLOCK_REALTIME, &ts)) {
|
||||
if (px4_clock_settime(CLOCK_REALTIME, &ts)) {
|
||||
warn("failed setting clock");
|
||||
}
|
||||
|
||||
@@ -123,6 +130,10 @@ int ASHTECH::handle_message(int len)
|
||||
_gps_position->time_utc_usec = 0;
|
||||
}
|
||||
|
||||
#else
|
||||
_gps_position->time_utc_usec = 0;
|
||||
#endif
|
||||
|
||||
_gps_position->timestamp_time = hrt_absolute_time();
|
||||
}
|
||||
|
||||
@@ -514,10 +525,6 @@ int ASHTECH::handle_message(int len)
|
||||
int ASHTECH::receive(unsigned timeout)
|
||||
{
|
||||
{
|
||||
/* poll descriptor */
|
||||
pollfd fds[1];
|
||||
fds[0].fd = _fd;
|
||||
fds[0].events = POLLIN;
|
||||
|
||||
uint8_t buf[32];
|
||||
|
||||
@@ -541,38 +548,31 @@ int ASHTECH::receive(unsigned timeout)
|
||||
}
|
||||
}
|
||||
|
||||
/* in case we keep trying but only get crap from GPS */
|
||||
if (time_started + timeout * 1000 * 2 < hrt_absolute_time()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
/* everything is read */
|
||||
j = bytes_count = 0;
|
||||
|
||||
/* then poll for new data */
|
||||
int ret = ::poll(fds, sizeof(fds) / sizeof(fds[0]), timeout * 2);
|
||||
/* then poll or read for new data */
|
||||
int ret = poll_or_read(_fd, buf, sizeof(buf), timeout * 2);
|
||||
|
||||
if (ret < 0) {
|
||||
/* something went wrong when polling */
|
||||
return -1;
|
||||
|
||||
} else if (ret == 0) {
|
||||
/* Timeout */
|
||||
return -1;
|
||||
/* Timeout while polling or just nothing read if reading, let's
|
||||
* stay here, and use timeout below. */
|
||||
|
||||
} else if (ret > 0) {
|
||||
/* if we have new data from GPS, go handle it */
|
||||
if (fds[0].revents & POLLIN) {
|
||||
/*
|
||||
* We are here because poll says there is some data, so this
|
||||
* won't block even on a blocking device. If more bytes are
|
||||
* available, we'll go back to poll() again...
|
||||
*/
|
||||
bytes_count = ::read(_fd, buf, sizeof(buf));
|
||||
}
|
||||
bytes_count = ret;
|
||||
}
|
||||
|
||||
/* in case we get crap from GPS or time out */
|
||||
if (time_started + timeout * 1000 * 2 < hrt_absolute_time()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user