Add support for DOTNET Facade FFI#320
Add support for DOTNET Facade FFI#320TekuSP wants to merge 12 commits intoFrameworkComputer:mainfrom
Conversation
- Introduce a new crate that exposes C-compatible functions for interacting with the EC and SMBIOS. - Integrate `csbindgen` to automatically generate C# bindings during the build process. - Implement helper types and snapshot functions in `framework_lib` to facilitate structured data retrieval. - Export functionality for platform identification, battery status, and thermal/fan control.
- Add build steps for the .NET interop crate to FreeBSD, Linux, and Windows CI jobs. - Configure CI to upload compiled native libraries and generated C# bindings as build artifacts. - Update README with build instructions and technical details for the optional .NET interop functionality.
|
(And yes I did use Copilot for some tasks, as I have absolutely almost zero knowledge of RUST, I have knowledge of firmwares, OS, and frameworks in .NET (Yes we had C# OS)) |
|
All tests pass and library works on my laptop, there is one slight formatting change (Cause meh Lint) and one extended helper in original source code for getting some internal values. No changes made to RUST functionality (I hope), just exported a lot of stuff for C (And C#) |
Signed-off-by: TekuSP <richard.torhan@windowslive.com>
|
Signed commit. |
Refactors the FFI boundary to provide more comprehensive and structured error reporting, and to consolidate function return values. - The `FrameworkStatus` struct now uses a union to provide specific error details (e.g., invalid fan index, detailed EC response codes, device error messages). - FFI functions now return dedicated `Result` structs that combine status and data, simplifying consumption from .NET. - Introduces functions to retrieve human-readable descriptions for status codes and device errors. - Updates `build.rs` to ensure `csbindgen` reruns when `src/lib.rs` changes, improving build reliability.
|
Updated to latest main, after new Framework 13 Pro with new Intel CPUs. Reworked some internal structures to make more C# sense. |
…pshot Consolidates fan RPM, presence, and stalled status into a `FrameworkFanReading` struct, leveraging a new `FrameworkFanState` enum. This improves data encapsulation and provides clearer, type-safe status information for each fan within the `FrameworkThermalSnapshot`.
Modernizes the FFI interfaces by introducing type-safe enums for various states and capabilities, and by enabling dynamic length strings for textual data. - Replaces boolean flags with dedicated enums (`FrameworkFanFeaturesState`, `FrameworkPowerSourceState`, `FrameworkBatteryState`) for clearer and more robust state representation in fan capabilities and power snapshots. - Adopts `FrameworkByteBuffer` for variable-length strings in battery details (manufacturer, model, etc.) and EC flash versions, eliminating fixed-size buffer limitations. - Restructures `FrameworkPowerSnapshot` to embed a new `FrameworkBatterySnapshot`, providing a more organized and extensible data model for power and battery information.
|
Final C# version to have refactored objects, where original structs did not make sense (We have battery_count, but we cannot index batteries now etc) |
|
Finalized, I am using it now in https://github.com/TekuSP/framework-dotnet and I am pretty happy about it. |
Hello,
I am .NET Developer and not RUST Developer, this is warning of things to come.
I needed to integrate Framework-System into .NET ecosystem, using export "c" of RUST.
I have no idea if I have done this right, but I tried my best.
I made .NET integration library of other side here: https://github.com/TekuSP/framework-dotnet
With GIT Submodule, sample output of my test console app is:
Therefore even if my solution is bad, it works. It would be silly and stupid of me to not push this idea upstream, maybe someone will do it better, maybe someone has better solution. But this is for me only way to access Framework-System from .NET.
I did in the past app for cooling fans of MSI, want to port that for my Framework, including separate fan curves and control.