MODE2(1)

✨ MODE2(1) ✨

okay bestie, gather round πŸ’– this is mode2 from the lirc fam (version 0.10.2, if you were wondering), and it's literally the tool you use to peek at what the kernel is handing over for LIRC drivers. it's giving "let me see what my IR receiver is actually doing" and honestly? iconic.


🌸 NAME 🌸

mode2 β€” show kernel output available for LIRC drivers


πŸŽ€ SYNOPSIS πŸŽ€

mode2 --driver <driver> [--device <device>] [other options]

mode2 --raw --device <device> [other options]

mode2 --driver <driver>  --list-devices

πŸ’… DESCRIPTION πŸ’…

so the original reason this program exists? checking that your home-brew LIRC receiver hardware actually works, and staring at the IR waveform from your remote without having to drop cash on an expensive oscilloscope. no cap. over time though, mode2 grew up and became a whole generic tool for checking what kind of output the kernel is making available for lirc. glow-up fr fr ✨

mode2 will simply print pulse and space lengths to stdout for drivers supporting LIRC_MODE_MODE2. for drivers supporting LIRC_MODE_LIRCCODE β€” think TV-cards and the irman driver β€” it writes the decoded, integer values instead.

from version 0.9.4 onward, mode2 can also list the devices available for a given driver πŸ¦‹. this needs enumeration support, which is present in most but not all drivers. (iykyk.)

when you give it the correct driver, mode2 should always work. without a driver, the --raw option should always work for /dev/lirc* devices. at the time of writing, usb devices also work in most cases β€” but the path to the usb device is tricky to get, so those are normally best accessed using a driver.

and psa: not all drivers require a device.


🌈 OPTIONS 🌈

  • -d --device=device β€” read from the given device.
  • -H --driver=driver β€” use the given driver.
  • -m --mode β€” write pulse/space data as raw config files. does not affect LIRCCODE drivers.
  • -s --scope=time β€” turn on a 'scope-like display with time in us per char. does not affect lirccode drivers.
  • -k --keep-root β€” don't drop root privileges after opening the device. go read RUNNING AS ROOT below, bestie.
  • -l --list-devices β€” list all available devices for the given driver. needs support that isn't present in all drivers, so it might just not vibe.
  • -g --gap=time β€” treat spaces longer than time as the gap. time is in microseconds.
  • -r --raw β€” access the device directly. this is primarely intended to be used with kernel rc drivers i .e., when accessing /dev/lirc* devices. using other devices might work, but is in general undefined 😭.
  • -A --driver-options=key:value[|key:value...] β€” set the driver-specific option named key to the given value.
  • -U --plugindir=directory β€” load drivers from directory. see DRIVER LOADING.
  • -O, --options-file <path> β€” a file containing default values for all options. a relative path is interpreted from the current directory. see [FILES] below.
  • -D --loglevel=level β€” decides how much logging info you get. level can be a symbolic syslog level: 'error', 'warning', 'info', 'notice' or 'debug'. lirc also defines three extra levels β€” 'trace', 'trace1' and 'trace2' β€” which give you even more messages ('trace2' brings the most). however, in the log these messages are marked as 'debug'. the level can also be an integer in the range 3 (almost no messages) to 10.
  • -h --help β€” display the usage summary.
  • -v --version β€” display the version.

πŸ‘‘ RUNNING AS ROOT πŸ‘‘

in many cases mode2 needs to run as root to access devices that regular users can't touch. but on the other hand, running as root creates problems β€” log files owned by root, security concerns, etc. πŸ™ˆ the eternal struggle.

to cope with this, mode2 by default drops root privileges after opening the input device. this support is based on root permissions being accquired using sudo(1), e. g. like this:

$ sudo mode2 --raw /dev/lirc0

if you're not using sudo, you can get the same behaviour with the SUDO_USER environment variable, e. g.:

# SUDO_USER=$LOGNAME mode2 --raw /dev/lirc0

the --keep-root option makes mode2 keep root privileges for the complete run. use with intention, bestie.


πŸ”₯ EXAMPLES πŸ”₯

invoked with a MODE2 type driver, mode2 prints space/mark timings:

al@snorken $ ./mode2 --driver default --device /dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0
Using device: /dev/lirc0
pulse 2750
space 800
pulse 500
space 350
pulse 550
space 350
pulse 550
...

invoked with a LIRCCODE type driver, mode2 prints decoded values:

$ ./mode2 --driver atilibusb
Using driver atilibusb on device /dev/lirc0
Trying device: /dev/bus/usb/001/007
Using device: /dev/bus/usb/001/007
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
code: 0x14709b0000
...

invoked using mode2 --list-devices for the devinput driver with a single X10 RF usb device plugged in:

$ ./mode2 --list-devices --driver devinput
/dev/input/event12 [0bc7:0006] X10 WTI RF receiver vers:  1.10 serial: ?
/dev/input/by-id/usb-X10_WTI_RF_receiver-event-if00 -> ../event12
/dev/input/by-path/pci-0000:0b:00.0-usb-0:1:1.0-event -> ../event12

πŸ¦‹ DRIVER LOADING πŸ¦‹

drivers are loaded dynamically, and the search path used for this is determined by (falling priority):

  • the --plugindir option.
  • the 'plugindir' entry in the [lircd] section of the lirc_options.conf file.
  • the environment variable LIRC_PLUGINDIR.
  • a hardcoded default (/usr/lib/x86_64-linux-gnu/lirc/plugins).

πŸ“ ENVIRONMENT πŸ“

  • LIRC_LOGLEVEL β€” used as fallback when there is no --loglevel option present. syntax is the same as for --loglevel, see OPTIONS.

πŸ’œ FILES πŸ’œ

  • /etc/lirc/lirc_options.conf β€” the options file holding default values for command line options in the [mode2] section. for some values β€” including debug, plugindir, driver and device β€” mode2 falls back to the [lircd] section if it's not found in [mode2].

the location of this file can be changed using the -O/--options-file command-line option or using the environment variable LIRC_OPTIONS_PATH.

  • ~/.cache/mode2.log β€” debug log. setting the XDG_CACHE_HOME environment variable relocates this file to $XDG_CACHE_HOME/mode2.log. the amount of logging respects the LIRC_LOGLEVEL environment variable, defaulting to the debug value in lirc_options.conf.

⭐ SEE ALSO ⭐

the documentation for lirc is maintained as html pages. they are located under html/ in the documentation directory.


and that's the whole page, bestie 🫢 this was mode2, last changed back in Jan 2017, from the 0.10.2 era of lirc. go forth and vibe check your IR receivers πŸ’–βœ¨

πŸ“¦ where this page comes from