Questions tagged [can-bus]

Controller Area Network (CAN) bus is a networking technology typically used in cars and other vehicles. It supports deterministic priority arbitration with multiple transmitting nodes.

The CAN bus is a serial bus that allows multiple masters and uses a broadcast model. A message start with an ID, can contain up to eight data bytes (64 data bytes for CAN FD) and uses non-return-to-zero encoding. Each node can receive, but only one can send at each point in time. It uses CSMA/CA algorithm for bus access. The lower the (numerical) ID, the higher the priority. Short networks (below 40 m) can achieve bit rates up to 1 Mbit/s.

A distinguishing feature of CAN is that when two nodes with different message identifiers attempt to transmit at the same time, there are no collisions (CSMA/CA). The higher priority message will go through without any need for the sender to re-transmit it. This ensures that a CAN system can never get into a live lock state in which two nodes would continually re-send the same two messages, and continually collide with each other.

A newer version/generation called CAN FD was recently developed. It supports higher clocking of the data portion of the message, allowing up to 64 bytes of payload.

Tag usage:

  • Use this tag for all questions related to CAN or CAN FD software/firmware: drivers, controllers, communication, frames etc. Please note that hardware questions are off-topic and should be asked at https://electronics.stackexchange.com instead.
  • It is recommended to combine the tag with , to draw more attention to the question from the right kind of people.
  • If you are using a particular programming language (say, ), you should add that tag as well.
  • If the question is about higher layer protocols such as CANopen, J1939 or DeviceNet, the tag should be combined with the applicable higher layer protocol tag.

Links:

1162 questions
5
votes
2 answers

avoid SD card corruption in ansi C

I am currently working on an embedded Linux device for data logging. The Linux device is plugged into a CANbus and writes the traffic to an SD card. From time to time the SD card corrupts and is mounted read-only. This behavior needs to be…
user1320852
  • 97
  • 1
  • 2
  • 8
4
votes
1 answer

python-can J1939 filter mask

I have been working in a Raspberry with an MCP2515 CAN bus device for read entire values of J1939 messages on broadcasting with python . I would like to filter the J1939 messages, but i'm not undestand the meaning of the can-mask and how I discorver…
Gabriel Lincoln
  • 155
  • 1
  • 10
4
votes
4 answers

AttributeError when using python-can (module 'can' has no attribute 'interface')

I'm getting an error when running the following code: import can #importing CAN module import time bus1 = can.interface.Bus(bustype='vector', channel=0, bitrate=500000, app_name='python-can') bus2 =…
Nandu
  • 53
  • 2
  • 5
4
votes
1 answer

Can a can.Bus instance in python-can receive and transmit simultaneously?

I've been using python-can and cantools to transmit and receive CAN bus messages without any issue. But when I begin transmitting periodic messages while also trying to receive messages there seems to be some error. I'm not sure if there is a…
Tim51
  • 141
  • 3
  • 13
4
votes
2 answers

STM32F using HAL_CAN Library

I'm trying to communicate over CAN using the HAL_CAN library between two STM32F boards. Specifically the issue seems to be in receiving messages. Following the documentation: …
Russell
  • 71
  • 2
  • 6
4
votes
1 answer

How to add comments to .dbc for CAN bus

I am trying to figure out how to add comments to a .dbc file, but the DBC specification doesn't seem to address this. I tried adding // and it seems to work, but I don't want to rely on undefined behaviour.
Ken Lin
  • 986
  • 1
  • 8
  • 22
4
votes
0 answers

How to remove a CAN message filter from a CAN_RAW socket?

SocketCAN's description says about adding some filters to a socket: struct can_filter rfilter[2]; rfilter[0].can_id = 0x123; rfilter[0].can_mask = CAN_SFF_MASK; rfilter[1].can_id = 0x200; rfilter[1].can_mask = 0x700; setsockopt(s, SOL_CAN_RAW,…
Greenberet
  • 490
  • 1
  • 5
  • 18
4
votes
2 answers

How to call CAPL general functions from Python 3.x?

Issue I'm trying to call CAPL general functions (in my case timeNowNS) but I don't know if it's possible. What I'm using? I'm using Python 3.7 and Vector CANoe 11.0. The connection is done using the .NET CANoe API. This is how i've accesed the…
Stefan Muresan
  • 101
  • 2
  • 10
4
votes
3 answers

Overload and error differentiation by a CAN controller

How does a CAN controller differentiate the overload frame and error frame when it was received on the CAN bus? As far as I know, theses two frames are having the same frame format. In my project, I mostly encountered an error frame rather than an…
Jeganraj
  • 383
  • 2
  • 4
  • 9
4
votes
2 answers

CAN-Controller acceptance filtering with the SJA1000 (ESP32)

I'm try to use the acceptance filter from the SJA1000 CAN-Controller on a ESP23. The Messages should be filtered in a defined area (e.g. Arbitration ID from: 0x30 to: 0x35). Example for filtering a single message (0x30): #define…
Philipp Fu
  • 75
  • 1
  • 6
4
votes
1 answer

Is it possible to generate CAN bus error using STM32?

For one of my project, I would like to generate some CAN bus errors (e.g. bit stuffing or CRC error). This is just a small idea I had, but do you think it is possible to achieve ? I know all the protocol stuffs are handled by the CAN driver, but I…
Stabilo
  • 45
  • 5
4
votes
3 answers

What is Object dictionary in CANOpen?

I will use CANOpen in linux. In kernel, linux has socketcan and i have some questions for further implementation. 1-) How object dictionary looks like, is it a header file or EDS file? 2-) Do i need to use object dictionary for pdo and sdo…
onur aslan
  • 283
  • 3
  • 8
4
votes
1 answer

Sending notification to only changed signal

I have an API to subscribe a CAN signal as below : bool subscribe(signal name); SubscribeResponse(const CAN_DATA& data); data.signal is the signal name data.value is the signal value. Now lets say client C1 and client C2 subscribe to different…
leuage
  • 566
  • 3
  • 17
4
votes
1 answer

How do I convert .blf data from CAN to .csv using python

I have CAN-Data in the blf-format from the Vector software. For further investigation I want to convert it into csv format using python. My progress so far: import can filename = "test.blf" log = can.BLFReader(filename) I dont know if thats the…
JulianWgs
  • 961
  • 1
  • 14
  • 25
4
votes
1 answer

Why is the CAN BUS Frame ID backwards when reading from a Socket?

So I have a Raspberry Pi reading CAN Data from a vehicle. If I use the candump program included in canutils I get a bunch of data, an example look like: can0 1C4 [8] 03 F3 26 08 00 00 7F 70 I then wrote a simple C++ app to open a socket to the…
user3832227
  • 61
  • 1
  • 3
1 2
3
77 78