在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对小数进行除法运算的正确方法示例

求一个算式 复制代码 代码如下: a=1 b=2 c=3   print c*(a/b) 运行结果总是0,反复检查拆开以后,发现在Python里,整数初整数,只能得出整数。...

python多进程读图提取特征存npy

本文实例为大家分享了python多进程读图提取特征存npy的具体代码,供大家参考,具体内容如下 import multiprocessing import os, time, ran...

安装Pycharm2019以及配置anconda教程的方法步骤

安装Pycharm2019以及配置anconda教程的方法步骤

一、获取安装包: Pycharm 官网 下载页面 :点击打开 Anconda 官网 下载页面 :点击打开 选择对应的系统和需要的版本进行下载,pycharm 分为付费专业版和社区免...

Python3实现的字典、列表和json对象互转功能示例

本文实例讲述了Python3实现的字典、列表和json对象互转功能。分享给大家供大家参考,具体如下: python3可以使用json模块操作json json.dumps(): 对jso...

Python3批量移动指定文件到指定文件夹方法示例

Python3批量移动指定文件到指定文件夹方法示例

引言 某人需求:以某excel中姓名信息为名建立一系列文件夹,分别将四个文件夹中与人名对应的文件汇总到该人名对应的文件夹中,共近200人,手工处理费时费力。 需求分解: 从exc...