Sully
Posts: 2
Joined: Tue Nov 19, 2013 5:13 pm

Re: CAN controller

Wed Nov 20, 2013 10:30 pm

Thanks Martin, I think that's exactly what I was looking for. Now I just need to get Python 3.3 on my RPI.

-Sully

floeckschlager
Posts: 5
Joined: Sun Nov 03, 2013 4:23 pm

Re: CAN controller

Fri Nov 22, 2013 8:14 pm

Hi Martin,

I just want to tell that I've just reinstalled everything from scratch and now it seems like CAN and SPI work fine together.
Thanks for your help!

floeckschlager
Posts: 5
Joined: Sun Nov 03, 2013 4:23 pm

Re: CAN controller

Fri Nov 22, 2013 8:56 pm

Nooo, there are still the same problems. But I found out that these only occur when the raspberry-camera is enabled via the raspi-config tool!
When I disable the cam and reboot everything is fine again...
Can it be? Do you have any idea?

floeckschlager
Posts: 5
Joined: Sun Nov 03, 2013 4:23 pm

Re: CAN controller

Sat Nov 23, 2013 4:15 pm

Hmmm... today I have all the same problems as before. I don't know what it is.
My hardware should be ok, because transmission in both directions works fine. Just until I send some bytes on spidev0.1
Then sometimes I can send some can-frames but not receive and sometimes the pi begins to send the same frame many times one after an other...

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Sat Nov 23, 2013 9:27 pm

Hello to all !
I've been and lot busy and a bit sick, so not much progress on my side about the packaging.
I still manage to package the can-utils programs using the proposed package mentioned here : http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568303.

Here are the instructions to build it (and the small patch to apply):

Code: Select all

# Prerequisites :
sudo apt-get install git-buildpackage

# Download
git clone git://anonscm.debian.org/collab-maint/can-utils.git
cd can-utils
# Patch to use /usr, and not /usr/local otherwise the build fails
sed -i Makefile -e "s?/usr/local?/usr?g"
# Commit locally the patch, as it can't build with local modifications
git add Makefile
git commit -m "Change makefile prefix to build to /usr in place of /usr/local"
# Compile. Options "-uc -us" => unsigned changes/source => avoid needing GPG configured
sudo git-buildpackage -us -uc
If you don't want to compile it yourself, you can download it from here : http://sagittarii.fr/rpi/can-utils_0.0. ... _armhf.deb

Code: Select all

# To install :
sudo dpkg -i can-utils_0.0.2+gitba9b189-1_armhf.deb
You can find all the packages I tried (look at my previous posts for more details) on my website : http://sagittarii.fr/rpi/
* rpi-can-3611-spi-dma_1-2_all.deb => deb package made from Gerd's archive with alien
* linux-image-3.6.11-can-2+_3.6.11_armhf.deb => full kernel that can be installed at the same time as the original raspbian one, with can fonctionnality, spi-config and mcp2515 driver
* can-utils_0.0.2+gitba9b189-1_armhf.deb => the can utilities (cansend, candump,...)
* socketcand_0.3.1-1_armhf.deb => a daemon that create a gateway between can and tcp. Allows to use the Pi as a wireless CAN adapter. Documentation here : https://github.com/dschanoeh/socketcand ... rotocol.md

I still hope to find how to make a better package for the kernel, but don't know how long it will take.

Zeta

st1g
Posts: 1
Joined: Sat Oct 26, 2013 12:17 pm

Re: CAN controller

Sun Nov 24, 2013 10:48 am

Mayco wrote: After preparing my Raspberry Pi and connecting JP3 for the 120 ohm resistor ending, I hooked up this cable between my PICAN and a cars OBDII interface (I'm pretty sure it's a Opel Corsa D, which should have the following CAN specifications: CAN 11bit @ 500kb/s). I initialize the PICAN shield using:

Code: Select all

rmmod spidev
modprobe spi_bcm2708
modprobe spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pd$
modprobe mcp251x
/sbin/ip link set can0 type can bitrate 500000
/sbin/ifconfig can0 up
Then, I connect the cable, start the candump (and/or cansniffer), start the car... and nothing happens.

