strawberry-cake
Posts: 3
Joined: Tue Jul 03, 2018 12:14 pm

PICAN 2 (MCP2515) - Raspberry Pi 3 -

Thu Jul 05, 2018 10:49 am

Hey Everybody,

I don't know why this is not working!

The Goal of my Project is to develop a CAN-Sniffer.

I have two devices that communicate with each other via a bus cable (Image: https://picload.org/view/dlgpogai/20180 ... 8.jpg.html). At this cable, I have each picked up on the CAN high and the CAN low and soldered to the DBus connector at points 2 (low) and 7 (high). Furthermore, I have a PiCAN 2 (MCP2515) and a Raspberry Pi 3 Model B. These two I have connected normally via the GPIO interface. Then I connected the DB9 connector to the DB9 connector of the PiCAN2 (Image: https://picload.org/view/dlgpoggr/20180 ... 5.jpg.html).
Now I mean that on the hardware side everything was done. The two devices communicate with each other and in the meantime the signals are also intercepted via the tapped cables.

Now to the software:

I tried almost everything, unfortunately without success. I just want to be able to use the commands candump and cansniffer, nothing more.

I have followed the steps in sequence:

First I followed the instructions on this page:

http://skpang.co.uk/blog/archives/1165 and https://elinux.org/Can-utils

It doesn't work. I can execute the commands without any problems, but nothing is displayed. It behaves as if nothing was connected. But I know that definite signals are transmitted via the cable. So I experimented a lot and followed the instructions in this video: https://www.youtube.com/watch?v=S1c5QhnjTmE

Now comes to me the following question: What exactly must be written in the files:

- /boot/config.txt,
- /etc/modules-load.d/modules.conf
- /etc/modprobe.d/raspi-blacklist.conf

There are many different suggestions and none helped me any further.

Code: Select all

uname -a
Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux
(I also don't know if I have to load anything at the current kernel)
And even if I want to load modules via modules.conf, I get the following error message during reboot:
[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.

In addition, I have tried the software program Wireshark and also get here no CAN signals.

http://skpang.co.uk/blog/archives/1141


I would be very happy, if you could help me, because I think it should work.

If you need more information, please let me know.

Thanks,
strawberry-cake
Last edited by strawberry-cake on Tue Jul 10, 2018 12:36 pm, edited 1 time in total.

cloroxman
Posts: 3
Joined: Sun Mar 18, 2018 10:18 pm
Contact: Website

Re: PICAN 2 (MCP2515) - Raspberry Pi 3 -

Sun Jul 08, 2018 9:59 pm

Hey there!

Here is a link to my gist; I am currently using the PiCAN2 (The screw terminals port) for my Teslonda dash project. I documented what I did to get it working.

https://gist.github.com/Mathews2115/ed3 ... g-with-can

Installing needed drivers

Code: Select all

sudo apt-get -y install can-utils libsocketcan2 libsocketcan-dev
Setting up PiCAN2
1. PiCAN2 Device Overlays (enable CAN device) - Enable SPI either through raspi-config or add dtparam=spi=on to /boot/config.txt
2. put the following in: /boot/config.txt

Code: Select all

#CAN bus controllers
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
Then I just had it autostart when I booted (otherwise you have to do this manually)
auto-start CAN interface on bootup
1. sudo nano /etc/network/interfaces
2. Paste this into there

Code: Select all

auto can0
iface can0 inet manual
   pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on
   up /sbin/ifconfig can0 up
   down /sbin/ifconfig can0 down

Many many ways to tackle this but this worked for me. I'm sure I can move that last part into a proper service too. But hopefully this will get you started.

With the above, I can successfully candump/play, etc.

Edit:

When you have everything installed and the interface up and running, you should be able to see a can0 when you type ifconfig.

strawberry-cake
Posts: 3
Joined: Tue Jul 03, 2018 12:14 pm

Re: PICAN 2 (MCP2515) - Raspberry Pi 3 -

Tue Jul 10, 2018 9:41 am

Hey cloroxman,

Thanks for your quick reply.
cloroxman wrote:
Sun Jul 08, 2018 9:59 pm
Edit:

When you have everything installed and the interface up and running, you should be able to see a can0 when you type ifconfig.

With ifconfig I could see before already the interface can0. Unfortunately, my problem still exists.
cloroxman wrote:
Sun Jul 08, 2018 9:59 pm
Installing needed drivers

Code: Select all

sudo apt-get -y install can-utils libsocketcan2 libsocketcan-dev
Setting up PiCAN2
1. PiCAN2 Device Overlays (enable CAN device) - Enable SPI either through raspi-config or add dtparam=spi=on to /boot/config.txt
2. put the following in: /boot/config.txt

Code: Select all

#CAN bus controllers
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
I have also followed the instructions you have given.
But every time I run candump can0 the command will be executed, but it will not show me anything:

Image: https://picload.org/view/dlrorgdi/ifcon ... 0.png.html

Thanks,
strawberry-cake

cloroxman
Posts: 3
Joined: Sun Mar 18, 2018 10:18 pm
Contact: Website

Re: PICAN 2 (MCP2515) - Raspberry Pi 3 -

Tue Jul 10, 2018 9:33 pm

Alright. So good news is you are all setup up software side.

With the screw terminals, as long as you have Hi / Lo in the correct spots, you should get data.
With the DB9 connector, I believe there is additional work to get that interface working. I believe you need an additional jumper on the PiCAN2 to read from from the DB9. I may be recalling this incorrectly but I double check the documents from their website on the DB9 connector.

Edit:
I was just checking this page out:
http://copperhilltech.com/pican2-contro ... berry-pi/

(grep for Configuring the DB9 Connector)

According to their documentation - Using pins 2 and 7 - you have to:
Close the solder bridges on the righthand side on SJ1, SJ2 and SJ3
Sorry I'm not more help, I don't have any experience with the DB9 portion.

strawberry-cake
Posts: 3
Joined: Tue Jul 03, 2018 12:14 pm

Re: PICAN 2 (MCP2515) - Raspberry Pi 3 -

Tue Jul 17, 2018 7:37 am

cloroxman wrote:
Tue Jul 10, 2018 9:33 pm

According to their documentation - Using pins 2 and 7 - you have to:
Close the solder bridges on the righthand side on SJ1, SJ2 and SJ3
Thanks for the reply, but I've already done that, it still doesn't work, I've also added a Jumper.

I despair slowly... :cry:

gunahmt
Posts: 15
Joined: Mon Jun 25, 2018 12:31 pm
Location: Turkey

Re: PICAN 2 (MCP2515) - Raspberry Pi 3 -

Fri Jul 20, 2018 7:47 am

check the crystal on piccan2 is it 16mhz or not.

and u cant read or write daha on canbus right ? are you sure other side of can bus(not raspberry other device) working correctly? if you want i wrote the c code for canbus via spi with wiringpi i could upload.

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 7 guests