Gauge drive day: CANNY comparison, cluster signal research, serial tools
Wiki: two new pages - canny-5-3-pico-gauge-drive (why the CANNY's 12V negative output moved the needles and 3.3V push-pull could not; 2SK3069 low-side stage) and patrol-instrument-cluster (tach 2 ppr + trim -13 calibration, NTC temp sender curve, 20 kHz PWM flutter fix, and the four-layer steppy-needle diagnosis ending at the cluster's ~150 rpm count quantization, defeated with adaptive dither on B). Tools: serial_logger.py (multi-port capture to wiki/raw), serial_cmd.py (one-shot cfg commands to A), dual_serial_capture.py (bench snapshots), tach_ramp.py / tach_ramp2.py (synthetic rpm sweeps via cfg override). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Capture N seconds from two serial ports in parallel and print what arrived."""
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
|
||||
import serial
|
||||
|
||||
PORTS = sys.argv[1].split(",") if len(sys.argv) > 1 else ["COM8", "COM9"]
|
||||
SECONDS = float(sys.argv[2]) if len(sys.argv) > 2 else 6.0
|
||||
MAX_LINES = 40
|
||||
|
||||
|
||||
def cap(port, out):
|
||||
try:
|
||||
s = serial.Serial(port, 115200, timeout=0.5)
|
||||
end = time.time() + SECONDS
|
||||
buf = b""
|
||||
while time.time() < end:
|
||||
buf += s.read(4096)
|
||||
s.close()
|
||||
out[port] = buf
|
||||
except Exception as e:
|
||||
out[port] = ("ERR: %s" % e).encode()
|
||||
|
||||
|
||||
out = {}
|
||||
threads = [threading.Thread(target=cap, args=(p, out)) for p in PORTS]
|
||||
for t in threads:
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
|
||||
for p in PORTS:
|
||||
data = out.get(p, b"")
|
||||
print("=" * 20, p, "bytes:", len(data), "=" * 20)
|
||||
lines = data.decode("utf-8", "replace").splitlines()
|
||||
for ln in lines[:MAX_LINES]:
|
||||
print(ln)
|
||||
if len(lines) > MAX_LINES:
|
||||
print("... (%d more lines)" % (len(lines) - MAX_LINES))
|
||||
Reference in New Issue
Block a user