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

相关文章

Django项目后台不挂断运行的方法

方法一: 1、进入项目目录下,运行下面程序: nohup python manage.py runserver 0.0.0.0:5008 & nohup(no hang up)用...

浅析python 内置字符串处理函数的使用方法

一、lower():将大写字母全部转为小写字母。如: 复制代码 代码如下:name='G'b=name.lower() 二、title”":将字符串转化为标题,即所有单词的首字母大写,其...

centos7中安装python3.6.4的教程

Python3.6.4官方版是一款在适合开发人员使用的windows系统上运行的脚本语言工具,Python3.6.4官方版是目前程序设计从业者必学的语言之一。我们可以通过python平台...

Python字符串中查找子串小技巧

惭愧啊,今天写了个查找子串的Python程序被BS了… 如果让你写一个程序检查字符串s2中是不是包含有s1。也许你会很直观的写下下面的代码: 复制代码 代码如下: #determine...

python 容器总结整理

python 容器总结整理 list 可变数组 tuple 不可变数组 dict 键值对(key-value)的字典(dictionary) 初始化: a={‘lyt':90}...