From e01764d1f20039bf497541adc9dac615d1dce21a Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Tue, 2 Apr 2024 10:06:58 -0300 Subject: [PATCH] src: decoder: Fix: Skip to final step if payload lenght is 0 --- src/decoder.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/decoder.rs b/src/decoder.rs index 0202f5e77..eb5ac8107 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -65,7 +65,12 @@ impl Decoder { self.message.message_id = u16::from_le_bytes([self.buffer[2], self.buffer[3]]); self.message.src_device_id = self.buffer[4]; self.message.dst_device_id = self.buffer[5]; - self.state = DecoderState::ReadingPayload; + + if self.message.payload_length == 0 { + self.state = DecoderState::ReadingChecksum + } else { + self.state = DecoderState::ReadingPayload; + } self.buffer.clear(); } return DecoderResult::InProgress;