在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 数据库迁移(migrate)应该知道的一些事

命令 首先数据库迁移的两大命令: python manage.py makemigrations & python manage.py migrate 前者是将model层转为...

pycharm重置设置,恢复默认设置的方法

pycharm重置设置,恢复默认设置的方法

window 系统 找到下方目录-->删除. 再重新打开pycharm # Windows Vista, 7, 8, 10: <SYSTEM DRIVE>\User...

Python列表常见操作详解(获取,增加,删除,修改,排序等)

本文实例讲述了Python列表常见操作。分享给大家供大家参考,具体如下: 列表是由一系列按特定顺序排列的元素组成的对象。因为列表通常包含多个元素, 所以建议给列表指定一个表示复数的名称。...

python实现windows下文件备份脚本

在windows下用python脚本实现文件的备份,参考《A Byte of Python3》第十一章(Page59)。 #!/usr/bin/python # -*- codin...

python实现微信小程序自动回复

本文是使用Python的itchat模块进行微信私聊消息以及群消息的自动回复功能,必须在自己的微信中添加微信号xiaoice-ms(微软的微信机器人)才能实现,直接复制代码运行之后扫一扫...