Now I have some pretty in-depth knowledge about the CAN standard, but I clearly don't know as much about car diagnostics OBDII as I would like. I didn't expect any data I could make sense of, but I at least expected to see a lot of (seemingly random) CAN frames scroll by in the sniffer/dump program. Are OBDII and CAN seperate things or do I need to send some "data request" frame before the car starts "talking"?
The same issue. I have connected Raspberry with this adapter (http://lnxpps.de/rpie/) to Audi Infotainment CAN bus and I can't see any messages :(
Sending and receiving messages on the loopback works fine...

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Sun Nov 24, 2013 2:33 pm

st1g wrote:The same issue. I have connected Raspberry with this adapter (http://lnxpps.de/rpie/) to Audi Infotainment CAN bus and I can't see any messages :(
Sending and receiving messages on the loopback works fine...
If the loopback mode works, then at least the raspberry pi and adapter works.
So the problem can be :
1) in the connection to the OBD-II bus:
* OBD-II connector is a standard that provides several buses. Not all are used on a given vehicle. Check that yours has CAN. Looking there http://obdii.com/connector.html, to have CAN "The connector should have metallic contacts in pins 4, 5, 6, 14 and 16"
* CAN Low and High wires can be switched. With a multimeter, you should find a DC voltage of about 2V between CAN Low and ground, and 3V between CAN High and ground. CAN High voltage is higher than CAN Low. CAN is not like a RS 232 serial line (where the emitter TX line is the receiver RX line), the "CAN L" wire should be connected to the "CAN L" pin of all devices connected to the bus, and same for "CAN H" wire.
2) in the speed:
* the raspi must be configured with the correct bus frequency. If you don't know and don't have an oscilloscope to check, you can try the usual ones: 125/250/500 kbps or 1Mbps. There are also some other ones that are not much used (If I remember : 50/80/100/800kbps). The bitrate parameter of this example configures a 500kbps bus frequency:

Code: Select all

/sbin/ip link set can0 type can bitrate 500000
* the can driver set the bus frequency according to its crystal, so check that its crystal frequency is correctly set. The "pds32-0" argument here defines a 16MHz driver crystal, whereas the speed parameter only defines the SPI link speed between the CAN driver and the raspi, which has no impact on the CAN bus frequency :

Code: Select all

modprobe spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pd$
If all this is good, then it may be that the bus don't send messages without being triggered first.
In that case, you can try to send some dummy message (like id=0/no data. But it is safer to actually read the OBDII can protocol to see what to send, to avoid breaking stuff...) 20 times with cansend. If there is nothing on the other side, then you will get an error that the emit buffer is full, as a frame is only successfully emitted if there is a device to acknowledge its transmission, otherwise the driver keeps retrying (by default at least, it could be configured) . If there is a device on the other side, then it will acknowledge the frame sent, and you will get no error.

Good luck !

Mayco
Posts: 2
Joined: Sat Nov 02, 2013 3:49 pm

Re: CAN controller

Sun Nov 24, 2013 2:38 pm

Very useful post, thanks!

SteffenBHT
Posts: 4
Joined: Wed Oct 23, 2013 8:33 am

Re: CAN controller

Wed Nov 27, 2013 4:46 pm

Hello,

thank you for the useful posts and utilities!!
The loopback mode works, now i want to write a c program to send and receice data from the can bus. Is there any included comand to send and receive the data?

best regards
Steffen

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Wed Nov 27, 2013 7:10 pm

Look here: http://en.wikipedia.org/wiki/SocketCAN
the page also contains some code

Martin

SteffenBHT
Posts: 4
Joined: Wed Oct 23, 2013 8:33 am

Re: CAN controller

Thu Nov 28, 2013 1:42 pm

thanks :)

but there are still questions:

1) is there any documentation about the SocketCan?

EDIT: i think i found it under http://elk.informatik.fh-augsburg.de/pu ... cf-api.pdf

2) Where is the adress of the modul stored?
3) i think the modul should have the lowest adress if it is the master, right?

much thanks,
Steffen

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Thu Nov 28, 2013 3:50 pm

The wikipedia page already contains everything you need to send a message:

here the portion to get from device name (can0) to device index:

Code: Select all

        strcpy(ifr.ifr_name, "can0");
        ioctl(s, SIOCGIFINDEX, &ifr);
And then the rest of the code to get you to send a message.

Receive is similar using the same socket you have been binding to when transmitting.

Code: Select all

/* check if there is something to read from socket s using select */
struct can_frame frame;
recv(s, &frame,sizeof(frame),0);
/* check for number of bytes read - should be sizeof(frame) */
/* now you got the data of the can message in frame and you can access it */
You can also add receive-filters if you want, but you can find that on the internet or reading linux/can.h and/or linux/can/raw.h.

