NervesUEvent listens for events from the Linux kernel, automatically loads device drivers, and forwards them to your Elixir programs.
NervesUEvent is a very simple version of the Linux udevd. Just like udevd
does for desktop Linux, NervesUEvent registers to receive UEvents from the Linux
kernel. Unlike udevd, NervesUEvent only runs modprobe when needed and keeps
track of what hardware is in the system. For most Nerves use cases, udevd
isn't needed.
Summary
Functions
Get the most recent value of UEvent report
Get all reported UEvents
Run an arbitrary match against UEvents
Return counters collected by the uevent port.
Subscribe to uevent notifications
Functions
@spec get(PropertyTable.property(), PropertyTable.value()) :: PropertyTable.value()
Get the most recent value of UEvent report
For example,
> NervesUEvent.get(["devices", "platform", "leds", "leds", "red:indicator-1"])
%{
"of_compatible_n" => "0",
"of_fullname" => "/leds/rgb1-blue",
"of_name" => "rgb1-blue",
"subsystem" => "leds"
}}
@spec get_all() :: [{PropertyTable.property(), PropertyTable.value()}]
Get all reported UEvents
@spec match(PropertyTable.pattern()) :: [ {PropertyTable.property(), PropertyTable.value()} ]
Run an arbitrary match against UEvents
Use :_ in the path to accept any value in that position
Use :"$" at the end of the path to perform an exact match
@spec stats() :: NervesUEvent.UEvent.stats()
Return counters collected by the uevent port.
Top-level keys:
:uevents_received— netlink messages successfully read:uevents_dropped— ENOBUFS incidents (kernel dropped one or more messages):modprobes_called— modprobe child processes launched:modaliases_queued— modaliases queued for modprobe:modaliases_dropped— modaliases dropped because the queue was full while a modprobe was already in flight:modprobe_fork_failures—fork()failures when launching modprobe:peak_queue_n— high-water mark for queued modalias count:peak_queue_bytes— high-water mark for the modalias byte buffer:actions— nested map ofadd | change | remove | move | bind | unbind | othercounts, matching the uevent ACTION field
Counters are cumulative since the port started and updated after 5 seconds of inactivity. Values will lag bursts especially at boot.
@spec subscribe(PropertyTable.pattern()) :: :ok
Subscribe to uevent notifications
Pass a pattern like one you'd pass to match/1. Instead of getting a
response, you'll receive a message when a matching UEvent happens.