Fixed bug of first scanned frequency

This commit is contained in:
gertjan 2026-03-27 13:21:15 +01:00
parent b07edd3839
commit 390dccedfe

View file

@ -189,7 +189,7 @@ class TelnetReader:
# Main loop: reads incoming lines forever # Main loop: reads incoming lines forever
try: try:
while state["freq"] > state["stop_freq"]: while state["freq"] > state["stop_freq"]:
if state["initializing"] == 1: if state["initializing"]>0:
self.process_line("Va=") self.process_line("Va=")
else: else:
line = self.tn.read_until(b"\n") # read line line = self.tn.read_until(b"\n") # read line
@ -240,7 +240,9 @@ class TelnetReader:
response = f"a{state["ampl"]:.1f}\r" # set amplitude response = f"a{state["ampl"]:.1f}\r" # set amplitude
self.tn.write(response.encode("utf-8")) self.tn.write(response.encode("utf-8"))
# there will be a lot of lines, but they will be skipped as they do not match the pattern # there will be a lot of lines, but they will be skipped as they do not match the pattern
else: # regular loop (not initializing) state["initializing"] = 2
else: # regular loop (initializing is 0 (normal) or 2 (first sample))
if state["initializing"] == 0:
extract_to_dataframe(line) # capture the measurement extract_to_dataframe(line) # capture the measurement
if state["freq"]>3.0: if state["freq"]>3.0:
Inoise_baseline = 0.8*Inoise_baseline + 0.2*data_rows[-1][12] # remember last baseline around 3Hz (assuming top-down scanning) Inoise_baseline = 0.8*Inoise_baseline + 0.2*data_rows[-1][12] # remember last baseline around 3Hz (assuming top-down scanning)
@ -269,6 +271,7 @@ class TelnetReader:
while (any(item["Freq"] == state["freq"] for item in blacklist)): while (any(item["Freq"] == state["freq"] for item in blacklist)):
print("skipping freq") print("skipping freq")
state["freq"] *= freq_multiplier # skip all frequencies that are blacklisted state["freq"] *= freq_multiplier # skip all frequencies that are blacklisted
if state["freq"] <= state["stop_freq"]: if state["freq"] <= state["stop_freq"]:
print("Reached stop frequency") print("Reached stop frequency")
else: else: