Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ringbufs with count: u16 #476

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name = "humility"
#
# Be sure to check in and push all of the files that change. Happy versioning!
#
version = "0.11.3"
version = "0.11.4"
authors = ["Bryan Cantrill <[email protected]>"]
edition = "2018"
license = "MPL-2.0"
Expand Down
27 changes: 26 additions & 1 deletion humility-doppel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,35 @@ impl humility::reflect::Load for TaskId {
pub struct RingbufEntry {
pub line: u16,
pub generation: u16,
pub count: u32,
pub count: RingbufCount,
pub payload: Value,
}

#[derive(Clone, Debug)]
pub struct RingbufCount(Option<u64>);

impl humility::reflect::Load for RingbufCount {
fn from_value(v: &Value) -> Result<Self> {
match v.as_base()? {
Base::U0 => Ok(Self(None)),
Base::U8(v) => Ok(Self(Some(u64::from(*v)))),
Base::U16(v) => Ok(Self(Some(u64::from(*v)))),
Base::U32(v) => Ok(Self(Some(u64::from(*v)))),
Base::U64(v) => Ok(Self(Some(*v))),
_ => bail!("not an unsigned integer: {v:?}"),
}
}
}

impl std::fmt::Display for RingbufCount {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self.0 {
Some(v) => v.fmt(f),
None => "()".fmt(f),
}
}
}

/// Double of the struct from `ringbuf`.
///
/// The Hubris equivalent has a type parameter. We're dynamic instead; see
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd/chip.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more information try --help

```
$ humility --chip this-can-be-anything -V
humility 0.11.3
humility 0.11.4

```

Expand All @@ -28,7 +28,7 @@ For more information try --help

```
$ humility -c apx432 -V
humility 0.11.3
humility 0.11.4

```

Binary file added tests/cmd/cores/hubris.core.u16-ringbuf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/cmd/counters-arg/counters-arg.u16-ringbuf.stderr

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions tests/cmd/counters-arg/counters-arg.u16-ringbuf.stdout

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/cmd/counters-arg/counters-arg.u16-ringbuf.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

492 changes: 492 additions & 0 deletions tests/cmd/counters-csv-full/counters-csv-full.u16-ringbuf.stdout

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tests/cmd/counters-csv-full/counters-csv-full.u16-ringbuf.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/cmd/counters-csv/counters-csv.u16-ringbuf.stderr

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/cmd/counters-csv/counters-csv.u16-ringbuf.stdout

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/cmd/counters-csv/counters-csv.u16-ringbuf.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/cmd/counters-full/counters-full.u16-ringbuf.stderr

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading