在Python中COM口的调用方法

yipeiwu_com6年前Python基础

如下所示:

import serial
import time

t = serial.Serial('com6', 115200) #USB COM number on your PC and the transfer bit rate of the COM port.
print t.portstr #Display the working UART port number on your PC.
n = t.write('logcat -c \r')
n = t.write('ampclient_samples 2 -O 3 /mnt/media_rw/B278-E25A/video_google_clips/New_Webm/bunny_1080P.webm \r')
time.sleep(3)
print "Does the stream output normally? Yes=1 or No=2"
Input = int(raw_input())
if Input == 1:
  print "Pass!!!"
  n = t.write(chr(0x03)) #Call for Ctrl+C command in UART port
  n = t.write('logcat -c \r')
else:
  print "Fail!!!"
  n = t.write(chr(0x03))
  #n = t.write('logcat -v threadtime /r')

以上这篇在Python中COM口的调用方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python计算对角线有理函数插值的方法

本文实例讲述了python计算对角线有理函数插值的方法。分享给大家供大家参考。具体实现方法如下: ''' p = rational(xData,yData,x) Evaluate...

python实现列表中由数值查到索引的方法

python实现列表中由数值查到索引的方法

如下所示: 以上这篇python实现列表中由数值查到索引的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。...

PyCharm在新窗口打开项目的方法

PyCharm在新窗口打开项目的方法

File->Setting 找到Appearance & Behavior -->System Setting,在右边窗口中选择 Open project in new wi...

Python面向对象程序设计中类的定义、实例化、封装及私有变量/方法详解

本文实例讲述了Python面向对象程序设计中类的定义、实例化、封装及私有变量/方法。分享给大家供大家参考,具体如下: 1. 定义类 python中定义一个类的格式如下: class...

Python对象的深拷贝和浅拷贝详解

本文内容是在《Python核心编程2》上看到的,感觉很有用便写出来,给大家参考参考! 浅拷贝 首先我们使用两种方式来拷贝对象,一种是切片,另外一种是工厂方法。然后使用id函数来看看它们的...