Skip to content

Commit caf1e6a

Browse files
authored
Add MeasurementKind::CpuTctl (#291)
This commit adds a `CpuTctl` variant to the `MeasurementKind` enum. This is intended to be used to represent AMD CPU T<sub>ctl</sub> thermal values, which are a unitless value from 0-100 representing a kind of "abstract thermal throttling danger level" --- see oxidecomputer/hubris#1881 for details on why we need to differentiate this from other temperature measurements.
1 parent e8a9cf0 commit caf1e6a

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

Diff for: gateway-messages/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub const ROT_PAGE_SIZE: usize = 512;
6666
/// for more detail and discussion.
6767
pub mod version {
6868
pub const MIN: u32 = 2;
69-
pub const CURRENT: u32 = 15;
69+
pub const CURRENT: u32 = 16;
7070

7171
/// MGS protocol version in which SP watchdog messages were added
7272
pub const WATCHDOG_VERSION: u32 = 12;

Diff for: gateway-messages/src/sp_to_mgs/measurement.rs

+1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ pub enum MeasurementKind {
6767
InputCurrent,
6868
InputVoltage,
6969
Speed,
70+
CpuTctl,
7071
}

Diff for: gateway-messages/tests/versioning/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mod v12;
2020
mod v13;
2121
mod v14;
2222
mod v15;
23+
mod v16;
2324

2425
pub fn assert_serialized(
2526
out: &mut [u8],

Diff for: gateway-messages/tests/versioning/v16.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! This source file is named after the protocol version being tested,
6+
//! e.g. v01.rs implements tests for protocol version 1.
7+
//! The tested protocol version is represented by "$VERSION" below.
8+
//!
9+
//! The tests in this module check that the serialized form of messages from MGS
10+
//! protocol version $VERSION have not changed.
11+
//!
12+
//! If a test in this module fails, _do not change the test_! This means you
13+
//! have changed, deleted, or reordered an existing message type or enum
14+
//! variant, and you should revert that change. This will remain true until we
15+
//! bump the `version::MIN` to a value higher than $VERSION, at which point these
16+
//! tests can be removed as we will stop supporting $VERSION.
17+
18+
use super::assert_serialized;
19+
use gateway_messages::measurement::MeasurementKind;
20+
use gateway_messages::SerializedSize;
21+
use gateway_messages::SpResponse;
22+
23+
#[test]
24+
fn measurement_kinds() {
25+
let mut out = [0; SpResponse::MAX_SIZE];
26+
27+
for (kind, serialized) in [
28+
(MeasurementKind::Temperature, &[0]),
29+
(MeasurementKind::Power, &[1]),
30+
(MeasurementKind::Current, &[2]),
31+
(MeasurementKind::Voltage, &[3]),
32+
(MeasurementKind::InputCurrent, &[4]),
33+
(MeasurementKind::InputVoltage, &[5]),
34+
(MeasurementKind::Speed, &[6]),
35+
(MeasurementKind::CpuTctl, &[7]),
36+
] {
37+
assert_serialized(&mut out, serialized, &kind);
38+
}
39+
}

0 commit comments

Comments
 (0)