pub struct SwitchtecDevice { /* private fields */ }
Expand description
SwitchtecDevice
offers an safer way to work with the underlying switchtec_dev
and
represents an open Switchtec PCI Switch device that can be passed into switchtec-user
C library functions
SwitchtecDevice
closes the Switchtec character device when it goes out of scope
Implementations§
Source§impl SwitchtecDevice
impl SwitchtecDevice
Sourcepub fn open<T: AsRef<Path>>(path: T) -> Result<Self>
pub fn open<T: AsRef<Path>>(path: T) -> Result<Self>
Open the Switchtec PCIe Switch character device at the given path
,
returning a SwitchtecDevice
that can be used to pass into
switchtec-user
C library functions
use switchtec_user_sys::{switchtec_die_temp, SwitchtecDevice};
let device = SwitchtecDevice::open("/dev/pciswitch0")?;
// SAFETY: We know that device holds a valid/open switchtec device
let temperature = unsafe { switchtec_die_temp(*device) };
println!("Temperature: {temperature}");
// Switchtec device is closed with `device` goes out of scope
}
Sourcepub fn name(&self) -> Result<String>
pub fn name(&self) -> Result<String>
Get the device name (E.g. “pciswitch0” in “/dev/pciswitch0”)
This can fail if the device name is not valid UTF-8
https://microsemi.github.io/switchtec-user/group__Device.html#ga8d416a587f5e37e818ee937bd0c0dab1
Sourcepub fn boot_phase(&self) -> switchtec_boot_phase
pub fn boot_phase(&self) -> switchtec_boot_phase
Get the PCIe generation of the device
https://microsemi.github.io/switchtec-user/group__Device.html#ga9eab19beb39d2104b5defd28787177ae
Sourcepub fn firmware_version(&self) -> Result<String>
pub fn firmware_version(&self) -> Result<String>
Get the firmware version as a user readable string
This can fail if the firmware version is not valid UTF-8
https://microsemi.github.io/switchtec-user/group__Device.html#gad16f110712bd23170ad69450c361122e
Sourcepub fn generation(&self) -> switchtec_gen
pub fn generation(&self) -> switchtec_gen
Get the PCIe generation of the device
https://microsemi.github.io/switchtec-user/group__Device.html#gab9f59d48c410e8dde13acdc519943a26
Sourcepub fn partition(&self) -> i32
pub fn partition(&self) -> i32
Get the partition of the device
https://microsemi.github.io/switchtec-user/group__Device.html#gac70f47bb86ac6ba1666446f27673cdcf
Sourcepub fn die_temp(&self) -> Result<f32>
pub fn die_temp(&self) -> Result<f32>
Get the die temperature of the switchtec device (in Celcius)
https://microsemi.github.io/switchtec-user/group__Misc.html#ga56317f0a31a83eb896e4a987dbd645df