From 1fa3866147ee794ec098c7be4e1615118e7812d7 Mon Sep 17 00:00:00 2001 From: Philippe Leduc Date: Thu, 21 Oct 2021 14:56:40 +0200 Subject: [PATCH] Fix: LRW expected working counter is wrong. (#19) --- src/Bus.cc | 2 +- unit/bus-t.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bus.cc b/src/Bus.cc index 8737fa45..96684305 100644 --- a/src/Bus.cc +++ b/src/Bus.cc @@ -486,7 +486,7 @@ namespace kickcat auto process = [pi_frame](DatagramHeader const*, uint8_t const* data, uint16_t wkc) { - if (wkc != pi_frame.inputs.size()) + if (wkc != (pi_frame.inputs.size() + pi_frame.outputs.size() * 2)) { DEBUG_PRINT("Invalid working counter\n"); return DatagramState::INVALID_WKC; diff --git a/unit/bus-t.cc b/unit/bus-t.cc index bb70f826..33fe83fe 100644 --- a/unit/bus-t.cc +++ b/unit/bus-t.cc @@ -322,7 +322,7 @@ TEST_F(BusTest, logical_cmd) logical_write = 0x1716151413121110; std::memcpy(slave.output.data, &logical_write, sizeof(int64_t)); checkSendFrame(Command::LRW, logical_write); - handleReply({logical_read}); + handleReply({logical_read}, 3); bus.processDataReadWrite([](DatagramState const&){}); for (int i = 0; i < 8; ++i)