Skip to content

Commit 4a11780

Browse files
committed
Merge branch 'main' into tech-port-unlock
2 parents 68df5ec + 64f5741 commit 4a11780

File tree

10 files changed

+185
-67
lines changed

10 files changed

+185
-67
lines changed

Cargo.lock

Lines changed: 69 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ anyhow = "1.0"
2626
async-trait = "0.1"
2727
backoff = { version = "0.4.0", features = ["tokio"] }
2828
base64 = "0.22.1"
29-
bitflags = "2.9.3"
30-
camino = "1.1.12"
29+
bitflags = "2.9.4"
30+
camino = "1.2.0"
3131
camino-tempfile = "1.4.1"
3232
clap = { version = "4.5", features = ["derive", "env"] }
3333
convert_case = "0.8"
@@ -37,7 +37,7 @@ fxhash = "0.2.1"
3737
glob = "0.3.3"
3838
hex = "0.4.3"
3939
hubpack = "0.1.2"
40-
humantime = "2.2.0"
40+
humantime = "2.3.0"
4141
indicatif = "0.18"
4242
lru-cache = "0.1.2"
4343
lzss = "0.8"
@@ -49,9 +49,9 @@ parse_int = "0.6"
4949
rand = "0.9.2"
5050
serde = { version = "1.0", default-features = false, features = ["derive"] }
5151
serde-big-array = "0.5.1"
52-
serde_bytes = "0.11.17"
52+
serde_bytes = "0.11.19"
5353
serde_cbor = "0.11.2"
54-
serde_json = "1.0.143"
54+
serde_json = "1.0.145"
5555
serde_repr = { version = "0.1" }
5656
sha2 = "0.10"
5757
slog = { version = "2.7", features = ["max_level_trace", "release_max_level_trace"] }
@@ -66,14 +66,14 @@ strum = { version = "0.27.2", default-features = false }
6666
strum_macros = "0.27.2"
6767
string_cache = "0.8.9"
6868
termios = "0.3"
69-
thiserror = "2.0.16"
69+
thiserror = "2.0.17"
7070
tokio = { version = "1.29", features = ["full"] }
7171
tokio-stream = { version = "0.1", features = ["fs"] }
7272
tokio-util = { version = "0.7", features = ["compat"] }
7373
usdt = "0.5.0"
74-
uuid = { version = "1.16", default-features = false }
74+
uuid = { version = "1.18", default-features = false }
7575
version_check = "0.9.5"
76-
zerocopy = "0.8.26"
76+
zerocopy = "0.8.27"
7777
zip = { version = "0.6.6", default-features = false, features = ["deflate", "bzip2"] }
7878

7979
gateway-messages.path = "gateway-messages"

faux-mgs/src/main.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,9 +1356,31 @@ async fn run_command(
13561356
if json {
13571357
return Ok(Output::Json(component_details_to_json(details)));
13581358
}
1359+
1360+
/// Helper `struct` to pretty-print component details
1361+
///
1362+
/// This normally delegates to `Debug`, but prints `LastPostCode` as
1363+
/// a hex value for convenience.
1364+
struct ComponentDetailPrinter(gateway_messages::ComponentDetails);
1365+
impl std::fmt::Display for ComponentDetailPrinter {
1366+
fn fmt(
1367+
&self,
1368+
f: &mut std::fmt::Formatter<'_>,
1369+
) -> std::fmt::Result {
1370+
use gateway_messages::ComponentDetails;
1371+
match &self.0 {
1372+
ComponentDetails::LastPostCode(p) => {
1373+
write!(f, "LastPostCode({:#x})", p.0)
1374+
}
1375+
d => write!(f, "{d:?}"),
1376+
}
1377+
}
1378+
}
1379+
13591380
let mut lines = Vec::new();
13601381
for entry in details.entries {
1361-
lines.push(format!("{entry:?}"));
1382+
let d = ComponentDetailPrinter(entry);
1383+
lines.push(format!("{d}"));
13621384
}
13631385
Ok(Output::Lines(lines))
13641386
}
@@ -2310,6 +2332,7 @@ fn component_details_to_json(details: SpComponentDetails) -> serde_json::Value {
23102332
enum ComponentDetails {
23112333
PortStatus(Result<PortStatus, PortStatusError>),
23122334
Measurement(Measurement),
2335+
LastPostCode(u32),
23132336
}
23142337

23152338
#[derive(serde::Serialize)]
@@ -2333,6 +2356,9 @@ fn component_details_to_json(details: SpComponentDetails) -> serde_json::Value {
23332356
value: m.value,
23342357
})
23352358
}
2359+
gateway_messages::ComponentDetails::LastPostCode(code) => {
2360+
ComponentDetails::LastPostCode(code.0)
2361+
}
23362362
})
23372363
.collect::<Vec<_>>();
23382364

