在Python中COM口的调用方法

yipeiwu_com5年前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计算三角函数之acos()方法的使用

 acos()方法返回x的反余弦值,以弧度表示。 语法 以下是acos()方法的语法: acos(x) 注意:此函数是无法直接访问的,所以我们需要导入math模块,然...

python实现鸢尾花三种聚类算法(K-means,AGNES,DBScan)

python实现鸢尾花三种聚类算法(K-means,AGNES,DBScan)

一.分散性聚类(kmeans) 算法流程: 1.选择聚类的个数k. 2.任意产生k个聚类,然后确定聚类中心,或者直接生成k个中心。 3.对每个点确定其聚类中心点。 4.再计算其聚类新中心...

selenium+python自动化测试之环境搭建

selenium+python自动化测试之环境搭建

最近由于公司有一个向谷歌网站上传文件的需求,需要进行web的自动化测试,选择了selenium这个自动化测试框架,以前没有接触过这门技术,所以研究了一下,使用python来实现自动化脚本...

Python挑选文件夹里宽大于300图片的方法

本文实例讲述了Python挑选文件夹里宽大于300图片的方法。分享给大家供大家参考。具体分析如下: 这段代码需要用到PIL库。代码如下所示: import sys import os...

python利用smtplib实现QQ邮箱发送邮件

python利用smtplib实现QQ邮箱发送邮件

python的smtplib提供了一种很方便的途径发送电子邮件。它对smtp协议进行了简单的封装。 下面是一个利用smtplib,实现QQ邮箱发送邮件的例子。 首先必须要打开QQ邮箱的s...