在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查找文件中包含中文的行方法

前言 近几天在做多语言版本的时候再次发现,区分各种语言真的是一件比较困难的事情,上一次做中文提取工具的就花了不少时间,这次决定用python试一试,结果写起来发现真是方便不少,自己整理了...

python冒泡排序简单实现方法

本文实例讲述了python冒泡排序简单实现方法。分享给大家供大家参考。具体实现方法如下: #!/usr/bin/python import random def bubble_sor...

Pycharm无法使用已经安装Selenium的解决方法

Pycharm无法使用已经安装Selenium的解决方法

电脑C盘安装python27的时候也安装了selenium,但是最近刚刚使用工具Pycharm,新建工程后,然后建立.py文件后,使用语句:from selenium.webdriver...

Python实现某论坛自动签到功能

1.[文件] DakeleSign.py ~ 4KB #!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'popp...

python文件绝对路径写法介绍(windows)

python在描述路径时有两种方式: 'd:\\a.txt',转义的方式 r'd:\a.txt',声明字符串不需要转义 (使用raw string,也就是在string'前面加r,告诉p...