[Tutor] connecting to USB
BILAL Mustapha
Mustapha.Bilal at imag.fr
Wed Jun 6 11:59:46 CEST 2012
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 -d10000 (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','-d10000'],
> 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 at 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",
"-d10000")
usb = Popen(args, stdout=PIPE, stdin=PIPE)
usb.wait()
usb.communicate()[0]
Second method:
cmd = 'sudo ../../tools/stm32w/serialdump-linux -b115200 -d10000'
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 -d10000 are two options related to USB so you can change
the whole command and use any option you would like to.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120606/5ebfb19a/attachment.html>
More information about the Tutor
mailing list