104 Commits

Author SHA1 Message Date
Beat Küng
00cd2902c7 fix logger: avoid leaking file descriptor in get_log_time()
orb_subscribe can succeed, but if there is no publisher, orb_copy will fail.
We still need to unsubscribe in that case.
2016-10-31 12:41:04 +01:00
Beat Küng
f7d8612bc9 logger: enable all backends by default
This requires ~270B more RAM
2016-10-23 15:25:20 +02:00
Beat Küng
09d8e4fd8c logger: reduce stack size, which got freed in 05a771152520
commit msg: 'logger: avoid uORB::Subscription, directly use orb_subscribe() instead'
2016-10-23 15:25:20 +02:00
Beat Küng
64df463a85 logger: avoid setting the interval for topics where not needed
Saves some RAM, although not much in that case. But all subscriptions
combined need ~1.5KB only for the interval data within uORB.
2016-10-23 15:25:20 +02:00
Beat Küng
7140914d38 logger: remove LoggerSubscription::time_tried_subscribe
Instead use a single timestamp for subscription checks. This frees up
~800B of RAM.

Also make sure the subscription checks are distributed over time. On each
update, at most 1 topic subscription is checked. Reduces the load of the
logger from 7.3% to 5.8% (Pixracer)
2016-10-23 15:25:20 +02:00
Beat Küng
f244a78368 logger: avoid uORB::Subscription, directly use orb_subscribe() instead
This frees up ~160B stack size
2016-10-23 15:25:20 +02:00
Beat Küng
4120cd93df logger: make sure structs are properly aligned
ulog_message_info_header_s *msg = reinterpret_cast<ulog_message_info_header_s *>(buffer);
members of msg could end up unaligned, because of the uint8_t buffer.
2016-10-23 15:25:20 +02:00
Beat Küng
326800e5a8 logger: increase stack size
evaluated with: logger start -e -t -m all
and then make sure to get an error printf in the mavlink writer backend,
eg. for an ack timeout.
2016-10-19 13:13:47 +02:00
Beat Küng
8e0d548f51 logger: increase default queue size for mavlink logging to 14
tested on Pixracer: 14 still produces some dropouts once in a while, but I
think it's a fair tradefoff between RAM usage & dropouts. The queue needs
about 3.5KB of RAM.

When topic sizes/logging rates change, this will have to be reevaluated.
2016-10-19 13:13:47 +02:00
Beat Küng
f29a50df31 logger: add support for mavlink backend in Logger class, handle start/stop 2016-10-19 13:13:47 +02:00
Beat Küng
b233753e23 logger: don't exit if directory creation failed & mavlink mode enabled 2016-10-19 13:13:47 +02:00
Beat Küng
8ea38bc278 logger: better status output with configured backend mode 2016-10-19 13:13:47 +02:00
Beat Küng
7a60c1296e logger: re-use subscribed topic id's, only set them once on first use
Will be necessary when using multiple backends in parallel.
2016-10-19 13:13:47 +02:00
Beat Küng
12ded377d1 refactor logger: add need_reliable_transfer flag, remove write_wait 2016-10-19 13:13:47 +02:00
Beat Küng
de20f1778e logger: add -m <mode> and -q <queue_size> parameters, prepare for mavlink backend 2016-10-19 13:13:47 +02:00
Beat Küng
1ddddccb81 logger: move thread start/stop logic into LogWriterFile 2016-10-19 13:13:47 +02:00
Beat Küng
ccdaabc7fb refactor logger: prepare for multiple write backends 2016-10-19 13:13:47 +02:00
Beat Küng
4e1a4440ca logger: remove _enabled attribute and add LogWriter::is_started() instead 2016-10-19 13:13:47 +02:00
Beat Küng
c26e29d11c logger: move writer_thread variable into function (never accessed outside) 2016-10-19 13:13:47 +02:00
Beat Küng
ce0d31b7d9 mavlink log: ensure all critical & emergency msgs are also logged to console & ulog
Critical messages that the user sees should also go to the log file, so
that the exact error (with time) can later be analyzed from the log file.
2016-09-30 13:50:51 +02:00
Mark Whitehorn
ca9ac1c807 add default simulator groundtruth topic only for SITL builds 2016-09-19 13:05:14 +02:00
Mark Whitehorn
f24b199775 add HIL_STATE message handler and publish to uORB
add missing break

uorb topics generator: add multi-topics to the list of all topics

topic names with '# TOPICS <name>' were previously not in orb_get_topics().
This means the logger could not find them.

Affects for example actuator_controls_0.

px_generate_uorb_topic_files.py: add multitopics to generate_topics_list_file_from_files method

switch simulated attitude to new topic: vehicle_attitude_groundtruth

logger: add input_rc topic. needed for web plotting

input_rc.msg: remove timestamp_publication, use timestamp instead

mixer.cpp: warnx -> PX4_ERR

logger: initialize timer_call to 0 (hrt_call_every reads some fields)

position_setpoint_triplet topic: set the timestamp when publishing

px_generate_uorb_topic_files.py: add multitopics to generate_topics_list_file_from_files method

add vehicle_attitude_groundtruth to default topics

change to hil_state_quaternion
2016-09-19 13:05:14 +02:00
Beat Küng
4e1652fa6b logger: initialize timer_call to 0 (hrt_call_every reads some fields) 2016-09-19 13:03:40 +02:00
Beat Küng
3a94afb03c logger: add input_rc topic. needed for web plotting 2016-09-19 13:02:31 +02:00
Beat Küng
528ca931af logger: only add data message to the log if orb_copy succeeds, when adding a new instance 2016-08-24 21:24:35 +02:00
Beat Küng
df53fb0fde logging: publish a message for PX4_{WARN,ERR} & store them to the ulog file
- ulog file message rate limited to 50Hz
- queuing with size 2
- this replaces the mavlink log message in the ulog
  (but the mavlink warnings & errors still go to the ulog)
2016-08-24 21:24:35 +02:00
Beat Küng
eae1585e38 logger: store full file name in logger, remove it from log writer
- also add log file to the status output
2016-08-24 21:24:35 +02:00
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
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
76d6ffd445 logger: use the defined interval for all multi-instances (& fix code style) 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
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