在Python中COM口的调用方法

作者:呱呱王子 时间:2023-10-05 14:16:39 

如下所示:


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')

来源:https://blog.csdn.net/weixin_34926800/article/details/78589686

标签:Python,COM口,调用
0
投稿

猜你喜欢

  • 基于Mysql+JavaSwing的超市商品管理系统设计与实现

    2024-01-29 00:31:46
  • Python中random模块常用方法的使用教程

    2023-12-03 16:30:11
  • python如何通过实例方法名字调用方法

    2021-04-24 09:00:31
  • 在linux下实现 python 监控usb设备信号

    2022-04-18 15:29:24
  • Vite版本更新检查实现页面自动刷新的解决思路

    2024-04-27 16:17:07
  • 通过不同的CSS设计字体大小来提高用户体验

    2008-12-10 19:17:00
  • 最新整理Python中的type和object的示例详解

    2023-08-10 05:21:44
  • 深入探索数据库MySQL性能优化与复杂查询相关操作

    2024-01-26 20:25:11
  • Python实战之实现简单的名片管理系统

    2023-07-18 06:48:02
  • javascript显示动态时间的方法汇总

    2024-05-02 17:31:27
  • 微信小程序 滚动选择器(时间日期)详解及实例代码

    2024-01-27 22:57:53
  • 如何用python GUI(tkinter)写一个闹铃小程序(思路详解)

    2021-03-23 09:11:49
  • 安装python-docx后,无法在pycharm中导入的解决方案

    2022-09-08 10:08:13
  • 解决Microsoft VBScript 运行时错误 (0x800A0046) 没有权限的解决方案

    2009-09-03 13:28:00
  • 实用技巧:优化SQL Server数据库查询方法

    2009-02-04 13:46:00
  • Python装饰器的定义和使用详情

    2021-01-26 23:22:15
  • MySql导入CSV文件或制表符分割的文件

    2024-01-19 07:43:54
  • Django auth 应用模块详解

    2023-05-20 11:17:17
  • Django中的cookie和session

    2022-02-21 02:40:42
  • 浅析python中while循环和for循环

    2022-10-26 18:56:18
  • asp之家 网络编程 m.aspxhome.com