以下のコードでは、candump という関数を開くスレッドを作成しています。Candump は入力チャネルを監視し、データが入ってくると値を std out に返します。
私がやりたいことは、これがいつ終了するか (つまり、cansend 後の固定時間) を制御することです。ドキュメントに目を通した後、参加するのが正しい方法だと思われますか?
わからない。何かご意見は?
import threading
from subprocess import call, Popen,PIPE
import time
delay=1
class ThreadClass(threading.Thread):
def run(self):
start=time.time()
proc=Popen(["candump","can0"],stdout=PIPE)
while True:
line=proc.stdout.readline()
if line !='':
print line
t = ThreadClass()
t.start()
time.sleep(.1)
call(["cansend", "can0", "-i", "0x601", "0x40", "0xF6", "0x60", "0x01", "0x00", "0x00", "0x00", "0x00"])
time.sleep(0.01)
#right here is where I want to kill the ThreadClass thread