Created
August 20, 2019 00:39
-
-
Save Hurricane996/2c36eb0b63e44ca1efeadd0b63bdb453 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
import time | |
import sys,os | |
import serial | |
def follow(f): | |
while True: | |
line = f.readline() | |
if not line: | |
time.sleep(0.1) | |
continue | |
yield line.rstrip() | |
#clear the log file | |
open(sys.argv[1],"w").close() | |
try: | |
ser_path = sys.argv[2] | |
except IndexError: | |
ser_path = "/dev/tty" | |
with serial.Serial(ser_path,112500,1) as ser: | |
for line in follow(open(sys.argv[1],"r")): | |
if line=="[Bomb] Boom": | |
print("Explosion detected.") | |
ser.write(b"zap me daddy uwu") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment