Struct gpio_cdev::LineHandle

source ·
pub struct LineHandle { /* private fields */ }
Expand description

Handle for interacting with a “requested” line

In order for userspace to read/write the value of a GPIO it must be requested from the chip using Line::request. On success, the kernel creates an anonymous file descriptor for interacting with the requested line. This structure is the go-between for callers and that file descriptor.

Implementations§

source§

impl LineHandle

source

pub fn get_value(&self) -> Result<u8, Error>

Request the current state of this Line from the kernel

This call is expected to succeed for both input and output lines. It should be noted, however, that some drivers may not be able to give any useful information when the value is requested for an output line.

This value should be 0 or 1 which a “1” representing that the line is active. Usually this means that the line is at logic-level high but it could mean the opposite if the line has been marked as being ACTIVE_LOW.

source

pub fn set_value(&self, value: u8) -> Result<(), Error>

Request that the line be driven to the specified value

The value should be 0 or 1 with 1 representing a request to make the line “active”. Usually “active” means logic level high unless the line has been marked as ACTIVE_LOW.

Calling set_value on a line that is not an output will likely result in an error (from the kernel).

source

pub fn line(&self) -> &Line

Get the Line information associated with this handle.

source

pub fn flags(&self) -> LineRequestFlags

Get the flags with which this handle was created

Trait Implementations§

source§

impl AsRawFd for LineHandle

source§

fn as_raw_fd(&self) -> RawFd

Gets the raw file descriptor for the LineHandle.

source§

impl Debug for LineHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.