Skip to content

Commit

Permalink
Makes "found short" be persistent in programming track backend operat…
Browse files Browse the repository at this point in the history
…ions. (#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.
  • Loading branch information
balazsracz authored Sep 19, 2022
1 parent 4764083 commit 769c62a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dcc/ProgrammingTrackBackend.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 769c62a

Please sign in to comment.