Skip to content

Fix oem_file_classification_name field, add AsciiString and Timestamp handling #23

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

Merged
merged 4 commits into from
Aug 4, 2025
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: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions pldm-file/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pldm = { workspace = true }

[dev-dependencies]
anyhow = "1.0"
chrono = { workspace = true }
mctp-linux = { workspace = true }
pldm-platform = { workspace = true, features = ["alloc"] }
smol = "2.0"
Expand Down
17 changes: 8 additions & 9 deletions pldm-file/examples/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ async fn handle_platform<R: AsyncRespChannel>(

let mut resp = req.response();

let update_time =
Timestamp104::try_from(&chrono::Local::now().fixed_offset())
.unwrap_or_default();

resp.cc = match Cmd::try_from(req.cmd)? {
Cmd::GetPDRRepositoryInfo => {
let pdrinfo = GetPDRRepositoryInfoResp {
state: PDRRepositoryState::Available,
update_time: [0u8; 13],
oem_update_time: [0u8; 13],
update_time,
oem_update_time: Default::default(),
record_count: 1,
// TODO. "An implementation is allowed to round this number up to the nearest kilobyte (1024 bytes)."
repository_size: 1024,
Expand Down Expand Up @@ -173,11 +177,6 @@ fn handle_get_pdr(
.try_into()
.context("File size > u32")?;

// null terminated filename
let mut file_name = FILENAME.as_bytes().to_vec();
file_name.push(0x00);
let file_name = pldm_platform::Vec::from_slice(&file_name).unwrap();

let pdr_resp = GetPDRResp::new_single(
PDR_HANDLE,
PdrRecord::FileDescriptor(FileDescriptorPdr {
Expand All @@ -196,8 +195,8 @@ fn handle_get_pdr(
file_max_size,
// TODO
file_max_desc_count: 1,
file_name: file_name.into(),
oem_file_name: Default::default(),
file_name: FILENAME.try_into().expect("Filename too long"),
oem_file_classification_name: Default::default(),
}),
)?;
let enc = pdr_resp.to_bytes().context("Encoding failed")?;
Expand Down
1 change: 1 addition & 0 deletions pldm-platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository.workspace = true
categories = ["network-programming", "embedded", "hardware-support"]

[dependencies]
chrono = { workspace = true }
deku = { workspace = true }
heapless = { workspace = true }
log = { workspace = true }
Expand Down
Loading