fw: reset packet parser after full packet received

This commit is contained in:
David Lenfesty 2023-06-16 16:29:52 -06:00
parent 1ab57fe316
commit ea94072e42
3 changed files with 9 additions and 4 deletions

View File

@ -42,6 +42,8 @@ impl CommandInterface {
(processed_bytes, res.ok())
});
defmt::debug!("Received data");
// Check for socket errors
let packet = match res {
// We got a packet! unwrap it

View File

@ -89,8 +89,9 @@ fn main() -> ! {
// Set a keepalive on the socket to handle unexpected client disconnects
{
let mut sock = socket_set.get_mut::<TcpSocket>(command_socket);
sock.set_keep_alive(Some(Duration::from_secs(5)));
sock.set_timeout(Some(Duration::from_secs(5)))
// TODO these values are obscene, should fix the underlying bug
sock.set_keep_alive(Some(Duration::from_secs(2)));
sock.set_timeout(Some(Duration::from_secs(10)))
}

View File

@ -194,11 +194,13 @@ impl PacketParser {
// Check CRC
7 => {
if self.crc.get_crc() == byte {
return Ok(CommandPacket {
let out = CommandPacket {
is_write: self.is_write,
setting: self.setting,
value: self.value,
});
};
self.reset();
return Ok(out);
} else {
self.reset();
return Err(Error::BadCrc);