Code: Select all

    struct can_filter filterdef;
    filterdef.can_mask=CAN_MASK&((1<<29)-1);
    filterdef.can_id=CAN_ID&((1<<29)-1);
    setsockopt(can_socket,
                   SOL_CAN_RAW,
                   CAN_RAW_FILTER,
                   &filterdef,
                   sizeof(filterdef)
        ));
/* bind here */
Martin

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Thu Nov 28, 2013 7:21 pm

For people that don't speak german, the official documentation of SocketCAN is in the kernel source, and well written:
https://www.kernel.org/doc/Documentatio ... ng/can.txt

The wiki page took the gist of it to provide a working code example, which is enough to start, but all details of it are in the doc above.

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Mon Dec 02, 2013 7:53 pm

As the DMA driver is only progressing slowly (and there are some optimizations going upstream that need to filter back into the raspbien kernel eventually) and I came to the realization that there are still latencies in a heavily loaded linux kernel (say lots of IO to SD Card,...) which could result in unnecessary delays which would result in CAN message loss on a highly saturated CAN bus.

So I am now thinking of a setup with a tiny micro processor that could handle up to 3 MCP2515 with hard realtime setup and feed them to the Linux kernel in an optimized way, so that the kernel would just need to do long reads/writes of just messages which is much better handled than the "get status, read message, clear flags,..." flows that we need to run when talking to a MCP2515 directly.

It is similar to an idea that Gerd had already hatched a year ago...

So I wonder what would be the "nice to have" features for such a system?

My current thought are for a setup like this:
  • ATTiny861 as the MCU @16 or 20MHz
  • up to 3 MCP2515 connected (maybe modular)
  • corresponding MCP2515
  • plain GND,CANL,CANH connections (maybe also CAN-TX/CAN-RX)
This means approximately 32 CAN messages could get buffered and avoid packet loss due to kernel latencies.
There would be can0, can1 and can2 devices.
Also it should be possible to handle all 3 CAN Controllers to be connected to a 1MHz CAN bus.
My estimate is that with Standard frames and 4 byte data (average) we should be able to continuously read at this data rate from the SPI/MCU perspective. The problem might then be the CPUutilization on the RPI handling all those messages...

Anyway - the buffers are there mostly to hide latencies and the immanent packet-loss not a constant transfer rate like I had mentioned above...

Note: I would like to keep it simple, so I am thinking of exposing GND,CANL,CANH as well as 5V,CANTX,CANRX.
If someone needs to have a decoupled CANtransceiver, then the above pins should allow for a custom interface board (say with an ADM3053) that just handles this task - similar for specific OBDII connectors,...

So what would be on your wishlist of features for such a thing?

Ciao, Martin

dplamp
Posts: 21
Joined: Mon Jan 21, 2013 9:23 am
Location: France

Re: CAN controller

Tue Dec 03, 2013 8:19 am

Wow, that sounds like a labyrinthine system ! If it's too complex, I'd better be off with a PC/104 and a CAN board.

But if you really want to go that way, I would recommend a uC that has a built-in CAN controller ; no more SPI, little board space usage, 3.3V compatible and 5V tolerant. I have some experience with Microchip's PIC32MX575F512L-80I/PF : 32 FIFO's of 32 messages each, 1024 messages total. How many MCP2515 to beat this ?

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Tue Dec 03, 2013 8:40 am

well, that is 100 TQFP pins plus the price-tag...

Also my knowledge of PIC is 0...

Also as my calculations shows you would need a RPI-SPI-Bus-speed of 1.5-2x the CAN speed/BUS to transfer the amount of data realistically (with some latencies). AND that is is just communication between what the RPI and the MCU totally independent of the CAN Controller used in the end...

So with 3 CAN BUSes running 1MBit that would mean 4.5-6MHz to handle the worsted case...

I am not sure yet if I can pull it of with 3 MCP2515, but I think it could be possible to run that.
Doing my math 2 is definitely possible with a attiny861 at 1MHz, 3 might require one (or all of the) MCP2515 to run <=500khz.
(and 3 is the limit from the pinout of the ATTiny)

The only thing I am not 100% sure yet is how the SPI-slave part really works out - some testing required there if I can deliver data as quickly as MCUCLK/4 - I might need to go down to MCUCLK/6 on the CPU Speed...

Martin

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Tue Dec 03, 2013 6:57 pm

