Koozali.org: home of the SME Server

php/perl to switch relais on lp0

freakinger

php/perl to switch relais on lp0
« on: December 18, 2002, 01:58:28 PM »
Hi,

i want to switch a relais hanging on the parallel port of my e-smith box (5.1.2)
kinda web bases switching, so i can switch the relais on/off remotely with a browser.
the problem isn't the hardware but the software for that, any ideas ?
regards
freakinger

freakinger

Re: php/perl to switch relais on lp0
« Reply #1 on: December 18, 2002, 06:20:35 PM »
got it

http://schmail.com/dslmon/
i used the lptout from this page and called it with exec("sudo /usr/bin/lptout 0"); to switch 5V on pin 2 of the pp on and exec("sudo /usr/bin/lptout 1"); to switch off.
had to use sudo because lptout only will rus as root because of ioperm
works perfectly

regards
freakinger

Nathan Fowler

Re: php/perl to switch relais on lp0
« Reply #2 on: December 19, 2002, 05:28:41 PM »
I'm doing something similar myself but I'm using serial DB9.  It's a little bit easier.  I've got a silicon switching diode to trap polarity.  I found that the port in an idle state is +5/-5, when data transmission occurs it switches the polarity.  I used a transisitor (240V Max I believe) in conjunction with a 12AMP relay.  When I send data to the port it trips the relay and cycles the power for the duration of the data send.  I wrote some PHP code that I call via cron to PING the second hop on the network, if that node is down (100% packet loss) I then trigger a DSL modem reboot by cutting power for 30 seconds.  It's very useful and I'd be willing to share the schematic as well as the code if you want.

This goes for the rest of you guys.  I think total cost was around $40 from Radio Shack.

Nathan