@@ -42,7 +42,7 @@ fn main() -> Result<()> {
let rconfig = request::Config::new()?;
let mut buffer = request::Buffer::new(1)?;
- let request = chip.request_lines(&rconfig, &lconfig)?;
+ let request = chip.request_lines(Some(&rconfig), &lconfig)?;
loop {
match request.wait_edge_events(None) {
@@ -40,7 +40,7 @@ fn request_reconfigure_line(
let request = chip
.lock()
.unwrap()
- .request_lines(&rconfig, &lconfig)
+ .request_lines(Some(&rconfig), &lconfig)
.unwrap();
// Signal the parent to continue
@@ -37,7 +37,7 @@ fn main() -> Result<()> {
let rconfig = request::Config::new()?;
rconfig.set_consumer(&args[0])?;
- let request = chip.request_lines(&rconfig, &lconfig)?;
+ let request = chip.request_lines(Some(&rconfig), &lconfig)?;
let map = request.values()?;
println!("{:?}", map);
@@ -41,7 +41,7 @@ fn main() -> Result<()> {
let rconfig = request::Config::new()?;
let mut buffer = request::Buffer::new(1)?;
- let request = chip.request_lines(&rconfig, &lconfig)?;
+ let request = chip.request_lines(Some(&rconfig), &lconfig)?;
loop {
match request.wait_edge_events(None) {
@@ -54,7 +54,7 @@ fn main() -> Result<()> {
let rconfig = request::Config::new()?;
rconfig.set_consumer(&args[0])?;
- chip.request_lines(&rconfig, &lconfig)?;
+ chip.request_lines(Some(&rconfig), &lconfig)?;
// Wait for keypress, let user verify line status.
stdin().read_exact(&mut [0u8]).unwrap();
@@ -11,6 +11,7 @@ use std::cmp::Ordering;
use std::ffi::{CStr, CString};
use std::os::{raw::c_char, unix::prelude::AsRawFd};
use std::path::Path;
+use std::ptr;
use std::str;
use std::sync::Arc;
use std::time::Duration;
@@ -195,13 +196,18 @@ impl Chip {
/// Request a set of lines for exclusive usage.
pub fn request_lines(
&self,
- rconfig: &request::Config,
+ rconfig: Option<&request::Config>,
lconfig: &line::Config,
) -> Result<request::Request> {
+ let req_cfg = match rconfig {
+ Some(cfg) => cfg.config,
+ _ => ptr::null(),
+ } as *mut gpiod::gpiod_request_config;
+
// SAFETY: The `gpiod_line_request` returned by libgpiod is guaranteed to live as long
// as the `struct Request`.
let request = unsafe {
- gpiod::gpiod_chip_request_lines(self.ichip.chip, rconfig.config, lconfig.config)
+ gpiod::gpiod_chip_request_lines(self.ichip.chip, req_cfg, lconfig.config)
};
if request.is_null() {
@@ -106,7 +106,7 @@ impl TestConfig {
pub(crate) fn request_lines(&mut self) -> Result<()> {
let chip = Chip::open(&self.sim.lock().unwrap().dev_path())?;
- self.request = Some(chip.request_lines(&self.rconfig, &self.lconfig)?);
+ self.request = Some(chip.request_lines(Some(&self.rconfig), &self.lconfig)?);
self.chip = Some(chip);
Ok(())
@@ -32,7 +32,7 @@ mod info_event {
let request = chip
.lock()
.unwrap()
- .request_lines(&rconfig, &lconfig1)
+ .request_lines(Some(&rconfig), &lconfig1)
.unwrap();
// Signal the parent to continue