From 841277d7c09477f72651493514239c7e7c1e42c6 Mon Sep 17 00:00:00 2001 From: Helge Kruse Date: Mon, 8 Dec 2025 18:33:46 +0100 Subject: [PATCH] sdcard_sd: Decode commands always as command The SD card decoder predicts always the next token type from the current token type. This is working if the SD card is responding as expected. But if the card is not responding, the prediction is wrong. A second command token is decoded as a response token. To fix this behavior the decoder state is set to St.GET_COMMAND_TOKEN, if the current token is a command token. --- decoders/sdcard_sd/pd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/decoders/sdcard_sd/pd.py b/decoders/sdcard_sd/pd.py index a6e983423..fdce41a6f 100644 --- a/decoders/sdcard_sd/pd.py +++ b/decoders/sdcard_sd/pd.py @@ -142,6 +142,11 @@ def get_token_bits(self, cmd_pin, n): self.token.append(Bit(self.samplenum, self.samplenum, cmd_pin)) if len(self.token) > 0: self.token[len(self.token) - 2].es = self.samplenum + # check the transmission bit if this is a command + if len(self.token) == 2: + transmission = self.token[1].bit + if transmission: + self.state = St.GET_COMMAND_TOKEN if len(self.token) < n: return False self.token[n - 1].es += self.token[n - 1].ss - self.token[n - 2].ss