From 769c62ac5d6e8aab5e56d424932085e37bb8532e Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Mon, 19 Sep 2022 21:07:09 +0200 Subject: [PATCH] Makes "found short" be persistent in programming track backend operations. (#655) When we get a backend op, we check if the output is already disabled due to short, and if yes, we report that to the caller. * Adds missing braces. --- src/dcc/ProgrammingTrackBackend.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/dcc/ProgrammingTrackBackend.hxx b/src/dcc/ProgrammingTrackBackend.hxx index b556dcd7d..7dd4f282b 100644 --- a/src/dcc/ProgrammingTrackBackend.hxx +++ b/src/dcc/ProgrammingTrackBackend.hxx @@ -191,6 +191,10 @@ public: Action entry() override { request()->resultCode = OPERATION_PENDING; + auto* pgm = get_dcc_output(DccOutput::PGM); + const bool has_short = pgm->get_disable_output_reasons() & + (uint8_t)DccOutput::DisableReason::SHORTED; + switch (request()->cmd_) { case ProgrammingTrackRequest::Type::ENTER_SERVICE_MODE: @@ -200,9 +204,17 @@ public: return call_immediately(STATE(exit_service_mode)); case ProgrammingTrackRequest::Type::SEND_RESET: + if (has_short) + { + request()->hasShortCircuit_ = 1; + } return call_immediately(STATE(send_reset)); case ProgrammingTrackRequest::Type::SEND_SERVICE_PACKET: + if (has_short) + { + request()->hasShortCircuit_ = 1; + } return call_immediately(STATE(send_service_packet)); } DIE("Unknown programming track request command"); @@ -321,6 +333,7 @@ private: Action send_reset() { + // record that we want to send reset packets. request()->packetToSend_.set_dcc_reset_all_decoders(); request()->packetToSend_.packet_header.send_long_preamble = 1;