User Tools

Site Tools


cbus:socketcan-en

SocketCAN

Introduction

The RPI-CAN MCP251x Interface board needs a Raspberry Pi 2/3.
SocketCAN is only available if the Rocrail server runs on the same Raspberry Pi with the RPi-MCP251x on it.
The communication with CBUS(CAN) is direct and binary; No bidirectional conversion needed between the MERG Gridconnect ASCII framing.
The 12VDC power supply for the connected CANGC* units can be provided wit a GCA-08. See Cable connections for more information.


Documentation

RPI-CAN MCP251x Interface

Raspi Setup

config.txt

Edit
/boot/config.txt

; uncomment
dtparam=spi=on
; add
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay

Reboot

sudo shutdown -r now

interfaces

Add to the file
/etc/network/interfaces
the following section:

# CAN Interface
auto can0
iface can0 inet manual
        pre-up /sbin/ip link set $IFACE type can bitrate 125000 restart-ms 100
        up /sbin/ifconfig $IFACE up
        down /sbin/ifconfig $IFACE down

Check

pi@keltenbahn:~ $ dmesg | egrep -i "can|spi" 
[    3.998382] CAN device driver interface
[    4.051102] mcp251x spi0.0 can0: MCP2515 successfully initialized.


Rocrail Setup


  • Select type SocketCAN
  • Set Hostname(device name) to can0 (If not set: can0 will be used.)

Check the device name

Check the device name by using the command ifconfig on the Raspberry Pi:

pi@keltenbahn:~ $ ifconfig
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Hardware

cbus/socketcan-en.txt · Last modified: 2018/11/12 08:56 (external edit)