Quozl's Desk Charger Timer
The reason for this was that the two signals are normally found either both on or both off, except in rare circumstances. It is this rare circumstance which is desirable. We don't want activation during boot.
|condition||DTR||RTS||difference||system power off||unpowered||unpowered||none|
|serial port opened by conventional software||on||on||none|
|serial port closed by conventional software||off||off||none|
|serial port opened by software designed to lower RTS||on||off||full swing|
Since control signals such as RTS and DTR are logically inverted, a positive voltage with respect to ground occurs when the signal is on. So with RTS off the signal has a voltage of -5V to -15V depending on the serial port internal power supply. With DTR on the signal has a voltage of 5V to 15V. Therefore the difference will be between 10V and 30V, current limited.
Depends on the Debian package python-serial.
#!/usr/bin/python import sys, serial, signal # raises DTR and RTS, null effect device = serial.Serial('/dev/ttyS2') # lowers RTS, powers charger device.setRTS(0) # pause until signal received, e.g. from parent signal.pause() # raises RTS, depowers charger device.setRTS(1) # lowers DTR and RTS, null effect device.close() sys.exit(0)
#!/bin/sh killall --signal SIGUSR1 charger
#!/bin/sh timeout -10 3600 charger