玄柴のセットアップ(2)リモコンで照明制御

KURO-RS 玄柴(KURO-SHEEVA)

オープンソースカンファレンス 2010 Kansai @ Kyoto の展示のためのセットアップを進める。

今回は、 KURO-RS の送受信プログラムと、 オーム社の「赤外線リモコンコンセント OCR-05」 のリモコンデータを準備して、照明!を制御する。

SheevaPlug の時は、一から準備したが、今回は手を抜いて SheevaPlug からコピーする(藁

SheevaPlug でアーカイブ

root@debian:~# cd /usr/lib/cgi-bin/
root@debian:/usr/lib/cgi-bin# ls
BUTTON_OFF  BUTTON_ON  common  off  on  rs_send  webcam  webcamrc
root@debian:/usr/lib/cgi-bin# tar zcvf /tmp/cgi-bin.tar.gz *
BUTTON_OFF
BUTTON_ON
common
off
on
rs_send
webcam
webcamrc
root@debian:/usr/lib/cgi-bin#

ftp で転送

家庭内のファイルサーバに一旦転送する。
root@debian:/usr/lib/cgi-bin# ftp sil
Connected to sil.yamasita.jp.
220 sil FTP server (GNU inetutils 1.5) ready.
Name (sil:root): yasunari
331 Password required for yasunari.
Password:
230- Linux sil 2.6.16.16-arm1 #6 Fri Aug 31 13:07:15 JST 2007 armv5tejl
230-
230- The programs included with the Debian GNU/Linux system are free software;
230- the exact distribution terms for each program are described in the
230- individual files in /usr/share/doc/*/copyright.
230-
230- Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
230- permitted by applicable law.
230 User yasunari logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /tmp
250 CWD command successful.
ftp> bin
200 Type set to I.
ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> put /tmp/cgi-bin.tar.gz
local: /tmp/cgi-bin.tar.gz remote: /tmp/cgi-bin.tar.gz
200 PORT command sucessful.
150 Opening BINARY mode data connection for '/tmp/cgi-bin.tar.gz'.
##############################
226 Transfer complete.
31082 bytes sent in 0.00 secs (26212.0 kB/s)
ftp> bye
221 Goodbye.
root@debian:/usr/lib/cgi-bin#

ftp のインストール

玄柴で ftp しようとしたら
root@debian:/tmp# ftp sil
-bash: ftp: command not found
root@debian:/tmp#
となったので、ftp をインストールする。
こんなの、デフォルトで入れといてよ
root@debian:/tmp# apt-get install ftp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libx11-data libxcb1 libxau6 libxdmcp6 libxcb-xlib0 libx11-6
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
  ftp
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 56.3kB of archives.
After this operation, 168kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com jaunty/main ftp 0.17-18 [56.3kB]
Fetched 56.3kB in 2s (19.6kB/s)
Selecting previously deselected package ftp.
(Reading database ... 13457 files and directories currently installed.)
Unpacking ftp (from .../archives/ftp_0.17-18_armel.deb) ...
Setting up ftp (0.17-18) ...

root@debian:/tmp#

アーカイブの取得、展開

SheevaPlug で作成して、家庭内サーバに置いておいた アーカイブを取得する
root@debian:/tmp# ftp sil
Connected to sil.yamasita.jp.
220 sil FTP server (GNU inetutils 1.5) ready.
Name (sil:root): yasunari
331 Password required for yasunari.
Password:
230- Linux sil 2.6.16.16-arm1 #6 Fri Aug 31 13:07:15 JST 2007 armv5tejl
230-
230- The programs included with the Debian GNU/Linux system are free software;
230- the exact distribution terms for each program are described in the
230- individual files in /usr/share/doc/*/copyright.
230-
230- Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
230- permitted by applicable law.
230 User yasunari logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /tmp
250 CWD command successful.
ftp> ls
200 PORT command sucessful.
150 Opening ASCII mode data connection for '/bin/ls'.
bitotal 68
drwxrwxrwt 2 root         6 Jun 27 04:46 .ICE-unix
drwxrwxrwt 2 root         6 Jun 27 04:46 .X11-unix
-rw-r----- 1 yamasita 31082 Jun 27 22:38 cgi-bin.tar.gz
-rw-r--r-- 1 root     15768 Jun 27 22:45 fancontrol
-rw-r--r-- 1 root     18784 Jun 27 06:31 hackdemaruroku.log
226 Transfer complete.
ftp> bin
200 Type set to I.
ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> get cgi-bin.tar.gz
local: cgi-bin.tar.gz remote: cgi-bin.tar.gz
200 PORT command sucessful.
150 Opening BINARY mode data connection for 'cgi-bin.tar.gz' (31082 bytes).
##############################
226 Transfer complete.
31082 bytes received in 0.04 secs (691.0 kB/s)
ftp> bye
221 Goodbye.
root@debian:/tmp#

展開する

root@debian:/tmp# cd /usr/lib/cgi-bin/
root@debian:/usr/lib/cgi-bin# ls
root@debian:/usr/lib/cgi-bin# tar zxvf /tmp/cgi-bin.tar.gz
BUTTON_OFF
BUTTON_ON
common
off
on
rs_send
webcam
webcamrc
root@debian:/usr/lib/cgi-bin# ls -l
total 69
-rw-r--r-- 1 root root   240 Mar  3 23:22 BUTTON_OFF
-rw-r--r-- 1 root root   240 Mar  3 23:22 BUTTON_ON
-rwxr-xr-x 1 root root   400 Mar 13 12:35 common
-rwxr-xr-x 1 root root    91 Mar  6 15:19 off
-rwxr-xr-x 1 root root    90 Mar  6 15:19 on
-rwsr-sr-x 1 root root 10045 Mar  3 23:22 rs_send
-rwsr-sr-x 1 root root 56872 Mar  6 14:37 webcam
-rw-r--r-- 1 root root    50 Mar  3 23:57 webcamrc
root@debian:/usr/lib/cgi-bin#

動作確認

オーム社の「赤外線リモコンコンセント OCR-05」 をコンセントに刺し準備、
KURO-RS を玄柴に刺して、
root@debian:/usr/lib/cgi-bin# tail -f /var/log/messages
Jun 27 22:41:48 debian kernel: Freeing init memory: 140K
Jun 27 22:41:48 debian kernel: NET: Registered protocol family 10
Jun 27 22:41:48 debian kernel: device-mapper: ioctl: 4.17.0-ioctl (2010-03-05) initialised: dm-devel@redhat.com
Jun 27 22:41:54 debian kernel: usbcore: registered new interface driver usbserial
Jun 27 22:41:54 debian kernel: USB Serial support registered for generic
Jun 27 22:41:54 debian kernel: usbcore: registered new interface driver usbserial_generic
Jun 27 22:41:54 debian kernel: usbserial: USB Serial Driver core
Jun 27 22:41:54 debian kernel: USB Serial support registered for FTDI USB Serial Device
Jun 27 22:41:54 debian kernel: usbcore: registered new interface driver ftdi_sio
Jun 27 22:41:54 debian kernel: ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver


Jun 27 22:47:42 debian kernel: usb 1-1: new full speed USB device using orion-ehci and address 2
Jun 27 22:47:42 debian kernel: ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
Jun 27 22:47:42 debian kernel: usb 1-1: Detected FT232BM
Jun 27 22:47:42 debian kernel: usb 1-1: Number of endpoints 2
Jun 27 22:47:42 debian kernel: usb 1-1: Endpoint 1 MaxPacketSize 64
Jun 27 22:47:42 debian kernel: usb 1-1: Endpoint 2 MaxPacketSize 64
Jun 27 22:47:42 debian kernel: usb 1-1: Setting MaxPacketSize 64
Jun 27 22:47:42 debian kernel: usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0

ON にしてみる
root@debian:/usr/lib/cgi-bin# ./rs_send BUTTON_ON 1 /dev/ttyUSB0
BUTTON_ON - 1 - /dev/ttyUSB0
Send File : [BUTTON_ON]
root@debian:/usr/lib/cgi-bin#
オーム社の「赤外線リモコンコンセント OCR-05」 が「かちっ」という。

OFF にしてみる。

root@debian:/usr/lib/cgi-bin# ./rs_send BUTTON_OFF 1 /dev/ttyUSB0
BUTTON_OFF - 1 - /dev/ttyUSB0
Send File : [BUTTON_OFF]
root@debian:/usr/lib/cgi-bin#
OCR-05 が「ぽこっ」という

念のため、 USB-AC チャージャ経由で USB 10 LED LIGHT を接続して、ON/OFF を確認。OK

でも、これだと(良く見えないですが) オープンソースカンファレンス 2009 Kansai @ Kobe の時と同じで面白くないなぁ、、、



KURO-SHEEVA
楽天市場
KURO-RS
バッファローダイレクト
楽天市場
Amazon

←(前のページ)
玄柴のセットアップ(1)KURO-RS の認識
当月のハックの記録
SheevaPlug/玄柴(KURO-SHEEVA)をハックしよう トップ
(次のページ)→
今年の OSC Kansai @ kyoto は、玄柴で空調をリモート制御

Copyright (C) 2003-2010 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市