在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的Twisted框架中使用Deferred对象来管理回调函数

Python的Twisted框架中使用Deferred对象来管理回调函数

首先抛出我们在讨论使用回调编程时的一些观点: 激活errback是非常重要的。由于errback的功能与except块相同,因此用户需要确保它们的存在。他们并不是可选项,而是必选项...

Python2比较当前图片跟图库哪个图片相似的方法示例

本文实例讲述了Python2比较当前图片跟图库哪个图片相似的方法。分享给大家供大家参考,具体如下: # -*- coding: utf-8 -*- ''' Created on 20...

pytorch动态网络以及权重共享实例

pytorch 动态网络+权值共享 pytorch以动态图著称,下面以一个栗子来实现动态网络和权值共享技术: # -*- coding: utf-8 -*- import rando...

Python实现获取汉字偏旁部首的方法示例【测试可用】

Python实现获取汉字偏旁部首的方法示例【测试可用】

本文实例讲述了Python实现获取汉字偏旁部首的方法。分享给大家供大家参考,具体如下: 功能介绍 传入一个汉字,返回其偏旁部首 字典 分为本地字典与网络字典,本地词典来自精简版的新华字典...

python十进制和二进制的转换方法(含浮点数)

本文介绍了python十进制和二进制的转换方法(含浮点数),分享给大家,也给自己留个笔记,具体如下: 我终于写完了 , 十进制转二进制的小数部分卡了我将近一个小时 上代码 #...