「LIRC」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(項目を整理)
 
(4人の利用者による、間の18版が非表示)
1行目: 1行目:
[[Category:他のハードウェア]]
+
[[Category:ハードウェア]]
[[Category:音声/動画]]
+
[[Category:マルチメディア]]
 
[[en:LIRC]]
 
[[en:LIRC]]
  +
[https://lirc.org/ official website] から:
{{Related articles start}}
 
  +
:'''LIRC''' (Linux 赤外線リモコン) は、一般的に使用される多くの (すべてではない) リモコンの赤外線信号をデコードして送信するパッケージです。
{{Related|LIRC Device Examples}}
 
{{Related articles end}}
 
   
  +
{{Note|4.18 以降、カーネルは BPF を使用して一部の IR リモコンの信号をデコードできるため、LIRC が重複する場合があります。[https://lwn.net/Articles/759188/]}}
 
この記事ではシリアル・USB 赤外線デバイスを使って [http://lirc.org/ LIRC] "Linux Infrared Remote Control" を設定・使用する方法を説明しています。
 
この記事ではシリアル・USB 赤外線デバイスを使って [http://lirc.org/ LIRC] "Linux Infrared Remote Control" を設定・使用する方法を説明しています。
   
  +
LIRC はサポートしているリモコンのキーが押されたときにプログラムにあわせて特定のコマンドに変換することができるデーモンです。ここで、「プログラムにあわせて」とは同じキーでも実行しているプログラムによって異なる動作をさせることができることを意味します。LIRC から取得されたリモコンの情報は以下のようにプログラムに流れます:
==概要==
 
  +
# ユーザーがリモコンのボタンを押すことで IR または RF 信号が送信されます。
LIRC はサポートしているリモコンのキーが押されたのをプログラムにあわせてコマンドに変換することができるデーモンです。ここで、「プログラムにあわせて」とは実行しているプログラムによってキーの押下で異なる動作をさせることができることを意味します。
 
  +
# Linux パソコンに接続されたレシーバーによって信号が受信されます。
  +
# カーネル (のモジュール) によってリモコンから送信されたパルス信号が {{ic|/dev/lirc0}}, {{ic|/dev/input/eventX}}, {{ic|/dev/ttyUSBX}}, {{ic|/dev/ttyS0}} などのデバイスに変換されます。
  +
# {{ic|/usr/bin/lircd}} は {{ic|/etc/lirc/lircd.conf.d/foo.conf}} の情報を使ってパルス信号をボタンの押下情報に変換します。
  +
# LIRC を使用するプログラムは {{ic|~/.lircrc}} に書かれている情報に従って {{ic|/usr/bin/lircd}} のボタン押下情報をユーザーが定義した操作に解釈します。
   
  +
==インストール==
=== LIRC の役割 ===
 
LIRC を使ってリモコンからの情報がプログラムに流れる過程は以下の通りです:
 
* ユーザーがリモコンのボタンを押すことで IR または RF 信号が送信されます。
 
* 信号が Linux が入ったパソコンに接続されたレシーバーによって受信されます。
 
* カーネル (の適切なモジュール) は {{ic|/dev/lirc0}} でレシーバーからのパルス幅の情報をキャラクタライズします。
 
* {{ic|/usr/bin/lircd}} は {{ic|/etc/lirc/lircd.conf}} からの情報でパルス幅をボタンの押下情報に変換します。
 
* LIRC を使用するプログラムは {{ic|/usr/bin/lircd}} のボタン押下情報を {{ic|~/.lircrc}} によってユーザーが定義した操作に解釈します。
 
   
  +
{{Pkg|lirc}} パッケージを[[インストール]]してください。
=== 必要なファイル ===
 
* {{ic|/etc/lirc/lircd.conf}} - スキャンコード --> キーに変換するシステムレベルの設定。システムの各リモートコントローラ・レシーバー固有で、必要ならば複数のリモコン・レシーバの設定を記述することもできる。
 
* {{ic|~/.lircrc}} - プログラムごとの lirc マップ ({{ic|~/.lirc/foo}}, {{ic|~/.lirc/bar}} など) を指定する '''include''' ステートメントを記述するファイル。
 
* {{ic|~/.lirc/foo}} - キー --> 操作に翻訳するユーザーレベルの設定。各リモコンとアプリケーション foo の固有設定。
 
   
  +
== 設定 ==
==インストール==
 
  +
[[公式リポジトリ]]にある {{Pkg|lirc-utils}} パッケージを[[インストール]]します。ほとんどの LIRC カーネルドライバーは既にメインラインのカーネルに入っています。ハードウェアが '''lirc_wpc8769l''' モジュールを必要とする場合は、{{Pkg|lirc}} パッケージだけをインストールしてください。
 
  +
=== 受信機と送信機の設定 ===
  +
  +
{{Note|このセクションは簡単な概要です。完全なドキュメントが利用可能です [https://lirc.sourceforge.net/lirc.org/html/index.html upstream]}}
   
  +
適切に実行するには、LIRC サービスの ''ドライバー'' および/または ''デバイス'' を指定する必要がある場合があります。''irrecord'' などの LIRC 依存プログラムの実行中にサービスが突然停止した場合は、[[journalctl]] 出力で次のようなメッセージを探してください。
==設定==
 
リモコンによっては LIRC がなくても"キーボード"として認識されそのように動作することがあります。このように認識されているとコマンドを二重に実行してしまう可能性があります。シェルやテキストエディタを開いて、リモコンのボタンを押してキーボードとして認識されていないかテストして下さい。文字や数字が打ち込まれたり、物理キーボードの上・下・右・左矢印キーのように動く場合、無効にする必要があります。次に進む前に [[#リモコンがキーボードとして機能する]] を見て下さい。
 
   
  +
Driver `devinput' not found or not loadable (wrong or missing -U/--plugindir?).
=== LIRC の設定ファイル ===
 
  +
readlink() failed for "auto": No such file or directory
Defining {{ic|/etc/lirc/lircd.conf}} which is specific to each remote/IR receiver is the first step in setting up a remote.
 
{{Note|Common configs are provided by {{Pkg|lirc-utils}}, like those bundled with TV cards that can be installed automatically. The primary source of config files is the LIRC homepage. Check the [http://lirc.org/html/table.html official list of supported hardware] to know, which LIRC kernel modules and lircd driver required.}}
 
   
==== 規定の設定ファイルを使う ====
+
これらを設定ファイルに設定し、サービス再起動します。
Identify which remote/receiver is to be used and see if {{ic|/usr/share/lirc}} contains a pre-built config file for it. Once identified, create/edit {{ic|/etc/lirc/lircd.conf}} to use an '''include''' statement that points to the selected one.
 
   
  +
{{hc|/etc/lirc/lirc_options.conf|2=
Example:
 
  +
[lircd]
{{hc|/etc/lirc/lircd.conf|
 
  +
driver = ''driver-name''
include "/usr/share/lirc/streamzap/lircd.conf.streamzap"
 
  +
device = /dev/''path-to-dev''
 
}}
 
}}
   
==== 設定ファイを作成する ====
+
==== シリアポート ====
Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one. Creating one is fairly straightforward using the included {{ic|/usr/bin/irrecord}} program which guides users along the needed process. If using a detected remote, invoke it like so:
 
irrecord --device=/dev/lirc0 MyRemote
 
   
  +
{{Tip|DIY 回路図については、シリアルポート [https://www.lirc.org/receivers.html 受信機] および [https://www.lirc.org/transmitters.html 送信機] のドキュメントを参照してください。シリアルポートデバイスは、''audio_alsa'' や ''audio'' よりもはるかに信頼性が高いことに注意してください。}}
The program will ask users to begin hitting keys on the remote in an attempt to learn it. If all goes well, the user will be prompted to map out each key press to a specific scancode LIRC uses to identify that specific key press. The process should take no more than 10 minutes. When finished, save the resulting file to {{ic|/etc/lirc/lircd.conf}} and proceed.
 
   
  +
最新のカーネルには、古い ''lirc_serial'' ドライバーに代わる ''serial_ir'' モジュールがあります。マザーボードのシリアルポートに接続された DIY 受信機および送信機もサポートします。{{AUR|setserial}} をインストールして実行します:
{{Note|Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.}}
 
   
  +
# setserial /dev/ttyS0 uart none
== リモコンのテスト ==
 
  +
# modprobe serial_ir
   
  +
''serial_ir'' モジュールをロードすると、デバイス {{ic|/dev/lirc0}} が、カーネルによって [https://github.com/torvalds/linux/blob/master/drivers/media/rc/serial_ir.c created] になります。そうでない場合は、[[systemd/ジャーナル|ジャーナル]] で関連するエラーがないか確認してください。シリアルデバイスの LIRC 設定例:
LIRC デーモンを起動:
 
# systemctl start lirc
 
   
  +
{{hc|/etc/lirc/lirc_options.conf|2=
{{ic|/usr/bin/irw}} を使ってリモコンをテストしてください、リモコンのボタンを押した時に LIRC が受信したものを全て標準出力に流します。
 
  +
[lircd]
  +
driver = default
  +
device = auto
   
  +
[modinit]
例:
 
  +
code = /usr/bin/setserial /dev/ttyS0 uart none
$ irw
 
  +
code1 = /usr/sbin/modprobe serial_ir
000000037ff07bfe 00 One mceusb
 
  +
}}
000000037ff07bfd 00 Two mceusb
 
000000037ff07bfd 01 Two mceusb
 
000000037ff07bf2 00 Home mceusb
 
000000037ff07bf2 01 Home mceusb
 
   
  +
==== サウンドカード ====
==プログラムごとの設定 ==
 
LIRC has the ability to allow for different programs to use the same keypress and result in unique commands. In other words, mplayer and vlc can respond differently to a given key press.
 
   
  +
{{Note|サウンドカードを赤外線デバイスとして使用すると、多くの落とし穴があり、他のハードウェア設定よりも利点が得られません。}}
Decide which programs are to use LIRC commands. Common programs include: {{Pkg|mplayer}}, {{Pkg|mythtv}}, {{Pkg|totem}}, {{Pkg|vlc}}, and {{Pkg|kodi}}.
 
   
  +
外部 DIY 回路が接続されたサウンドカードは、[https://www.lirc.org/ir-audio.html 受信] および IR コードを [https://web.archive.org/web/20150511192459/http://www.lirc.org:80/html/audio.html 送受信] できます。
{{Note|Kodi implements LIRC in a non-standard way. Users must edit {{ic|~/.xbmc/userdata/Lircmap.xml}} which is a unique xml file, rather than the LIRC standard files the rest of the programs use. Interested users should consult the [[Kodi#Using a remote controller]] article.}}
 
   
  +
''audio_alsa'' [https://www.lirc.org/html/audio-alsa.html driver] は {{pkg|lirc}} に含まれていますが、受信のみをサポートしています。
Users should create the expected files showing LIRC where the various program-specific maps reside:
 
$ mkdir ~/.lirc
 
$ touch ~/.lircrc
 
   
  +
{{ic|alsamixer}} でマイク入力のミュートを解除し、十分なゲインを設定します。{{pkg|audacity}} で波形とゲインを確認できます。区別できる方形パルスが存在する必要があります。平坦でも過負荷でもありません。また、良好に復調されたパルスは耳で簡単に認識できます。LIRC と {{ic|irrecord}} は ''右オーディオチャネルの正のパルス'' を読み取ることに注意してください。負のパルスは機能しません。
* Populate {{ic|~/.lirc}} with the program specific config files named for each program.
 
   
  +
{{hc|/etc/lirc/lirc_options.conf|2=
Example:
 
  +
driver = audio_alsa
$ ls ~/.lirc
 
  +
device = default
mplayer
 
  +
}}
mythtv
 
vlc
 
   
  +
{{AUR|lirc-git}} に含まれる ''audio'' [https://web.archive.org/web/20150511192459/http://www.lirc.org:80/html/audio.html driver] が受信と送信の両方をサポートします。デフォルトの遅延が 0.02 程度であると、"Warning: Output underflow" が発生し、送信が破損する可能性があることに注意してください。受信機はそれに応答しません。0.05 などのより高い値を試してください。
{{Note|Providing an exhaustive listing of keymaps for each program is beyond the scope of this wiki article. Many pre-made files unique to each remote/program are available via googling.}}
 
   
  +
サウンドカードの出力音量を上げて下さい。そうしないと、LED 信号が弱く、範囲が狭くなります。LEDフラッシュは赤外線の波長に敏感であるため、スマートフォンのカメラで検出できます。
* Edit {{ic|~/.lircrc}} to contain an '''include''' statement pointing to {{ic|~/.lirc/foo}} and repeat for each program that is to be controlled by LIRC.
 
   
  +
{{hc|/etc/lirc/lirc_options.conf|2=
Example:
 
  +
driver = audio
{{hc|~/.lircrc|
 
  +
device = ALSA:default@48000:0.05
include "~/.lirc/mplayer"
 
include "~/.lirc/mythtv"
 
include "~/.lirc/vlc"
 
 
}}
 
}}
   
  +
=== リモート設定 ===
==トラブルシューティング==
 
=== リモコンがキーボードとして機能する ===
 
Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as key strokes as if entered from the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device.
 
To disable, create the following file and restart X:
 
   
  +
ディレクトリ {{ic|/etc/lirc/lircd.conf.d/}} には、リモートのシステム全体の設定ファイルが含まれています。各 ''*.conf'' ファイルは 1 つのデバイスに対応し、そのプロトコル、スキャンコード、キーコードが記述されています。これにより、LIRC が特定のハードウェアに対して信号を送受信できるようになります。これらのファイルは {{Pkg|lirc}} パッケージには含まれていないため、ユーザーが作成する必要があります。
{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|
 
Section "InputClass"
 
Identifier "Ignore Streamzap IR"
 
MatchProduct "Streamzap"
 
MatchIsKeyboard "true"
 
Option "Ignore" "true"
 
EndSection}}
 
   
  +
==== リモート設定の検索 ====
Don't forget to alter the {{ic|MatchProduct}} property according to one shown in {{ic|Name}} from output of
 
$ cat /proc/bus/input/devices | grep -e IR
 
For example {{ic|WinFast}} for {{ic|<nowiki>N: Name="cx88 IR (WinFast DTV2000 H rev."</nowiki>}}
 
   
  +
多くの設定ファイルは [http://lirc-remotes.sourceforge.net/remotes-table.html LIRC リモートデータベース] にあります。URL に従うか、{{man|1|irdb-get}} を使用してデータベースを検索します。
== Legacy Info Which Needs to be Modernized and Vetted for Accuracy ==
 
{{Accuracy|Someone with greater knowledge needs vet everything below this line for accuracy.}}
 
{{Out of date|Parts of the following are out-of-date and need to be modernized.}}
 
   
  +
{{ic|irdb-get}} を使用して "Streamzap" リモートの設定ファイルを検索する例:
=== Setup a HID device with LIRC ===
 
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.
 
   
  +
{{hc|$ irdb-get find stream|
Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to {{ic|lircd.conf}}.
 
  +
atiusb/atiusb.lircd.conf
  +
digital_stream/DTX9900.lircd.conf
  +
snapstream/Firefly-Mini.lircd.conf
  +
streamzap/PC_Remote.lircd.conf
  +
streamzap/streamzap.lircd.conf
  +
x10/atiusb.lircd.conf
  +
}}
   
  +
{{hc|$ irdb-get download streamzap/streamzap.lircd.conf|
First we need the {{ic|/dev/input}} device for our remote:
 
  +
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf
  +
}}
   
  +
特定したら、必要な ''.conf'' を {{ic|/etc/lirc/lircd.conf.d/}} にコピーして、デーモンがそのサポートを初期化できるようにします。
$ ls /sys/class/rc/rc0
 
   
  +
# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/
One of the files should be input''#'', where the number matches the event''#'' of the device. (To clarify you can check that directory, it will have an event''#'' file.
 
   
  +
==== リモート設定の作成 ====
{{Note|If you have more than one ir device then there may be multiple directories under {{ic|/sys/class/rc}}. Under event''#'' {{ic|cat name}} to verify which device you are looking at.}}
 
   
  +
リモートコントロール設定は、ユーザーがプロセスをガイドする {{man|1|irrecord}} を使用して作成できます。検出されたリモートを使用する場合は、次のように呼び出します。
then go to {{ic|/dev/input/by-id}}
 
   
  +
# irrecord --device=/dev/lirc0 MyRemote
$ ls -l /dev/input/by-id
 
   
  +
プログラムはユーザーにリモコンのキーを押して学習するよう指示し、最終的にすべてのボタンとそれに対応するスキャンコードをマッピングします。完了したら、結果のファイルを {{ic|/etc/lirc/lircd.conf.d/foo.conf}} に保存します。設定ファイルを他の人と共有することを検討してください。
You should find a file that symlinks to the input''#'' above, and possibly others with a similar names for mouse events.
 
   
  +
=== アプリケーション固有のアクション ===
lrwxrwxrwx 1 root root 9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9
 
lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10
 
   
  +
{{Tip|多くのアプリケーション固有の lircrc ファイルがインターネット上で入手できます。}}
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.
 
  +
キーコードをアプリケーション固有のアクションにバインドするには、それぞれの設定ファイルを {{ic|~/.config/lircrc/}} に配置します。必要に応じて手動で作成する必要があります。{{man|5|lircrc}} を参照してください。これは、[[MPlayer]]、[[VLC]]、[[MythTV]]、{{Pkg|totem}} などの LIRC 対応アプリケーションでのみ機能します ([[Kodi]] も LIRC をサポートしていますが、非対応-標準的な方法、[[Kodi#リモートコントロールの使用]]を参照してください。
   
  +
これらのアプリケーション固有の設定を別のファイルで定義し、次のように ''lircrc'' に含めます。
Then, we need to edit {{ic|/etc/conf.d/lircd.conf}}. This file contains the parameters for LIRC daemon
 
 
#
 
#Parameters for daemon
 
#
 
 
LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"
 
LIRC_DRIVER="devinput"
 
LIRC_EXTRAOPS=""
 
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"
 
   
  +
include "~/.config/lircrc/mplayer"
{{Note|Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.}}
 
  +
include "~/.config/lircrc/mythtv"
  +
include "~/.config/lircrc/vlc"
   
  +
=== 通常のユーザーとして実行する ===
The latest version of the config file for HID remotes exists in the LIRC git repository [http://lirc.git.sourceforge.net/git/gitweb.cgi?p=lirc/lirc;a=blob_plain;f=remotes/devinput/lircd.conf.devinput;hb=HEAD]. Simply save it as {{ic|/etc/lirc/lircd.conf}}.
 
 
In order to launch the LIRC daemon for HID remote, You must enable evdev module first
 
# modprobe evdev
 
   
  +
デフォルトでは、''lircd'' は root として実行されます。安定性とセキュリティを向上させるために、アップストリームでは通常のユーザーとして実行することをお勧めします。[https://www.lirc.org/html/configuration-guide.html この]リンクにある付録 14 を参照してください。
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}
 
   
  +
==== lirc-user-service の AUR パッケージを使用する ====
===Serial receivers that depend on lirc_serial===
 
   
  +
すべてを自動的に行う {{AUR|lirc-user-service}} が提供されています。
Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.
 
   
  +
== テスト ==
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]
 
   
  +
{{ic|lircd.service}} を [[起動/有効化]] して下さい。
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:
 
   
  +
=== コマンドの受信 ===
options lirc_serial io=0x2f8 irq=3
 
   
  +
{{man|1|irw}} を実行し、リモコンを受信機に向けていくつかのボタンを押します。受信したコードは標準出力に出力されます。
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:
 
   
  +
{{hc|$ irw|
$ dmesg | grep ttyS
 
  +
000000037ff07bfe 00 One mceusb
  +
000000037ff07bfd 00 Two mceusb
  +
000000037ff07bfd 01 Two mceusb
  +
000000037ff07bf2 00 Home mceusb
  +
000000037ff07bf2 01 Home mceusb
  +
}}
   
  +
{{ic|irw}} が出力を返さない場合:
====Building the lirc_serial module for another ttySx====
 
   
  +
* ''mode2'' または ''xmode2'' を実行して、LIRC が実際に IR センサーから何かを読み取ったかどうかを確認します。読み取っていない場合は、ハードウェアを確認してください
Update abs
 
  +
* ''mode2'' がパルスデータを受信した場合は、{{ic|/etc/lirc/lircd.conf.d/}} の設定ファイルにエラーがないか確認してください。
   
  +
=== コマンドの送信 ===
# abs
 
   
  +
登録されているリモート (設定ファイル) をリストします。
Copy the LIRC files to a directory you choose yourself:
 
   
  +
{{hc|$ irsend LIST "" ""|
$ cp /var/abs/extra/system/lirc /some/dir
 
  +
LG_6710CMAP01A
  +
}}
   
  +
特定のデバイスで利用可能なコードをリストします:
$ cd /some/dir
 
   
  +
{{hc|$ irsend LIST LG_6710CMAP01A ""|
Edit the PKGBUILD in that directory.
 
  +
0000000000007887 KEY_POWER
  +
000000000000f807 KEY_MUTE
  +
000000000000e817 KEY_VOLUMEUP
  +
...
  +
}}
   
  +
検出されたデバイス {{ic|LG_6710CMAP01A}} を選択し、コマンド {{ic|KEY_POWER}} を送信します。
Replace the line:
 
   
  +
$ irsend SEND_ONCE LG_6710CMAP01A KEY_POWER
./configure --enable-sandboxed --prefix=/usr \
 
--with-driver=all \\
 
return 1[/code]
 
   
  +
==トラブルシューティング==
with:
 
   
  +
=== リモコンがキーボードとして機能する ===
./configure --enable-sandboxed --prefix=/usr \
 
--with-driver=com2 \
 
|| return 1[/code]
 
   
  +
==== Xorg を使用している場合 ====
Where you replace com2 with the com-port you need.
 
   
  +
Streamzap USB PC Remote など、リモコンによっては [[Xorg]] によって Human Interface Device (HID) と認識されるものがあり、物理キーボードからの入力のようにキーの一部または全てがキーストロークとして認識されます。この挙動は LIRC でデバイスを管理しようとしたときに問題になります。
Build and install the package:
 
   
  +
無効にするには、以下のファイルを作成して X を再起動してください:
$ makepkg
 
# pacman -U lirc-version.pkg.tar.gz
 
   
  +
{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|
====Loading====
 
  +
Section "InputClass"
  +
Identifier "Ignore Streamzap IR"
  +
MatchProduct "Streamzap"
  +
MatchIsKeyboard "true"
  +
Option "Ignore" "true"
  +
EndSection}}
   
  +
次のコマンドで得られる出力の {{ic|Name}} に合わせて {{ic|MatchProduct}} は適切に変更するようにしてください:
Now try to load the serial module:
 
   
  +
$ cat /proc/bus/input/devices | grep -e IR
# modprobe lirc_serial
 
   
  +
例えば {{ic|<nowiki>N: Name="cx88 IR (WinFast DTV2000 H rev."</nowiki>}} の場合 {{ic|WinFast}} にします。
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)
 
   
  +
==== Xorg を使用していない場合 ====
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)
 
   
  +
{{ic|/etc/modprobed.d/streamzap.conf}} を作成して問題を起こすモジュールをブラックリストに追加してください。例えば Streamzap のリモコンの場合:
You will have to release the serial port:
 
  +
install ir_sharp_decoder /bin/false
  +
install ir_xmp_decoder /bin/false
  +
install ir_rc5_decoder /bin/false
  +
install ir_nec_decoder /bin/false
  +
install ir_sony_decoder /bin/false
  +
install ir_mce_kbd_decoder /bin/false
  +
install ir_jvc_decoder /bin/false
  +
install ir_rc6_decoder /bin/false
  +
install ir_sanyo_decoder /bin/false
   
  +
=== デフォルト設定を変更する ===
# setserial /dev/ttySx uart none
 
   
  +
{{ic|irw}} で何も出力されない場合、{{ic|/etc/lirc/lirc_options.conf}} のデフォルト設定が原因である可能性があります (あるいはアップデートによって上書きされた可能性もあります)。
(Replace x with your port number)
 
   
  +
まず、{{ic|/dev/lirc0}} が存在するかどうか確認してください:
Load the module again:
 
   
  +
$ mode2 --driver default --device /dev/lirc0
# modprobe lirc_serial
 
   
  +
リモコンのボタンを押してみて何か出力されないか確認してください。出力がある場合、{{ic|/etc/lirc/lirc_options.conf}} を編集して ''driver'' と ''device'' を適当な値に変更してください。
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod
 
   
  +
何も出力されない場合、適切なドライバーとデバイスの組み合わせを探します。最初に lirc がデフォルトでどの組み合わせを認識しているのか確認します。{{Pkg|v4l-utils}} パッケージに含まれている {{ic|ir-keytable}} を実行して出力を確認してください。以下のように出力されます:
===Checking module based receivers===
 
   
  +
Found /sys/class/rc/rc0/ (/dev/input/event5) with:
''NOTE: This section only applies if your device requires a lirc_[driver] kernel module.''
 
  +
Driver ite-cir, table rc-rc6-mce
  +
Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
  +
Enabled protocols: lirc
  +
Extra capabilities: <access denied>
   
  +
上記の場合、lirc は {{ic|/dev/input/event5}} を赤外線デバイスとして自動的に認識して、{{ic|devinput}} ドライバーが使われています。以下のコマンドを実行することで組み合わせが正しいか確認します:
Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.
 
   
# mode2 -d /dev/lirc0
+
$ mode2 --driver devinput --device /dev/input/event5
   
  +
リモコンのボタンを押してみてください。何も出力されない場合、別のドライバーとデバイスの組み合わせを試してみてください。機能する組み合わせを発見したら、{{ic|/etc/lirc/lirc_options.conf}} の ''driver'' と ''device'' を変更してください。
If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.
 
   
  +
==== サンプル ====
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.
 
  +
  +
MCE RC6 互換レシーバの設定例:
  +
{{hc|/etc/lirc/lirc_options.conf|2=[lircd]
  +
nodaemon = False
  +
driver = default
  +
device = /dev/lirc0
  +
output = /var/run/lirc/lircd
  +
pidfile = /var/run/lirc/lircd.pid
  +
plugindir = /usr/lib/lirc/plugins
  +
permission = 666
  +
allow-simulate = No
  +
repeat-max = 600
  +
  +
[lircmd]
  +
uinput = False
  +
nodaemon = False
  +
}}
   
 
== 参照 ==
 
== 参照 ==
   
  +
* [http://lirc.sourceforge.net/lirc.org/html/index.html 開発元のドキュメント]
  +
* [http://lirc-remotes.sourceforge.net/remotes-table.html リモコンデータベース]
  +
* [http://sf.net/p/lirc プロジェクトサイト]
  +
* [http://lirc.org/html/configuration-guide.html 開発元の設定ガイド]
 
* [http://www.mythtv.org/wiki/Category:Remote_Controls MythTV Wiki:Remotes article]
 
* [http://www.mythtv.org/wiki/Category:Remote_Controls MythTV Wiki:Remotes article]
* [http://lirc.org/html/table.html サポートしているハードウェアの公式リスト]
+
* [http://lirc-remotes.sourceforge.net/remotes-table.html サポートしているハードウェアの公式リスト]
  +
* [https://github.com/graysky2/streamzap Linux Streamzap config files]

2024年2月26日 (月) 00:38時点における最新版

official website から:

LIRC (Linux 赤外線リモコン) は、一般的に使用される多くの (すべてではない) リモコンの赤外線信号をデコードして送信するパッケージです。
ノート: 4.18 以降、カーネルは BPF を使用して一部の IR リモコンの信号をデコードできるため、LIRC が重複する場合があります。[1]

この記事ではシリアル・USB 赤外線デバイスを使って LIRC "Linux Infrared Remote Control" を設定・使用する方法を説明しています。

LIRC はサポートしているリモコンのキーが押されたときにプログラムにあわせて特定のコマンドに変換することができるデーモンです。ここで、「プログラムにあわせて」とは同じキーでも実行しているプログラムによって異なる動作をさせることができることを意味します。LIRC から取得されたリモコンの情報は以下のようにプログラムに流れます:

  1. ユーザーがリモコンのボタンを押すことで IR または RF 信号が送信されます。
  2. Linux パソコンに接続されたレシーバーによって信号が受信されます。
  3. カーネル (のモジュール) によってリモコンから送信されたパルス信号が /dev/lirc0, /dev/input/eventX, /dev/ttyUSBX, /dev/ttyS0 などのデバイスに変換されます。
  4. /usr/bin/lircd/etc/lirc/lircd.conf.d/foo.conf の情報を使ってパルス信号をボタンの押下情報に変換します。
  5. LIRC を使用するプログラムは ~/.lircrc に書かれている情報に従って /usr/bin/lircd のボタン押下情報をユーザーが定義した操作に解釈します。

インストール

lirc パッケージをインストールしてください。

設定

受信機と送信機の設定

ノート: このセクションは簡単な概要です。完全なドキュメントが利用可能です upstream

適切に実行するには、LIRC サービスの ドライバー および/または デバイス を指定する必要がある場合があります。irrecord などの LIRC 依存プログラムの実行中にサービスが突然停止した場合は、journalctl 出力で次のようなメッセージを探してください。

Driver `devinput' not found or not loadable (wrong or missing -U/--plugindir?).
readlink() failed for "auto": No such file or directory

これらを設定ファイルに設定し、サービスを再起動します。

/etc/lirc/lirc_options.conf
[lircd]
driver = driver-name
device = /dev/path-to-dev

シリアルポート

ヒント: DIY 回路図については、シリアルポート 受信機 および 送信機 のドキュメントを参照してください。シリアルポートデバイスは、audio_alsaaudio よりもはるかに信頼性が高いことに注意してください。

最新のカーネルには、古い lirc_serial ドライバーに代わる serial_ir モジュールがあります。マザーボードのシリアルポートに接続された DIY 受信機および送信機もサポートします。setserialAUR をインストールして実行します:

# setserial /dev/ttyS0 uart none
# modprobe serial_ir

serial_ir モジュールをロードすると、デバイス /dev/lirc0 が、カーネルによって created になります。そうでない場合は、ジャーナル で関連するエラーがないか確認してください。シリアルデバイスの LIRC 設定例:

/etc/lirc/lirc_options.conf
[lircd]
driver          = default
device          = auto

[modinit]
code = /usr/bin/setserial /dev/ttyS0 uart none
code1 = /usr/sbin/modprobe serial_ir

サウンドカード

ノート: サウンドカードを赤外線デバイスとして使用すると、多くの落とし穴があり、他のハードウェア設定よりも利点が得られません。

外部 DIY 回路が接続されたサウンドカードは、受信 および IR コードを 送受信 できます。

audio_alsa driverlirc に含まれていますが、受信のみをサポートしています。

alsamixer でマイク入力のミュートを解除し、十分なゲインを設定します。audacity で波形とゲインを確認できます。区別できる方形パルスが存在する必要があります。平坦でも過負荷でもありません。また、良好に復調されたパルスは耳で簡単に認識できます。LIRC と irrecord右オーディオチャネルの正のパルス を読み取ることに注意してください。負のパルスは機能しません。

/etc/lirc/lirc_options.conf
driver          = audio_alsa
device          = default

lirc-gitAUR に含まれる audio driver が受信と送信の両方をサポートします。デフォルトの遅延が 0.02 程度であると、"Warning: Output underflow" が発生し、送信が破損する可能性があることに注意してください。受信機はそれに応答しません。0.05 などのより高い値を試してください。

サウンドカードの出力音量を上げて下さい。そうしないと、LED 信号が弱く、範囲が狭くなります。LEDフラッシュは赤外線の波長に敏感であるため、スマートフォンのカメラで検出できます。

/etc/lirc/lirc_options.conf
driver          = audio
device          = ALSA:default@48000:0.05

リモート設定

ディレクトリ /etc/lirc/lircd.conf.d/ には、リモートのシステム全体の設定ファイルが含まれています。各 *.conf ファイルは 1 つのデバイスに対応し、そのプロトコル、スキャンコード、キーコードが記述されています。これにより、LIRC が特定のハードウェアに対して信号を送受信できるようになります。これらのファイルは lirc パッケージには含まれていないため、ユーザーが作成する必要があります。

リモート設定の検索

多くの設定ファイルは LIRC リモートデータベース にあります。URL に従うか、irdb-get(1) を使用してデータベースを検索します。

irdb-get を使用して "Streamzap" リモートの設定ファイルを検索する例:

$ irdb-get find stream
atiusb/atiusb.lircd.conf
digital_stream/DTX9900.lircd.conf
snapstream/Firefly-Mini.lircd.conf
streamzap/PC_Remote.lircd.conf
streamzap/streamzap.lircd.conf
x10/atiusb.lircd.conf
$ irdb-get download streamzap/streamzap.lircd.conf
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf

特定したら、必要な .conf/etc/lirc/lircd.conf.d/ にコピーして、デーモンがそのサポートを初期化できるようにします。

# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/

リモート設定の作成

リモートコントロール設定は、ユーザーがプロセスをガイドする irrecord(1) を使用して作成できます。検出されたリモートを使用する場合は、次のように呼び出します。

# irrecord --device=/dev/lirc0 MyRemote

プログラムはユーザーにリモコンのキーを押して学習するよう指示し、最終的にすべてのボタンとそれに対応するスキャンコードをマッピングします。完了したら、結果のファイルを /etc/lirc/lircd.conf.d/foo.conf に保存します。設定ファイルを他の人と共有することを検討してください。

アプリケーション固有のアクション

ヒント: 多くのアプリケーション固有の lircrc ファイルがインターネット上で入手できます。

キーコードをアプリケーション固有のアクションにバインドするには、それぞれの設定ファイルを ~/.config/lircrc/ に配置します。必要に応じて手動で作成する必要があります。lircrc(5) を参照してください。これは、MPlayerVLCMythTVtotem などの LIRC 対応アプリケーションでのみ機能します (Kodi も LIRC をサポートしていますが、非対応-標準的な方法、Kodi#リモートコントロールの使用を参照してください。

これらのアプリケーション固有の設定を別のファイルで定義し、次のように lircrc に含めます。

include "~/.config/lircrc/mplayer"
include "~/.config/lircrc/mythtv"
include "~/.config/lircrc/vlc"

通常のユーザーとして実行する

デフォルトでは、lircd は root として実行されます。安定性とセキュリティを向上させるために、アップストリームでは通常のユーザーとして実行することをお勧めします。このリンクにある付録 14 を参照してください。

lirc-user-service の AUR パッケージを使用する

すべてを自動的に行う lirc-user-serviceAUR が提供されています。

テスト

lircd.service起動/有効化 して下さい。

コマンドの受信

irw(1) を実行し、リモコンを受信機に向けていくつかのボタンを押します。受信したコードは標準出力に出力されます。

$ irw
000000037ff07bfe 00 One mceusb
000000037ff07bfd 00 Two mceusb
000000037ff07bfd 01 Two mceusb
000000037ff07bf2 00 Home mceusb
000000037ff07bf2 01 Home mceusb

irw が出力を返さない場合:

  • mode2 または xmode2 を実行して、LIRC が実際に IR センサーから何かを読み取ったかどうかを確認します。読み取っていない場合は、ハードウェアを確認してください
  • mode2 がパルスデータを受信した場合は、/etc/lirc/lircd.conf.d/ の設定ファイルにエラーがないか確認してください。

コマンドの送信

登録されているリモート (設定ファイル) をリストします。

$ irsend LIST "" ""
LG_6710CMAP01A

特定のデバイスで利用可能なコードをリストします:

$ irsend LIST LG_6710CMAP01A ""
0000000000007887 KEY_POWER
000000000000f807 KEY_MUTE
000000000000e817 KEY_VOLUMEUP
...

検出されたデバイス LG_6710CMAP01A を選択し、コマンド KEY_POWER を送信します。

$ irsend SEND_ONCE LG_6710CMAP01A KEY_POWER

トラブルシューティング

リモコンがキーボードとして機能する

Xorg を使用している場合

Streamzap USB PC Remote など、リモコンによっては Xorg によって Human Interface Device (HID) と認識されるものがあり、物理キーボードからの入力のようにキーの一部または全てがキーストロークとして認識されます。この挙動は LIRC でデバイスを管理しようとしたときに問題になります。

無効にするには、以下のファイルを作成して X を再起動してください:

/etc/X11/xorg.conf.d/90-streamzap.conf
Section "InputClass"
  Identifier "Ignore Streamzap IR"
  MatchProduct "Streamzap"
  MatchIsKeyboard "true"
  Option "Ignore" "true"
EndSection

次のコマンドで得られる出力の Name に合わせて MatchProduct は適切に変更するようにしてください:

$ cat /proc/bus/input/devices | grep -e IR

例えば N: Name="cx88 IR (WinFast DTV2000 H rev." の場合 WinFast にします。

Xorg を使用していない場合

/etc/modprobed.d/streamzap.conf を作成して問題を起こすモジュールをブラックリストに追加してください。例えば Streamzap のリモコンの場合:

install ir_sharp_decoder /bin/false
install ir_xmp_decoder /bin/false
install ir_rc5_decoder /bin/false
install ir_nec_decoder /bin/false
install ir_sony_decoder /bin/false
install ir_mce_kbd_decoder /bin/false
install ir_jvc_decoder /bin/false
install ir_rc6_decoder /bin/false
install ir_sanyo_decoder /bin/false

デフォルト設定を変更する

irw で何も出力されない場合、/etc/lirc/lirc_options.conf のデフォルト設定が原因である可能性があります (あるいはアップデートによって上書きされた可能性もあります)。

まず、/dev/lirc0 が存在するかどうか確認してください:

$ mode2 --driver default --device /dev/lirc0

リモコンのボタンを押してみて何か出力されないか確認してください。出力がある場合、/etc/lirc/lirc_options.conf を編集して driverdevice を適当な値に変更してください。

何も出力されない場合、適切なドライバーとデバイスの組み合わせを探します。最初に lirc がデフォルトでどの組み合わせを認識しているのか確認します。v4l-utils パッケージに含まれている ir-keytable を実行して出力を確認してください。以下のように出力されます:

Found /sys/class/rc/rc0/ (/dev/input/event5) with:
      Driver ite-cir, table rc-rc6-mce
      Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
      Enabled protocols: lirc
      Extra capabilities: <access denied>

上記の場合、lirc は /dev/input/event5 を赤外線デバイスとして自動的に認識して、devinput ドライバーが使われています。以下のコマンドを実行することで組み合わせが正しいか確認します:

$ mode2 --driver devinput --device /dev/input/event5

リモコンのボタンを押してみてください。何も出力されない場合、別のドライバーとデバイスの組み合わせを試してみてください。機能する組み合わせを発見したら、/etc/lirc/lirc_options.confdriverdevice を変更してください。

サンプル

MCE RC6 互換レシーバの設定例:

/etc/lirc/lirc_options.conf
[lircd]
nodaemon        = False
driver          = default
device          = /dev/lirc0
output          = /var/run/lirc/lircd
pidfile         = /var/run/lirc/lircd.pid
plugindir       = /usr/lib/lirc/plugins
permission      = 666
allow-simulate  = No
repeat-max      = 600

[lircmd]
uinput          = False
nodaemon        = False

参照