serial中python通信
2020-12-13 05:56
标签:load write roo usr 模块 串口 default ports end 1、需要导入pyserial 的模块 脚本如下: serial中python通信 标签:load write roo usr 模块 串口 default ports end 原文地址:https://www.cnblogs.com/classics/p/11155875.html# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
reload(sys);
sys.setdefaultencoding("utf-8")
import serial
# 导入串口模块
import threading
import time
import serial
ser = serial.Serial("COM3",115200)
send = ser.write("\n")
send = ser.write("\n")
time.sleep(2)
send = ser.write("root")
send = ser.write("\n")
print ser.portstr
print send
time.sleep(2)
send = ser.write("nE7jA%5m")
send = ser.write("\n")
print send
time.sleep(2)
send = ser.write("export")
send = ser.write("\n")
print send
time.sleep(2)
data = ""
while ser.in_waiting > 0 :
data+=ser.read(1)
if data != "":
print data
上一篇:Spring 中的Bean配置
下一篇:Java将网页上的js下载下来。