在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编程实现两个文件夹里文件的对比功能示例【包含内容的对比】

本文实例讲述了Python编程实现两个文件夹里文件的对比功能。分享给大家供大家参考,具体如下: #-*-coding:utf-8-*- #======================...

python try except 捕获所有异常的实例

如下所示: try: a=1 except Exception as e: print (e) import traceback import sys try: a = 1...

对Python新手编程过程中如何规避一些常见问题的建议

这篇文章收集了我在Python新手开发者写的代码中所见到的不规范但偶尔又很微妙的问题。本文的目的是为了帮助那些新手开发者渡过写出丑陋的Python代码的阶段。为了照顾目标读者,本文做了一...

Python 字符串换行的多种方式

第一种: x0 = '<?xml version="1.0"?>' \ '<ol>' \ ' <li><a hr...

python写的ARP攻击代码实例

注:使用这个脚本需要安装scapy 包最好在linux平台下使用,因为scapy包在windows上安装老是会有各种问题 复制代码 代码如下:#coding:utf-8#example...