Skip to content
Discussion options

You must be logged in to vote

I finally found a solution:
Iterate over all channel groups and select the latest record only (and then find the max value of all of them).

def _get_timestamp_of_last_sample(self, mdf: asammdf.MDF, group_idx: int) -> float:
    """Return the timestamp of the last sample of the given group."""
    group = mdf._mdf.groups[group_idx]
    sample_cnt = group.channel_group.cycles_nr
    last_sig_record = mdf.select(
        channels=[(None, group_idx, 0)],
        record_offset=sample_cnt-1,
        record_count=1,
    )
    last_ts = last_sig_record[0].timestamps[0]
    return last_ts

with asammdf.MDF(name=self.filepath, process_bus_logging=False) as mdf_file:
    duration_s = max([self._get_…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by geo4711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant