Skip to content

Instantly share code, notes, and snippets.

@Hurricane996
Created August 20, 2019 00:39
Show Gist options
  • Save Hurricane996/2c36eb0b63e44ca1efeadd0b63bdb453 to your computer and use it in GitHub Desktop.
Save Hurricane996/2c36eb0b63e44ca1efeadd0b63bdb453 to your computer and use it in GitHub Desktop.
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