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
+8
View File
@@ -112,9 +112,11 @@ public:
static void forward_message(const mavlink_message_t *msg, Mavlink *self);
#ifndef __PX4_QURT
static int get_uart_fd(unsigned index);
int get_uart_fd();
#endif
/**
* Get the MAVLink system id.
@@ -190,12 +192,14 @@ public:
int get_instance_id();
#ifndef __PX4_QURT
/**
* Enable / disable hardware flow control.
*
* @param enabled True if hardware flow control should be enabled
*/
int enable_flow_control(bool enabled);
#endif
mavlink_channel_t get_channel();
@@ -320,7 +324,9 @@ private:
bool _forwarding_on;
bool _passing_on;
bool _ftp_on;
#ifndef __PX4_QURT
int _uart_fd;
#endif
int _baudrate;
int _datarate; ///< data rate for normal streams (attitude, position, etc.)
int _datarate_events; ///< data rate for params, waypoints, text messages
@@ -378,7 +384,9 @@ private:
void mavlink_update_system();
#ifndef __PX4_QURT
int mavlink_open_uart(int baudrate, const char *uart_name, struct termios *uart_config_original, bool *is_usb);
#endif
static unsigned int interval_from_rate(float rate);
+5 -2
View File
@@ -39,6 +39,7 @@
* @author Anton Babushkin <anton.babushkin@me.com>
*/
#include <px4_time.h>
#include <stdio.h>
#include <commander/px4_custom_mode.h>
@@ -354,6 +355,7 @@ protected:
}
}
#ifndef __PX4_QURT
void send(const hrt_abstime t)
{
if (!mavlink_logbuffer_is_empty(_mavlink->get_logbuffer())) {
@@ -391,7 +393,7 @@ protected:
char log_file_path[64] = "";
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
px4_clock_gettime(CLOCK_REALTIME, &ts);
/* use GPS time for log file naming, e.g. /fs/microsd/2014-01-19/19_37_52.bin */
time_t gps_time_sec = ts.tv_sec + (ts.tv_nsec / 1e9);
struct tm tt;
@@ -410,6 +412,7 @@ protected:
}
}
}
#endif
};
class MavlinkStreamCommandLong : public MavlinkStream
@@ -975,7 +978,7 @@ protected:
mavlink_system_time_t msg;
timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
px4_clock_gettime(CLOCK_REALTIME, &tv);
msg.time_boot_ms = hrt_absolute_time() / 1000;
msg.time_unix_usec = (uint64_t)tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
+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);
+2
View File
@@ -79,7 +79,9 @@ MavlinkStream::update(const hrt_abstime t)
if (dt > 0 && dt >= interval) {
/* interval expired, send message */
#ifndef __PX4_QURT
send(t);
#endif
if (const_rate()) {
_last_sent = (t / _interval) * _interval;
+2
View File
@@ -92,7 +92,9 @@ protected:
Mavlink *_mavlink;
unsigned int _interval;
#ifndef __PX4_QURT
virtual void send(const hrt_abstime t) = 0;
#endif
private:
hrt_abstime _last_sent;