Power Controller by Browser
I have decided to put the wireless networking problems on hold for now. I spent another two hours trying different access point settings, but the end result is that the access point just does not seem to be communicating wireless to the router. So I will wait until I get the wireless USB network adapter running and try troubleshooting with that.
In the meantime, time to go back to Taking Over the World. I decided to get my X10 modules running again with University linux. This forms the subject of a Project on the UL website. X10 modules are inexpensive, readily available (Radio Shack usually has them) and they can turn 110 VAC power on or off. They can do this cleverly via a serial interface port and wireless transmitter. There are Linux drivers for the wireless X10 serial interface (Bottlerocket) that work quite well. So I decided to write some improved Perl scripting to allow a browser page turn my Black Tower worklight on and off.
I have always wanted to improve on the UL project. As it was originally described on the UL website, there was no way for the state of the X10 module to be known when the browser page loaded. So I added a Perl script that executes when a button is pushed from a web page. A file carrying the state of the X10 module (On = 1, Off = 0)is loaded and the state of radio buttons on a browser page is set depending on the contents of the file. The file is changed according to the selected state when the Bottlerocket drivers are activated. The result is that you can load the X10 control page over the Internet, see the state of an incandescent light, for example, change the state, and return later. The actual state of the lamp will be loaded by the browser page on each visit.
All of this went together quite well and I put it up on the Beta machine. Beta was set to IP 192.168.0.125 (the firewall's virtual server address) and the necessary HTML and Perl files loaded. I powered up Beta, started its webserver and went off to work.
I commute about 45 miles by train, so this is a good test of remote control capability. I fired up my Internet Explorer at work and typed in my static IP into the browser URL address bar. The X10 page came up, just as expected. I tried changing the state of the lamp, but got a text error message: "permission denied on ttyS0". So I had forgotten to allow browser users (nobody's in the UL passwd scheme) to be able to read or write to the serial port. Because Perl calls take on the permissions of the browser calling them, nothing could happen with the Bottlerocket serial drivers.
This was quickly fixed by Telnetting into Beta as root, and changing permissions with a couple of chmod commands. This worked and the browser page was soon able to turn my Black Tower light on or off.
Because the work light is a 50 watt incandescent, the X10 dimming commands should work. These are supported by Bottlerocket also. I should be able to put a drop-down menu in the browser page that specifies the intensity of the lamp. The Bottlerocket syntax on this is a bit elliptical, in my opinion, but it should just be a matter of following the Bottlerocket Helps.
I also have an X10 hand-held remote control so when I am working around the Black Tower I can switch the light on or off locally. And of course the switch on the top of the light also turns it on or off. But what fun is that?
Heartened by this success I plan to add a second X10 module to the system. This will make the browser page more complicated, but turning one light on and off is hardly a giant step towards Taking Over the World.
But it is a start.
In the meantime, time to go back to Taking Over the World. I decided to get my X10 modules running again with University linux. This forms the subject of a Project on the UL website. X10 modules are inexpensive, readily available (Radio Shack usually has them) and they can turn 110 VAC power on or off. They can do this cleverly via a serial interface port and wireless transmitter. There are Linux drivers for the wireless X10 serial interface (Bottlerocket) that work quite well. So I decided to write some improved Perl scripting to allow a browser page turn my Black Tower worklight on and off.
I have always wanted to improve on the UL project. As it was originally described on the UL website, there was no way for the state of the X10 module to be known when the browser page loaded. So I added a Perl script that executes when a button is pushed from a web page. A file carrying the state of the X10 module (On = 1, Off = 0)is loaded and the state of radio buttons on a browser page is set depending on the contents of the file. The file is changed according to the selected state when the Bottlerocket drivers are activated. The result is that you can load the X10 control page over the Internet, see the state of an incandescent light, for example, change the state, and return later. The actual state of the lamp will be loaded by the browser page on each visit.
All of this went together quite well and I put it up on the Beta machine. Beta was set to IP 192.168.0.125 (the firewall's virtual server address) and the necessary HTML and Perl files loaded. I powered up Beta, started its webserver and went off to work.
I commute about 45 miles by train, so this is a good test of remote control capability. I fired up my Internet Explorer at work and typed in my static IP into the browser URL address bar. The X10 page came up, just as expected. I tried changing the state of the lamp, but got a text error message: "permission denied on ttyS0". So I had forgotten to allow browser users (nobody's in the UL passwd scheme) to be able to read or write to the serial port. Because Perl calls take on the permissions of the browser calling them, nothing could happen with the Bottlerocket serial drivers.
This was quickly fixed by Telnetting into Beta as root, and changing permissions with a couple of chmod commands. This worked and the browser page was soon able to turn my Black Tower light on or off.
Because the work light is a 50 watt incandescent, the X10 dimming commands should work. These are supported by Bottlerocket also. I should be able to put a drop-down menu in the browser page that specifies the intensity of the lamp. The Bottlerocket syntax on this is a bit elliptical, in my opinion, but it should just be a matter of following the Bottlerocket Helps.
I also have an X10 hand-held remote control so when I am working around the Black Tower I can switch the light on or off locally. And of course the switch on the top of the light also turns it on or off. But what fun is that?
Heartened by this success I plan to add a second X10 module to the system. This will make the browser page more complicated, but turning one light on and off is hardly a giant step towards Taking Over the World.
But it is a start.

0 Comments:
Post a Comment
<< Home