kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
simply retry
rodzic
4204bad346
commit
2ddde80dfc
|
@ -52,6 +52,8 @@ WAIT = 0.05
|
|||
# incompatible hardware info like:
|
||||
# 'PORTS\\VID_04B4&PID_0008\\DEMO'
|
||||
# This function will fix it.
|
||||
|
||||
|
||||
def _fix_v2_hwinfo(dev):
|
||||
if dev.hwid == r'PORTS\VID_04B4&PID_0008\DEMO':
|
||||
dev.vid, dev.pid = 0x04b4, 0x0008
|
||||
|
@ -112,12 +114,17 @@ def get_VNA(iface: Interface) -> 'VNA':
|
|||
logger.warning("Did not recognize NanoVNA type from firmware.")
|
||||
return NanoVNA(iface)
|
||||
|
||||
|
||||
def detect_version(serial_port: serial.Serial) -> str:
|
||||
data = ""
|
||||
for i in range(RETRIES):
|
||||
drain_serial(serial_port)
|
||||
serial_port.write("\r".encode("ascii"))
|
||||
# workaround for some UnicodeDecodeError ... repeat ;-)
|
||||
drain_serial(serial_port)
|
||||
serial_port.write("\r".encode("ascii"))
|
||||
sleep(0.05)
|
||||
|
||||
data = serial_port.read(128).decode("ascii")
|
||||
if data.startswith("ch> "):
|
||||
return "v1"
|
||||
|
@ -130,6 +137,7 @@ def detect_version(serial_port: serial.Serial) -> str:
|
|||
logger.error('No VNA detected. Hardware responded to CR with: %s', data)
|
||||
return ""
|
||||
|
||||
|
||||
def get_info(serial_port: serial.Serial) -> str:
|
||||
for _ in range(RETRIES):
|
||||
drain_serial(serial_port)
|
||||
|
|
Ładowanie…
Reference in New Issue