|
|
@@ -11,18 +11,18 @@ import chardet
|
|
|
|
|
|
#串口打开
|
|
|
def openSer():
|
|
|
- port_list = list(serial.tools.list_ports.comports())
|
|
|
- if len(port_list) == 0:
|
|
|
- print('无可用串口')
|
|
|
- raise RuntimeError('无可用串口')
|
|
|
- else:
|
|
|
- for i in range(0, len(port_list)):
|
|
|
- print(port_list[i])
|
|
|
- for port in port_list:
|
|
|
- print(port[0])
|
|
|
- name = port[0]
|
|
|
-
|
|
|
- ser = serial.Serial(name, 9600, timeout=0.5)
|
|
|
+ # port_list = list(serial.tools.list_ports.comports())
|
|
|
+ # if len(port_list) == 0:
|
|
|
+ # print('无可用串口')
|
|
|
+ # raise RuntimeError('无可用串口')
|
|
|
+ # else:
|
|
|
+ # for i in range(0, len(port_list)):
|
|
|
+ # print(port_list[i])
|
|
|
+ # for port in port_list:
|
|
|
+ # print(port[0])
|
|
|
+ # name = port[0]
|
|
|
+
|
|
|
+ ser = serial.Serial("COM3", 9600, timeout=0.5)
|
|
|
# 字节大小
|
|
|
ser.bytesize = 8
|
|
|
# 无校验
|
|
|
@@ -38,11 +38,11 @@ def reader():
|
|
|
ser = openSer()
|
|
|
print(ser.port)
|
|
|
while 1 > 0:
|
|
|
-
|
|
|
+ time.sleep(2)
|
|
|
hz=ser.read(150)
|
|
|
|
|
|
strUser = hz.decode('GB2312')
|
|
|
- print("等待上传中")
|
|
|
+ print("等待上传中"+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
|
|
|
if(strUser != ''):
|
|
|
strReq = str(strUser.replace("\r\n", ""))
|
|
|
strReq=strReq.replace(" ","")
|