Skip to main content

leodos_libcfs/psp/
version.rs

1//! Wrappers for PSP version query functions.
2
3use crate::ffi;
4use core::ffi::CStr;
5
6/// Retrieves the PSP version identifier string (e.g., "equuleus-rc1").
7pub fn get_version_string() -> &'static str {
8    unsafe {
9        CStr::from_ptr(ffi::CFE_PSP_GetVersionString())
10            .to_str()
11            .unwrap_or("Invalid Version String")
12    }
13}
14
15/// Retrieves the PSP version code name (e.g., "Equuleus").
16pub fn get_version_code_name() -> &'static str {
17    unsafe {
18        CStr::from_ptr(ffi::CFE_PSP_GetVersionCodeName())
19            .to_str()
20            .unwrap_or("Invalid Code Name")
21    }
22}
23
24/// Retrieves the numeric PSP version identifier.
25///
26/// The returned array contains
27/// `[Major, Minor, Revision, MissionRevision]`.
28///
29/// MissionRevision semantics: 0 = official release,
30/// 1–254 = local patch (mission use), 255 = development build.
31pub fn get_version_number() -> [u8; 4] {
32    let mut numbers: [u8; 4] = [0; 4];
33    unsafe {
34        ffi::CFE_PSP_GetVersionNumber(numbers.as_mut_ptr());
35    }
36    numbers
37}
38
39/// Retrieves the PSP library build number.
40///
41/// Monotonically increasing number reflecting commits since the
42/// epoch release. Fixed at compile time.
43pub fn get_build_number() -> u32 {
44    unsafe { ffi::CFE_PSP_GetBuildNumber() }
45}