93 Commits

Author SHA1 Message Date
Julian Oes
c4cb916afa Fix sdlog2/logger path/file name overflows. (#5138)
* logger: prevent logpath buffer overflows

The handling of the log path had the potential to cause buffer
overflows, especially on POSIX platforms where the paths are often much
longer than just 64 chars.

* sdlog2: prevent logpath buffer overflows

When the log folder path was created, this was done with the unsafe
sprintf function instead of snprintf. This caused buffer overflows in
SITL but the overflow was usually not detected until recent testing of
some work in progress.
2016-07-27 00:55:29 -07:00
Beat Küng
a1b710025b Improve new logger update rate (#5073)
* logger: disable some default topics, which are most likely not used

This is also to safe CPU and lower the amount of file descriptors used.

* logger: use the hrt timer for more accurate scheduling

Under NuttX with the default rate of 285Hz, the actual measured rate was
only 200Hz while on Linux it was ~280Hz. The reason is that NuttX only
uses a usleep() granularity of 1ms, so that the typical sleep time is
longer than what we set.

Now the logger waits on a semaphore, which gets activated periodically
with a hrt timer. With this the measured rate is exactly the expected one,
285Hz.
2016-07-15 16:55:32 -07:00
Beat Küng
c9652fd42a logger: update set of default topics to match functionality of sdlog2
logging rate with these topics: ~50KB/s

The rates may need to be adjusted
2016-07-11 10:04:44 +02:00
Beat Küng
84a1a10006 logger: check if we are in replay mode via ENV variable 'replay' 2016-07-07 12:51:42 +02:00
Beat Küng
28ad6066aa replay: add replay module, build for sitl_default, but do not load on startup
This adds a new module that does:
- read an parse an ULog file, given via ENV variable 'replay'
- apply all parameters from the log file
- read and apply user-defined override parameters from a file
- publish all messages in 'real-time' from the log file and add a constant
  offset to the timestamp to match the system time.
- apply changed parameters in the log (which are not overridden)
2016-07-07 12:51:42 +02:00
Beat Küng
09ecc84cc7 gps file dump: re-implement with an uORB topic & write to the log file (#4987)
Drawbacks of the previous method: when writing to the SD card, there are
high delays in the write() call of several 100ms, every now and then. The
frequency and length of these events depend on:
- SD card
- used logger bandwidth
- bandwidth of gps data (RTCM)
Since the whole gps thread was blocked during this period, it lead to
gps timeouts and lost module.

What we do now is: publish an orb topic with queuing. This makes it async
and the logger takes care of buffering. This means it's best to:
- use high logger rate
- use large logger buffer
- reduce logger bandwith by disabling unused topics
2016-07-06 09:32:37 +02:00
Beat Küng
c4e77cf411 logger: fix '-r 0' parameter: should be unlimited rate instead of 1Hz 2016-07-05 14:08:25 +02:00
Beat Küng
c94fe845ec fix logger: remove space in format for changed parameters 2016-07-05 14:08:25 +02:00
Beat Küng
a455962e17 logger: only call write_add_logged_msg when sucessfully subscribed 2016-07-05 14:08:25 +02:00
Beat Küng
3bfedfff19 logger: printf cleanup, output statistics when stopping the logger 2016-06-10 08:51:54 +02:00
Mark Whitehorn
0ca63fa379 move default topics into logger.cpp; add on/off command
look for alternate topic list at
/fs/microsd/etc/logging/logger_topics.txt
on and off commands have the same effect as arm/disarm
2016-06-10 08:51:54 +02:00
Mark Whitehorn
2bd15f1698 fix string handling issues and simplify parser 2016-06-10 08:51:54 +02:00
Mark Whitehorn
f250911776 read topics to log from a text file 2016-06-10 08:51:54 +02:00
Beat Küng
c64b0d4573 logger: don't use system time for log file name if system time obviously wrong 2016-06-06 23:27:16 +02:00
Beat Küng
605f731ac4 logger: reduce maximum logged string length to 128 (use less memory) 2016-06-06 23:27:16 +02:00
Beat Küng
76d6ffd445 logger: use the defined interval for all multi-instances (& fix code style) 2016-06-06 23:27:16 +02:00
Beat Küng
0fb0f17ccb logger: reduce memory usage, by limiting the nr of added topics to 64 (was 128) 2016-06-06 23:27:16 +02:00
Beat Küng
78d357cb0c logger: free up ~200B stack size
we now use the already existing buffer for logging messages, which is
allocated on the heap.
In fact, stack usage was too high before this, now it's ok again.
2016-06-06 23:27:16 +02:00
Beat Küng
febe75bb12 logger: don't use uint8_t buffer[msg_size]; (it's C99 not C++)
Also, it's not clear where the allocation was. It looks like it was on
the heap, but the compiler could decide to put it on the stack. This is
very bad for us because we use fixed size stacks with tights bounds. So if
a user specifies a large topic to log, it could have crashed.

Now the allocation is on the heap and the user can specify any size of
topic to log (as long as there is enough memory).
2016-06-06 23:27:16 +02:00
Beat Küng
8ef493c82d logger: use local time if orb_copy(vehicle_gps_position) fails for -t option
orb_copy can fail if there is no advertiser yet
2016-06-06 23:27:16 +02:00
Beat Küng
b51ec04938 logger: fix alignment issue in data message header 2016-06-06 23:27:16 +02:00
Beat Küng
0e3d660ccd logger refactor: add ulog_ prefix to struct names and header length 2016-06-02 07:32:49 +02:00
Beat Küng
034772056a logger: prepare for replay: add replayed file to the log, use _replayed as file name suffix 2016-06-02 07:32:49 +02:00
Beat Küng
069dd01cb0 logger: subscribe to mavlink_log messages and write them to the log 2016-06-02 07:32:49 +02:00
Beat Küng
659ac8faf2 refactor logger: use static fields & move them to source file
avoids multiple declarations of...
2016-06-02 07:32:49 +02:00
Lorenz Meier
4d4f8d25c2 Logger: Be more efficient 2016-05-29 16:26:47 +02:00
Beat Küng
7f3a95508e logger: move SDLOG_UTC_OFFSET param definition into logger module
It's still used in sdlog2, but once we'll depricate/remove sdlog2, we will
not remove this parameter as well.
2016-05-22 13:31:35 +02:00
Beat Küng
cd7c955067 logger: -t param: fall back to px4_clock_gettime if there's no gps fix 2016-05-22 13:31:35 +02:00
Beat Küng
a9930c2173 logger: avoid logging the padding if it's at the end of a message format 2016-05-22 13:31:35 +02:00
Beat Küng
bd96afa00b logger: use int32_t for utc_offset instead of uint32_t 2016-05-22 13:31:35 +02:00
Beat Küng
623fe7ca2c logger + uorb msg template: rm msg name from o_fields to save space
Instead we use o_name to get the topic name. Now the topic names are not
upper case anymore in the log format. This makes it more consistent, eg.
if used as a nested topic
2016-05-22 13:31:35 +02:00
Beat Küng
4f8d16cc4d logger: log dropout events 2016-05-22 13:31:35 +02:00
Beat Küng
c13247e14f logger: log all known formats, add ADD_LOGGED_MSG message
this is needed for nested topics.
2016-05-22 13:31:35 +02:00
Beat Küng
2d037d1a1c logger: add an MSG_HEADER_LEN to clarify meaning 2016-05-22 13:31:35 +02:00
Beat Küng
df803fc4b9 logger: remove redundant format_len from message_format_s 2016-05-22 13:31:35 +02:00
Beat Küng
971e97745f logger: reorder message header fields (for alignment) 2016-05-22 13:31:35 +02:00
Beat Küng
0ddd7a408c logger: write "sys_name" and "time_ref_utc" info to log file 2016-05-22 13:31:35 +02:00
Beat Küng
908f7eb47f logger: remove some comments, logging output 2016-05-22 13:31:35 +02:00
Beat Küng
1719d9a957 logger: add a file magic 2016-05-22 13:31:35 +02:00
Daniel Agar
97bcea292e logger.cpp fix style 2016-05-14 11:27:07 +02:00
Beat Küng
4b8152465d logger: unsubscribe from all topics when logger exits 2016-05-14 11:27:07 +02:00
Beat Küng
0f30bfa0ac logger: fix -e parameter (logger immediately stopped again after start) 2016-05-14 11:27:07 +02:00
Beat Küng
fcf7e8b78c logger: -e option only logs until disarm, add -f option to log until shutdown 2016-05-14 11:27:07 +02:00
Beat Küng
fc51f81bf5 logger: add free space check (need at least 50MB to start) 2016-05-14 11:27:07 +02:00
Beat Küng
501544520f logger: change some PX4_WARN to PX4_INFO and PX4_ERR 2016-05-14 11:27:07 +02:00
Beat Küng
fe2b80ffb8 logger: add '-t' option to use GPS date/time for file and dir name 2016-05-14 11:27:07 +02:00
Beat Küng
9da2eac3d3 logger: remove unneeded start parameters (-x & -a) 2016-05-14 11:27:07 +02:00
Beat Küng
d9ced9730b logger: remove unnecessary MODULE_CFLAGS from CMakeLists.txt 2016-05-14 11:27:07 +02:00
Beat Küng
ec6c53eb60 logger: correct cleanup in case 'logger start' fails 2016-05-14 11:27:07 +02:00
Beat Küng
da1e63eaf3 logger: fix resource leaks in LogWriter 2016-05-14 11:27:07 +02:00