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]
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
Hi Phil, Great to hear you got the Rns-e control function to work! You could use a script like this: #!/home/pi/sendVideoMessage.py # DECLARE IMPORTS EN VARIABELS # __________________________________________ import os import time from time import sleep # DECLARE FUNCTION # __________________________________________ def sendcan(): # Repeatively sending CAN message var=1 while var == 1: # Send CAN-message to tell Rns-e VIDEO input is available os.system(“cansend can0 602#8912300000000000”) # Sleep 0.2 seconds sleep(0.2) # CALL THE FUNCTION # __________________________________________ sendcan() #(end of script) In this example you save this script to location [/home/pi/sendVideoMessage.py] At /etc/rc.local you could add the next line to… Lees meer »
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?
Hi Phil,
I get that as a response a lot 🙂
I asume the rc.local link is ok. If so, there could be an error in the python script. What happends if you try to run the python manually?
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.
There is none.. I just made an example. I see this editor changes the appearance of the (“). These are used in: os.system(“cansend can0 602#8912300000000000”)
Could you check if these (double)quotes are just regular?! (Maybe type them yourself)
Comments are now also on the Forum!
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.
Hi Thilo, could you try to type; [python –version] in your terminal screen?! If it doesn’t reply with 2.7.9 than thats probably the issue.
Kind regards
Jeroen
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
Hi Thilo,
The ‘interface’ error it gives is a module installed with python-can. Have you tried installing this with the instructions on;
https://www.janssuuh.nl/blog/2016/03/18/python-can/
[pip install python-can]