msperl wrote:So I am now thinking of a setup with a tiny micro processor that could handle up to 3 MCP2515 with hard realtime setup and feed them to the Linux kernel in an optimized way, so that the kernel would just need to do long reads/writes of just messages which is much better handled than the "get status, read message, clear flags,..." flows that we need to run when talking to a MCP2515 directly.
Or use a BeagleBoneBlack... ?
2 CAN bus hardware modules embedded in the processor, only need 2 external transceivers (like the MCP2551). Each one have an internal memory of 64 messages, and can also be directly connected to the DMA interface.
If the third channel is absolutely needed, then it is still possible to put it in SPI like we are doing, and use a PRU (one of the two small 200MHz RISC coprocessor of the Sitara CPU) to handle it without missing frames.
Last benefit of the BBB would be the 1GHz Cortex-A8 to handle all these frames on the software side, as the raspberry pi would probably not handle too much from 3 loaded bus.

At least it would be far easier and faster than doing a custom SPI CAN driver for the RPi, I think.

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Tue Dec 03, 2013 9:32 pm

True, but then: what is the challenge?
The dma driver will take some time to propagate - that is for sure...
Martin

bertr2d2
Posts: 98
Joined: Wed Aug 08, 2012 10:12 pm

Re: CAN controller

Wed Dec 04, 2013 4:12 pm

Zeta wrote:
msperl wrote:So I am now thinking of a setup with a tiny micro processor that could handle up to 3 MCP2515 with hard realtime setup and feed them to the Linux kernel in an optimized way, so that the kernel would just need to do long reads/writes of just messages which is much better handled than the "get status, read message, clear flags,..." flows that we need to run when talking to a MCP2515 directly.
Or use a BeagleBoneBlack... ?
2 CAN bus hardware modules embedded in the processor, only need 2 external transceivers (like the MCP2551). Each one have an internal memory of 64 messages, and can also be directly connected to the DMA interface.
If the third channel is absolutely needed, then it is still possible to put it in SPI like we are doing, and use a PRU (one of the two small 200MHz RISC coprocessor of the Sitara CPU) to handle it without missing frames.
Last benefit of the BBB would be the 1GHz Cortex-A8 to handle all these frames on the software side, as the raspberry pi would probably not handle too much from 3 loaded bus.

At least it would be far easier and faster than doing a custom SPI CAN driver for the RPi, I think.
Even if the new SPI driver is well designed and uses only few CPU cycles the SocketCAN itself will be a limit. IMHO you can't serve 3 fully loaded 1 Mbaud CAN-Busses. I have done a test using vcan bouncing a packet force and back. Here are results:

Code: Select all

Platform    CPU     Clock [MHZ] Bogomips   p/sec [1000]   Mbit
RaspberryPI ARMv6     700             700    21.36        1.69
Beaglebone  ARMv7     720             720    44.29        3.50
Laptop     PentiumM  1500            1500   168.06       13.27
Workstation  AMD64   3000            6000   449.34       35.50
Sourcecode:bounce.c
Seriously spoken the RPi could serve one or maybe 2 CAN Interfaces, but you can't serve
fully saturated 3x1Mbaud CAN IMHO.

I've done the test on the BeagleBone (White) - the BeagleBone Black is even faster (1GHz).
If you need more than one CAN bus the BBB is defintly the better choice (today). And like
Zeta mentioned, the PRUSS could connect even more CAN interfaces, if the two integrated
CAN controller aren't enough. Of course, you need to write the PRUSS driver for MCP2515.

What I would like to see is the can4linux on RPi. I'm quite sure, that this API is less CPU intensive.
But can4linux doesn't got into mainline kernel and the build process and code is confusing me.
Maybe somebody else could have a look at it.

Regards,

Gerd

PS: I'm curious about the new RPi-SPI driver from Martin. Hopefully his excellent work on the spi,
mcp251x-mod and spi-custum modules will be continued.
@Martin,
please go ahead and show with the new drivers that my tests are rediculous ;-)
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie

msperl
Posts: 353
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Wed Dec 04, 2013 5:22 pm

Thanks for the measurements Bert!

Still the effort here is there to avoid packet loss in the face of short bursts of messages on a CAN-Bus.

21.36k messages/s would be above the worsted case of 19K CAN messages/second with 1MBit , standard ID and 0 data length.
That is something that a RPI can not handle easily (especially wit a frame length of 0.05ms and the buffer getting filled within 0.1ms after which we would have packet loss) - most of this due to the fact that the IRQ latencies are in the order of 0.02ms.
But with the protocol I have in mind the 368byte buffer would be able to "cache" 73 of those short messages, which would amount to 3.6ms of possible delay before loosing a packet... while the transfer of those 73 buffered messages would take 1.5ms @2MHz SPI Bus speed - so it is an improvement.

