えっと、
配線を間違えたせいで、赤外線受信モジュールが壊れました。
まぁ、もう一個あったので、そちらに交換しましたが。
そして、もう一つ、
前回のやり方だと、TVが反応してくれるコマンドもあれば、反応してくれないコマンドもありました。
むしろ、反応してくれないコマンドの方が多い。
なので、やり方を変えます。
こちらの記事を参考にしました。
https://qiita.com/amaebi-tabetai/items/211b9c6f751c96ff1fd7
irrecordというコマンドを使用して、赤外線のデータを何回か入力させて、正しい信号に直してくれることができるみたいです。
irrecord --disable-namespace -f -d /dev/lirc1 --driver default ~/lircd.conf
受信機をlirc1にしているので、こちらを使用します。
pi@raspberrypi:~ $ irrecord --disable-namespace -f -d /dev/lirc1 --driver default ~/lircd.
conf
Using raw access on device /dev/lirc1
irrecord - application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)
This program will record the signals from your remote control
and create a config file for lircd.
A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION at https://sf.net/p/lirc-remotes/wiki
If there already is a remote control of the same brand available at
http://sf.net/p/lirc-remotes you might want to try using such a
remote as a template. The config files already contains all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available. Templates can be downloaded using irdb-get(1). You use a
template file by providing the path of the file as a command line
parameter.
Please take the time to finish the file as described in
https://sourceforge.net/p/lirc-remotes/wiki/Checklist/ an send it
to <lirc@bartelmus.de> so it can be made available to others.
Press RETURN to continue.
Checking for ambient light creating too much disturbances.
Please don't press any buttons, just wait a few seconds...
No significant noise (received 0 bytes)
Enter name of remote (only ascii, no spaces) :
Enter name of remote (only ascii, no spaces) :tv
Using tv.lircd.conf as output filename
Now start pressing buttons on your remote control.
It is very important that you press many different buttons randomly
and hold them down for approximately one second. Each button should
generate at least one dot but never more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have
been generated.
Press RETURN now to start recording.
................................................................................
Please enter the name for the next button (press <ENTER> to finish recording)
channel1
Now hold down button "channel1".
Timeout (10 seconds), try again (29 retries left).
Now hold down button "channel1".
Please enter the name for the next button (press <ENTER> to finish recording)
Successfully written config file tv.lircd.conf
Press RETURN now to start recording.のところで、学習するボタンをひたすら押し続ける。
それが終われば、コマンド名に名前をつけて終了。
作成されたconfファイルには、こんな感じになっていました。
begin raw_codes
name channel1
9082 4465 624 508 619 514
621 514 622 515 621 515
596 541 621 1645 596 541
640 1636 588 1671 621 1645
595 1671 596 1683 585 1671
594 543 564 1703 566 1703
593 548 560 571 565 573
563 571 564 572 564 572
564 572 563 572 563 1708
567 1696 564 1702 564 1708
560 1702 576 1692 565 1700
565
end raw_codes
これを、前回と同じように/etc/lirc/lircd.conf.d/tv.confに記入して、lircdを再起動。
これで、コマンドが動くことを確認しました。
こっちのやり方の方が確実かもしれない。