From e2b801a3239df53c743e343caf5512ab772eeeb7 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 26 Sep 2015 20:12:15 +0300 Subject: [PATCH 1/3] Fixes 2911 --- src/modules/uavcan/sensors/baro.cpp | 9 ++++++++- src/modules/uavcan/sensors/gnss.cpp | 10 +++++++++- src/modules/uavcan/sensors/mag.cpp | 9 ++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/modules/uavcan/sensors/baro.cpp b/src/modules/uavcan/sensors/baro.cpp index 1986de4247..694a3988a1 100644 --- a/src/modules/uavcan/sensors/baro.cpp +++ b/src/modules/uavcan/sensors/baro.cpp @@ -159,7 +159,14 @@ void UavcanBarometerBridge::air_pressure_sub_cb(const { baro_report report; - report.timestamp = msg.getMonotonicTimestamp().toUSec(); + /* + * FIXME HACK + * This code used to rely on msg.getMonotonicTimestamp().toUSec() instead of HRT. + * It stopped working when the time sync feature has been introduced, because it caused libuavcan + * to use an independent time source (based on hardware TIM5) instead of HRT. + * The proper solution is to be developed. + */ + report.timestamp = hrt_absolute_time(); report.temperature = last_temperature_kelvin - 273.15F; report.pressure = msg.static_pressure / 100.0F; // Convert to millibar report.error_count = 0; diff --git a/src/modules/uavcan/sensors/gnss.cpp b/src/modules/uavcan/sensors/gnss.cpp index 0830aba4ee..d80b4b425d 100644 --- a/src/modules/uavcan/sensors/gnss.cpp +++ b/src/modules/uavcan/sensors/gnss.cpp @@ -96,7 +96,15 @@ void UavcanGnssBridge::gnss_fix_sub_cb(const uavcan::ReceivedDataStructure Date: Sun, 27 Sep 2015 11:37:30 +0200 Subject: [PATCH 2/3] fix 'unterminated function-like macro invocation', fixes #2913 --- src/platforms/px4_log.h | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/platforms/px4_log.h b/src/platforms/px4_log.h index a8208313e6..0c1063883b 100644 --- a/src/platforms/px4_log.h +++ b/src/platforms/px4_log.h @@ -63,7 +63,7 @@ static inline void do_nothing(int level, ...) #define PX4_ERR(...) ROS_WARN(__VA_ARGS__) #define PX4_WARN(...) ROS_WARN(__VA_ARGS__) #define PX4_INFO(...) ROS_WARN(__VA_ARGS__) -#define PX4_DEBUG(...) +#define PX4_DEBUG(...) #elif defined(__PX4_QURT) #include "qurt_log.h" @@ -137,13 +137,13 @@ __END_DECLS * * To write to a specific stream for each message type, open the streams and * set __px4__log_startline to something like: - * if (level <= __px4_log_level_current) printf(_px4_fd[level], + * if (level <= __px4_log_level_current) printf(_px4_fd[level], * * Additional behavior can be added using "{\" for __px4__log_startline and * "}" for __px4__log_endline and any other required setup or teardown steps ****************************************************************************/ -#define __px4__log_startcond(cond) if (cond) printf( -#define __px4__log_startline(level) if (level <= __px4_log_level_current) printf( +#define __px4__log_printcond(cond, ...) if (cond) printf(__VA_ARGS__) +#define __px4__log_printline(level, ...) if (level <= __px4_log_level_current) printf(__VA_ARGS__) #define __px4__log_timestamp_fmt "%-10" PRIu64 " " #define __px4__log_timestamp_arg ,hrt_absolute_time() @@ -172,12 +172,12 @@ __END_DECLS * if the first arg/condition is true. ****************************************************************************/ #define __px4_log_named_cond(name, cond, FMT, ...) \ - __px4__log_startcond(cond)\ + __px4__log_printcond(cond,\ "%s " \ FMT\ __px4__log_end_fmt \ ,name, ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log: @@ -187,12 +187,12 @@ __END_DECLS * printf("%-5s val is %d\n", __px4_log_level_str[3], val); ****************************************************************************/ #define __px4_log(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt \ FMT\ __px4__log_end_fmt \ __px4__log_level_arg(level), ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp: @@ -203,7 +203,7 @@ __END_DECLS * hrt_absolute_time(), val); ****************************************************************************/ #define __px4_log_timestamp(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -211,7 +211,7 @@ __END_DECLS __px4__log_level_arg(level)\ __px4__log_timestamp_arg\ , ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_thread: @@ -222,7 +222,7 @@ __END_DECLS * hrt_absolute_time(), pthread_self(), val); ****************************************************************************/ #define __px4_log_timestamp_thread(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ __px4__log_thread_fmt\ @@ -232,18 +232,18 @@ __END_DECLS __px4__log_timestamp_arg\ __px4__log_thread_arg\ , ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s val is %d (file %s line %u)\n", + * printf("%-5s val is %d (file %s line %u)\n", * __px4_log_level_str[3], val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -253,19 +253,19 @@ __END_DECLS __px4__log_timestamp_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %-10lu val is %d (file %s line %u)\n", + * printf("%-5s %-10lu val is %d (file %s line %u)\n", * __px4_log_level_str[3], hrt_absolute_time(), * val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_timestamp_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -275,19 +275,19 @@ __END_DECLS __px4__log_timestamp_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_thread_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %#X val is %d (file %s line %u)\n", - * __px4_log_level_str[3], pthread_self(), + * printf("%-5s %#X val is %d (file %s line %u)\n", + * __px4_log_level_str[3], pthread_self(), * val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_thread_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_thread_fmt\ FMT\ @@ -297,19 +297,19 @@ __END_DECLS __px4__log_thread_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_thread_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %-10lu %#X val is %d (file %s line %u)\n", - * __px4_log_level_str[3], hrt_absolute_time(), + * printf("%-5s %-10lu %#X val is %d (file %s line %u)\n", + * __px4_log_level_str[3], hrt_absolute_time(), * pthread_self(), val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_timestamp_thread_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ __px4__log_thread_fmt\ @@ -321,7 +321,7 @@ __END_DECLS __px4__log_thread_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** From 0a79c809adce17f6bb757249c5681d3da8daa679 Mon Sep 17 00:00:00 2001 From: Thomas Gubler Date: Sun, 27 Sep 2015 11:38:05 +0200 Subject: [PATCH 3/3] fix 'ignoring return value of function declared with warn_unused_result' --- src/systemcmds/esc_calib/esc_calib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/systemcmds/esc_calib/esc_calib.c b/src/systemcmds/esc_calib/esc_calib.c index 8da9580207..86939ff686 100644 --- a/src/systemcmds/esc_calib/esc_calib.c +++ b/src/systemcmds/esc_calib/esc_calib.c @@ -233,7 +233,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + return 0; + } if (c == 'y' || c == 'Y') { break; @@ -315,7 +318,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + goto done; + } if (c == 13) { break; @@ -352,7 +358,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + goto done; + } if (c == 13) { break;