Skip to content

Commit 7e3a596

Browse files
ConnorRigbyfhunleth
authored andcommitted
Only retry transactions on CRC Mismatch
This prevents i2c nacs, bus hangs and other similar issues from doing retries that will never complete
1 parent 53e0780 commit 7e3a596

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/sht4x/comm.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ defmodule SHT4X.Comm do
4343

4444
defp repeat_transaction(transport, command, delay_ms, retries) do
4545
case do_transaction(transport, command, delay_ms) do
46-
{:error, _any_reason} when retries > 0 ->
46+
# only retry in the event of a CRC mismatch
47+
{:error, :crc_mismatch} when retries > 0 ->
4748
repeat_transaction(transport, command, delay_ms, retries - 1)
4849

4950
result ->

0 commit comments

Comments
 (0)