QuRT and POSIX changes - part 5

Last part of the main QuRT related changes

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-04-24 01:39:25 -07:00
parent 187f13cd70
commit a1332e699c
10 changed files with 42 additions and 19 deletions
+9 -7
View File
@@ -41,12 +41,8 @@
*/
/* XXX trim includes */
#ifdef __PX4_NUTTX
#include <nuttx/config.h>
#include <nuttx/sched.h>
#else
#include <px4_config.h>
#endif
#include <px4_time.h>
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>
@@ -64,8 +60,10 @@
#include <time.h>
#include <float.h>
#include <unistd.h>
#ifndef __PX4_QURT
#include <sys/prctl.h>
#include <termios.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <poll.h>
@@ -993,7 +991,7 @@ MavlinkReceiver::handle_message_system_time(mavlink_message_t *msg)
mavlink_msg_system_time_decode(msg, &time);
timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
px4_clock_gettime(CLOCK_REALTIME, &tv);
// date -d @1234567890: Sat Feb 14 02:31:30 MSK 2009
bool onb_unix_valid = (unsigned long long)tv.tv_sec > PX4_EPOCH_SECS;
@@ -1002,7 +1000,7 @@ MavlinkReceiver::handle_message_system_time(mavlink_message_t *msg)
if (!onb_unix_valid && ofb_unix_valid) {
tv.tv_sec = time.time_unix_usec / 1000000ULL;
tv.tv_nsec = (time.time_unix_usec % 1000000ULL) * 1000ULL;
if(clock_settime(CLOCK_REALTIME, &tv)) {
if(px4_clock_settime(CLOCK_REALTIME, &tv)) {
warn("failed setting clock");
}
else {
@@ -1488,6 +1486,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
void *
MavlinkReceiver::receive_thread(void *arg)
{
#ifndef __PX4_QURT
int uart_fd = _mavlink->get_uart_fd();
const int timeout = 500;
@@ -1530,6 +1529,7 @@ MavlinkReceiver::receive_thread(void *arg)
_mavlink->count_rxbytes(nread);
}
}
#endif
return NULL;
}
@@ -1576,9 +1576,11 @@ MavlinkReceiver::receive_start(Mavlink *parent)
pthread_attr_t receiveloop_attr;
pthread_attr_init(&receiveloop_attr);
#ifndef __PX4_QURT
// set to non-blocking read
int flags = fcntl(parent->get_uart_fd(), F_GETFL, 0);
fcntl(parent->get_uart_fd(), F_SETFL, flags | O_NONBLOCK);
#endif
struct sched_param param;
(void)pthread_attr_getschedparam(&receiveloop_attr, &param);