[Tutor] connecting to USB

2012-06-06 Thread BILAL Mustapha

Hello,

 I am working to connect to a serial link (USB). In order to do that I 
have to write this command:


sudo ../../tools/stm32w/serialdump-linux -b115200 -d1 (keeping in 
mind dat*serialdump-linux*, which is in the path, is not a folder, it's 
an executable)


To get to the root, I have used: returncode = 
subprocess.call([/usr/bin/sudo, /usr/bin/id])


Then to connect to the USB through the command above I tried the following:

usb = 
Popen(['../../tools/stm32w/serialdump-linux','-b115200','-d1'], 
stdout=PIPE, stdin=PIPE, stderr=STDOUT)


usb.communicate()[0]

 But I am getting an error, it's considering that serialdump-linux as a 
folder!!


 Any help how I can run the command?

 Many thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] connecting to USB

2012-06-06 Thread BILAL Mustapha

Le 06/06/2012 11:02, BILAL Mustapha a écrit :

Hello,

 I am working to connect to a serial link (USB). In order to do that I 
have to write this command:


sudo ../../tools/stm32w/serialdump-linux -b115200 -d1 (keeping in 
mind dat*serialdump-linux*, which is in the path, is not a folder, 
it's an executable)


To get to the root, I have used: returncode = 
subprocess.call([/usr/bin/sudo, /usr/bin/id])


Then to connect to the USB through the command above I tried the 
following:


usb = 
Popen(['../../tools/stm32w/serialdump-linux','-b115200','-d1'], 
stdout=PIPE, stdin=PIPE, stderr=STDOUT)


usb.communicate()[0]

 But I am getting an error, it's considering that serialdump-linux as 
a folder!!


 Any help how I can run the command?

 Many thanks


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

I resolved the issue, you can do the following:

First method:
args = (sudo, ../../tools/stm32w/serialdump-linux, -b115200, 
-d1)

usb = Popen(args, stdout=PIPE, stdin=PIPE)
usb.wait()
usb.communicate()[0]

Second method:
cmd = 'sudo ../../tools/stm32w/serialdump-linux -b115200 -d1'
os.system(cmd)

you can run it using cmd and os or using Popen if you need to use stdout 
and stdin in your application (which is my case)


PS. -b115200 -d1 are two options related to USB so you can change 
the whole command and use any option you would like to.


Regards

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor