pub struct LircMode2 { /* private fields */ }Expand description
A program used to decode IR into key events for a lirc device.
LircMode2 programs can be used to inspect infrared pulses, spaces,
and timeouts received by a lirc IR receiver.
§Minimum kernel version
The minimum kernel version required to use this feature is 4.18.
§Examples
use std::fs::File;
use aya::programs::LircMode2;
let file = File::open("/dev/lirc0")?;
let mut bpf = aya::Ebpf::load_file("imon_rsc.o")?;
let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc").unwrap().try_into().unwrap();
decoder.load()?;
decoder.attach(file)?;Implementations§
Source§impl LircMode2
impl LircMode2
Sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
Sourcepub fn attach<T: AsFd>(
&mut self,
lircdev: T,
) -> Result<LircLinkId, ProgramError>
pub fn attach<T: AsFd>( &mut self, lircdev: T, ) -> Result<LircLinkId, ProgramError>
Attaches the program to the given lirc device.
The returned value can be used to detach, see LircMode2::detach.
Sourcepub fn detach(&mut self, link_id: LircLinkId) -> Result<(), ProgramError>
pub fn detach(&mut self, link_id: LircLinkId) -> Result<(), ProgramError>
Detaches the program.
See LircMode2::attach.
Sourcepub fn take_link(
&mut self,
link_id: LircLinkId,
) -> Result<LircLink, ProgramError>
pub fn take_link( &mut self, link_id: LircLinkId, ) -> Result<LircLink, ProgramError>
Takes ownership of the link referenced by the provided link_id.
The link will be detached on Drop and the caller is now responsible
for managing its lifetime.
Source§impl LircMode2
impl LircMode2
Sourcepub fn unload(&mut self) -> Result<(), ProgramError>
pub fn unload(&mut self) -> Result<(), ProgramError>
Unloads the program from the kernel.
Links will be detached before unloading the program. Note
that owned links obtained using take_link() will not be
detached.
Source§impl LircMode2
impl LircMode2
Sourcepub fn fd(&self) -> Result<&ProgramFd, ProgramError>
pub fn fd(&self) -> Result<&ProgramFd, ProgramError>
Returns the file descriptor of this Program.
Source§impl LircMode2
impl LircMode2
Sourcepub fn pin<P: AsRef<Path>>(&mut self, path: P) -> Result<(), PinError>
pub fn pin<P: AsRef<Path>>(&mut self, path: P) -> Result<(), PinError>
Pins the program to a BPF filesystem.
When a BPF object is pinned to a BPF filesystem it will remain loaded after Aya has unloaded the program. To remove the program, the file on the BPF filesystem must be removed. Any directories in the the path provided should have been created by the caller.
Source§impl LircMode2
impl LircMode2
Sourcepub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, ProgramError>
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Self, ProgramError>
Creates a program from a pinned entry on a bpffs.
Existing links will not be populated. To work with existing links you should use crate::programs::links::PinnedLink.
On drop, any managed links are detached and the program is unloaded. This will not result in the program being unloaded from the kernel if it is still pinned.
Source§impl LircMode2
impl LircMode2
Sourcepub fn info(&self) -> Result<ProgramInfo, ProgramError>
pub fn info(&self) -> Result<ProgramInfo, ProgramError>
Returns metadata information of this program.
Uses kernel v4.13 features.