Fix log sorting for good
Unfortunately, this is really hard to split up, so a bunch of stuff
happens at once.
When a message is sent from node A -> node B, add support for sending
that timestamp back from node B to node A for logging.
{
"name": "/pi1/aos",
"type": "aos.message_bridge.Timestamp",
"source_node": "pi1",
"frequency": 10,
"max_size": 200,
"destination_nodes": [
{
"name": "pi2",
"priority": 1,
"timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
"timestamp_logger_nodes": ["pi1"]
}
]
},
This gives us a way to log enough information on node A such that
everything is self contained. We know all the messages we sent to B,
and when they got there, so we can recreate the time offset and replay
the node.
This data is then published over
{ "name": "/aos/remote_timestamps/pi2", "type": ".aos.logger.MessageHeader"}
The logger then treats that channel specially and log the contents
directly as though the message contents were received on the remote
node.
This (among other things) exposes log sorting problems. Use our fancy
new infinite precision noncausal filter to estimate time precise enough
to actually order events. This gets us down to 2-3 ns of error due to
integer precision.
Change-Id: Ia843c5176a2c4efc227e669c07d7bb4c7cbe7c91
diff --git a/aos/flatbuffers.h b/aos/flatbuffers.h
index 392a7eb..bd095b8 100644
--- a/aos/flatbuffers.h
+++ b/aos/flatbuffers.h
@@ -328,6 +328,14 @@
virtual ~SizePrefixedFlatbufferDetachedBuffer() override {}
+ static SizePrefixedFlatbufferDetachedBuffer<T> Empty() {
+ flatbuffers::FlatBufferBuilder fbb;
+ fbb.ForceDefaults(true);
+ const auto end = fbb.EndTable(fbb.StartTable());
+ fbb.FinishSizePrefixed(flatbuffers::Offset<flatbuffers::Table>(end));
+ return SizePrefixedFlatbufferDetachedBuffer<T>(fbb.Release());
+ }
+
// Returns references to the buffer, and the data.
const flatbuffers::DetachedBuffer &buffer() const { return buffer_; }
const uint8_t *data() const override {
@@ -340,6 +348,13 @@
return buffer_.size() - sizeof(flatbuffers::uoffset_t);
}
+ absl::Span<uint8_t> full_span() {
+ return absl::Span<uint8_t>(buffer_.data(), buffer_.size());
+ }
+ absl::Span<const uint8_t> full_span() const {
+ return absl::Span<const uint8_t>(buffer_.data(), buffer_.size());
+ }
+
private:
flatbuffers::DetachedBuffer buffer_;
};