在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进行TCP端口扫描的实现

首先我们供给一台主机要进行的步骤就是对其主机端口的扫描,查看其中开放的端口。 我们首先创建一个TCP的全连接的扫描器。我们使用socket来创建连接器。 扫描端口开放 #测试当前...

简单了解django缓存方式及配置

前言 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存, 1. 缓存的概述: 缓存将一个某个views的...

python机器学习理论与实战(六)支持向量机

python机器学习理论与实战(六)支持向量机

上节基本完成了SVM的理论推倒,寻找最大化间隔的目标最终转换成求解拉格朗日乘子变量alpha的求解问题,求出了alpha即可求解出SVM的权重W,有了权重也就有了最大间隔距离,但是其实上...

对python中UDP,socket的使用详解

对python中UDP,socket的使用详解

讲到UDP和TCP之前咱们先了解一下socket Socket socket简称套接字,是进程间通信的一种方式。与其他的方式的进程间的通讯的方式不同的是,socket是实现了主机间进程间...

PyQt5 QTableView设置某一列不可编辑的方法

如下所示: class EmptyDelegate(QItemDelegate): def __init__(self,parent): super(EmptyDeleg...