Skip to content

Instantly share code, notes, and snippets.

@inesusvet
Last active April 23, 2018 06:43
Show Gist options
  • Save inesusvet/0f306b00b368ab226f2f09f5be05e1bb to your computer and use it in GitHub Desktop.
Save inesusvet/0f306b00b368ab226f2f09f5be05e1bb to your computer and use it in GitHub Desktop.
"""
Sends system's pulse to a watchdog device
Usage:
python pulse.py <serial device>
Example:
SLEEP=25 python pulse.py /dev/ttyUSB0
"""
import os
import sys
import time
SLEEP = os.environ.get('SLEEP', 1)
def main(filename):
with open(filename, 'rw+') as file_obj:
file_obj.write('y')
if __name__ == '__main__':
if len(sys.argv) < 2:
print __doc__
exit(1)
filename = sys.argv[1]
while True:
main(filename)
time.sleep(SLEEP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment