def setup_serial(ser, port, lock):
"""Setup all parameters for the serial communication"""
try:
with lock:
ser.baudrate = 4800
ser.port = port
ser.bytesize = serial.EIGHTBITS
ser.stopbits = serial.STOPBITS_ONE
ser.parity = serial.PARITY_NONE
ser.timeout = 0.1 # Read timeout in seconds
ser.write_timeout = 0.1 # Write timeout in seconds
except Exception as e:
helper.show_error("Problem initializing serial port " + port + ".\n\n"
"Exception:\n" + str(e) + "\n\n"
"The application will now exit.")
sys.exit(0)
评论列表
文章目录