I'm trying to do some scripting, but one of the utilities I have returns a value to stdout, where I would like to assign it to a variable.
The utility (candump) is constantly running and only prints to std out when it receives data.
import threading
from subprocess import call
import time
class ThreadClass(threading.Thread):
def run(self):
call(["candump","can0"])
t = ThreadClass()
t.start()
time.sleep(1)
call(["cansend", "can0", "-i", "0x601", "0x40", "0xF6", "0x60", "0x01", "0x00", "0x00", "0x00", "0x00"])
It returns the following values, which I would like to use in my python script:
<0x601> [8] 40 f6 60 01 00 00 00 00
<0x581> [8] 4b f6 60 01 96 08 00 00
The documentation on candump (what is dumping the data to stdout) is sparse
Is there I way I can tap into stdout and snatch the data going to it?
Sorry if this is incredibly obvious... learning Linux bit by bit.