Track the bench scripts (run_overnight.py and its stages, the link and ITS client libraries, the phone-vs-node comparison) with the first reports. Changes for the spare XIAO (no cell): - run_overnight.py picks the single Espressif board by default and refuses to test a build that is not this checkout's HEAD. - The unsigned soak stops as "transmit path wedged" after 40 resource_limit refusals in a row and tries whether a repeated STATION_CONFIGURE clears it. - "Refused requests put nothing on the radio" counts only own transmissions; frames heard from other stations are copied by RAW_CAPTURE too. - start_overnight.ps1: optional build and flash, host C tests in the background, Windows kept awake. setup_workstation.ps1 checks and installs git, Python 3.11, pyserial, asn1tools, MSYS2 gcc and make, ESP-IDF 6.0.2. - obu-firmware/docs/overnight-bench-test.tex (and PDF) describe the test, the workstation set-up and the findings of the 2026-11-25 runs.
476 lines
20 KiB
Python
476 lines
20 KiB
Python
"""Station-link client for the bench tests (obu-firmware/docs/station-link.tex, revision 3), over the native USB
|
|
Serial/JTAG port. Standard library plus pyserial. Written from the spec and main/link_protocol.*, not from the
|
|
phone app, so it is a second implementation of the host side.
|
|
|
|
Opening the port resets the board (USB Serial/JTAG): a reopen is how the tests get a clean, unconfigured station.
|
|
"""
|
|
import collections
|
|
import os
|
|
import random
|
|
import re
|
|
import struct
|
|
import threading
|
|
import time
|
|
import zlib
|
|
|
|
import serial
|
|
|
|
LINK, LOG = 0x10, 0x7F
|
|
|
|
# opcodes, host -> station
|
|
STATION_CONFIGURE, POTI_UPDATE, BTP_DATA_REQUEST, CREDENTIALS_PROVISION, CREDENTIALS_ERASE = 0x01, 0x02, 0x03, 0x04, 0x05
|
|
SF_IDCHANGE_SUBSCRIBE, SF_IDCHANGE_UNSUBSCRIBE, SF_IDCHANGE_EVENT_RESPONSE, SF_IDCHANGE_TRIGGER = 0x06, 0x07, 0x08, 0x09
|
|
SF_ID_LOCK, SF_ID_UNLOCK, STATUS_REQUEST, RAW_CAPTURE, PKI_STATUS = 0x0A, 0x0B, 0x0C, 0x0D, 0x15
|
|
# station -> host
|
|
CONFIRM, BTP_DATA_INDICATION, SF_IDCHANGE_EVENT, RAW_FRAME, PKI_REQUEST_DATA, V2X_RX = 0x80, 0x81, 0x82, 0x85, 0x87, 0x90
|
|
|
|
CODES = {0: "accepted", 1: "invalid_argument", 2: "unsupported", 3: "wrong_entry_point", 4: "security_unavailable",
|
|
5: "resource_limit", 6: "rejected", 7: "time_regression", 8: "identity_change_pending", 0x10: "unknown_opcode",
|
|
0x11: "malformed", 0x12: "not_configured", 0x13: "busy", 0x14: "no_credentials"}
|
|
ACCEPTED, INVALID_ARGUMENT, UNSUPPORTED, RESOURCE_LIMIT, REJECTED, TIME_REGRESSION = 0, 1, 2, 5, 6, 7
|
|
UNKNOWN_OPCODE, MALFORMED, NOT_CONFIGURED, NO_CREDENTIALS = 0x10, 0x11, 0x12, 0x14
|
|
|
|
ITS_EPOCH_UNIX_MS = 1072915200000 # 2004-01-01T00:00:00Z
|
|
LEAP_SECONDS_MS = 5000 # TimestampIts counts TAI: 5 leap seconds ahead of UTC
|
|
MAX_FRAME_PAYLOAD = 1536 # serial_link.hpp maximum_payload
|
|
MAX_MESSAGE = 512 # link message, header included
|
|
REQUEST_MAX = 1536 # complete host-to-station body
|
|
|
|
PANIC_PATTERNS = re.compile(r"Guru Meditation|abort\(\)|assert failed|Task watchdog|stack overflow|panic|Backtrace:|"
|
|
r"CORRUPT HEAP|heap_caps_|LoadProhibited|StoreProhibited|Illegal instruction|rst:0x(?!15)|"
|
|
r"Rebooting|Brownout|brownout", re.I)
|
|
|
|
STATUS_FIELDS = ( # name, offset, struct format; the 131-octet snapshot (link_protocol.cpp encode(Status))
|
|
("uptime_ms", 0, "<I"), ("configured", 4, "<B"), ("change_pending", 21, "<B"), ("tickets", 22, "<B"),
|
|
("signed_messages", 23, "<I"), ("refused_no_ticket", 27, "<I"), ("refused_change_pending", 31, "<I"),
|
|
("refused_permission", 35, "<I"), ("sign_failed", 39, "<I"), ("verified", 43, "<I"), ("rejected", 47, "<I"),
|
|
("requests_accepted", 51, "<I"), ("requests_refused", 55, "<I"), ("indications", 59, "<I"),
|
|
("radio_submitted", 63, "<I"), ("radio_failed", 67, "<I"), ("radio_received", 71, "<I"), ("radio_dropped", 75, "<I"),
|
|
("link_rx_frames", 79, "<I"), ("link_crc_errors", 83, "<I"), ("link_malformed", 87, "<I"), ("poti_updates", 91, "<I"),
|
|
("its_time_ms", 95, "<Q"), ("cbr_local", 103, "<H"), ("cbr_global", 105, "<H"), ("dcc_delta", 107, "<H"),
|
|
("heap_free", 111, "<I"), ("heap_min_free", 115, "<I"), ("heap_largest", 119, "<I"), ("dma_largest", 123, "<I"),
|
|
("temp_deci", 127, "<h"), ("battery_mv", 129, "<H"),
|
|
)
|
|
|
|
|
|
def crc16(data, crc=0xFFFF):
|
|
"""CRC-16/CCITT-FALSE, the frame checksum."""
|
|
for b in data:
|
|
crc ^= b << 8
|
|
for _ in range(8):
|
|
crc = ((crc << 1) ^ 0x1021) & 0xFFFF if crc & 0x8000 else (crc << 1) & 0xFFFF
|
|
return crc
|
|
|
|
|
|
def frame(ftype, payload, bad_crc=False):
|
|
head = bytes([ftype]) + struct.pack("<H", len(payload))
|
|
crc = crc16(head + payload)
|
|
if bad_crc:
|
|
crc ^= 0x5A5A
|
|
return b"\xAA\x55" + head + payload + struct.pack("<H", crc)
|
|
|
|
|
|
def link_message(opcode, seq, body=b"", flags=0):
|
|
return bytes([opcode, flags]) + struct.pack("<H", seq & 0xFFFF) + body
|
|
|
|
|
|
def timestamp_its(offset_ms=0):
|
|
return int(time.time() * 1000) - ITS_EPOCH_UNIX_MS + LEAP_SECONDS_MS + offset_ms
|
|
|
|
|
|
def parse_status(detail):
|
|
"""131-octet STATUS (or one of its older, shorter forms) -> dict, or None."""
|
|
if len(detail) not in (111, 127, 129, 131):
|
|
return None
|
|
out = {}
|
|
for name, off, fmt in STATUS_FIELDS:
|
|
if off + struct.calcsize(fmt) <= len(detail):
|
|
out[name] = struct.unpack_from(fmt, detail, off)[0]
|
|
out["raw_len"] = len(detail)
|
|
return out
|
|
|
|
|
|
# ---------------------------------------------------------------- message bodies --------------------------
|
|
|
|
def configure_body(secured=False, power=5, channel=180, station_type=2, beaconing=0, mac=None, radio=2):
|
|
"""STATION_CONFIGURE: the 6-octet form, or with `mac` the 16-octet form that names the MAC."""
|
|
if mac is None and radio == 2:
|
|
return struct.pack("<BHBBB", station_type, channel, power, 1 if secured else 0, beaconing)
|
|
mac = mac or bytes([2, 0xB3, 0x0A, 0xCE, 0, 1])
|
|
# type, security, address_configuration 0 (AUTO: the MID below), mid, beaconing, channel, power, radio, DP2, 1 s
|
|
return struct.pack("<BBB6sBHBBBB", station_type, 1 if secured else 0, 0, mac, beaconing, channel, power, radio, 2, 5)
|
|
|
|
|
|
def poti_body(lat=535546667, lon=100223889, offset_ms=0, speed_cms=0, flags=0x02 | 0x08):
|
|
"""POTI_UPDATE: Hamburg St. Georg, standing still, position accuracy indicator set."""
|
|
return struct.pack("<QiiHHHBiHH", timestamp_its(offset_ms), lat, lon, 300, 300, 0, flags, 0, speed_cms, 0)
|
|
|
|
|
|
def btp_body(payload, secured=False, port=2001, aid=36, permissions=bytes.fromhex("010000"), btp_type=1,
|
|
transport=1, profile=None, generated_at_ms=None, context=b"", extra=b""):
|
|
"""BTP_DATA_REQUEST. profile None: 1 unsecured / 2 secured by `secured`. Destination area only for transport 3."""
|
|
if profile is None:
|
|
profile = 2 if secured else 1
|
|
body = (struct.pack("<BHHBBBBBBHHI", btp_type, port, 0, transport, 1, profile, 0xFF, 0xFF, 0, 0, 0, aid)
|
|
+ bytes([len(permissions)]) + permissions + bytes([len(context)]) + context)
|
|
if transport == 3:
|
|
body += struct.pack("<BiiHHH", 0, 535546667, 100223889, 50, 0, 0)
|
|
body += struct.pack("<H", len(payload)) + payload
|
|
if generated_at_ms is not None:
|
|
body += struct.pack("<Q", generated_at_ms)
|
|
return body + extra
|
|
|
|
|
|
def max_btp_payload(permissions=b"\x01\x00\x00"):
|
|
"""Largest fl_sdu that keeps the whole request body at 1536 octets."""
|
|
return REQUEST_MAX - (19 + 1 + len(permissions) + 1 + 2)
|
|
|
|
|
|
# ---------------------------------------------------------------- test payloads ----------------------------
|
|
|
|
TEST_STATION_ID = 0x7E57B0A7
|
|
TEST_MESSAGE_ID = 0xF1 # not an assigned ETSI messageID: a receiver that decodes it as a CAM refuses it
|
|
|
|
|
|
def test_payload(run_id, seq, size):
|
|
"""A payload that no ITS receiver will take for a real message and that proves its own integrity.
|
|
|
|
ItsPduHeader (protocolVersion 2, messageID 0xF1, stationId 0x7E57B0A7), u32 run id, u32 sequence, u16 size, pseudo-random
|
|
filler seeded by (run, seq), CRC-32 of everything before it. At least 24 octets.
|
|
"""
|
|
size = max(24, size)
|
|
head = bytes([2, TEST_MESSAGE_ID]) + struct.pack(">I", TEST_STATION_ID) + struct.pack("<IIH", run_id, seq, size)
|
|
rnd = random.Random((run_id << 32) | seq)
|
|
filler = bytes(rnd.getrandbits(8) for _ in range(size - len(head) - 4))
|
|
body = head + filler
|
|
return body + struct.pack("<I", zlib.crc32(body))
|
|
|
|
|
|
def check_test_payload(payload):
|
|
"""(run_id, seq, size, ok) of a test payload; ok False when the size or the CRC is wrong. None if not ours."""
|
|
if len(payload) < 24 or payload[0] != 2 or payload[1] != TEST_MESSAGE_ID or payload[2:6] != struct.pack(">I", TEST_STATION_ID):
|
|
return None
|
|
run_id, seq, size = struct.unpack_from("<IIH", payload, 6)
|
|
ok = size == len(payload) and zlib.crc32(payload[:-4]) == struct.unpack("<I", payload[-4:])[0]
|
|
return run_id, seq, size, ok
|
|
|
|
|
|
# ---------------------------------------------------------------- the link ---------------------------------
|
|
|
|
class Reply:
|
|
def __init__(self, code, detail, latency):
|
|
self.code, self.detail, self.latency = code, detail, latency
|
|
|
|
@property
|
|
def name(self):
|
|
return CODES.get(self.code, "0x%02x" % self.code)
|
|
|
|
def __repr__(self):
|
|
return "Reply(%s, %d detail octets)" % (self.name, len(self.detail))
|
|
|
|
|
|
class Link:
|
|
"""One open station-link session over USB. A background thread decodes frames; everything is thread safe."""
|
|
|
|
def __init__(self, port, outdir, baud=115200, echo=None):
|
|
self.port, self.baud, self.outdir = port, baud, outdir
|
|
self.echo = echo or (lambda s: None)
|
|
self.ser = None
|
|
self.lock = threading.Lock()
|
|
self.pending = {} # seq -> [Event, Reply|None, sent_at]
|
|
self._seq = random.randrange(1000, 30000)
|
|
self.reader = None
|
|
self.stop = threading.Event()
|
|
self.v2x_rx = collections.deque(maxlen=20000) # (t, body) complete V2X_RX messages
|
|
self.raw_frames = collections.deque(maxlen=20000) # (t, flags, rssi, 802.11 frame)
|
|
self.counts = collections.Counter() # frames_ok, frames_bad_crc, opcodes, fragments, ...
|
|
self.frag = {} # (opcode, seq) -> [total, bytearray, t]
|
|
self.log_lines = collections.deque(maxlen=5000)
|
|
self.noise = bytearray() # bytes outside frames: ROM boot text, panic output
|
|
self.boots = 0 # "ESP-ROM:" banners seen on the port since open
|
|
self.panics = [] # (t, line) of every line matching PANIC_PATTERNS
|
|
self.opened_at = 0.0
|
|
os.makedirs(outdir, exist_ok=True)
|
|
self.app_version = self.app_compile_time = self.app_project = None # from the boot log (esp app_init lines)
|
|
self.logfile = open(os.path.join(outdir, "device.log"), "a", encoding="utf-8", buffering=1)
|
|
self.bootfile = open(os.path.join(outdir, "boot.log"), "a", encoding="utf-8", errors="replace", buffering=1)
|
|
self.statuslog = open(os.path.join(outdir, "status.csv"), "a", encoding="utf-8", buffering=1)
|
|
if self.statuslog.tell() == 0:
|
|
self.statuslog.write("time,phase," + ",".join(n for n, _, _ in STATUS_FIELDS) + "\n")
|
|
|
|
# -- open / close
|
|
def open(self, boot_wait=4.0, retries=40):
|
|
last = None
|
|
for _ in range(retries):
|
|
try:
|
|
self.ser = serial.Serial(self.port, self.baud, timeout=0.05, write_timeout=3)
|
|
break
|
|
except (serial.SerialException, OSError) as e: # the port briefly disappears when the board resets
|
|
last = e
|
|
time.sleep(0.5)
|
|
else:
|
|
raise RuntimeError("cannot open %s: %s" % (self.port, last))
|
|
self.ser.dtr = False
|
|
self.ser.rts = False
|
|
self.stop.clear()
|
|
self.opened_at = time.time()
|
|
self.boots = 0
|
|
self.noise.clear()
|
|
self.reader = threading.Thread(target=self._read_loop, daemon=True)
|
|
self.reader.start()
|
|
time.sleep(boot_wait)
|
|
|
|
def close(self):
|
|
self.stop.set()
|
|
if self.reader:
|
|
self.reader.join(2)
|
|
if self.ser:
|
|
try:
|
|
self.ser.close()
|
|
except Exception:
|
|
pass
|
|
self.ser = None
|
|
|
|
def reboot(self, boot_wait=4.0):
|
|
"""Close and reopen the port: the board resets. Clears the receive queues."""
|
|
self.close()
|
|
time.sleep(0.7)
|
|
self.open(boot_wait)
|
|
self.v2x_rx.clear()
|
|
self.raw_frames.clear()
|
|
self.frag.clear()
|
|
with self.lock:
|
|
self.pending.clear()
|
|
|
|
# -- reader thread
|
|
def _read_loop(self):
|
|
buf = bytearray()
|
|
while not self.stop.is_set():
|
|
try:
|
|
data = self.ser.read(4096)
|
|
except (serial.SerialException, OSError, AttributeError, TypeError):
|
|
time.sleep(0.2)
|
|
continue
|
|
if not data:
|
|
continue
|
|
buf += data
|
|
while True:
|
|
i = buf.find(b"\xAA\x55")
|
|
if i < 0:
|
|
if len(buf) > 8192:
|
|
self._noise(bytes(buf[:-2]))
|
|
del buf[:-2]
|
|
break
|
|
if i > 0:
|
|
self._noise(bytes(buf[:i]))
|
|
del buf[:i]
|
|
if len(buf) < 7:
|
|
break
|
|
ftype, n = buf[2], struct.unpack("<H", buf[3:5])[0]
|
|
if n > MAX_FRAME_PAYLOAD:
|
|
del buf[:2]
|
|
self.counts["frames_bad_length"] += 1
|
|
continue
|
|
if len(buf) < 5 + n + 2:
|
|
break
|
|
payload = bytes(buf[5:5 + n])
|
|
got = struct.unpack("<H", buf[5 + n:7 + n])[0]
|
|
if got != crc16(bytes(buf[2:5 + n])):
|
|
del buf[:2] # resync at the next marker
|
|
self.counts["frames_bad_crc"] += 1
|
|
continue
|
|
del buf[:5 + n + 2]
|
|
self.counts["frames_ok"] += 1
|
|
try:
|
|
self._frame(ftype, payload)
|
|
except Exception as e: # a bug here must not kill the reader
|
|
self.counts["frame_handler_errors"] += 1
|
|
self.echo("reader: %r" % e)
|
|
|
|
def _noise(self, data):
|
|
self.noise += data
|
|
text = data.decode("utf-8", "replace")
|
|
if "ESP-ROM:" in text:
|
|
self.boots += 1
|
|
for line in text.splitlines():
|
|
if PANIC_PATTERNS.search(line):
|
|
self.panics.append((time.time(), line.strip()))
|
|
self.bootfile.write(text)
|
|
for key, attr in (("App version:", "app_version"), ("Compile time:", "app_compile_time"), ("Project name:", "app_project")):
|
|
m = re.search(re.escape(key) + r"[ \t]*([^\r\n]+)", text)
|
|
if m:
|
|
setattr(self, attr, m.group(1).strip())
|
|
|
|
def _frame(self, ftype, payload):
|
|
now = time.time()
|
|
if ftype == LOG:
|
|
text = payload.decode("utf-8", "replace").rstrip()
|
|
self.log_lines.append((now, text))
|
|
self.logfile.write("%.3f %s\n" % (now, text))
|
|
if PANIC_PATTERNS.search(text):
|
|
self.panics.append((now, text))
|
|
return
|
|
if ftype != LINK or len(payload) < 4:
|
|
self.counts["frames_other_type"] += 1
|
|
return
|
|
op, flags, seq = payload[0], payload[1], struct.unpack("<H", payload[2:4])[0]
|
|
body = payload[4:]
|
|
self.counts["op_0x%02x" % op] += 1
|
|
if flags:
|
|
body = self._reassemble(op, flags, seq, body, now)
|
|
if body is None:
|
|
return
|
|
if op == CONFIRM:
|
|
with self.lock:
|
|
p = self.pending.get(seq)
|
|
if p and len(body) >= 2:
|
|
p[1] = Reply(body[0], body[2:2 + body[1]], now - p[2])
|
|
p[0].set()
|
|
else:
|
|
self.counts["confirm_unmatched"] += 1
|
|
elif op == V2X_RX:
|
|
self.v2x_rx.append((now, body))
|
|
elif op == RAW_FRAME:
|
|
if len(body) >= 20 and body[6:10] == b"ITS5":
|
|
n = struct.unpack("<H", body[18:20])[0]
|
|
self.raw_frames.append((now, body[4], struct.unpack("<b", body[5:6])[0], bytes(body[20:20 + n])))
|
|
else:
|
|
self.counts["raw_frame_malformed"] += 1
|
|
|
|
def _reassemble(self, op, flags, seq, body, now):
|
|
"""Strict host-side reassembly (spec: validate length + offset, drop gaps/duplicates, complete exactly)."""
|
|
key = (op, seq)
|
|
for k in [k for k, v in self.frag.items() if now - v[2] > 2.0]:
|
|
del self.frag[k]
|
|
self.counts["frag_timeouts"] += 1
|
|
if len(body) < 4:
|
|
self.counts["frag_errors"] += 1
|
|
return None
|
|
total, offset = struct.unpack("<HH", body[:4])
|
|
data = body[4:]
|
|
cur = self.frag.get(key)
|
|
if flags == 1:
|
|
if cur is not None:
|
|
self.counts["frag_restarted"] += 1
|
|
if offset != 0:
|
|
self.counts["frag_errors"] += 1
|
|
return None
|
|
cur = self.frag[key] = [total, bytearray(), now]
|
|
elif cur is None:
|
|
self.counts["frag_orphans"] += 1
|
|
return None
|
|
if cur[0] != total or len(cur[1]) != offset:
|
|
self.counts["frag_errors"] += 1
|
|
del self.frag[key]
|
|
return None
|
|
cur[1] += data
|
|
cur[2] = now
|
|
if flags == 3:
|
|
del self.frag[key]
|
|
if len(cur[1]) != total:
|
|
self.counts["frag_errors"] += 1
|
|
return None
|
|
self.counts["frag_complete"] += 1
|
|
return bytes(cur[1])
|
|
if len(cur[1]) >= total:
|
|
self.counts["frag_errors"] += 1
|
|
del self.frag[key]
|
|
return None
|
|
|
|
# -- sending
|
|
def next_seq(self):
|
|
self._seq = (self._seq + 1) & 0xFFFF or 1
|
|
return self._seq
|
|
|
|
def write(self, data):
|
|
with self.lock:
|
|
ser = self.ser
|
|
if ser is None:
|
|
raise RuntimeError("port closed")
|
|
ser.write(data)
|
|
|
|
def send(self, opcode, body=b"", seq=None, flags=0):
|
|
seq = self.next_seq() if seq is None else seq
|
|
self.write(frame(LINK, link_message(opcode, seq, body, flags)))
|
|
return seq
|
|
|
|
def request(self, opcode, body=b"", timeout=2.0, seq=None):
|
|
"""Send one request and wait for its CONFIRM; Reply or None on timeout.
|
|
|
|
A body that does not fit one 512-octet link message is sent in fragments, as the spec requires (the station
|
|
silently ignores an unfragmented message over 512 octets).
|
|
"""
|
|
seq = self.next_seq() if seq is None else seq
|
|
ev = [threading.Event(), None, time.time()]
|
|
with self.lock:
|
|
self.pending[seq] = ev
|
|
try:
|
|
if len(body) > MAX_MESSAGE - 4:
|
|
self.send_fragmented(opcode, body, seq=seq, cap=MAX_MESSAGE - 8)
|
|
else:
|
|
self.write(frame(LINK, link_message(opcode, seq, body)))
|
|
ev[0].wait(timeout)
|
|
return ev[1]
|
|
finally:
|
|
with self.lock:
|
|
self.pending.pop(seq, None)
|
|
|
|
def send_fragmented(self, opcode, body, seq=None, cap=240, total_override=None):
|
|
"""The request fragments of the spec: flags 1/2/3, then u16 total, u16 offset, data. Returns the sequence."""
|
|
seq = self.next_seq() if seq is None else seq
|
|
total = len(body) if total_override is None else total_override
|
|
for off in range(0, len(body), cap):
|
|
chunk = body[off:off + cap]
|
|
flags = 1 if off == 0 else (3 if off + len(chunk) == len(body) else 2)
|
|
self.write(frame(LINK, link_message(opcode, seq, struct.pack("<HH", total, off) + chunk, flags)))
|
|
return seq
|
|
|
|
def request_fragmented(self, opcode, body, timeout=3.0, cap=240):
|
|
seq = self.next_seq()
|
|
ev = [threading.Event(), None, time.time()]
|
|
with self.lock:
|
|
self.pending[seq] = ev
|
|
try:
|
|
self.send_fragmented(opcode, body, seq=seq, cap=cap)
|
|
ev[0].wait(timeout)
|
|
return ev[1]
|
|
finally:
|
|
with self.lock:
|
|
self.pending.pop(seq, None)
|
|
|
|
# -- conveniences
|
|
def status(self, timeout=2.0):
|
|
r = self.request(STATUS_REQUEST, b"", timeout)
|
|
if r is None or r.code != ACCEPTED:
|
|
return None
|
|
s = parse_status(r.detail)
|
|
if s is not None:
|
|
s["_t"] = time.time()
|
|
return s
|
|
|
|
def wait_status(self, timeout=15.0):
|
|
"""Poll STATUS until the board answers (after a reset), or None."""
|
|
end = time.time() + timeout
|
|
while time.time() < end:
|
|
s = self.status(1.0)
|
|
if s:
|
|
return s
|
|
return None
|
|
|
|
def log_status(self, s, phase):
|
|
if s:
|
|
self.statuslog.write("%.3f,%s,%s\n" % (s["_t"], phase, ",".join(str(s.get(n, "")) for n, _, _ in STATUS_FIELDS)))
|
|
|
|
def configure(self, secured=False, power=5, mac=None, timeout=5.0, **kw):
|
|
r = self.request(STATION_CONFIGURE, configure_body(secured=secured, power=power, mac=mac, **kw), timeout)
|
|
return r
|
|
|
|
def raw_capture(self, mode, timeout=2.0):
|
|
return self.request(RAW_CAPTURE, bytes([mode]), timeout)
|
|
|
|
def poti(self, **kw):
|
|
self.send(POTI_UPDATE, poti_body(**kw))
|
|
|
|
def drain_log(self, since):
|
|
return [t for (ts, t) in self.log_lines if ts >= since]
|