Skip to content

Commit ee50b5a

Browse files
committed
docs: cli: document proxies module
Signed-off-by: Artie Poole <stuart.poole@canonical.com>
1 parent 35d68e1 commit ee50b5a

3 files changed

Lines changed: 264 additions & 0 deletions

File tree

cli/src/proxies/control_proxy.rs

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,94 @@
1010
//
1111
// You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
1212

13+
//! DBus proxy for the fpgad control interface.
14+
//!
15+
//! This module provides the auto-generated DBus proxy for the `com.canonical.fpgad.control`
16+
//! interface, which handles all write operations to the FPGA subsystem including:
17+
//! - Loading FPGA bitstreams
18+
//! - Applying device tree overlays
19+
//! - Removing overlays
20+
//! - Writing to FPGA manager properties
21+
//! - Setting FPGA flags
22+
//!
23+
//! The proxy is generated using the `zbus` crate's `#[proxy]` macro and provides
24+
//! type-safe, asynchronous access to the daemon's control interface.
25+
//!
26+
//! # DBus Interface Details
27+
//!
28+
//! - **Service**: `com.canonical.fpgad`
29+
//! - **Interface**: `com.canonical.fpgad.control`
30+
//! - **Object Path**: `/com/canonical/fpgad/control`
31+
//!
32+
//! # Usage
33+
//!
34+
//! ```rust,no_run
35+
//! use zbus::Connection;
36+
//! use control_proxy::ControlProxy;
37+
//!
38+
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
39+
//! let connection = Connection::system().await?;
40+
//! let proxy = ControlProxy::new(&connection).await?;
41+
//! let result = proxy.write_bitstream_direct(
42+
//! "",
43+
//! "fpga0",
44+
//! "/lib/firmware/design.bit.bin",
45+
//! ""
46+
//! ).await?;
47+
//! # Ok(())
48+
//! # }
49+
//! ```
50+
//!
51+
//! For detailed method documentation, see the daemon's
52+
//! [control interface documentation](../../../../daemon/comm/dbus/control_interface/index.html).
53+
1354
use zbus::{Result, proxy};
55+
56+
/// DBus proxy trait for the fpgad control interface.
57+
///
58+
/// This trait is auto-generated by the `#[proxy]` macro and provides methods to invoke
59+
/// the control interface methods on the fpgad daemon. All methods return `Result<String>`
60+
/// containing success messages or FpgadError messages.
61+
///
62+
/// See the main [module documentation](index.html) for usage examples.
1463
#[proxy(
1564
default_service = "com.canonical.fpgad",
1665
interface = "com.canonical.fpgad.control",
1766
default_path = "/com/canonical/fpgad/control"
1867
)]
1968
pub trait Control {
69+
/// Set FPGA programming flags for a device.
70+
///
71+
/// # Arguments
72+
///
73+
/// * `platform_string` - Platform identifier (can be empty for auto-detection)
74+
/// * `device_handle` - [Device handle](../../index.html#device-handles) (e.g., "fpga0")
75+
/// * `flags` - Programming flags as a 32-bit unsigned integer
76+
///
77+
/// # Returns: `Result<String>`
78+
/// * `Ok(String)` - Success message with confirmation of flags set
79+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
80+
/// See [Error Handling](../../index.html#error-handling)
2081
async fn set_fpga_flags(
2182
&self,
2283
platform_string: &str,
2384
device_handle: &str,
2485
flags: u32,
2586
) -> Result<String>;
2687

88+
/// Write a bitstream directly to an FPGA device.
89+
///
90+
/// # Arguments
91+
///
92+
/// * `platform_string` - Platform identifier (can be empty for auto-detection)
93+
/// * `device_handle` - [Device handle](../../index.html#device-handles) (e.g., "fpga0")
94+
/// * `bitstream_path_str` - Absolute path to the bitstream file
95+
/// * `firmware_lookup_path` - Optional firmware search path (empty for default)
96+
///
97+
/// # Returns: `Result<String>`
98+
/// * `Ok(String)` - Success message confirming bitstream loaded
99+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
100+
/// See [Error Handling](../../index.html#error-handling)
27101
async fn write_bitstream_direct(
28102
&self,
29103
platform_string: &str,
@@ -32,6 +106,19 @@ pub trait Control {
32106
firmware_lookup_path: &str,
33107
) -> Result<String>;
34108

109+
/// Apply a device tree overlay to the system.
110+
///
111+
/// # Arguments
112+
///
113+
/// * `platform_string` - Platform identifier string
114+
/// * `overlay_handle` - [Overlay handle](../../index.html#overlay-handles) for the overlay directory
115+
/// * `overlay_source_path` - Absolute path to the overlay file (.dtbo)
116+
/// * `firmware_lookup_path` - Optional firmware search path (empty for default)
117+
///
118+
/// # Returns: `Result<String>`
119+
/// * `Ok(String)` - Success message confirming overlay applied
120+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
121+
/// See [Error Handling](../../index.html#error-handling)
35122
async fn apply_overlay(
36123
&self,
37124
platform_string: &str,
@@ -40,8 +127,42 @@ pub trait Control {
40127
firmware_lookup_path: &str,
41128
) -> Result<String>;
42129

130+
/// Remove a device tree overlay from the system.
131+
///
132+
/// # Arguments
133+
///
134+
/// * `platform_str` - Platform identifier string
135+
/// * `overlay_handle` - [Overlay handle](../../index.html#overlay-handles) to remove
136+
///
137+
/// # Returns: `Result<String>`
138+
/// * `Ok(String)` - Success message confirming overlay removed
139+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
140+
/// See [Error Handling](../../index.html#error-handling)
43141
async fn remove_overlay(&self, platform_str: &str, overlay_handle: &str) -> Result<String>;
44142

143+
/// Write a string value to an FPGA manager property.
144+
///
145+
/// # Arguments
146+
///
147+
/// * `property_path_str` - Full sysfs path to the property (must be under `/sys/class/fpga_manager/`)
148+
/// * `data` - String data to write
149+
///
150+
/// # Returns: `Result<String>`
151+
/// * `Ok(String)` - Success message confirming write
152+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
153+
/// See [Error Handling](../../index.html#error-handling)
45154
async fn write_property(&self, property_path_str: &str, data: &str) -> Result<String>;
155+
156+
/// Write binary data to an FPGA manager property.
157+
///
158+
/// # Arguments
159+
///
160+
/// * `property_path_str` - Full sysfs path to the property (must be under `/sys/class/fpga_manager/`)
161+
/// * `data` - Binary data to write as a byte slice
162+
///
163+
/// # Returns: `Result<String>`
164+
/// * `Ok(String)` - Success message confirming write
165+
/// * `Err(zbus::Error)` - DBus error or FpgadError.
166+
/// See [Error Handling](../../index.html#error-handling)
46167
async fn write_property_bytes(&self, property_path_str: &str, data: &[u8]) -> Result<String>;
47168
}

cli/src/proxies/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,37 @@
1010
//
1111
// You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
1212

13+
//! DBus proxy interfaces for the fpgad daemon.
14+
//!
15+
//! This module provides auto-generated DBus proxy traits that allow the CLI to communicate
16+
//! with the fpgad daemon over the system DBus. The proxies are generated using the `zbus`
17+
//! crate's `#[proxy]` macro and provide type-safe, asynchronous access to the daemon's
18+
//! DBus interfaces.
19+
//!
20+
//! # Modules
21+
//!
22+
//! - [`control_proxy`] - Write operations (load bitstreams, apply overlays, set properties)
23+
//! - [`status_proxy`] - Read-only operations (query device state, platform info, overlays)
24+
//!
25+
//! # DBus Service Information
26+
//!
27+
//! - **Service Name**: `com.canonical.fpgad`
28+
//! - **Control Interface**: `com.canonical.fpgad.control` at `/com/canonical/fpgad/control`
29+
//! - **Status Interface**: `com.canonical.fpgad.status` at `/com/canonical/fpgad/status`
30+
//!
31+
//! # Usage
32+
//!
33+
//! These proxies are used internally by the CLI's command handlers ([`load`], [`remove`],
34+
//! [`set`], [`status`]) to communicate with the fpgad daemon. The proxies handle DBus
35+
//! connection management and method call marshalling automatically.
36+
//!
37+
//! For more information on the DBus interfaces, see the
38+
//! [daemon DBus documentation](../../../daemon/comm/dbus/index.html).
39+
//!
40+
//! [`load`]: ../load/index.html
41+
//! [`remove`]: ../remove/index.html
42+
//! [`set`]: ../set/index.html
43+
//! [`status`]: ../status/index.html
44+
1345
pub mod control_proxy;
1446
pub mod status_proxy;

cli/src/proxies/status_proxy.rs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,132 @@
1010
//
1111
// You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
1212

13+
//! DBus proxy for the fpgad status interface.
14+
//!
15+
//! This module provides the auto-generated DBus proxy for the `com.canonical.fpgad.status`
16+
//! interface, which handles all read-only operations for querying FPGA subsystem state:
17+
//! - Querying FPGA device states (operating, unknown, etc.)
18+
//! - Reading FPGA programming flags
19+
//! - Listing loaded device tree overlays
20+
//! - Getting platform compatibility strings
21+
//! - Checking overlay status
22+
//!
23+
//! The proxy is generated using the `zbus` crate's `#[proxy]` macro and provides
24+
//! type-safe, asynchronous access to the daemon's status interface.
25+
//!
26+
//! # DBus Interface Details
27+
//!
28+
//! - **Service**: `com.canonical.fpgad`
29+
//! - **Interface**: `com.canonical.fpgad.status`
30+
//! - **Object Path**: `/com/canonical/fpgad/status`
31+
//!
32+
//! # Usage
33+
//!
34+
//! ```rust,no_run
35+
//! use zbus::Connection;
36+
//! use status_proxy::StatusProxy;
37+
//!
38+
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
39+
//! let connection = Connection::system().await?;
40+
//! let proxy = StatusProxy::new(&connection).await?;
41+
//! let state = proxy.get_fpga_state("", "fpga0").await?;
42+
//! println!("FPGA state: {}", state);
43+
//! # Ok(())
44+
//! # }
45+
//! ```
46+
//!
47+
//! For detailed method documentation, see the daemon's
48+
//! [status interface documentation](../../../../daemon/comm/dbus/status_interface/index.html).
49+
1350
use zbus::{Result, proxy};
51+
52+
/// DBus proxy trait for the fpgad status interface.
53+
///
54+
/// This trait is auto-generated by the `#[proxy]` macro and provides methods to invoke
55+
/// the status interface methods on the fpgad daemon. All methods return `Result<String>`
56+
/// containing requested information or FpgadError messages.
57+
///
58+
/// See the main [module documentation](index.html) for usage examples.
1459
#[proxy(
1560
default_service = "com.canonical.fpgad",
1661
interface = "com.canonical.fpgad.status",
1762
default_path = "/com/canonical/fpgad/status"
1863
)]
1964
pub trait Status {
65+
/// Get the current state of an FPGA device.
66+
///
67+
/// Returns the device state such as "operating", "unknown", "write init", "write",
68+
/// "write complete", or "write error".
69+
///
70+
/// # Arguments
71+
///
72+
/// * `platform_string` - Platform identifier (can be empty for auto-detection)
73+
/// * `device_handle` - [Device handle](../../index.html#device-handles) (e.g., "fpga0")
74+
///
75+
/// # Returns: `Result<String>`
76+
/// * `Ok(String)` - Current state of the FPGA device
77+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
2078
async fn get_fpga_state(&self, platform_string: &str, device_handle: &str) -> Result<String>;
79+
80+
/// Get the current programming flags for an FPGA device.
81+
///
82+
/// Returns the flags as a hexadecimal string with no prefix (decimal value of 32 -> "20").
83+
///
84+
/// # Arguments
85+
///
86+
/// * `platform_string` - Platform identifier (can be empty for auto-detection)
87+
/// * `device_handle` - [Device handle](../../index.html#device-handles) (e.g., "fpga0")
88+
///
89+
/// # Returns: `Result<String>`
90+
/// * `Ok(String)` - Current flags in hexadecimal format
91+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
2192
async fn get_fpga_flags(&self, platform_string: &str, device_handle: &str) -> Result<String>;
93+
94+
/// Get the status of a specific device tree overlay.
95+
///
96+
/// # Arguments
97+
///
98+
/// * `platform_string` - Platform identifier string
99+
/// * `overlay_handle` - [Overlay handle](../../index.html#overlay-handles) to query
100+
///
101+
/// # Returns: `Result<String>`
102+
/// * `Ok(String)` - Status information for the overlay
103+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
22104
async fn get_overlay_status(
23105
&self,
24106
platform_string: &str,
25107
overlay_handle: &str,
26108
) -> Result<String>;
109+
110+
/// Get a list of all loaded device tree overlays.
111+
///
112+
/// Returns a newline-separated list of overlay handles.
113+
///
114+
/// # Returns: `Result<String>`
115+
/// * `Ok(String)` - Newline-separated list of overlay handles
116+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
27117
async fn get_overlays(&self) -> Result<String>;
118+
119+
/// Get the platform compatibility string for an FPGA device.
120+
///
121+
/// Returns the platform/compatibility string that identifies the hardware type
122+
/// (e.g., "xlnx,zynqmp-pcap-fpga", "universal").
123+
///
124+
/// # Arguments
125+
///
126+
/// * `device_handle` - [Device handle](../../index.html#device-handles) (e.g., "fpga0")
127+
///
128+
/// # Returns: `Result<String>`
129+
/// * `Ok(String)` - Platform compatibility string
130+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
28131
async fn get_platform_type(&self, device_handle: &str) -> Result<String>;
132+
133+
/// Get all FPGA devices and their platform strings.
134+
///
135+
/// Returns a newline-separated list where each line is formatted as "device:platform".
136+
///
137+
/// # Returns: `Result<String>`
138+
/// * `Ok(String)` - Newline-separated list of "device:platform" pairs
139+
/// * `Err(zbus::Error)` - DBus error or FpgadError. See [Error Handling](../../index.html#error-handling)
29140
async fn get_platform_types(&self) -> Result<String>;
30141
}

0 commit comments

Comments
 (0)