Last active
April 23, 2018 06:43
-
-
Save inesusvet/0f306b00b368ab226f2f09f5be05e1bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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