#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# TEST1.PY -- by Dr. ZhuoQing 2020-10-23
#
# Note:
#============================================================
from head import *
import serial
from _ast import Or
from serial.serialutil import SerialException
sport = serial.Serial()
sport.baudrate = 115200
sport.timeout = 0.05
try:
sport.port = 'COM10'
except:
printf('Set sport port COM10 error. ')
try:
sport.open()
except serial.serialutil.SerialException:
printf('Open sport port COM10 error.')
else:
printf('Open sport port COM10 Ok.')
while True:
sport.write(b'U')
time.sleep(1)
ret = sport.read(100)
printf(ret)
#------------------------------------------------------------
# END OF FILE : TEST1.PY
#============================================================
|
下载程序