Skip to content

Instantly share code, notes, and snippets.

@InfinityCliff
Last active July 14, 2017 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InfinityCliff/c9621bf8ed8b1ecd6112b4e82e108fc4 to your computer and use it in GitHub Desktop.
Save InfinityCliff/c9621bf8ed8b1ecd6112b4e82e108fc4 to your computer and use it in GitHub Desktop.
Raspberry pi 3 - setup

Fix issue with ping

$ sudo chmod U+s /bin/ping

enable VNC

$ sudo raspi-config
  • Navigate to Interfacing Options.
  • Scroll down and select VNC > Yes.

Remove Uneeded Packages

$ sudo apt-get purge libreoffice wolfram-engine sonic-pi scratch
$ sudo apt-get purge minecraft-pi penguinspuzzle
$ sudo apt-get remove --purge libreoffice*
$ sudo apt-get clean
$ sudo apt-get autoremove

Fix Can boot config

$ sudo nano /boot/config.txt

at end - change dtparam=spi=off to on

clean and reboot

$ sudo apt-get udpate
$ sudo apt-get upgrade
$ sudo reboot

Initialize the CAN Interface

http://copperhilltech.com/pican2-controller-area-network-can-interface-for-raspberry-pi/ :

$ sudo /sbin/ip link set can0 up type can bitrate 500000

Download and setup Test Programs

$ wget http://www.skpang.co.uk/dl/can-test_pi2.zip
$ unzip can-test_pi2.zip
$ cd can-test_pi2
$ chmod u+x cansend
$ chmod u+x candump

Download the Python-CAN files

$ wget https://bitbucket.org/hardbyte/python-can/get/4085cffd2519.zip
$ unzip 4085cffd2519.zip
$ cd hardbyte-python-can-4085cffd2519
$ sudo python3 setup.py install 

Monitor can from command line :

$./candump can0

Send can message from command line

$./cansend can0 <CAN 11-bit> or <CAN 29-bit>

in python :

>>> # to send
>>> import can
>>> bus = can.interface.Bus(channel='can0', bustype='socketcan_native')msg= can.Message(arbitration_id=0x7de, data=[0, 25, 0, 1, 3, 1, 4, 1], extended_id=False)
>>> bus.send(msg)

>>> # to recieve >>> notifier = can.Notifier(bus, [can.Printer()])

Python Related

Install Cython :

$ pip3 install cython

Install kivy https://kivy.org/docs/installation/installation-rpi.html

Dependancies: :

$ sudo apt-get update
$ sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config libgl1-mesa-dev libgles2-mesa-dev python-setuptools libgstreamer1.0-dev git-core gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} python-dev libmtdev-dev xclip

Kivy: :

$ sudo pip install git+https://github.com/kivy/kivy.git@master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment