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
4
votes
2 answers

Send one-shot message using SocketCAN

Is it possible to send a "one-shot" CAN message using SocketCAN? This is basically a message that does not expect an acknowledgement back from the receiver. The protocol allows this ACK bit not to be set.
ilya1725
  • 4,496
  • 7
  • 43
  • 68
4
votes
2 answers

How to filter result of CAN bus for IDs with Python-Can and Raspberry

Hello I have a Raspberry with an MCP2515 CAN bus device, for read entire values of broadcasting it's only this source in Python with use of python-can: import can bus = can.interface.Bus(channel='can0', bustype='socketcan_native') notifier =…
Francesco Valla
  • 214
  • 3
  • 11
4
votes
3 answers

Non trivial example code for the bxCAN i/f on the STM32?

I am using the STM Peripheral Library to set up and use CANBus. Problem is that I have to put a delay between Tx packets or I start dropping packets. Putting in read status loops etc does not seem to have any effect. Does anyone have a working…
Dirk Bruere
  • 237
  • 2
  • 15
4
votes
1 answer

CAN for large packets of data exchange without using standard protocols

Im working on a project that requires me to use CAN for communication. There are 3 Master nodes and 48 slave nodes. Each Master does the same functions(for redundancy in decisions and voting). Each master will be sending about 64 bytes of data per…
AlphaGoku
  • 968
  • 1
  • 9
  • 24
4
votes
1 answer

Writing custom CAN protocol with SocketCAN

I'm trying to write a slightly modified CAN protocol for SocketCAN. The SocketCAN documentation has a short section about this: 5.3 writing own CAN protocol modules To implement a new protocol in the protocol family PF_CAN a new protocol has to be…
RuthSB
  • 49
  • 3
4
votes
2 answers

Is it possible to read manufacturer specific codes with ELM327

I plan on creating a SW which interacts with the CAN bus (for Cars) over OBDII protocols. The SW will be for PC mainly, and perhaps Android. However, it is no use if I cannot adapt it to read more codes than what is legislated and "public". Is it…
obd_dude
  • 49
  • 1
4
votes
3 answers

CAN Network With Single Node (CAN protocol)

I am new to CAN protocol, going through the Robert Bosch's CAN Specification ver2.0 Part B. I can't understand the following lines on page 63 " Note: Start up / Wake up: if during startup only one node is online, and if this node transmits some…
Jagdish
  • 45
  • 2
  • 4
4
votes
1 answer

c# .Net 4.5 Communication between threads

I am building an application where it is possible to monitor some MCU hardware (sensors readings etc) in real time. For the communication I am using a CAN bus. Basically i have 2 threads as of now. One is the main thread where the GUI is running and…
xnonamex
  • 405
  • 2
  • 5
  • 17
4
votes
2 answers

command "ip" is not fully supported in busybox?

everybody, I using busybox 1.2.1 as my shell in embedded linux runing on Xilinx Zynq ARM Cortex x2.Any command that busybox support is ok but "ip".In busybox, I tried "ip",it shows that: BusyBox v1.21.1 (2013-08-15 15:21:48 CST) multi-call…
Ezio
  • 1,116
  • 4
  • 13
  • 25
4
votes
4 answers

Does the .NET Micro Framework support the CAN bus?

I know that the .NET Micro Framework supports the I²C bus. Are there some libraries for CAN or CANopen too? If not, does it support CAN without using other peripherals? Can I build CAN support myself?
Markus Bruckner
  • 2,852
  • 2
  • 24
  • 29
3
votes
2 answers

CANopen/CAN bus, what do I need, including a protocol (OD?), to communicate between PC terminal and CAN device module

I have a dsPIC33 with ECAN and wish to establish a protocol (using SDO if possible) in such way that it communicate between terminal software and dsPIC33 where I can perform diagnostics within dsPIC33 and supporting ICs. I do not know what is…
Riscy
  • 843
  • 4
  • 13
  • 28
3
votes
1 answer

How to perform UDS session unlock using security dll from python program?

I want to automate some WDBI services which requires security unlock. I have a dll which can be invoked from CANoe, but I don't want to use canoe hardware also I don't know the function calls in the dll. Is there any way that I can invoke dll from…
GGG
  • 55
  • 1
  • 1
  • 10
3
votes
1 answer

Interview question - How to continuosly read a buffer without losing data

I am an embedded engineer, with not much experience. I was at an interview and I was asked a question, which I guess is not new and already has answers: You have a peripheral which is constantly receiving input from external world, the peripheral…
Naveen
  • 73
  • 6
3
votes
2 answers

Optimizing pandas dataframe apply to decode CAN frames - iterating over rows

I am trying to reduce the time taken to apply a complex function from the cantools library on each row within a dataframe (up to 2 million rows): Timestamp Type ID Data 0 16T122109957 0 522 b'0006' 1 …
RMRiver
  • 625
  • 1
  • 5
  • 19
3
votes
2 answers

Is there a CAN bus library for STM32 to direct connect with a CAN transceiver?

Many STM32 chipsets support 1 or 2 channel CAN PIN Outs. Is there a CAN bus library for STM32 to direct connect with a CAN transceiver such as MCP2551? But it does not matter what the CAN transceiver is.
lei lei
  • 1,753
  • 4
  • 19
  • 44