Merge changes I538141eb,I799d3b29,I38fb794d
* changes:
Make roboRIO logs stand on their own
Make log_stats handle multi-node log files.
Ignore messages with 0 size
diff --git a/aos/events/logging/log_stats.cc b/aos/events/logging/log_stats.cc
index 88bf15c..c07b6b8 100644
--- a/aos/events/logging/log_stats.cc
+++ b/aos/events/logging/log_stats.cc
@@ -93,34 +93,38 @@
int it = 0; // iterate through the channel_stats
for (flatbuffers::uoffset_t i = 0; i < channels->size(); i++) {
const aos::Channel *channel = channels->Get(i);
- if (channel->name()->string_view().find(FLAGS_name) != std::string::npos) {
- // Add a record to the stats vector.
- channel_stats.push_back({channel});
- // Lambda to read messages and parse for information
- stats_event_loop->MakeRawWatcher(
- channel,
- [&logfile_stats, &channel_stats, it](const aos::Context &context,
- const void * /* message */) {
- channel_stats[it].max_message_size =
- std::max(channel_stats[it].max_message_size, context.size);
- channel_stats[it].total_message_size += context.size;
- channel_stats[it].total_num_messages++;
- // asume messages are send in sequence per channel
- channel_stats[it].channel_end_time = context.realtime_event_time;
- channel_stats[it].first_message_time =
- std::min(channel_stats[it].first_message_time,
- context.monotonic_event_time);
- channel_stats[it].current_message_time =
- context.monotonic_event_time;
- // update the overall logfile statistics
- logfile_stats.logfile_length += context.size;
- });
- it++;
- // TODO (Stephan): Frequency of messages per second
- // - Sliding window
- // - Max / Deviation
- found_channel = true;
+ if (!aos::configuration::ChannelIsReadableOnNode(
+ channel, stats_event_loop->node())) {
+ continue;
}
+
+ if (channel->name()->string_view().find(FLAGS_name) == std::string::npos) {
+ continue;
+ }
+
+ // Add a record to the stats vector.
+ channel_stats.push_back({channel});
+ // Lambda to read messages and parse for information
+ stats_event_loop->MakeRawWatcher(channel, [&logfile_stats, &channel_stats,
+ it](const aos::Context &context,
+ const void * /* message */) {
+ channel_stats[it].max_message_size =
+ std::max(channel_stats[it].max_message_size, context.size);
+ channel_stats[it].total_message_size += context.size;
+ channel_stats[it].total_num_messages++;
+ // asume messages are send in sequence per channel
+ channel_stats[it].channel_end_time = context.realtime_event_time;
+ channel_stats[it].first_message_time = std::min(
+ channel_stats[it].first_message_time, context.monotonic_event_time);
+ channel_stats[it].current_message_time = context.monotonic_event_time;
+ // update the overall logfile statistics
+ logfile_stats.logfile_length += context.size;
+ });
+ it++;
+ // TODO (Stephan): Frequency of messages per second
+ // - Sliding window
+ // - Max / Deviation
+ found_channel = true;
}
if (!found_channel) {
LOG(FATAL) << "Could not find any channels";
@@ -171,7 +175,7 @@
}
std::cout << std::setfill('-') << std::setw(80) << "-"
<< "\nLogfile statistics for: " << FLAGS_logfile << "\n"
- << "Log starts at:\t" << reader.realtime_start_time() << "\n"
+ << "Log starts at:\t" << reader.realtime_start_time(node) << "\n"
<< "Log ends at:\t" << logfile_stats.logfile_end_time << "\n"
<< "Log file size:\t" << logfile_stats.logfile_length << "\n"
<< "Total messages:\t" << logfile_stats.total_log_messages << "\n";
diff --git a/aos/events/logging/logfile_utils.cc b/aos/events/logging/logfile_utils.cc
index f062ad3..a7238ba 100644
--- a/aos/events/logging/logfile_utils.cc
+++ b/aos/events/logging/logfile_utils.cc
@@ -8,6 +8,7 @@
#include <vector>
+#include "absl/strings/escaping.h"
#include "aos/configuration.h"
#include "aos/events/logging/logger_generated.h"
#include "aos/flatbuffer_merge.h"
@@ -181,6 +182,15 @@
const size_t data_size =
flatbuffers::GetPrefixedSize(data_.data() + consumed_data_) +
sizeof(flatbuffers::uoffset_t);
+ if (data_size == sizeof(flatbuffers::uoffset_t)) {
+ LOG(ERROR) << "Size of data is zero. Log file end is corrupted, skipping.";
+ LOG(ERROR) << " Rest of log file is "
+ << absl::BytesToHexString(std::string_view(
+ reinterpret_cast<const char *>(data_.data() +
+ consumed_data_),
+ data_.size() - consumed_data_));
+ return absl::Span<const uint8_t>();
+ }
while (data_.size() < consumed_data_ + data_size) {
if (!ReadBlock()) {
return absl::Span<const uint8_t>();
diff --git a/y2020/y2020.json b/y2020/y2020.json
index b40ac87..81cf30c 100644
--- a/y2020/y2020.json
+++ b/y2020/y2020.json
@@ -325,6 +325,8 @@
"name": "/pi1/camera",
"type": "frc971.vision.sift.ImageMatchResult",
"source_node": "pi1",
+ "logger": "LOCAL_AND_REMOTE_LOGGER",
+ "logger_node": "roborio",
"frequency": 25,
"max_size": 10000,
"destination_nodes": [
@@ -361,6 +363,8 @@
"name": "/pi2/camera",
"type": "frc971.vision.sift.ImageMatchResult",
"source_node": "pi2",
+ "logger": "LOCAL_AND_REMOTE_LOGGER",
+ "logger_node": "roborio",
"frequency": 25,
"max_size": 300000,
"destination_nodes": [
@@ -397,6 +401,8 @@
"name": "/pi3/camera",
"type": "frc971.vision.sift.ImageMatchResult",
"source_node": "pi3",
+ "logger": "LOCAL_AND_REMOTE_LOGGER",
+ "logger_node": "roborio",
"frequency": 25,
"max_size": 10000,
"destination_nodes": [