mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-04-28 03:08:08 +00:00
fix timer overflow?
This commit is contained in:
@ -16,7 +16,8 @@ WRONG_PACK_SYNC — отдельное событие с причиной и т
|
||||
отброшенных фронтов; без флага эти события только в счётчиках сводки.
|
||||
|
||||
Не моделирует IRDEBUG_SERIAL_SOFT_REJECT (жёсткий Wrong sync).
|
||||
Таймауты: между фронтами, если gap > IR_timeout*2 и isRecive — checkTimeout.
|
||||
Таймауты: как IR_DecoderRaw::tick — listenStart и checkTimeout в начале каждого тика (не только при пустых
|
||||
очередях), пауза > IR_timeout*2 по lastEdgeTime; при checkTimeout: isReciveRaw=0, firstRX(), lastEdgeTime=now.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@ -360,8 +361,8 @@ class DecoderSim:
|
||||
|
||||
def listen_start(self, now: int) -> None:
|
||||
to = ir_timeout_us(self.rise_sync_time)
|
||||
if self.is_recive_raw and (now - self.prev_rise) > to * 2:
|
||||
self.events.append(f"t={now} listenStart abort raw (gap from prev_rise)")
|
||||
if self.is_recive_raw and self.last_edge_time > 0 and (now - self.last_edge_time) > to * 2:
|
||||
self.events.append(f"t={now} listenStart abort raw (gap since last edge, как IR_DecoderRaw)")
|
||||
self.is_recive_raw = False
|
||||
self._clear_packet_state()
|
||||
self.first_rx()
|
||||
@ -371,9 +372,12 @@ class DecoderSim:
|
||||
return
|
||||
to = ir_timeout_us(self.rise_sync_time)
|
||||
if now - self.last_edge_time > to * 2:
|
||||
self.events.append(f"t={now} checkTimeout (gap since last edge)")
|
||||
self.events.append(f"t={now} checkTimeout -> isReciveRaw=0, firstRX() (как IR_DecoderRaw)")
|
||||
self.is_recive = False
|
||||
self.last_edge_time = now
|
||||
self.is_recive_raw = False
|
||||
self._clear_packet_state()
|
||||
self.first_rx()
|
||||
# Не last_edge_time = now: в прошивке убрано — расхождение с метками фронтов из очереди.
|
||||
|
||||
def write_to_buffer(self, bit_val: int) -> None:
|
||||
if self.i_data_buffer > DATA_BYTE_SIZE_MAX * 8:
|
||||
@ -382,6 +386,7 @@ class DecoderSim:
|
||||
if self.is_buffer_overflow or self.is_preamb or self.is_wrong_pack:
|
||||
self.is_recive = False
|
||||
self.is_recive_raw = False
|
||||
self.first_rx()
|
||||
return
|
||||
|
||||
if self.buf_bit_pos == self.next_control_bit:
|
||||
@ -478,6 +483,9 @@ class DecoderSim:
|
||||
def tick_edge(self, t: int, level: int) -> None:
|
||||
"""Один фронт: level = состояние линии ПОСЛЕ фронта (как dir в C++)."""
|
||||
self.listen_start(t)
|
||||
to = ir_timeout_us(self.rise_sync_time)
|
||||
if self.is_recive and self.last_edge_time > 0 and (t - self.last_edge_time) > to * 2:
|
||||
self.check_timeout(t)
|
||||
self.last_edge_time = t
|
||||
rising = level == 1
|
||||
|
||||
@ -689,9 +697,6 @@ def main() -> int:
|
||||
|
||||
dec = DecoderSim(verbose=args.verbose)
|
||||
for e in edges:
|
||||
to_us = ir_timeout_us(dec.rise_sync_time)
|
||||
if dec.is_recive and dec.last_edge_time > 0 and (e.t_us - dec.last_edge_time) > to_us * 2:
|
||||
dec.check_timeout(e.t_us)
|
||||
dec.tick_edge(e.t_us, e.level)
|
||||
|
||||
print("--- События декодера (первые N), пакеты разделены пустой строкой ---")
|
||||
|
||||
Reference in New Issue
Block a user