Smart Home Automation with Linux- P3
Số trang: 30
Loại file: pdf
Dung lượng: 838.41 KB
Lượt xem: 19
Lượt tải: 0
Xem trước 3 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Smart Home Automation with Linux- P3:For every word I’ve written, five have been discarded. Such is the nature of writing. For every tenprograms I’ve downloaded, tried, and tested, nine have been discarded. Such is the nature of software.Finding a perspicuous overlap has been a long and arduous tasks, and one that I’d wish for no one tosuffer in solitude.
Nội dung trích xuất từ tài liệu:
Smart Home Automation with Linux- P3 CHAPTER 1 ■ APPLIANCE CONTROL■ Note You may need an IR bypass kit when passing IR signals over coax cables because the messages getmuddled when passing through distribution amplifiers.IR-RF-IR GatewaysThese devices relay IR data through the air, at the 433MHz radio frequency used by so much wirelessequipment, before being replayed. For these devices, you have a choice between IR-only transmissionsand TV senders. An IR-only transmitter, such as the Powermid XL, is the simplest of these devices and will allow youto remotely control devices without installing cables or sockets. They are fairly cheap but pass only IRdata, so the controlled device must be able to have an impact on you when you’re in another room. TV senders are the wireless versions of the over-the-aerial cables or old TV distribution systems,which involved an aerial amplifier and a separate aerial cable into each TV in the house. The TV sendertakes a single input and transmits it to whichever receivers are listening, encoding whatever IR signals italso saw. There are many variants on the market, including those with SCART sockets (instead of the old-school coaxial aerial sockets) and RCA composite video. Even the cheaper models often have a“channel” switch on them, allowing multiple receiver-transmitter pairs to be used in the same housewithout the signals getting mixed up. And with these devices becoming more mainstream, some arealmost as cheap as an IR-only transmitter, with the TV functionality becoming a free bonus feature.IR Over IPIt is also possible to send data over your existing Ethernet cables, using devices such as the Keene IRAnywhere over IP (KIRA). This eliminates any distance or interference issues you might get from theother methods and also provides a way of remotely controlling IR devices from a computer, withoutneeding to have the computer and its IR transmitter physically in range of the device. Being IP-controlled also means that IR signals can be sent via the Internet. Although this is pointlessin itself (because you can’t derive any benefit from changing the TV channel when you’re not sittingwatching it), it does provide an off-the-shelf way of controlling IR-based devices from a remotecomputer. And if something can be controlled from a computer, then it can be controlled from anythingconnected to the computer, such as a web page or cron job. Using KIRA to retransmit IR codes first requires that you teach it those codes in the first place. Thisis done by generating text files, using the software shown in Figure 1-15. 43 CHAPTER 1 ■ APPLIANCE CONTROL Figure 1-15. Configuring KIRA 15 This software is available from the Keene web site and has been thoughtfully written in Java, making it Linux-friendly. After attaching KIRA to your network and after it’s used your DHCP server to provide it with an IP address, you can add new commands. First you request that all the IR messages are 15 See www.keene.co.uk/electronics/multi.php?mycode=KIRA.44 CHAPTER 1 ■ APPLIANCE CONTROLsent to this machine, and then you press Learn before hitting the first key on your remote. This shouldpresent the code, such as the following, which can then be copied and pasted into a text file for later use:K 240C 037F 0369 03AC 034D 0624 035A 0378 0382 0378 0381 0396 0366 03770382 0396 0365 0396 06E0 03AF 034C 072C 0353 0378 2000 I have used a directory hierarchy for each device so that the on/off button for my TV is in thedirectory ir/tv/codes/on. Since the same button performs both functions, I created a symlink betweenoff and on. Those with bigger houses and more TVs might like to use a more descriptive name than TV. Although KIRA has a web page, it isn’t very configurable and limits you to four prestored IR codes.Fortunately, it also listens for commands sent on UDP ports 30303 and 65432. The former is for devicediscovery and configuration, so consequently the port cannot be changed. The latter is the IR controlport, which processes all the basic commands to control the various IR devices within range. Allresponses to these commands are returned by UDP also, so you need to run two instances of the SwissArmy knife of network utility, netcat, to handle it. Begin by creating two terminal windows, and start a UDP server in one of them by typing thefollowing:nc -u -l -p 30303 This will now listen on port 30303 for any UDP messages sent to it. Now, in the other window, send amessage to KIRA (whose IP has been determined as 192.168.1.111 by the DHCP server) on the same port.echo disD | nc -q 0 -u 192.168.1.111 30303 You should see the other window spring to life and report various stats about the device. If not,check that the ports are open and working with (that other Swiss Army knife of networking) netstat:netstat -ntpl With some averagely clever bash coding, you can achieve the same result with a script such as thefollowing:#!/bin/bashTEMPFILE=`mktemp`nc -u -l -p 30303 >$TEMPFILE &PROCESS=$!echo disD | nc -q 0 -u 192.168.1.111 30303# Wait for a second so the output has finished writingsleep 1kill $PROCESScat $TEMPFILErm $TEMPFILE 45 CHAPTER 1 ■ APPLIANCE CONTROL The process for sending IR messages is the same, except you need to switch onto the IR port. Here’s an example: cat ir/codes/tv/off | nc -q 0 -u ...
Nội dung trích xuất từ tài liệu:
Smart Home Automation with Linux- P3 CHAPTER 1 ■ APPLIANCE CONTROL■ Note You may need an IR bypass kit when passing IR signals over coax cables because the messages getmuddled when passing through distribution amplifiers.IR-RF-IR GatewaysThese devices relay IR data through the air, at the 433MHz radio frequency used by so much wirelessequipment, before being replayed. For these devices, you have a choice between IR-only transmissionsand TV senders. An IR-only transmitter, such as the Powermid XL, is the simplest of these devices and will allow youto remotely control devices without installing cables or sockets. They are fairly cheap but pass only IRdata, so the controlled device must be able to have an impact on you when you’re in another room. TV senders are the wireless versions of the over-the-aerial cables or old TV distribution systems,which involved an aerial amplifier and a separate aerial cable into each TV in the house. The TV sendertakes a single input and transmits it to whichever receivers are listening, encoding whatever IR signals italso saw. There are many variants on the market, including those with SCART sockets (instead of the old-school coaxial aerial sockets) and RCA composite video. Even the cheaper models often have a“channel” switch on them, allowing multiple receiver-transmitter pairs to be used in the same housewithout the signals getting mixed up. And with these devices becoming more mainstream, some arealmost as cheap as an IR-only transmitter, with the TV functionality becoming a free bonus feature.IR Over IPIt is also possible to send data over your existing Ethernet cables, using devices such as the Keene IRAnywhere over IP (KIRA). This eliminates any distance or interference issues you might get from theother methods and also provides a way of remotely controlling IR devices from a computer, withoutneeding to have the computer and its IR transmitter physically in range of the device. Being IP-controlled also means that IR signals can be sent via the Internet. Although this is pointlessin itself (because you can’t derive any benefit from changing the TV channel when you’re not sittingwatching it), it does provide an off-the-shelf way of controlling IR-based devices from a remotecomputer. And if something can be controlled from a computer, then it can be controlled from anythingconnected to the computer, such as a web page or cron job. Using KIRA to retransmit IR codes first requires that you teach it those codes in the first place. Thisis done by generating text files, using the software shown in Figure 1-15. 43 CHAPTER 1 ■ APPLIANCE CONTROL Figure 1-15. Configuring KIRA 15 This software is available from the Keene web site and has been thoughtfully written in Java, making it Linux-friendly. After attaching KIRA to your network and after it’s used your DHCP server to provide it with an IP address, you can add new commands. First you request that all the IR messages are 15 See www.keene.co.uk/electronics/multi.php?mycode=KIRA.44 CHAPTER 1 ■ APPLIANCE CONTROLsent to this machine, and then you press Learn before hitting the first key on your remote. This shouldpresent the code, such as the following, which can then be copied and pasted into a text file for later use:K 240C 037F 0369 03AC 034D 0624 035A 0378 0382 0378 0381 0396 0366 03770382 0396 0365 0396 06E0 03AF 034C 072C 0353 0378 2000 I have used a directory hierarchy for each device so that the on/off button for my TV is in thedirectory ir/tv/codes/on. Since the same button performs both functions, I created a symlink betweenoff and on. Those with bigger houses and more TVs might like to use a more descriptive name than TV. Although KIRA has a web page, it isn’t very configurable and limits you to four prestored IR codes.Fortunately, it also listens for commands sent on UDP ports 30303 and 65432. The former is for devicediscovery and configuration, so consequently the port cannot be changed. The latter is the IR controlport, which processes all the basic commands to control the various IR devices within range. Allresponses to these commands are returned by UDP also, so you need to run two instances of the SwissArmy knife of network utility, netcat, to handle it. Begin by creating two terminal windows, and start a UDP server in one of them by typing thefollowing:nc -u -l -p 30303 This will now listen on port 30303 for any UDP messages sent to it. Now, in the other window, send amessage to KIRA (whose IP has been determined as 192.168.1.111 by the DHCP server) on the same port.echo disD | nc -q 0 -u 192.168.1.111 30303 You should see the other window spring to life and report various stats about the device. If not,check that the ports are open and working with (that other Swiss Army knife of networking) netstat:netstat -ntpl With some averagely clever bash coding, you can achieve the same result with a script such as thefollowing:#!/bin/bashTEMPFILE=`mktemp`nc -u -l -p 30303 >$TEMPFILE &PROCESS=$!echo disD | nc -q 0 -u 192.168.1.111 30303# Wait for a second so the output has finished writingsleep 1kill $PROCESScat $TEMPFILErm $TEMPFILE 45 CHAPTER 1 ■ APPLIANCE CONTROL The process for sending IR messages is the same, except you need to switch onto the IR port. Here’s an example: cat ir/codes/tv/off | nc -q 0 -u ...
Tìm kiếm theo từ khóa liên quan:
Hệ điều hành Windows 7 Hướng dẫn sử dụng Cách cài đặt hệ thống hệ thống mạng mạng máy tínhTài liệu có liên quan:
-
HƯỚNG DẪN SỬ DỤNG PHẦN MỀM SOẠN THẢO VĂN BẢN OpenOffice.org - 1
12 trang 330 0 0 -
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 299 0 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 299 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 283 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 279 1 0 -
47 trang 250 4 0
-
vray for sketchup vietnamese PHẦN 3
10 trang 248 0 0 -
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 247 0 0 -
80 trang 239 0 0
-
Các hướng dẫn tích hợp dịch vụ của Google vào Linux (Phần 1)
7 trang 235 0 0