# -*- coding: utf-8 -*-
import time
import datetime
import serial.tools.list_ports
def request_500K():
ser = serial.Serial(port="COM_PORT", baudrate=460800, bytesize=serial.EIGHTBITS, stopbits=serial.STOPBITS_ONE,timeout=60)
if ser.isOpen():
print("打开串口成功, 串口号: %s" % ser.name)
else:
print("打开串口失败")
# 串口发送数据
data = "AT+QIOPEN=1,0,\"TCP\",ip,port,0,2\r\n\r\n"
data1 = "GET /test_500k.txt HTTP/1.1\r\nHost: ip\r\nConnection: close\r\n\r\n"
print("发送数据: %s" % data)
write_len = ser.write(data.encode('utf-8'))
print("等待2S")
time.sleep(2)
print("发送数据: %s" % data1)
write_len1 = ser.write(data1.encode('utf-8'))
com_input = ser.read(513000)
print(str(com_input))
with open("log.txt", "a") as f:
f.write(str(com_input) + "\r\n")
# 关闭串口
ser.close()
if ser.isOpen():
print("串口未关闭")
else:
print("串口已关闭")
i = 0
while i