Reputation: 52665
I want to automate capturing logs from serial port with 2 functions:
1) trigger to start capture
2) trigger to stop
First looks like
def start_capture_output():
file = '/home/test/Desktop/log.txt'
os.system('touch %s' % file)
os.system('chmod +rwx %s' % file)
os.system('cat </dev/ttyUSB0>%s' % file)
and it works, but I wonder how to stop this process without manually pressing Ctrl+C
Upvotes: 1
Views: 120
Reputation: 2384
If you spawn the process with
child = subprocess.Popen("command")
Then you can call
child.terminate()
child.kill()
Upvotes: 1