1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! API used between RTIC Scope front- and backends.

use chrono::prelude::Local;
use serde::{Deserialize, Serialize};

#[allow(unused_imports)]
use itm_decode::ExceptionAction;

use itm_decode::{TracePacket, MalformedPacket, TimestampDataRelation};

/// Derivative of [itm_decode::Timestamp]; an absolute timestamp `ts`
/// replaces `base` and `delta`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Timestamp {
    /// Absolute timestamp value
    pub ts: chrono::DateTime<Local>,

    /// In what manner this timestamp relate to the associated data
    /// packets, if known.
    pub data_relation: Option<TimestampDataRelation>,

    /// An overflow packet was recieved, which may have been caused by a
    /// local timestamp counter overflow. See
    /// [itm_decode::Timestamp::diverged].
    pub diverged: bool,
}

/// A set of events that occurred at a certain timepoint during target
/// execution.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EventChunk {
    /// Collective timestamp for the chunk of [EventChunk::events].
    pub timestamp: Timestamp,

    /// Set of events that occured during [EventChunk::timestamp].
    pub events: Vec<EventType>,
}

/// Verbatim copy of [ExceptionAction], sans the enum name.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum TaskAction {
    /// Task was entered.
    Entered,

    /// Task was exited.
    Exited,

    /// Task was returned to.
    Returned,
}

/// Derivative of [TracePacket], where RTIC task information has
/// been resolved.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum EventType {
    /// Equivalent to [TracePacket::Overflow].
    Overflow,

    /// An RTIC task performed an action. Either a software or a
    /// hardware task.
    Task {
        /// What RTIC task did something?

        /// Name of the RTIC task that did something. For example,
        /// `"app::some_task"`.
        name: String,

        /// What did the task do?
        action: TaskAction,
    },

    /// RTIC Scope does not know how to map this packet.
    Unknown(TracePacket),

    /// RTIC Scope knows how to map this packet, but recovered
    /// translation maps does not contain the correct information.
    Unmappable(TracePacket, String),

    /// Packet could not be decoded.
    Invalid(MalformedPacket),
}