latonita / arduino-canbus-monitor

Can bus monitoring tool based on arduino and can bus shield. Implements CAN ASCII/SLCAN protocol compatible with Lawicel CAN232/CANUSB. Can be used for monitoring low speed CAN (interior can bus of most cars, less than 500kbps). For higher speeds serial port can become a bottleneck in case data density is high.
MIT License
308 stars 91 forks source link

Is it an alternative to CANtact? #5

Closed crossband closed 7 years ago

crossband commented 7 years ago

Hi Anton,

would Arduino UNO and Freematics CAN-BUS shield v1.2 enough to sniff 500kbs CAN bus of car? I mean, is 16MHz Uno is capable to process all CAN data without running out of the buffer?

I know about CANtact, but it uses more powerful STM32.

Thanks!

latonita commented 7 years ago

Hi The exact answer is no, it is not. Because you will connect it via serial which is more likely much slower than your 500k can bus. Serial bus theoretically can work on speeds more than 115k -depends on your setup you can try higher serial speeds. (I had it working fine on around 500k)

However, can bus transiever on a shield actually has little data buffer. So it reads data on high speed and then spits it to serial port on lower speed. No problem with this in case real data rate on your bus is not high. However if there is a lot of data - it will not be able to process it all and can either skip some data (most likely) or (in worst case) just stop reading it from he bus.

So, you can try it. There is a chance it might work

Sent from my iPhone

On 24 May 2017, at 21:06, crossband notifications@github.com wrote:

Hi Anton,

would Arduino UNO and Freematics CAN-BUS shield v1.2 enough to sniff 500kbs CAN bus of car? I mean, is 16MHz Uno is capable to process all CAN data without running out of the buffer?

I know about CANtact, but it uses more powerful STM32.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

crossband commented 7 years ago

Thank for your answer and great work you are doing!

I have tried, it works fine with Wireshark and can-utils. Only problem is as you mentioned when there is a lot of data, it stops working.

Did you tried using something more powerful, e.g. Arduino DUE?

latonita commented 7 years ago

You are welcome.

No, i haven't tried more powerful boards. Actually atmega328 is quite powerful, obvious bottleneck is interface between board and computer. Did you try to run it with higher serial speeds? like 500k or even 1M?

crossband commented 7 years ago

Yes, I have tried it. It didn't work for me so far. It starts spiting random characters. I doubt about bottleneck because IMO many other CAN sniffers like CANtact are designed to work on same principles.

igittigitt commented 7 years ago

Problem 1 is the external, serial attached (SPI) CAN controller, MCP2515.0, which also has only 3 or 4 messagebuffers. Messages will be overwritten bevore they can be polled by the uC. Problem 2 is the serial interface to the PC. If you do or can not use a VCP driver which is capable of high datarates (1 Mbit or more) the datas could not send fadt enough to the PC. This is often limited by cheap Arduino clones using fake FDTI or more cheaper CP2102, CH340 USB interfaces.

The STM32 has a CAN controller included and talks to it via a parallel interface. It also has 32 message buffers, which gives the CPU enough time to handle long processing loops. Although it has native USB support.

Maybe it could be done with Atmega using a parallel controller like SJA1000. There are enough ports on Atmega for this. It has 8 receive buffers.

latonita commented 7 years ago

Intention of this exact project is to give access to canbus having only cheap arduino clone boards :) Easy jump into CAN world (can car hacking for me) with a standard interface - either on windows (CAN Hack, Can Tools) or linux (Socket CAN and wireshark). I definitely can make STM version and some other versions and also special PCB - but it will be different project, another goal and different audience ))