Skip to content

Commit

Permalink
tests/conn_can: make test support CAN FD
Browse files Browse the repository at this point in the history
Increase Shell buffer size for 64 bytes payload length of CAN FD frame.
This also implies to increase main thread stack size.
Fix frame length test to allow the 64 bytes of payload.
Activate CAN FD bitrate switching and CAN FD frame format by default
when module fdcan is activated.

Signed-off-by: Gilles DOFFE <[email protected]>
  • Loading branch information
gdoffe committed Feb 29, 2024
1 parent fdf2839 commit 06b739a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/sys/conn_can/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ include $(RIOTBASE)/Makefile.include
ifndef CONFIG_GNRC_PKTBUF_SIZE
CFLAGS += -DCONFIG_GNRC_PKTBUF_SIZE=4096
endif

CFLAGS += -DTHREAD_STACKSIZE_MAIN=2048
11 changes: 8 additions & 3 deletions tests/sys/conn_can/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include "can/can_trx.h"

#define SHELL_BUFSIZE 512 /* Needed for CAN FD frame */

#ifdef MODULE_TJA1042
#include "tja1042.h"
tja1042_trx_t tja1042 = { .trx.driver = &tja1042_driver,
Expand Down Expand Up @@ -150,7 +152,7 @@ static int _send(int argc, char **argv, bool rtr)
frame.can_id = strtoul(argv[3], NULL, 16);
frame.len = argc - 4;
}
if (frame.len > 8) {
if (frame.len > DEFAULT_CAN_MAX_DLEN) {
puts("Invalid length");
return 1;
}
Expand All @@ -164,6 +166,9 @@ static int _send(int argc, char **argv, bool rtr)
frame.data[i] = strtol(argv[4 + i], NULL, 16);
}
}
#ifdef MODULE_FDCAN
frame.flags |= CANFD_BRS | CANFD_FDF;
#endif

conn_can_raw_t conn;
conn_can_raw_create(&conn, NULL, 0, ifnum, 0);
Expand Down Expand Up @@ -736,8 +741,8 @@ int main(void)
(void*)i, "receive_thread");
}

char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
char line_buf[SHELL_BUFSIZE];
shell_run(_commands, line_buf, SHELL_BUFSIZE);

return 0;
}

0 comments on commit 06b739a

Please sign in to comment.