mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 01:12:30 -04:00
Implement GetAlsIntegrationTimeFileDescriptor.
And this attempt works now. I guess this is adequate to release as a throw away implementation to replace later with something better. Also add strip="symbols" for release builds to get it down to a lean 3.2M size.
This commit is contained in:
parent
b73ae9ebd1
commit
bf3cca29ac
4 changed files with 34 additions and 24 deletions
|
@ -23,8 +23,9 @@
|
|||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
use std::{ffi::OsStr};
|
||||
use std::{ffi::OsStr, os::fd::{FromRawFd, IntoRawFd}};
|
||||
use tokio::{process::Command, fs::File, io::AsyncWriteExt};
|
||||
use zbus::zvariant::OwnedFd;
|
||||
use zbus_macros::dbus_interface;
|
||||
pub struct SMManager {
|
||||
}
|
||||
|
@ -237,6 +238,23 @@ impl SMManager {
|
|||
}
|
||||
}
|
||||
|
||||
async fn get_als_integration_time_file_descriptor(&self) -> Result<zbus::zvariant::OwnedFd, zbus::fdo::Error> {
|
||||
// Get the file descriptor for the als integration time sysfs path
|
||||
// /sys/devices/platform/AMDI0010:00/i2c-0/i2c-PRP0001:01/iio:device0/in_illuminance_integration_time
|
||||
// Return -1 on error
|
||||
let result = File::create("/sys/devices/platform/AMDI0010:00/i2c-0/i2c-PRP0001:01/iio:device0/in_illuminance_integration_time").await;
|
||||
match result {
|
||||
Ok(f) => {
|
||||
let raw = f.into_std().await.into_raw_fd();
|
||||
unsafe {
|
||||
let fd: OwnedFd = OwnedFd::from_raw_fd(raw);
|
||||
Ok(fd)
|
||||
}
|
||||
},
|
||||
Err(message) => { println!("Error opening sysfs file for giving file descriptor {message}"); Err(zbus::fdo::Error::IOError(message.to_string())) }
|
||||
}
|
||||
}
|
||||
|
||||
/// A version property.
|
||||
#[dbus_interface(property)]
|
||||
async fn version(&self) -> u32 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue