Struct gpio_cdev::Line [−][src]
pub struct Line { /* fields omitted */ }
Information about and access to a specific GPIO Line
GPIO Lines must be obtained through a parent Chip
and
represent an actual GPIO pin/line accessible via that chip.
Not all accessible lines for a given chip may actually
map to hardware depending on how the board is setup
in the kernel.
Wraps kernel struct gpioline_info
.
Methods
impl Line
[src]
impl Line
pub fn refresh(self) -> Result<Line>
[src]
pub fn refresh(self) -> Result<Line>
Refresh the cached line info from the kernel
pub fn offset(&self) -> u32
[src]
pub fn offset(&self) -> u32
Offset of this line within its parent chip
pub fn name(&self) -> Option<&str>
[src]
pub fn name(&self) -> Option<&str>
Name assigned to this chip if assigned
pub fn consumer(&self) -> Option<&str>
[src]
pub fn consumer(&self) -> Option<&str>
The name of this GPIO line, such as the output pin of the line on the chip, a rail or a pin header name on a board, as specified by the gpio chip.
pub fn is_used(&self) -> bool
[src]
pub fn is_used(&self) -> bool
True if the any flags for the device are set (input or output)
pub fn is_kernel(&self) -> bool
[src]
pub fn is_kernel(&self) -> bool
True if this line is being used by something else in the kernel
If another driver or subsystem in the kernel is using the line then it cannot be used via the cdev interface. See relevant kernel code.
pub fn is_active_low(&self) -> bool
[src]
pub fn is_active_low(&self) -> bool
True if this line is marked as active low in the kernel
pub fn is_open_drain(&self) -> bool
[src]
pub fn is_open_drain(&self) -> bool
True if this line is marked as open drain in the kernel
pub fn is_open_source(&self) -> bool
[src]
pub fn is_open_source(&self) -> bool
True if this line is marked as open source in the kernel
pub fn direction(&self) -> LineDirection
[src]
pub fn direction(&self) -> LineDirection
Get the direction of this GPIO if configured
Lines are considered to be inputs if not explicitly marked as outputs in the line info flags by the kernel.
pub fn chip(&self) -> Chip
[src]
pub fn chip(&self) -> Chip
Get a handle to this chip's parent
pub fn request(
&self,
flags: LineRequestFlags,
default: u8,
consumer: &str
) -> Result<LineHandle>
[src]
pub fn request(
&self,
flags: LineRequestFlags,
default: u8,
consumer: &str
) -> Result<LineHandle>
Request access to interact with this line from the kernel
This is similar to the "export" operation present in the sysfs
API with the key difference that we are also able to configure
the GPIO with flags
to specify how the line will be used
at the time of request.
For an output, the default
parameter specifies the value
the line should have when it is configured as an output. The
consumer
string should describe the process consuming the
line (this will be truncated to 31 characters if too long).
Errors
The main source of errors here is if the kernel returns an
error to the ioctl performing the request here. This will
result in an Error
being returned with ErrorKind::Io
.
One possible cause for an error here would be if the line is
already in use. One can check for this prior to making the
request using is_kernel
.
pub fn events(
&self,
handle_flags: LineRequestFlags,
event_flags: EventRequestFlags,
consumer: &str
) -> Result<LineEventHandle>
[src]
pub fn events(
&self,
handle_flags: LineRequestFlags,
event_flags: EventRequestFlags,
consumer: &str
) -> Result<LineEventHandle>
Get an event handle that can be used as a blocking iterator over the events (state changes) for this Line
When used as an iterator, it blocks while there is not another event
available from the kernel for this line matching the subscription
criteria specified in the event_flags
. The line will be configured
with the specified handle_flags
and consumer
label.
Note that as compared with the sysfs interface, the character device interface maintains a queue of events in the kernel so events may happen (e.g. a line changing state faster than can be picked up in userspace in real-time). These events will be returned on the iterator in order with the event containing the associated timestamp attached with high precision within the kernel (from an ISR for most drivers).
Example
use gpio_cdev::*; let mut chip = Chip::new("/dev/gpiochip0")?; let input = chip.get_line(0)?; // Show all state changes for this line forever for event in input.events( LineRequestFlags::INPUT, EventRequestFlags::BOTH_EDGES, "rust-gpio" )? { println!("{:?}", event?); }
Trait Implementations
impl Debug for Line
[src]
impl Debug for Line
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Line
[src]
impl Clone for Line