diff --git a/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.cpp b/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.cpp index 8e36091ac..c113c48bf 100644 --- a/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.cpp +++ b/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.cpp @@ -339,6 +339,14 @@ ColumnTypeInfo DetectColumnType(const std::string& str) return info; } + // Check for hexadecimal with 0x prefix (case insensitive) + if (trimmed.size() > 2 && + (trimmed[0] == '0' && (trimmed[1] == 'x' || trimmed[1] == 'X'))) + { + info.type = ColumnType::HEX; + return info; + } + auto num_info = CheckNumeric(trimmed); if (num_info.is_number) { @@ -431,6 +439,11 @@ std::optional ParseWithType(const std::string& str, const ColumnTypeInfo return std::stod(normalized); } + case ColumnType::HEX: { + // Parse hex value with 0x prefix + return static_cast(std::stoll(trimmed, nullptr, 16)); + } + case ColumnType::EPOCH_SECONDS: case ColumnType::EPOCH_MILLIS: case ColumnType::EPOCH_MICROS: diff --git a/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.h b/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.h index e30f018ba..9ef4a88d8 100644 --- a/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.h +++ b/plotjuggler_plugins/DataLoadCSV/timestamp_parsing.h @@ -77,6 +77,7 @@ std::optional FormatParseTimestamp(const std::string& str, const std::st enum class ColumnType { NUMBER, // Plain numeric value + HEX, // Hexadecimal number with 0x prefix EPOCH_SECONDS, // Numeric epoch timestamp in seconds EPOCH_MILLIS, // Numeric epoch timestamp in milliseconds EPOCH_MICROS, // Numeric epoch timestamp in microseconds