Skip to content

Commit

Permalink
Fixes bugs around packet length.
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz committed Jul 4, 2021
1 parent d875dda commit b97b1dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/dcc/Receiver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public:
clear_packet();
pkt_->dlc = 0;
pkt_->payload[0] = 0;
pkt_->packet_header.skip_ec = 1;
}
else
{
Expand Down Expand Up @@ -209,6 +210,10 @@ public:
else
{
// end of packet 1 bit.
if (havePacket_)
{
pkt_->dlc++;
}
parseState_ = DCC_MAYBE_CUTOUT;
return;
}
Expand All @@ -233,7 +238,7 @@ public:
pkt_->dlc++;
if (pkt_->dlc >= DCC_PACKET_MAX_PAYLOAD)
{
pkt_ = nullptr;
havePacket_ = false;
}
else
{
Expand Down
12 changes: 5 additions & 7 deletions src/freertos_drivers/common/DccDecoder.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ __attribute__((optimize("-O3"))) void DccDecoder<Module>::interrupt_handler()
{
prepCutout_ = true;
Module::dcc_before_cutout_hook();
if (decoder_.pkt())
{
decoder_.pkt()->header_raw_data = 0;
decoder_.pkt()->packet_header.skip_ec = 1;
nextPacketFilled_ = true;
}
Module::trigger_os_interrupt();
}
// If we are at the second half of the last 1 bit and the
// value of the input pin is 1, then we cannot recognize when
Expand All @@ -324,6 +317,11 @@ __attribute__((optimize("-O3"))) void DccDecoder<Module>::interrupt_handler()
Module::set_cap_timer_delay_usec(RAILCOM_CUTOUT_PRE);
inCutout_ = true;
cutoutState_ = 0;
if (decoder_.pkt())
{
nextPacketFilled_ = true;
}
Module::trigger_os_interrupt();
}
else if (decoder_.state() == dcc::DccDecoder::DCC_CUTOUT)
{
Expand Down

0 comments on commit b97b1dd

Please sign in to comment.