2

I've got a command line utility from canutils called candump. It works like this:

I run candump (specifying the bus from which I want to dump)

root@beaglebone: candump can0

It then runs until I end it using CTRL+C

However, when I run it in a python script like so.

Popen(["candump","can0"],stdout=PIPE)

or

call(["candump","can0"])

I'm not sure how to end it. Any ideas?

2
  • Relevant. Commented Mar 6, 2013 at 22:58
  • 1
    Popen.terminate() and Popen.kill() should work if you don't want to use send_signal. Docs Commented Mar 6, 2013 at 23:01

2 Answers 2

3

Don't use use the call command if you want control over the subprocess

If you use Popen like you did above you should assign it to a variable like this:

p = Popen(["candump","can0"],stdout=PIPE)

Once you have p then you can use one of the following SIGNAL commands on it http://docs.python.org/2/library/subprocess.html#subprocess.Popen.send_signal

Sign up to request clarification or add additional context in comments.

Comments

2

Use Popen(), and call send_signal(signal.SIGINT) on the returned Popen object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.