Skip to content

Commit

Permalink
can2040: Convert report_is_rx_eof_pending() to report_is_not_in_tx()
Browse files Browse the repository at this point in the history
The report_state may change during a "matched" event on a successfully
received message, which would result in report_is_rx_eof_pending() not
properly reporting that a short EOF is permissible.

Invert the test to avoid this case - thus requiring the full EOF
whenever a self transmit is in progress.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Sep 12, 2023
1 parent 802e4cd commit 680ca7e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/can2040.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Software CANbus implementation for rp2040
//
// Copyright (C) 2022 Kevin O'Connor <[email protected]>
// Copyright (C) 2022,2023 Kevin O'Connor <[email protected]>
//
// This file may be distributed under the terms of the GNU GPLv3 license.

Expand Down Expand Up @@ -759,11 +759,11 @@ report_handle_eof(struct can2040 *cd)
pio_match_clear(cd);
}

// Check if in an rx message is being processed
// Check if message being processed is an rx message (not self feedback from tx)
static int
report_is_rx_eof_pending(struct can2040 *cd)
report_is_not_in_tx(struct can2040 *cd)
{
return cd->report_state == RS_NEED_RX_EOF;
return !(cd->report_state & RS_NEED_TX_ACK);
}

// Parser found a new message start
Expand Down Expand Up @@ -1139,7 +1139,7 @@ data_state_update_eof1(struct can2040 *cd, uint32_t data)
// Success
report_note_eof_success(cd);
data_state_go_next(cd, MS_START, 1);
} else if (data >= 0x1c || (data >= 0x18 && report_is_rx_eof_pending(cd))) {
} else if (data >= 0x1c || (data >= 0x18 && report_is_not_in_tx(cd))) {
// Message fully transmitted - followed by "overload frame"
report_note_eof_success(cd);
data_state_go_discard(cd);
Expand Down

0 comments on commit 680ca7e

Please sign in to comment.