网络编程
位置:首页>> 网络编程>> Python编程>> 在Python中COM口的调用方法

在Python中COM口的调用方法

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

标签:Python,COM口,调用

如下所示:


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

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com