Python Can

In the post about installing PiCan I described how you could use the tooling for CAN message receiving / sending.
However these are rather hard to understand .C scripts, which I had some trouble with to customize.

For this reason I chose to install the Hard byte-Python Can software on my Raspberry Pi. Python is a fairly easy programming language, and has no need to compile the code. Also Python is being used as default programming language for Kodi plug-ins. Both of these components are very useful to serve as interface between my Audi / Rns-e and my Raspberry Pi.

To install the Pycan library, you can run the following command;

[pip install python-can]

In the AudiRns FULL Beta plugin I have processed all of the default settings.

Do you want to set the correct settings (for example to use when the example plugins), then open;
[nano /etc/can.conf]
and put the following content to the file;
can.rc['interface'] = 'socketcan_ctypes'
can.rc['channel'] = 'can0'


[whohit]Python Can[/whohit]

Subscribe
Email me at:
11 Comments
oldest
latest most voted
Inline feedbacks
View all comments
Phil
9 year ago

Hello Janssuuh,

I have installed your RNS-E Skin on my Raspberry Pi.
I also have installed Python – Control Kodi with Rns-e and it works great.
Now, I want to simulate the „TV ON“ Signal, because I have no Multimedia Interface that support this.
How can I use this Code below with Python Script?
[canid == (“602”): # Telegramm for TV Tuner On]
[msg == (“81 12 30 3A 20 32 36 20”): #TV ON]
Loop: 200ms
By Booting with Raspberry Pi

Thanks in advance

Phil
9 year ago
Reply to Janssuuh

Thank you for your quick response.
I tried it yesterday but it did not work as you wrote.

I could not see that bytes were sent by looking into the [ifconfig] [ip -s -d link show can0] .

Do you have any idea what my problem could be?

Phil
9 year ago
Reply to Janssuuh

Hi Janssuuh,
There is no error when I run the script manually.?
Would be very nice if you could send me your videomessage.py script file for testing.

Thilo
6 year ago

Hello,

finished installation and getting this Error?!:

12:37:05.162 T:1945711264 ERROR: Control 402 in window 10107 has been asked to focus, but it can’t
12:37:07.994 T:1744212912 ERROR: EXCEPTION Thrown (PythonToCppException) : –>Python callback/script returned the following error<–
– NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type:
Error Contents: No module named interface
Traceback (most recent call last):
File “/root/.kodi/addons/skin.audi_rns/addon.py”, line 22, in
from dumpcan import dumpcan #dumpcan.pyo
File “/root/.kodi/addons/skin.audi_rns/dumpcan.py”, line 21, in
ImportError: No module named interface
–>End of Python script error report<–
ImportError: No module named interface

I hope that someone could help me out. Thanks in advance.

Thilo
6 year ago
Reply to Janssuuh

Thanks for you reply. So my actual version is:
root@raspberrypi:/home/pi# python –version
Python 2.7.9

and please have a look at my log at pastebin:

https://pastebin.com/5YznL0FC

Thanks