1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00
Marian Buschsieweke 780a02ef6c
tests/drivers/candev: minor cleanup
- Do not hard code the number of the CAN interface to use. (This
  also allows specifying it via make command line / environment
  variable.)
- Make less use of preprocessor and rely on compiler to eliminate dead
  branches and unused variables.

Co-authored-by: crasbe <crasbe@gmail.com>
2025-04-06 20:19:16 +02:00
..
2025-04-06 20:19:16 +02:00
2025-04-06 20:19:16 +02:00
2023-05-12 14:24:40 +02:00

candev test application

About

This application is a test for using the candev abstraction directly. Use this if you want to use a single CAN driver and thus don't need the CAN-DLL layer.

The CAN_DRIVER variable is used to select the default CAN_DRIVER, supported alternatives are:

  • MCP2515 to use mcp2515 stand-alone CAN controller
  • PERIPH_CAN to use periph_can controller, usually requires a CAN transceiver as well: e.g. tja1042 or ncv7356 (except for native)

Usage

Sending

Messages can be sent over the CAN-bus through the send command. Optionally, up to 8 bytes can be passed as arguments (in decimal form). If no arguments are passed it will default to sending AB CD EF (hex).

> send <bytes>
# e.g.: send AA BB CC
> send 170 187 204
send 170 187 204

Receiving

The test-app is always listening for incoming CAN messages. They will be stored asynchronously in a buffer and can be requested by means of the receive command. Optionally, an argument n can be passed to receive n messages in a row.

> receive <n>
# e.g.:
> receive 2
Reading from Rxbuf...
id: 1 dlc: 3 Data:
0xAA 0xBB 0xCC
Reading from Rxbuf...
id: 1 dlc: 3 Data:
0xAA 0xBB 0xCC

Native Setup

Refer to README.native.can.md.