v0.12.6 #10
@@ -1833,6 +1833,26 @@ def _encode_compliance_config(
|
|||||||
_ANC = b'\xbe\x80\x00\x00\x00\x00'
|
_ANC = b'\xbe\x80\x00\x00\x00\x00'
|
||||||
_anc = buf.find(_ANC, 0, 150)
|
_anc = buf.find(_ANC, 0, 150)
|
||||||
|
|
||||||
|
# Log anchor position every time so we can detect unexpected shifts due to
|
||||||
|
# DLE jitter or firmware differences. Expected position is ~15.
|
||||||
|
if _anc < 0:
|
||||||
|
log.warning(
|
||||||
|
"_encode_compliance_config: anchor NOT FOUND in cfg[0:150] "
|
||||||
|
"(buf len=%d) — all anchor-relative writes will be skipped",
|
||||||
|
len(buf),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
log.info(
|
||||||
|
"_encode_compliance_config: anchor at cfg[%d] buf_len=%d "
|
||||||
|
"(expected ~15; fields: recording_mode@%d sample_rate@%d:%d "
|
||||||
|
"histogram_interval@%d:%d record_time@%d:%d)",
|
||||||
|
_anc, len(buf),
|
||||||
|
_anc - 7,
|
||||||
|
_anc - 6, _anc - 4,
|
||||||
|
_anc - 4, _anc - 2,
|
||||||
|
_anc + 6, _anc + 10,
|
||||||
|
)
|
||||||
|
|
||||||
if recording_mode is not None:
|
if recording_mode is not None:
|
||||||
if _anc < 7:
|
if _anc < 7:
|
||||||
log.warning("_encode_compliance_config: anchor not found — cannot write recording_mode")
|
log.warning("_encode_compliance_config: anchor not found — cannot write recording_mode")
|
||||||
@@ -2001,6 +2021,27 @@ def _decode_compliance_config_into(data: bytes, info: DeviceInfo) -> None:
|
|||||||
# _anchor + 6 : record_time (float32 BE)
|
# _anchor + 6 : record_time (float32 BE)
|
||||||
_ANCHOR = b'\xbe\x80\x00\x00\x00\x00'
|
_ANCHOR = b'\xbe\x80\x00\x00\x00\x00'
|
||||||
_anchor = data.find(_ANCHOR, 0, 150)
|
_anchor = data.find(_ANCHOR, 0, 150)
|
||||||
|
|
||||||
|
# Log anchor position on every decode so we can compare read vs write and
|
||||||
|
# catch unexpected shifts from DLE jitter or firmware differences.
|
||||||
|
# Expected position is ~15 for the E5 read payload (anchor - 8 = recording_mode).
|
||||||
|
if _anchor < 0:
|
||||||
|
log.warning(
|
||||||
|
"_decode_compliance_config_into: anchor NOT FOUND in data[0:150] (len=%d)",
|
||||||
|
len(data),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
log.info(
|
||||||
|
"_decode_compliance_config_into: anchor at data[%d] data_len=%d "
|
||||||
|
"(expected ~15; recording_mode@%d sample_rate@%d:%d "
|
||||||
|
"histogram_interval@%d:%d record_time@%d:%d)",
|
||||||
|
_anchor, len(data),
|
||||||
|
_anchor - 8,
|
||||||
|
_anchor - 6, _anchor - 4,
|
||||||
|
_anchor - 4, _anchor - 2,
|
||||||
|
_anchor + 6, _anchor + 10,
|
||||||
|
)
|
||||||
|
|
||||||
if _anchor >= 8 and _anchor + 10 <= len(data):
|
if _anchor >= 8 and _anchor + 10 <= len(data):
|
||||||
try:
|
try:
|
||||||
config.recording_mode = data[_anchor - 8]
|
config.recording_mode = data[_anchor - 8]
|
||||||
|
|||||||
Reference in New Issue
Block a user