Aquos LC-45W5 をパケットで制御

Debian bashから

検索で、”LC-45W5″とかのキーワードですぐに見つかりますが、

ここの”取扱説明書”->”同意”->”取扱説明書 付録”を眺めるに、

に続いて、具体的なコマンドは、

等の記述がありますので、ネットからコマンドをパケットに載せて送ることで、電源のon/offや入力切り替えができそうです。Aquos側で、IPアドレスや受け付けるポート番号Aquos connectの許可等の設定は必要です。まずはbashから試してみましょう。具体的に使うコマンドは”nc”です。あんまりなじみはないですかね。man ncすると、

NC(1)                                             BSD General Commands Manual                                             NC(1)

NAME
     nc ― arbitrary TCP and UDP connections and listens

SYNOPSIS
     nc [-46bCDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl] [-m minttl] [-O length] [-P proxy_username] [-p source_port]
        [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout] [-X proxy_protocol]
        [-x proxy_address[:port]] [destination] [port]

DESCRIPTION
     The nc (or netcat) utility is used for just about anything under the sun involving TCP, UDP, or UNIX-domain sockets.  It
     can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both
     IPv4 and IPv6.  Unlike telnet(1), nc scripts nicely, and separates error messages onto standard error instead of sending
     them to standard output, as telnet(1) does with some.

     Common uses include:

           ~   simple TCP proxies
           ~   shell-script based HTTP clients and servers
           ~   network daemon testing
           ~   a SOCKS or HTTP ProxyCommand for ssh(1)
           ~   and much, much more

環境はRaspberry Pi Zero上なので、正確にはRaspbianです。ほぼDebianですけど、上記にあるように、netcat network版の cat(concatnate)的に使うもののようです。これが一応使えます。スクリプト本体は、aq2.shで、

#!/bin/bash
source /home/pi/ir/settvip
nc -q 5 $TVIP 10002 << EOF > /dev/null
POWR1
EOF
/home/pi/ir/settvipは
#!/bin/bash
export TVIP=192.168.0.211

紛らわしいのは、送っている文字列は、“POWR1 “であって、“POWR1”ではありません。空白はinvisibleなので、od -cしましょうかね?

pi@raspberrypi:~/ir $ od -c aq2.sh
0000000   #   !   /   b   i   n   /   b   a   s   h  \n   s   o   u   r
0000020   c   e       /   h   o   m   e   /   p   i   /   i   r   /   s
0000040   e   t   t   v   i   p  \n   n   c       -   C       -   q
0000060   5       $   T   V   I   P       1   0   0   0   2       <   <
0000100       E   O   F       >       /   d   e   v   /   n   u   l   l
0000120  \n   P   O   W   R   1              \n   E   O   F  \n
0000136

POWR1に続いて、空白が3個続いているのが見えますね。これが電源オンです。電源オフしたければ、POWR0ですね。実はPOWR1は”類推”によって見つけました。

さてわざわざloginしてからスクリプトを起動するというのはいかにも面倒なので、目の前のiPhoneでスクリプトを動かしたいですよね。それはiosのショートカットを使えばできます。実際筆者は他のスクリプトで使っています。

ここで書いたショートカットを使います。

コメント