On the other hand with regards to 8byte date + extended ID messages @1MHz we can cache 28 such messages that way.
Unfortunately my favorite page for timing calculations on the CAN bus (http://www.esacademy.com/en/library/cal ... lator.html) is currently not available, but if I remember correctly we were talking about 0.13ms/can message - so again about 3.6ms of time to fill the buffer and about 7700 messages/second.

So this is what my goal is for this - get a bit of buffering and have an optimized way of transferring the data.

If someone then finds the time to move the code from an AVR to a PIC33... with 2 internal CAN Bus controllers, then I guess we would have more RAM to buffer and maybe the SPI clock could be higher than possibly 2MHz (having to do with some limitations on the AVR SPI side in client mode)

Ciao, Martin

P.s: the envisioned protocol would look like this:

SubmitMessage:
  • 4 bit command
  • 4 bit channel on which to deliver
  • 4 bit flags (extended ID, RTR,ConfigFrame)
  • 4 bit length
  • 32 bit CAN ID (as used in linux - including error frames,...)
  • 0-8 byte data
This submit message would also be used to configure the speed of the CAN-bus and some other flags from the CAN perspective (listen only,one-shot, sampling, possibly firmware update,...)

ReadQueue:
  • TX:4 bit command
  • TX:12 bit dummy
  • RX:16 bit data available to read
  • RX: data to read (as much as you want to read)
The message encapsulated in the stream would look like this:
  • 8 bit Channel number (controller)
  • 4 bit flags (extended ID, RTR)
  • 4 bit length
  • 32 bit CAN ID (as used in linux - including error frames,...)
  • 0-8 byte data

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Fri Dec 06, 2013 5:45 am

HI Maddin
maddin1234 wrote:Hi,
here is the description to enable a raspbian distribution
to communicate with the can controller mcp2515

I was starting with Raspbian "wheezy"
2012-07-15-wheezy-raspbian
on the SD-card and inital raspi-config done

1.) change user to root
$ sudo su
2.) update and upgrade
I was asked to keep or to overwrite one file, I choosed "N" to keep it
# apt-get update
# apt-get -y dist-upgrade

3.) install git and ncurses-dev
(If you want to "make menuconfig", ncurses-dev is needed)
# apt-get -y install git ncurses-dev
4.) download kernel sources
# cd /usr/src
# git clone --depth 1 git://github.com/raspberrypi/linux.git
# cd linux
5.) copy the compiletime configuration out of the intial kernel to
the sources for the new kernel
(do not use this line, if you want to have another configuration file)
# zcat /proc/config.gz > .config
6.) edit .config with make menuconfig
# make menuconfig
This shows how I set the configurations
[*] Networking support --->
....<M> CAN bus subsystem support --->
........<M> Raw CAN Protocol (raw access with CAN-ID filtering)
........<M> Broadcast Manager CAN Protocol (with content filtering)
............CAN Device Drivers --->
................<M> Platform CAN drivers with Netlink support
................[*] CAN bit-timing calculation
................<M> Microchip MCP251x SPI CAN controllers
................[*] CAN devices debugging messages

....Device Drivers --->
........[*] SPI support --->
............<M> BCM2798 SPI controller driver (SPI0)
............<M> User mode SPI driver support
.......-*- GPIO Support --->
............[*] /sys/class/gpio/... (sysfs interface)
7.) patch the board definition bcm2708.c

Get a patchfile to the raspi with windows:
create a new txt-file and name it for example bcm2708.diff
copy the text of the posted patchfile from AlexB into that file
and save it on an usb-stick, if you have another clock frequency
change it in the patch-file or later in the patched bcm2708.c file

to mount a usb-stick follow
http://raspi.tv/2012/mount-a-usb-flash- ... erry-piebo

