From b6c249023ba2317d62add9c7ee2dea1ddeebb983 Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Sun, 19 Dec 2021 23:50:17 +0100 Subject: [PATCH] Adds extra unit tests where the CV read has a couple of ACKs on it. (#592) --- src/openlcb/TractionCvSpace.cxxtest | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/openlcb/TractionCvSpace.cxxtest b/src/openlcb/TractionCvSpace.cxxtest index dc95cd53c..ebc16f9b4 100644 --- a/src/openlcb/TractionCvSpace.cxxtest +++ b/src/openlcb/TractionCvSpace.cxxtest @@ -101,6 +101,42 @@ TEST_F(TractionCvTest, SingleCvRead) wait(); } +TEST_F(TractionCvTest, SingleCvReadWithStuffing) +{ + print_all_packets(); + expect_packet(":X19A28272N088380;"); + EXPECT_CALL(track_if_, packet(ElementsAre(0xC0, 0xAF, 0b11100100, 0x37, 0), + expected_feedback_key())).Times(1); + send_packet(":X1A272883N204000000037EF01;"); + wait(); + Mock::VerifyAndClear(&track_if_); + expect_packet(":X1A883272N205000000037EFC5;"); + // payload stuffed with 0x0f / ACK2 bytes + send_railcom_response(expected_feedback_key(), + {0b10100101, 0b10100110, 0x0F, 0x0F, 0x0F, 0x0F}); + wait(); + send_packet(":X19A28883N027200;"); + wait(); +} + +TEST_F(TractionCvTest, SingleCvReadWithOtherStuffing) +{ + print_all_packets(); + expect_packet(":X19A28272N088380;"); + EXPECT_CALL(track_if_, packet(ElementsAre(0xC0, 0xAF, 0b11100100, 0x37, 0), + expected_feedback_key())).Times(1); + send_packet(":X1A272883N204000000037EF01;"); + wait(); + Mock::VerifyAndClear(&track_if_); + expect_packet(":X1A883272N205000000037EFC5;"); + // payload stuffed with 0xF0 / ACK bytes + send_railcom_response(expected_feedback_key(), + {0b10100101, 0b10100110, 0xF0, 0xF0, 0xF0, 0xF0}); + wait(); + send_packet(":X19A28883N027200;"); + wait(); +} + TEST_F(TractionCvTest, SingleCvBusyRetry) { print_all_packets(); @@ -135,6 +171,9 @@ TEST_F(TractionCvTest, SingleCvWrite) wait(); } +// Tests the human-operable part of the CV space. This has individual variable +// for different parameters, and it is expected that JMRI will be used to +// individually set these. TEST_F(TractionCvTest, IndirectWrite) { print_all_packets();