import RPi.GPIO as GPIO import serial import time ser=serial.Serial("/dev/ttyACM0",115200,timeout=1) whileTrue: ser.flushInput() print("please input the number of steering engine:(1:left;2:right)") engine=input() print("please input the channel of steering engine:") channel=input() print("please input the angle of the steering engine:") angle=input() print("please input the second of the steering engine:") second=input() data=engine+"#"+channel+"P"+angle+"T"+second print("send data:"+data) ser.write(data.encode("utf-8")) #time.sleep(1) response=ser.readall() if response!=None: result=response.decode("utf-8") print("receiced data:"+result) time.sleep(1) #print(response) else: ser.close()