kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Tune timeouts in serial
rodzic
2244f57779
commit
9a73e8ba81
|
@ -23,15 +23,21 @@ import serial
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def drain_serial(serial_port: serial.Serial):
|
||||
"""drain up to 64k outstanding data in the serial incoming buffer"""
|
||||
# logger.debug("Draining: %s", serial_port)
|
||||
timeout = serial_port.timeout
|
||||
serial_port.timeout = 0.05
|
||||
for _ in range(512):
|
||||
cnt = len(serial_port.read(128))
|
||||
if not cnt:
|
||||
serial_port.timeout = timeout
|
||||
return
|
||||
serial_port.timeout = timeout
|
||||
logger.warning("unable to drain all data")
|
||||
|
||||
|
||||
class Interface(serial.Serial):
|
||||
def __init__(self, interface_type: str, comment, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -40,6 +46,7 @@ class Interface(serial.Serial):
|
|||
self.comment = comment
|
||||
self.port = None
|
||||
self.baudrate = 115200
|
||||
self.timeout = 0.05
|
||||
self.lock = Lock()
|
||||
|
||||
def __str__(self):
|
||||
|
|
Ładowanie…
Reference in New Issue