Thanks Driven Life

日々是感謝

赤外線学習リモコン PC-OP-RS1 を使ってみた

ノリで買いました。

PC-OP-RS1

玄人志向からでてる KURO-RS もあったんですが、
こっちの方が値段が安いってのと、中身も同じっぽかったので。



GuruPlug の Kernel は 下記な感じです。

# uname -a
Linux sheevaplug-debian 2.6.35.7 #5 PREEMPT Sat Oct 2 17:08:29 MDT 2010 armv5tel GNU/Linux

まずは GuruPlug につないでみる。

Oct 12 19:58:02 sheevaplug-debian kernel: usb 1-1.2: new full speed USB device using orion-ehci and address 4

認識してない。まあ予想通り。
かき集めた情報により、以下を実行する
vendor や product は PC-OP-RS1 に沿ってます。

# modprobe -r ftdi_sio
# modprobe ftdi_sio vendor=0x0411 product=0x00b3

PC-OP-RS1 を抜き差し

Oct 12 20:03:03 sheevaplug-debian kernel: usb 1-1.2: USB disconnect, address 4
Oct 12 20:03:03 sheevaplug-debian kernel: ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
Oct 12 20:03:03 sheevaplug-debian kernel: ftdi_sio 1-1.2:1.0: device disconnected
Oct 12 20:03:04 sheevaplug-debian kernel: usb 1-1.2: new full speed USB device using orion-ehci and address 5
Oct 12 20:03:04 sheevaplug-debian kernel: ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: Detected FT232BM
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: Number of endpoints 2
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: Endpoint 1 MaxPacketSize 64
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: Endpoint 2 MaxPacketSize 64
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: Setting MaxPacketSize 64
Oct 12 20:03:05 sheevaplug-debian kernel: usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0

認識しました。おめでとうございます。



てなわけでさっそく学習してみましょう。
学習スクリプトhttp://sites.google.com/site/tflaaa/files にある
rc_rec、rc_send を使わせていただきました。


コンパイル

# gcc rc_rec.c -o rc_rec
# gcc rc_send.c -o rc_send

おk


今回学習するのはこれ

IMG_0446.JPG

赤外線リモコンコンセントですね。
本当はクーラーとかやりたかったんですけど、
学習できる限界以上のデータ量(240byte)が必要っぽいので残念ながら。


そんなわけで実行。

# ./rc_rev test.data /dev/ttyUSB0
test OK
init OK
rec start

この間赤外線待ちなので、リモコンの ON を PC-OP-RS1 の受信部に向けて発射。
学習データは test.data に記録されます。
データを撮り終わったら

res = 89
res = 114
res = 38
res = 1
rec OK

こんな感じに表示されて終了します。
res は毎回違います。合計で 242 とると思います。


今度は今作った test.data を送信に使ってみましょう

# ./rc_send test.data 1 /dev/ttyUSB0

「1」はチャンネル番号。1だと、A ポートの黄色いシールが貼られてるやつです。
実行すると、リモコンコンセントが通常の動作通り「カチッ」と音がして
そこにつながれてる扇風機が起動しました。やったね!!


もっと面白いことしたいですね。
HTTP 経由でクーラー起動とかできたらよかったんですが残念。
まあいろいろあるでしょう。