From 5427e79300b00ddfb0578a0ba8c9a654ea4c6617 Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin <80598030+RaulTrombin@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:22:34 -0300 Subject: [PATCH] Update src/decoder.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Antônio Cardoso --- src/decoder.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/decoder.rs b/src/decoder.rs index 6500e6279..b609e6264 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -92,10 +92,11 @@ impl Decoder { self.reset(); let message = self.message.clone(); self.message = ProtocolMessage::new(); - if message.has_valid_crc() { - return DecoderResult::Success(message); + if !message.has_valid_crc() { + return DecoderResult::Error(ParseError::ChecksumError(message)); } - return DecoderResult::Error(ParseError::ChecksumError(message)); + + return DecoderResult::Success(message); } return DecoderResult::InProgress; }