Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ulog): the index of the timestamp may be non-zero #1016

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions plotjuggler_plugins/DataLoadULog/ulog_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ void ULogParser::parseDataMessage(const ULogParser::Subscription& sub, char* mes
}
Timeseries& timeseries = ts_it->second;

uint64_t time_val = *reinterpret_cast<uint64_t*>(message);
timeseries.timestamps.push_back(time_val);
message += sizeof(uint64_t);

size_t index = 0;
parseSimpleDataMessage(timeseries, sub.format, message, &index);
}
Expand All @@ -173,8 +169,15 @@ char* ULogParser::parseSimpleDataMessage(Timeseries& timeseries, const Format* f
continue;
}

bool timestamp_done = false;
for (int array_pos = 0; array_pos < field.array_size; array_pos++)
{
if (*index == format->timestamp_idx && !timestamp_done) {
timestamp_done = true;
uint64_t time_val = *reinterpret_cast<uint64_t*>(message);
timeseries.timestamps.push_back(time_val);
message += sizeof(uint64_t);
}
double value = 0;
switch (field.type)
{
Expand Down Expand Up @@ -619,7 +622,7 @@ bool ULogParser::readFormat(DataStream& datastream, uint16_t msg_size)

if (field.type == UINT64 && field_name == StringView("timestamp"))
{
// skip
format.timestamp_idx = format.fields.size();
}
else
{
Expand All @@ -628,6 +631,11 @@ bool ULogParser::readFormat(DataStream& datastream, uint16_t msg_size)
}
}

if (format.timestamp_idx < 0) {
// Required timestamp is not found in definition
return false;
}

format.name = name;
_formats[name] = std::move(format);

Expand Down
3 changes: 2 additions & 1 deletion plotjuggler_plugins/DataLoadULog/ulog_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ class ULogParser

struct Format
{
Format() : padding(0)
Format() : padding(0), timestamp_idx(-1)
{
}
std::string name;
std::vector<Field> fields;
int padding;
int timestamp_idx;
};

struct MessageLog
Expand Down