Skip to content

Commit b3448b9

Browse files
authored
Send three resets when connecting, not just one (#689)
* Send three resets when connecting, not just one * Fix unit test
1 parent 6972103 commit b3448b9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

bellows/ash.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,4 +715,8 @@ async def send_data(self, data: bytes) -> None:
715715
)
716716

717717
def send_reset(self) -> None:
718+
# Some adapters seem to send a NAK immediately but still process the reset frame
719+
# if one eventually makes it through
720+
self._write_frame(RstFrame(), prefix=(Reserved.CANCEL,))
721+
self._write_frame(RstFrame(), prefix=(Reserved.CANCEL,))
718722
self._write_frame(RstFrame(), prefix=(Reserved.CANCEL,))

tests/test_ash.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ async def test_ash_protocol_startup(caplog):
438438

439439
assert ezsp.reset_received.mock_calls == [call(t.NcpResetCode.RESET_SOFTWARE)]
440440
assert protocol._write_frame.mock_calls == [
441-
call(ash.RstFrame(), prefix=(ash.Reserved.CANCEL,))
441+
# We send three
442+
call(ash.RstFrame(), prefix=(ash.Reserved.CANCEL,)),
443+
call(ash.RstFrame(), prefix=(ash.Reserved.CANCEL,)),
444+
call(ash.RstFrame(), prefix=(ash.Reserved.CANCEL,)),
442445
]
443446

444447
protocol._write_frame.reset_mock()

0 commit comments

Comments
 (0)