Skip to content

Commit

Permalink
cansequence: add option to ignore classical CAN frames
Browse files Browse the repository at this point in the history
  • Loading branch information
marckleinebudde committed Nov 29, 2023
1 parent bd835f2 commit 6421906
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cansequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static bool running = true;
static volatile sig_atomic_t signal_num;
static bool infinite = true;
static bool canfd = false;
static bool canfd_strict = false;
static unsigned int drop_until_quit;
static unsigned int drop_count;
static bool use_poll = false;
Expand Down Expand Up @@ -66,6 +67,7 @@ static void print_usage(char *prg)
"Options:\n"
" -e, --extended send/receive extended frames\n"
" -f, --canfd send/receive CAN-FD CAN frames\n"
" -s, --strict refuse classical CAN frames in CAN-FD mode\n"
" -b, --brs send CAN-FD CAN frames with bitrate switch (BRS)\n"
" -i, --identifier=ID CAN Identifier (default = %u)\n"
" --loop=COUNT send message COUNT times\n"
Expand Down Expand Up @@ -151,6 +153,12 @@ static void do_receive()

sequence_rx = frame.data[0];

if (canfd_strict && nbytes == CAN_MTU) {
if (verbose > 1)
printf("sequence CNT: 0x%07x RX: 0x%02x (ignoring classical CAN frame)\n", sequence, sequence_rx);
continue;
}

if (sequence_init) {
sequence_init = false;
sequence = sequence_rx;
Expand Down Expand Up @@ -291,7 +299,7 @@ int main(int argc, char **argv)
{ 0, 0, 0, 0 },
};

while ((opt = getopt_long(argc, argv, "efbi:pq::rvh?", long_options, NULL)) != -1) {
while ((opt = getopt_long(argc, argv, "efsbi:pq::rvh?", long_options, NULL)) != -1) {
switch (opt) {
case 'e':
extended = true;
Expand All @@ -301,6 +309,10 @@ int main(int argc, char **argv)
canfd = true;
break;

case 's':
canfd_strict = true;
break;

case 'b':
brs = true; /* bitrate switch implies CAN-FD */
canfd = true;
Expand Down Expand Up @@ -409,6 +421,8 @@ int main(int argc, char **argv)
printf("error when enabling CAN FD support\n");
exit(EXIT_FAILURE);
}
} else {
canfd_strict = false;
}

if (brs)
Expand Down

0 comments on commit 6421906

Please sign in to comment.