diff --git a/application/apps/indexer/Cargo.lock b/application/apps/indexer/Cargo.lock index e7cbfaebfa..453a5d379e 100644 --- a/application/apps/indexer/Cargo.lock +++ b/application/apps/indexer/Cargo.lock @@ -650,9 +650,8 @@ dependencies = [ [[package]] name = "dlt-core" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fd69a328826e883613fbbcf468a33a53df1198c3e39bae7ad079c449431bfd" +version = "0.16.0" +source = "git+https://github.com/kruss/dlt-core.git?branch=dlt_network_traces#525f591862437ca15c56639143f205a956d01b6a" dependencies = [ "buf_redux 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder", @@ -1686,9 +1685,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea" dependencies = [ "memchr", ] @@ -2085,12 +2084,12 @@ dependencies = [ [[package]] name = "someip-payload" -version = "0.1.1" -source = "git+https://github.com/esrlabs/someip-payload#9a58a561a3d284e37a25ea2dc52188c70694682d" +version = "0.1.3" +source = "git+https://github.com/kruss/someip-payload.git?branch=robustness#ccd100907b38f60d9e1ac657250111b2e0a69518" dependencies = [ "byteorder", "log", - "quick-xml 0.22.0", + "quick-xml 0.23.1", "regex", "thiserror", "ux", diff --git a/application/apps/indexer/Cargo.toml b/application/apps/indexer/Cargo.toml index ea5581935d..3998b4b67a 100644 --- a/application/apps/indexer/Cargo.toml +++ b/application/apps/indexer/Cargo.toml @@ -22,7 +22,9 @@ thiserror = "1.0" lazy_static = "1.4" tokio = { version = "1", features = ["full"] } tokio-stream = "0.1" -dlt-core = "0.14" +# dlt-core = "0.14" +# TODO https://github.com/esrlabs/dlt-core/pull/24 +dlt-core = { git = "https://github.com/kruss/dlt-core.git", branch = "dlt_network_traces" } crossbeam-channel = "0.5" futures = "0.3" tokio-util = "0.7" diff --git a/application/apps/indexer/indexer_cli/src/interactive.rs b/application/apps/indexer/indexer_cli/src/interactive.rs index a12215d399..49955ee6c4 100644 --- a/application/apps/indexer/indexer_cli/src/interactive.rs +++ b/application/apps/indexer/indexer_cli/src/interactive.rs @@ -3,7 +3,10 @@ use futures::{pin_mut, stream::StreamExt}; use parsers::{dlt::DltParser, MessageStreamItem, ParseYield}; use processor::grabber::LineRange; use rustyline::{error::ReadlineError, DefaultEditor}; -use session::session::Session; +use session::{ + parse_rest_resolver::{resolve_log_msg, ParseRestReslover}, + session::Session, +}; use sources::{ factory::{DltParserSettings, FileFormat, ObserveOptions, ParserType}, producer::MessageProducer, @@ -46,6 +49,7 @@ pub(crate) async fn handle_interactive_session(input: Option) { let udp_source = UdpSource::new(RECEIVER, vec![]).await.unwrap(); let dlt_parser = DltParser::new(None, None, None, false); let mut dlt_msg_producer = MessageProducer::new(dlt_parser, udp_source, None); + let mut parse_reslover = ParseRestReslover::new(); let msg_stream = dlt_msg_producer.as_stream(); pin_mut!(msg_stream); loop { @@ -56,10 +60,12 @@ pub(crate) async fn handle_interactive_session(input: Option) { } item = msg_stream.next() => { match item { - Some((_, MessageStreamItem::Item(ParseYield::Message(msg)))) => { + Some((_, MessageStreamItem::Item(ParseYield::Message(item)))) => { + let msg = resolve_log_msg(item, &mut parse_reslover); println!("msg: {msg}"); } - Some((_, MessageStreamItem::Item(ParseYield::MessageAndAttachment((msg, attachment))))) => { + Some((_, MessageStreamItem::Item(ParseYield::MessageAndAttachment((item, attachment))))) => { + let msg = resolve_log_msg(item, &mut parse_reslover); println!("msg: {msg}, attachment: {attachment:?}"); } Some((_, MessageStreamItem::Item(ParseYield::Attachment(attachment)))) => { diff --git a/application/apps/indexer/parsers/Cargo.toml b/application/apps/indexer/parsers/Cargo.toml index c2ac11d3ac..8645323e88 100644 --- a/application/apps/indexer/parsers/Cargo.toml +++ b/application/apps/indexer/parsers/Cargo.toml @@ -18,7 +18,9 @@ rand.workspace = true # someip-messages = { path = "../../../../../someip"} someip-messages = { git = "https://github.com/esrlabs/someip" } # someip-payload = { path = "../../../../../someip-payload" } -someip-payload = { git = "https://github.com/esrlabs/someip-payload" } +# someip-payload = { git = "https://github.com/esrlabs/someip-payload" } +# TODO +someip-payload = { git = "https://github.com/kruss/someip-payload.git", branch = "robustness" } [dev-dependencies] stringreader = "0.1.1" diff --git a/application/apps/indexer/parsers/src/dlt/fmt.rs b/application/apps/indexer/parsers/src/dlt/fmt.rs index 52941eee2b..e645debd14 100644 --- a/application/apps/indexer/parsers/src/dlt/fmt.rs +++ b/application/apps/indexer/parsers/src/dlt/fmt.rs @@ -28,10 +28,12 @@ use log::trace; use serde::ser::{Serialize, SerializeStruct, Serializer}; use std::{ - fmt::{self, Formatter}, + fmt::{self, Formatter, Write}, str, }; +use crate::{LogMessage, LogMessageContent, ResolveParseHint, TemplateLogMsg, TemplateLogMsgChunk}; + const DLT_COLUMN_SENTINAL: char = '\u{0004}'; const DLT_ARGUMENT_SENTINAL: char = '\u{0005}'; const DLT_NEWLINE_SENTINAL_SLICE: &[u8] = &[0x6]; @@ -281,6 +283,17 @@ impl<'a> Serialize for FormattableMessage<'a> { None => state.serialize_field("payload", "[Unknown CtrlCommand]")?, } } + PayloadContent::NetworkTrace(slices) => { + state.serialize_field("app-id", &ext_header_app_id)?; + state.serialize_field("context-id", &ext_header_context_id)?; + state.serialize_field("message-type", &ext_header_msg_type)?; + let arg_string = slices + .iter() + .map(|slice| format!("{:02X?}", slice)) + .collect::>() + .join("|"); + state.serialize_field("payload", &arg_string)?; + } } state.end() } @@ -386,12 +399,25 @@ impl<'a> FormattableMessage<'a> { payload_string, )) } + PayloadContent::NetworkTrace(slices) => { + let payload_string = slices + .iter() + .map(|slice| format!("{:02X?}", slice)) + .collect::>() + .join("|"); + Ok(PrintableMessage::new( + ext_h_app_id, + eh_ctx_id, + ext_h_msg_type, + payload_string, + )) + } } } fn write_app_id_context_id_and_message_type( &self, - f: &mut fmt::Formatter, + f: &mut impl std::fmt::Write, ) -> Result<(), fmt::Error> { match self.message.extended_header.as_ref() { Some(ext) => { @@ -419,7 +445,7 @@ impl<'a> FormattableMessage<'a> { &self, id: u32, data: &[u8], - f: &mut fmt::Formatter, + f: &mut impl std::fmt::Write, ) -> fmt::Result { trace!("format_nonverbose_data"); let mut fibex_info_added = false; @@ -511,7 +537,14 @@ impl<'a> FormattableMessage<'a> { } } -impl<'a> fmt::Display for FormattableMessage<'a> { +impl LogMessage for FormattableMessage<'_> { + fn to_writer(&self, writer: &mut W) -> Result { + let bytes = self.message.as_bytes(); + let len = bytes.len(); + writer.write_all(&bytes)?; + Ok(len) + } + /// will format dlt Message with those fields: /// ********* storage-header ******** /// date-time @@ -528,43 +561,89 @@ impl<'a> fmt::Display for FormattableMessage<'a> { /// context-id /// /// payload - fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { + fn try_resolve(&self) -> LogMessageContent { + let mut msg = String::new(); + // Taken from Documentation: string formatting is considered an infallible operation. + // Thus we can ignore `fmt::Error` errors. + // Link from Clippy: 'https://rust-lang.github.io/rust-clippy/master/index.html#/format_push_string' + // TODO: Consider another way of concatenating the string after prototyping. if let Some(h) = &self.message.storage_header { let tz = self.options.map(|o| o.tz); match tz { Some(Some(tz)) => { - write_tz_string(f, &h.timestamp, &tz)?; - write!(f, "{DLT_COLUMN_SENTINAL}{}", h.ecu_id)?; + let _ = write_tz_string(&mut msg, &h.timestamp, &tz); + let _ = write!(msg, "{DLT_COLUMN_SENTINAL}{}", h.ecu_id); + } + _ => { + let _ = write!(msg, "{}", DltStorageHeader(h)); } - _ => write!(f, "{}", DltStorageHeader(h))?, }; } let header = DltStandardHeader(&self.message.header); - write!(f, "{DLT_COLUMN_SENTINAL}",)?; - write!(f, "{header}")?; - write!(f, "{DLT_COLUMN_SENTINAL}",)?; + write!(msg, "{DLT_COLUMN_SENTINAL}",).unwrap(); + write!(msg, "{header}").unwrap(); + write!(msg, "{DLT_COLUMN_SENTINAL}",).unwrap(); match &self.message.payload { PayloadContent::Verbose(arguments) => { - self.write_app_id_context_id_and_message_type(f)?; - arguments - .iter() - .try_for_each(|arg| write!(f, "{}{}", DLT_ARGUMENT_SENTINAL, DltArgument(arg))) + let _ = self.write_app_id_context_id_and_message_type(&mut msg); + arguments.iter().for_each(|arg| { + let _ = write!(msg, "{}{}", DLT_ARGUMENT_SENTINAL, DltArgument(arg)); + }); + } + PayloadContent::NonVerbose(id, data) => { + let _ = self.format_nonverbose_data(*id, data, &mut msg); } - PayloadContent::NonVerbose(id, data) => self.format_nonverbose_data(*id, data, f), PayloadContent::ControlMsg(ctrl_id, _data) => { - self.write_app_id_context_id_and_message_type(f)?; + let _ = self.write_app_id_context_id_and_message_type(&mut msg); match service_id_lookup(ctrl_id.value()) { - Some((name, _desc)) => write!(f, "[{name}]"), - None => write!(f, "[Unknown CtrlCommand]"), + Some((name, _desc)) => { + let _ = write!(msg, "[{name}]"); + } + None => { + let _ = write!(msg, "[Unknown CtrlCommand]"); + } } } + PayloadContent::NetworkTrace(slices) => { + let _ = self.write_app_id_context_id_and_message_type(&mut msg); + let is_someip = self + .message + .extended_header + .as_ref() + .is_some_and(|ext_header| { + matches!( + ext_header.message_type, + MessageType::NetworkTrace(NetworkTraceType::Ipc) + | MessageType::NetworkTrace(NetworkTraceType::Someip) + ) + }); + + if is_someip { + if let Some(slice) = slices.get(1) { + let template = TemplateLogMsg::new( + vec![ + TemplateLogMsgChunk::Text(msg), + TemplateLogMsgChunk::Bytes(slice.to_owned()), + ], + vec![ResolveParseHint::SomeIP], + ); + return LogMessageContent::Template(template); + } + } + + slices.iter().for_each(|slice| { + let _ = write!(msg, "{}{:02X?}", DLT_ARGUMENT_SENTINAL, slice); + }); + } } + + msg.into() } } fn write_tz_string( - f: &mut Formatter, + f: &mut impl std::fmt::Write, time_stamp: &DltTimeStamp, tz: &Tz, ) -> Result<(), fmt::Error> { diff --git a/application/apps/indexer/parsers/src/dlt/mod.rs b/application/apps/indexer/parsers/src/dlt/mod.rs index dae82f4ce4..fef9164e39 100644 --- a/application/apps/indexer/parsers/src/dlt/mod.rs +++ b/application/apps/indexer/parsers/src/dlt/mod.rs @@ -17,15 +17,6 @@ use std::{io::Write, ops::Range}; use self::{attachment::FtScanner, fmt::FormatOptions}; -impl LogMessage for FormattableMessage<'_> { - fn to_writer(&self, writer: &mut W) -> Result { - let bytes = self.message.as_bytes(); - let len = bytes.len(); - writer.write_all(&bytes)?; - Ok(len) - } -} - #[derive(Debug, Serialize)] pub struct RawMessage { pub content: Vec, @@ -54,6 +45,10 @@ impl LogMessage for RangeMessage { writer.write_u64::(self.range.end as u64)?; Ok(8 + 8) } + + fn try_resolve(&self) -> crate::LogMessageContent { + self.into() + } } impl LogMessage for RawMessage { @@ -62,6 +57,10 @@ impl LogMessage for RawMessage { writer.write_all(&self.content)?; Ok(len) } + + fn try_resolve(&self) -> crate::LogMessageContent { + self.into() + } } #[derive(Default)] diff --git a/application/apps/indexer/parsers/src/lib.rs b/application/apps/indexer/parsers/src/lib.rs index 1b7fce8efe..82d97923c5 100644 --- a/application/apps/indexer/parsers/src/lib.rs +++ b/application/apps/indexer/parsers/src/lib.rs @@ -78,12 +78,6 @@ pub enum ByteRepresentation { Range((usize, usize)), } -pub trait LogMessage: Display + Serialize { - /// Serializes a message directly into a Writer - /// returns the size of the serialized message - fn to_writer(&self, writer: &mut W) -> Result; -} - #[derive(Debug)] pub enum MessageStreamItem { Item(ParseYield), @@ -92,3 +86,117 @@ pub enum MessageStreamItem { Empty, Done, } + +pub trait LogMessage: Serialize { + /// Serializes a message directly into a Writer + /// returns the size of the serialized message + fn to_writer(&self, writer: &mut W) -> Result; + + /// Tries to resolve the message to get its text representation. + /// + /// TODO: This function should return another optional field, containing information + /// about errors, warning ... + fn try_resolve(&self) -> LogMessageContent; +} + +#[derive(Debug, Clone)] +/// Represents The content of a log message after trying to resolve it. +pub enum LogMessageContent { + Text(String), + Template(TemplateLogMsg), +} + +#[derive(Debug, Clone)] +/// Represents an unresolved log messages that contains chunks that needs to be resolved. +pub struct TemplateLogMsg { + chunks: Vec, + resolve_hints: Vec, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +/// Gives Hint about how the payload rest can be resolved +pub enum ResolveParseHint { + /// The message needs to be parsed with SomeIP Parser. + SomeIP, +} + +#[derive(Debug, Clone)] +/// Represents a chunk in [`TemplateLogMsg`] +pub enum TemplateLogMsgChunk { + /// Resolved Chunk + Text(String), + /// Unresolved Chunk + Bytes(Vec), +} + +impl From for LogMessageContent +where + T: Display, +{ + fn from(value: T) -> Self { + Self::Text(value.to_string()) + } +} + +impl TemplateLogMsg { + pub fn new(chunks: Vec, resolve_hints: Vec) -> Self { + Self { + chunks, + resolve_hints, + } + } + + pub fn get_resolve_hints(&self) -> Vec { + self.resolve_hints.to_vec() + } + + /// Applies the given [`FnMut`] on the unresolved chunks, replacing them with texts if succeed. + /// This function will return a String once chunks get resolved. + /// + /// * `parse_fn`: Function to apply on the unresolved chunks. + pub fn try_resolve(&mut self, mut parse_fn: F) -> Option + where + F: FnMut(&[u8]) -> Option, + { + let mut all_resolved = true; + for ch in self.chunks.iter_mut() { + match ch { + TemplateLogMsgChunk::Text(_) => continue, + TemplateLogMsgChunk::Bytes(bytes) => match parse_fn(&bytes) { + Some(resolved) => *ch = TemplateLogMsgChunk::Text(resolved), + None => all_resolved = false, + }, + } + } + + if all_resolved { + self.chunks + .iter() + .map(|ch| match ch { + TemplateLogMsgChunk::Text(msg) => msg, + TemplateLogMsgChunk::Bytes(_) => panic!("All must be resolved"), + }) + .cloned() + .reduce(|mut acc, msg| { + acc.push_str(&msg); + acc + }) + } else { + None + } + } + + /// Concatenates the chunks to a string, replacing the unresolved chunks with their bytes + /// representation. + pub fn resolve_lossy(self) -> String { + self.chunks + .into_iter() + .fold(String::new(), |mut acc, ch| match ch { + TemplateLogMsgChunk::Text(msg) => { + acc.push_str(&msg); + acc + } + TemplateLogMsgChunk::Bytes(bytes) => format!("{acc} {bytes:?}"), + }) + } +} diff --git a/application/apps/indexer/parsers/src/someip.rs b/application/apps/indexer/parsers/src/someip.rs index 1601017d78..79e3bc66ab 100644 --- a/application/apps/indexer/parsers/src/someip.rs +++ b/application/apps/indexer/parsers/src/someip.rs @@ -1,4 +1,4 @@ -use crate::{Error, LogMessage, ParseYield, Parser}; +use crate::{Error, LogMessage, LogMessageContent, ParseYield, Parser}; use std::{borrow::Cow, fmt, fmt::Display, io::Write, path::PathBuf}; use someip_messages::*; @@ -329,6 +329,10 @@ impl LogMessage for SomeipLogMessage { writer.write_all(&self.bytes)?; Ok(self.bytes.len()) } + + fn try_resolve(&self) -> LogMessageContent { + self.into() + } } impl Display for SomeipLogMessage { diff --git a/application/apps/indexer/parsers/src/text.rs b/application/apps/indexer/parsers/src/text.rs index 6a09a52b9c..a59aad423e 100644 --- a/application/apps/indexer/parsers/src/text.rs +++ b/application/apps/indexer/parsers/src/text.rs @@ -1,4 +1,4 @@ -use crate::{Error, LogMessage, ParseYield, Parser}; +use crate::{Error, LogMessage, LogMessageContent, ParseYield, Parser}; use serde::Serialize; use std::{fmt, io::Write}; @@ -21,6 +21,10 @@ impl LogMessage for StringMessage { writer.write_all(self.content.as_bytes())?; Ok(len) } + + fn try_resolve(&self) -> LogMessageContent { + self.into() + } } impl Parser for StringTokenizer diff --git a/application/apps/indexer/session/Cargo.toml b/application/apps/indexer/session/Cargo.toml index 803f87bd4c..8ae61602b4 100644 --- a/application/apps/indexer/session/Cargo.toml +++ b/application/apps/indexer/session/Cargo.toml @@ -8,7 +8,9 @@ edition = "2021" blake3 = "1.3" crossbeam-channel.workspace = true dirs.workspace = true -dlt-core.workspace = true +# dlt-core.workspace = true +# TODO https://github.com/esrlabs/dlt-core/pull/24 +dlt-core = { git = "https://github.com/kruss/dlt-core.git", branch = "dlt_network_traces", features=["statistics"] } envvars = "0.1" file-tools = { path = "../addons/file-tools" } futures.workspace = true diff --git a/application/apps/indexer/session/src/handlers/observing/mod.rs b/application/apps/indexer/session/src/handlers/observing/mod.rs index 48d8b1a250..3dd96eb903 100644 --- a/application/apps/indexer/session/src/handlers/observing/mod.rs +++ b/application/apps/indexer/session/src/handlers/observing/mod.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use crate::{ operations::{OperationAPI, OperationResult}, + parse_rest_resolver::{resolve_log_msg, ParseRestReslover}, state::SessionStateAPI, tail, }; @@ -77,6 +78,7 @@ async fn run_source_intern( rx_sde: Option, rx_tail: Option>>, ) -> OperationResult<()> { + let mut parse_err_resolver = ParseRestReslover::new(); match parser { ParserType::SomeIp(settings) => { let someip_parser = match &settings.fibex_file_paths { @@ -86,11 +88,27 @@ async fn run_source_intern( None => SomeipParser::new(), }; let producer = MessageProducer::new(someip_parser, source, rx_sde); - run_producer(operation_api, state, source_id, producer, rx_tail).await + run_producer( + operation_api, + state, + source_id, + producer, + rx_tail, + &mut parse_err_resolver, + ) + .await } ParserType::Text => { let producer = MessageProducer::new(StringTokenizer {}, source, rx_sde); - run_producer(operation_api, state, source_id, producer, rx_tail).await + run_producer( + operation_api, + state, + source_id, + producer, + rx_tail, + &mut parse_err_resolver, + ) + .await } ParserType::Dlt(settings) => { let fmt_options = Some(FormatOptions::from(settings.tz.as_ref())); @@ -101,7 +119,24 @@ async fn run_source_intern( settings.with_storage_header, ); let producer = MessageProducer::new(dlt_parser, source, rx_sde); - run_producer(operation_api, state, source_id, producer, rx_tail).await + + let someip_parse = match &settings.fibex_file_paths { + Some(paths) => { + SomeipParser::from_fibex_files(paths.iter().map(PathBuf::from).collect()) + } + None => SomeipParser::new(), + }; + parse_err_resolver.with_someip_parser(someip_parse); + + run_producer( + operation_api, + state, + source_id, + producer, + rx_tail, + &mut parse_err_resolver, + ) + .await } } } @@ -112,6 +147,7 @@ async fn run_producer, S: ByteSource>( source_id: u16, mut producer: MessageProducer, mut rx_tail: Option>>, + parse_err_resolver: &mut ParseRestReslover, ) -> OperationResult<()> { use log::debug; state.set_session_file(None).await?; @@ -139,16 +175,18 @@ async fn run_producer, S: ByteSource>( Next::Item(item) => { match item { MessageStreamItem::Item(ParseYield::Message(item)) => { + let msg = resolve_log_msg(item, parse_err_resolver); state - .write_session_file(source_id, format!("{item}\n")) + .write_session_file(source_id, format!("{msg}\n")) .await?; } MessageStreamItem::Item(ParseYield::MessageAndAttachment(( item, attachment, ))) => { + let msg = resolve_log_msg(item, parse_err_resolver); state - .write_session_file(source_id, format!("{item}\n")) + .write_session_file(source_id, format!("{msg}\n")) .await?; state.add_attachment(attachment)?; } diff --git a/application/apps/indexer/session/src/lib.rs b/application/apps/indexer/session/src/lib.rs index 45a70490c1..9e3d0d32bd 100644 --- a/application/apps/indexer/session/src/lib.rs +++ b/application/apps/indexer/session/src/lib.rs @@ -2,6 +2,7 @@ pub mod events; mod handlers; pub mod operations; +pub mod parse_rest_resolver; pub mod paths; pub mod progress; pub mod session; diff --git a/application/apps/indexer/session/src/parse_rest_resolver.rs b/application/apps/indexer/session/src/parse_rest_resolver.rs new file mode 100644 index 0000000000..ceb9582495 --- /dev/null +++ b/application/apps/indexer/session/src/parse_rest_resolver.rs @@ -0,0 +1,64 @@ +use parsers::{someip::SomeipParser, LogMessage, Parser, TemplateLogMsg}; + +#[derive(Default)] +pub struct ParseRestReslover { + someip_praser: Option, +} + +impl ParseRestReslover { + pub fn new() -> Self { + Self::default() + } + + /// Sets SomeIP parser on the resolver + pub fn with_someip_parser(&mut self, someip_praser: SomeipParser) -> &mut Self { + self.someip_praser = Some(someip_praser); + self + } + + /// Tries to resolve the given error returning the parsed string if succeeded. + pub fn resolve_log_template(&mut self, template: &mut TemplateLogMsg) -> Option { + for hint in template.get_resolve_hints() { + match hint { + parsers::ResolveParseHint::SomeIP => { + if let Some(p) = self.someip_praser.as_mut() { + let res = template.try_resolve(|bytes| { + let p_yield = p.parse(bytes, None).ok()?.1?; + match p_yield { + parsers::ParseYield::Message(item) => match item.try_resolve() { + parsers::LogMessageContent::Text(msg) => Some(msg), + // Ignore nested errors for now + parsers::LogMessageContent::Template(_) => None, + }, + // Ignore other parse types for now + parsers::ParseYield::Attachment(_) => None, + parsers::ParseYield::MessageAndAttachment(_) => None, + } + }); + + if res.is_some() { + return res; + } + } + } + } + } + None + } +} + +/// Get the text message of [`LogMessage`], resolving its rest payloads if existed when possible, +/// TODO: Otherwise it should save the error to the faulty messages store, which need to be +/// implemented as well :) +pub fn resolve_log_msg(item: T, err_resolver: &mut ParseRestReslover) -> String { + match item.try_resolve() { + parsers::LogMessageContent::Text(msg) => msg, + parsers::LogMessageContent::Template(mut template) => { + if let Some(resolved) = err_resolver.resolve_log_template(&mut template) { + return resolved; + } + //TODO: Add message to the faulty messages once implemented. + template.resolve_lossy() + } + } +} diff --git a/application/apps/rustcore/rs-bindings/Cargo.lock b/application/apps/rustcore/rs-bindings/Cargo.lock index 56cf3e3c13..a7559efd54 100644 --- a/application/apps/rustcore/rs-bindings/Cargo.lock +++ b/application/apps/rustcore/rs-bindings/Cargo.lock @@ -698,9 +698,8 @@ dependencies = [ [[package]] name = "dlt-core" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fd69a328826e883613fbbcf468a33a53df1198c3e39bae7ad079c449431bfd" +version = "0.16.0" +source = "git+https://github.com/kruss/dlt-core.git?branch=dlt_network_traces#525f591862437ca15c56639143f205a956d01b6a" dependencies = [ "buf_redux 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder", @@ -2026,9 +2025,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea" dependencies = [ "memchr", ] @@ -2476,12 +2475,12 @@ dependencies = [ [[package]] name = "someip-payload" -version = "0.1.1" -source = "git+https://github.com/esrlabs/someip-payload#9a58a561a3d284e37a25ea2dc52188c70694682d" +version = "0.1.3" +source = "git+https://github.com/kruss/someip-payload.git?branch=robustness#ccd100907b38f60d9e1ac657250111b2e0a69518" dependencies = [ "byteorder", "log", - "quick-xml 0.22.0", + "quick-xml 0.23.1", "regex", "thiserror", "ux",