apply a patch to board-configuration
# cd /usr/src/linux/arch/arm/mach-bcm2708
# cp /media/usbstick/bcm2708.diff .
# patch -p0 <mcp2515_patch.diff
8.) make a new kernel
(put the three commands to one command-line, because it will take very long)
# cd /usr/src/linux
# make; make modules;make modules_install
9.) replacing the old kernel with the new one
# cp arch/arm/boot/Image /boot/kernel.img
10.) reboot and login again
# shutdown -r now
11.) install can-tools
$ sudo su
# cd /home/pi
# mkdir can
#cd can
get socketcan and compile/install it
# wget http://www.pengutronix.de/software/libs ... .8.tar.bz2
# tar xvjf libsocketcan-0.0.8.tar.bz2
# rm libsocketcan-0.0.8.tar.bz2
# cd libsocketcan-0.0.8
# .configure
# make
# make install
# cd ..
get can-util
# git clone git://gitorious.org/linux-can/can-utils.git can-util
# cd can-util
# make
# make install
# cd ..
now you are ready to use can

load the modules
# modprobe spi-bcm2708
# modprobe can
# modprobe can-dev
# modprobe can-raw
# modprobe can-bcm
# modprobe mcp251x
# ip link set can0 up type can bitrate 500000
to see if you are receiving messages
# candump can0
have fun

maddin1234



I need ur help, I have RPI and SPI to CAN converter with 8 MHz oscillator circuit .
I installed NOOBS - Raspbian OS in my SD card .
Kernel - venilla kernel 3.6.11+
I want to communicate in CAN Bus .
Please help me how to make my RPi to communicate with CAN bus.
I'm new to Kernel things for compiling and installation .

Regards
Senthilkumar R
( cadsenthilkumar )

cadsenthilkumar
Posts: 29
Joined: Wed Sep 25, 2013 11:09 am

Re: CAN controller

Fri Dec 06, 2013 6:18 am

hi skyfisch
I too have the same problem u mentioned above like keyboard not working .May i know how many GB memory you using for your RPi??
And tell what are the steps u followed from OS installing please ?

Regards
Senthilkumar R
(cadsenthilkumar R)

skyfisch wrote:Hi,maddin1234.
Thank you for your instructions.My system worked.

The reason for my problem was, the capacity of my partition to make new kernel was not large enough.

skyfisch

shanlasani
Posts: 12
Joined: Wed Dec 11, 2013 12:46 am

Re: CAN controller

Wed Dec 11, 2013 2:08 am

Sully wrote:Hi,

Noob here with respect to linux and the raspberry pi but learning a lot from all the info in this forum. Thanks for all the help!

I finally got my RPI to read a CAN message that I'm sending from another controller as I can see the messages through candump. Now I would like to take that CAN message and do something useful with it via a Python script. I've been looking for some example python scripts utilizing SPI and CAN but haven't found anything that I could use to get started. An example script or a point in the right direction would be much appreciated.

Thanks,
Sully

Hi Sully,
Good to know that your CAN interface is working fine with Pi. I am relatively new to Raspberry Pi world but have to do CAN interfacing with Pi (with MCP2515 CAN Controller) and after that I have to read and send messages using Python.

So, Can you help me how to compile the kernel for CAN communication in a stepwise manner...... since its the first job for CAN Communication with Pi... It will be very helpful for me...

Thanks in advance,
Shan

Zeta
Posts: 72
Joined: Wed Dec 12, 2012 9:51 pm

Re: CAN controller

Wed Dec 11, 2013 8:08 pm

shanlasani wrote:I am relatively new to Raspberry Pi world [...] So, Can you help me how to compile the kernel for CAN communication in a stepwise manner......
Hello Shan,

Why not starting with one of the precompiled version available in the previous pages of this thread ?

If you make it work and need to add something special, then you can start to learn how to compile yourself a kernel (all needed should have already been said in this thread, and on gerd's blog or e-linux wiki).

Zeta.

shanlasani
Posts: 12
Joined: Wed Dec 11, 2013 12:46 am

Re: CAN controller

Thu Dec 12, 2013 1:21 pm

Zeta wrote:
shanlasani wrote:I am relatively new to Raspberry Pi world [...] So, Can you help me how to compile the kernel for CAN communication in a stepwise manner......
Hello Shan,

Why not starting with one of the precompiled version available in the previous pages of this thread ?

If you make it work and need to add something special, then you can start to learn how to compile yourself a kernel (all needed should have already been said in this thread, and on gerd's blog or e-linux wiki).

Zeta.

Hi Zeta,

Yes i will use the precompiled version as given on http://www.skpang.co.uk/catalog/pican-c ... -1196.html ...... But, i m a bit confused....... after receiving CAN messages, how can i use the MCP2515 driver to send specific messages based on specific received messages.... and which programming platform (C++, or Python) should i use to do this job.... Can u guide me in this regard..

Thanks,
Shan

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