在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设计】。

相关文章

pycharm访问mysql数据库的方法步骤

pycharm访问mysql数据库的方法步骤

不需要像eclipse那样添加驱动包,在pycharm里面下载一个pymysql包即可。 然后链接自己电脑的mysql并进行访问即可。 源码如下 import pymysql...

django 外键model的互相读取方法

先设定一个关系模型如下: from django.db import models class Blog(models.Model): name = models.CharFiel...

windows10下python3.5 pip3安装图文教程

windows10下python3.5 pip3安装图文教程

最近Google官方的开发者博客中宣布新的版本Tensorflow(0.12)将增加对Windows的支持,想试着windows10下学习tensorflow,之前已经安装anacond...

解决Numpy中sum函数求和结果维度的问题

使用Numpy(下面简称np)中的sum函数对某一维度求和时,由于该维度会在求和后变成一个数,所以所得结果的这一维度为空。 比如下面的例子: a = np.array([[1,2,3...

python适合人工智能的理由和优势

Python借助AI和数据科学,目前已经攀爬到了编程语言生态链的顶级位置,可以说Python基本上与AI已经紧密捆绑在了一起了。为什么人工智能开发要使用到python语言?小编认为基于以...