Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.

6 changes: 4 additions & 2 deletions task/control-plane-agent/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Inventory {
capabilities |= DeviceCapabilities::HAS_MEASUREMENT_CHANNELS;
}
DeviceDescription {
component: SpComponent { id: device.id },
component: SpComponent::from_bstr_unchecked(device.id.as_bytes()),
Comment thread
jamesmunns marked this conversation as resolved.
Outdated
device: device.device,
description: device.description,
capabilities,
Expand Down Expand Up @@ -179,7 +179,9 @@ impl TryFrom<&'_ SpComponent> for Index {

fn try_from(component: &'_ SpComponent) -> Result<Self, Self::Error> {
if let Ok(entry_idx) = task_validate_api::DEVICE_INDICES_BY_SORTED_ID
.binary_search_by_key(&component.id, |&(id, _)| id)
.binary_search_by_key(&component.as_bstr(), |&(id, _)| {
id.as_bytes()
})
Comment thread
jamesmunns marked this conversation as resolved.
{
let &(_, index) = task_validate_api::DEVICE_INDICES_BY_SORTED_ID
.get(entry_idx)
Expand Down
2 changes: 1 addition & 1 deletion task/control-plane-agent/src/update/rot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl ComponentUpdater for RotUpdate {
.map_err(SpError::OtherComponentUpdateInProgress)?;

// Which target are we updating?
ringbuf_entry!(Trace::Target(update.component.id[0], update.slot));
ringbuf_entry!(Trace::Target(update.component.id()[0], update.slot));
let target = match (update.component, update.slot) {
(SpComponent::ROT, 0) => UpdateTarget::ImageA,
(SpComponent::ROT, 1) => UpdateTarget::ImageB,
Expand Down
12 changes: 6 additions & 6 deletions task/validate-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ fn write_pub_device_descriptions() -> anyhow::Result<()> {
writeln!(file, " DeviceDescription {{")?;
writeln!(file, " device: {:?},", dev.device)?;
writeln!(file, " description: {:?},", dev.description)?;
if let Some(id) = dev.device_id {
if let Ok(component) = SpComponent::try_from(id.as_ref()) {
writeln!(file, " id: {:?},", component.id)?;
if id2idx.insert(component.id, idx).is_some() {
if let Some(id) = dev.device_id.as_ref() {
if id.len() <= SpComponent::MAX_ID_LENGTH {
writeln!(file, " id: \"{id}\",")?;
if id2idx.insert(id.to_string(), idx).is_some() {
println!("cargo::error=duplicate device id {id:?}",);
duplicate_ids += 1;
}
Expand Down Expand Up @@ -106,11 +106,11 @@ fn write_pub_device_descriptions() -> anyhow::Result<()> {

writeln!(
file,
"pub static DEVICE_INDICES_BY_SORTED_ID: [([u8; MAX_ID_LENGTH], usize); {}] = [",
"pub static DEVICE_INDICES_BY_SORTED_ID: [(&str, usize); {}] = [",
id2idx.len()
)?;
for (id, idx) in id2idx {
writeln!(file, " ({id:?}, {idx}),")?;
writeln!(file, " (\"{id}\", {idx}),")?;
}
writeln!(file, "];")?;

Expand Down
2 changes: 1 addition & 1 deletion task/validate-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct DeviceDescription {
pub device: &'static str,
pub description: &'static str,
pub sensors: &'static [SensorDescription],
pub id: [u8; MAX_ID_LENGTH],
pub id: &'static str,
pub is_pmbus: bool,
}

Expand Down
Loading