Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 4b9cc6b

Browse files
author
Alex Helfet
committed
More documentation in src/packet.rs, renamed UserData -> Instrumentation.
1 parent f4fff64 commit 4b9cc6b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/bin/itmdump.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern crate ref_slice;
1616

1717
use clap::{Arg, App, ArgMatches};
1818
use heapless::Vec as HVec;
19-
use itm::packet::{self, Packet, UserData};
19+
use itm::packet::{self, Packet, Instrumentation};
2020
use log::{LogRecord, LogLevelFilter};
2121
use std::fs::File;
2222
use std::io::{Read, Write};
@@ -126,7 +126,7 @@ fn run() -> Result<()> {
126126
match p {
127127
Ok(p) => {
128128
match p.kind {
129-
packet::Kind::UserData(ref ud) if ud.port == port => {
129+
packet::Kind::Instrumentation(ref ud) if ud.port == port => {
130130
stdout.write_all(&ud.payload)?;
131131
}
132132
_ => (),
@@ -181,8 +181,8 @@ fn read_packet(input: &mut Read) -> Result<Packet> {
181181
let header = header[0];
182182
match header & 0b111 {
183183
0b001|0b010|0b011 => {
184-
// User data packet.
185-
let mut ud = UserData {
184+
// Instrumentation packet.
185+
let mut ud = Instrumentation {
186186
payload: HVec::new(),
187187
port: header >> 3,
188188
};
@@ -200,7 +200,7 @@ fn read_packet(input: &mut Read) -> Result<Packet> {
200200

201201
Ok(Packet {
202202
header: header,
203-
kind: packet::Kind::UserData(ud),
203+
kind: packet::Kind::Instrumentation(ud),
204204
})
205205
},
206206
_ => {

src/packet.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use heapless::Vec as HVec;
44

55
pub const MAX_PAYLOAD_SIZE: usize = 4;
66

7+
/// Represents a complete received packet.
78
pub struct Packet {
89
/// The header byte received for this packet.
910
pub header: u8,
@@ -12,16 +13,19 @@ pub struct Packet {
1213
pub kind: Kind,
1314
}
1415

16+
/// The type of a packet.
1517
pub enum Kind {
16-
UserData(UserData),
18+
/// Data from a software application
19+
Instrumentation(Instrumentation),
1720

1821
#[doc(hidden)]
1922
/// External consumers shouldn't expect the public variants to
2023
/// be complete: there are more variants to implement.
2124
_NoExhaustiveMatch,
2225
}
2326

24-
pub struct UserData {
27+
/// Contents of an Instrumentation packet, with data from a software application
28+
pub struct Instrumentation {
2529
/// Data in this packet.
2630
pub payload: HVec<u8, [u8; MAX_PAYLOAD_SIZE]>,
2731

0 commit comments

Comments
 (0)