gateway-messages/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub const HF_PAGE_SIZE: usize = 256;
6969
/// for more detail and discussion.
7070
pub mod version {
7171
pub const MIN: u32 = 2;
72-
pub const CURRENT: u32 = 20;
72+
pub const CURRENT: u32 = 21;
7373

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

gateway-messages/src/sp_to_mgs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ use serde_repr::Serialize_repr;
2525
pub mod ignition;
2626
pub mod measurement;
2727
pub mod monorail_port_status;
28+
pub mod sp5_details;
2829

2930
pub use ignition::IgnitionState;
3031
pub use measurement::Measurement;
32+
pub use sp5_details::LastPostCode;
3133

3234
use ignition::IgnitionError;
3335
use measurement::MeasurementHeader;
@@ -710,17 +712,21 @@ pub struct TlvPage {
710712
/// serialization traits; it only serves as an organizing collection of the
711713
/// possible types contained in a component details message. Each TLV-encoded
712714
/// struct corresponds to one of these cases.
715+
///
716+
/// As such, it is not part of the explicit message versioning scheme
713717
#[derive(Debug, Clone)]
714718
pub enum ComponentDetails {
715719
PortStatus(Result<PortStatus, PortStatusError>),
716720
Measurement(Measurement),
721+
LastPostCode(LastPostCode),
717722
}
718723

719724
impl ComponentDetails {
720725
pub fn tag(&self) -> tlv::Tag {
721726
match self {
722727
ComponentDetails::PortStatus(_) => PortStatus::TAG,
723728
ComponentDetails::Measurement(_) => MeasurementHeader::TAG,
729+
ComponentDetails::LastPostCode(_) => LastPostCode::TAG,
724730
}
725731
}
726732

@@ -742,6 +748,9 @@ impl ComponentDetails {
742748
Ok(n + m.name.len())
743749
}
744750
}
751+
ComponentDetails::LastPostCode(code) => {
752+
hubpack::serialize(buf, code)
753+
}
745754
}
746755
}
747756
}

gateway-messages/src/sp_to_mgs/ignition.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub enum SystemType {
113113
Sidecar,
114114
Psc,
115115
Unknown(u16),
116+
Cosmo,
116117
}
117118

118119
impl From<u16> for SystemType {
@@ -121,6 +122,7 @@ impl From<u16> for SystemType {
121122
raw_system_type::GIMLET => Self::Gimlet,
122123
raw_system_type::SIDECAR => Self::Sidecar,
123124
raw_system_type::PSC => Self::Psc,
125+
raw_system_type::COSMO => Self::Cosmo,
124126
_ => Self::Unknown(val),
125127
}
126128
}
@@ -131,6 +133,7 @@ mod raw_system_type {
131133
pub(super) const GIMLET: u16 = 0b0000_0000_0001_0001;
132134
pub(super) const SIDECAR: u16 = 0b0000_0000_0001_0010;
133135
pub(super) const PSC: u16 = 0b0000_0000_0001_0011;
136+
pub(super) const COSMO: u16 = 0b0000_0000_0000_0100;
134137
}
135138

136139
#[derive(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
use crate::tlv;
6+
use hubpack::SerializedSize;
7+
use serde::{Deserialize, Serialize};
8+
9+
/// Most recent POST code seen by the sequencer FPGA
10+
#[derive(Copy, Clone, Debug, Serialize, Deserialize, SerializedSize)]
11+
pub struct LastPostCode(pub u32);
12+
13+
impl LastPostCode {
14+
pub const TAG: tlv::Tag = tlv::Tag(*b"POST");
15+
}

gateway-messages/tests/versioning/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod v17;
2626
mod v18;
2727
mod v19;
2828
mod v20;
29+
mod v21;
2930

3031
pub fn assert_serialized<T: Serialize + SerializedSize + std::fmt::Debug>(
3132
expected: &[u8],
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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::ignition::SystemType;
20+
21+
#[test]
22+
fn cosmo_ignition() {
23+
// We technically only need `Cosmo` but test everything else
24+
// here again for good measure
25+
for (system_type, system_type_val) in [
26+
(SystemType::Gimlet, &[0_u8] as &[_]),
27+
(SystemType::Sidecar, &[1]),
28+
(SystemType::Psc, &[2]),
29+
(SystemType::Unknown(0xa0a1), &[3, 0xa1, 0xa0]),
30+
(SystemType::Cosmo, &[4]),
31+
] {
32+
assert_serialized(&system_type_val, &system_type);
33+
}
34+
}

gateway-sp-comms/src/single_sp.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,7 @@ impl TlvRpc for ComponentDetailsTlvRpc<'_> {
15761576
use gateway_messages::measurement::MeasurementHeader;
15771577
use gateway_messages::monorail_port_status::PortStatus;
15781578
use gateway_messages::monorail_port_status::PortStatusError;
1579+
use gateway_messages::sp5_details::LastPostCode;
15791580

15801581
match tag {
15811582
PortStatus::TAG => {
@@ -1622,6 +1623,23 @@ impl TlvRpc for ComponentDetailsTlvRpc<'_> {
16221623
value: header.value,
16231624
})))
16241625
}
1626+
LastPostCode::TAG => {
1627+
let (result, leftover) =
1628+
gateway_messages::deserialize::<LastPostCode>(value)
1629+
.map_err(|err| CommunicationError::TlvDeserialize {
1630+
tag,
1631+
err,
1632+
})?;
1633+
1634+
if !leftover.is_empty() {
1635+
info!(
1636+
self.log,
1637+
"ignoring unexpected data in LastPostCode TLV entry"
1638+
);
1639+
}
1640+
1641+
Ok(Some(ComponentDetails::LastPostCode(result)))
1642+
}
16251643
_ => {
16261644
info!(
16271645
self.log,

0 commit comments

Comments
 (0)