pub struct ULogParser<R: Read> { /* private fields */ }
Expand description
A parser for ULog binary data.
The ULogParser
struct is responsible for parsing the binary data of a ULog file.
It provides methods to access the various components of the ULog data, such as the
header, format messages, subscriptions, logged messages, and parameter messages.
The parser is generic over the Read
trait, allowing it to work with different
types of input sources, such as files, network streams, or in-memory buffers.
Implementations§
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
Sourcepub fn read_data_message(
&mut self,
msg_id: u16,
msg_size: u16,
format: &FormatMessage,
) -> Result<DataMessage, ULogError>
pub fn read_data_message( &mut self, msg_id: u16, msg_size: u16, format: &FormatMessage, ) -> Result<DataMessage, ULogError>
Reads a data message from the ULog file and returns a DataMessage
struct containing the parsed data.
This function takes the message ID, message size, and the format of the message as input. It then reads the message data, parsing the values according to the specified format, and returns a DataMessage
struct containing the parsed data.
The function handles padding fields, nested messages, and any remaining bytes in the message. It also updates the current timestamp if a new timestamp value is present in the message data.
§Arguments
msg_id
- The ID of the message to be read.msg_size
- The size of the message in bytes.format
- The format of the message, as aFormatMessage
struct.
§Returns
A Result
containing a DataMessage
struct with the parsed data, or a ULogError
if there was an error parsing the message.
pub fn handle_data_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn handle_dropout( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
pub fn dropout_details(&self) -> &DropoutStats
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn formats(&self) -> &HashMap<String, FormatMessage>
pub fn read_format_message( &mut self, msg_size: u16, ) -> Result<FormatMessage, ULogError>
pub fn handle_format_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn info_messages(&self) -> &HashMap<String, InfoMessage>
pub fn read_info_message(&mut self) -> Result<InfoMessage, ULogError>
pub fn handle_info_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn logged_messages(&self) -> &[LoggedMessage]
pub fn log_level_to_string(level: u8) -> &'static str
pub fn handle_logged_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn multi_messages(&self) -> &HashMap<String, Vec<MultiMessage>>
pub fn handle_multi_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn initial_params(&self) -> &HashMap<String, ParameterMessage>
pub fn default_params(&self) -> &HashMap<String, DefaultParameterMessage>
pub fn changed_params(&self) -> &HashMap<String, Vec<ParameterMessage>>
pub fn read_default_parameter( &mut self, ) -> Result<DefaultParameterMessage, ULogError>
pub fn handle_default_parameter(&mut self) -> Result<(), ULogError>
pub fn get_default_value( &self, param_name: &str, default_type: DefaultType, ) -> Option<&ULogValue>
pub fn handle_initial_param( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
pub fn handle_parameter_change( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn subscriptions(&self) -> &HashMap<u16, SubscriptionMessage>
pub fn handle_subscription_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn read_tagged_logged_message( &mut self, msg_size: u16, ) -> Result<TaggedLoggedMessage, ULogError>
pub fn handle_tagged_logged_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>
pub fn logged_messages_tagged(&self) -> &HashMap<u16, Vec<TaggedLoggedMessage>>
Source§impl<R: Read> ULogParser<R>
impl<R: Read> ULogParser<R>
pub fn new(reader: R) -> Result<Self, ULogError>
pub fn header(&self) -> &ULogHeader
pub fn read_message_header(&mut self) -> Result<MessageHeader, ULogError>
pub fn read_flag_bits(&mut self) -> Result<FlagBitsMessage, ULogError>
Sourcepub fn parse_definitions(&mut self) -> Result<(), ULogError>
pub fn parse_definitions(&mut self) -> Result<(), ULogError>
Parses the definitions section of the ULog file until the data section is reached. This method reads the flag bits message first, then iterates through the definition section, handling various message types such as info messages, format messages, initial parameters, and multi messages. Once the first subscription message is encountered, the method breaks out of the loop to continue parsing the data section.
Sourcepub fn parse_data(&mut self) -> Result<(), ULogError>
pub fn parse_data(&mut self) -> Result<(), ULogError>
Parses the data section of the ULog file, handling various message types such as subscription messages, info messages, multi messages, logged messages, data messages, parameter changes, and dropouts. The method reads the message headers and dispatches to the appropriate handler for each message type. If an unknown message type is encountered, the message is skipped. The method continues parsing the data section until the end of the file is reached.
Sourcepub fn parse_reader(reader: R) -> Result<ULogParser<R>, ULogError>
pub fn parse_reader(reader: R) -> Result<ULogParser<R>, ULogError>
Main method to create a new ULogParser
instance.
This function creates a new ULogParser
instance, parses the definitions,
and then parses the data from the reader. If any errors occur during the
parsing process, they are returned as a ULogError
.