SoftPanda

From Tinkla: Tinkering with Tesla
Revision as of 15:48, 28 May 2019 by BogGyver (talk | contribs) (A simple restart script)
To install and use the softPanda for IC/CID integration you have to have root access and mofiy important files on the IC and CID of your Tesla car. Please read carefully the whole document as well as the disclaimers. If you have questions or doubts, please reach out to our user group on the Comma.ai Tesla channel on Discord.
DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

Which source code branch is needed?

You will have to be on one of the branches in my repo that is based on OpenPilot 0.5.9 or above.


Changes to OpenPilot Configuration File

The following options must be set to true in the OpenPilot Configuration File for the IC/CID integration to work:

use_tesla_gps = True
use_tesla_map_data = True
has_tesla_ic_integration = True
# below is optional changes speedo from flying car to old non-ap gauge when EON is not connected; not implemented yet
use_analog_when_no_eon = True

Download softPanda Executable

Dwnload the softPanda Executable and place it in /var/root/bin

Download Language Strings File

Find and download the QtCar_xx.qm specific to your language (for example English is en) on both IC and CID and place it in /var/root/lang on both systems.

English - QtCar_en.qm

German - QtCar_de.qm

Changes on IC

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

Add the following 6 lines at the top of this Root:special file on IC. The language file should match the language set on your car and the file you downloaded above.

/bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm 
/usr/tesla/UI/bin/QtCar_en.qm
QCPORT=":20201"
export QCPORT
QCHPPORT=":31515"
export QCHPPORT

Changes on CID

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

Add the following 4 lines at the top of this Root:special file on CID. The language file should match the language set on your car and the file you downloaded above.

/bin/mount | /bin/grep -c /var/root/lang/QtCar >/dev/null || /bin/mount --bind /var/root/lang/QtCar_en.qm 
/usr/tesla/UI/bin/QtCar_en.qm
QCPORT=":20201"
export QCPORT
NOTE: Do NOT declare QCHPPORT on CID!!!

Updating Maps

Remove any old Map data:

If you have any of these files from the old Maps 3.x.x system in /opt/navigoff, delete them to free up space (otherwise rsync may run out of space). Leave other files / directories alone!. 5.5GB free space is required:

dr-xr-xr-x 4 nvidia fuse 4.0K Dec 19  2016 NA
dr-xr-xr-x 2 nvidia fuse  16K Dec 19  2016 lost+found
-r--r--r-- 1 nvidia fuse   17 Dec 19  2016 FILESYNC.VERSION
dr-xr-xr-x 2 nvidia fuse 4.0K Dec 19  2016 sound

Download Maps:

A high speed internet connection (wifi or LTE) is recommended, 3G will take a long time

sudo rsync -r -v --progress --partial --append-verify spam@maps-1620467086.us-west-2.elb.amazonaws.com:/var/data/maps/NA-180906-1605/ /opt/navigoff/

Startup Script

Use /var/root/scripts/startSoftPanda.sh script.

Changing the crontab

DISCLAMER: Improper changes to IC or CID can result in the system (and thus your car) being rederend unusable. Potentially not even Tesla can revert some of the changes if done incorrectly. You are doing this at your own risk. You alone are ultimately responsible, not the creator of this site, Comma.ai, Comma.ai community, Tesla, or anyone else. 

In order to start the script you need to modify your crontab. To make the script always-running:

sudo crontab -e

Then insert:

@reboot /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/startSoftPanda.sh
*/1 * * * * /sbin/start-stop-daemon --start --quiet --make-pidfile --oknodo --background --pidfile /var/run/proxy.pid --exec /bin/bash /var/root/scripts/startSoftPanda.sh

A simple restart script

The softPanda startup script creates a lock file and prevents two restarts in less than 10 minutes to allow you to still access your car computers in the event of a mistake. To manually restart the process you have to delete the lock file and then kill the softPanda process. Or just create a bash file with this content and run it.

Optional Flags

Here are the optional flags for softPanda EtherCan Proxy

  • -runOnIc: sets the spammer to run on IC instead of CID (CID default)
  • -triggerOnCan: start the spam only when receiving a certain CAN message from EON (OFF by default)
  • -autoRestartQtCarCluster: sends command to restart QtCarCluster when app starts (OFF by default)
  • -onlyCarConfig3: sends spam only for DasHw in GTW_carConfig3 (OFF by default)
  • -spamFrequency XX: spam frequency in Hz (100Hz by default)
  • -autopilot Y: autopilot mode (1:Highway, 2:Enhanced DEFAULT, 3:SelfDrive)
  • -bridge ZZZZZ: bridge mode where the packets received on 20101 are sent to port ZZZZZ (20102-27000)
  • -hBridge ZZZZZ: bridge mode where the packets received on 31415 are sent to port ZZZZZ (31515-32000)
  • -sendAfterReceive: sends modded message right after it is received (OFF by default)
  • -bindToPort WWWWW: Binds to a certain port and local IP address for sending (OFF by default)
  • -sendDiAccStatus: Send the DI_accStatus message; experimental for now (OFF by default)
  • -modifyDiState: Modifies the DI_state message for long control showing on IC (OFF by default)
  • -includeParrot: Include data from parrot to be sent through the bridge (OFF by default)
  • -includeLb: Include data from LB to be sent through the bridge (OFF by default)
  • -forwardDebug: forward also the debug messages show in Developer Mode (OFF by default)
  • -forwardUnique: forward only unique CAN messages in each direction (OFF by default)

Help, All Screens Are Black!

It’s not uncommon to see both IC and CID black the first time you start your car after enabling everything. This is caused by the CID not receiving messages from the gateway to wake up, which in turn is caused by softPanda having either not started or crashed. (Remember in the steps above we tell the CID to only listen to the gateway on the port softPanda proxies data to it on). The car will still drive with no screens, if you push the brake and wait 30 seconds for the gateway to give up trying to contact the screens.

Quickfix: Reboot the CID using the steering wheel (sometimes the speakers give a slight pop when the reboot command is executed). If everything is setup properly, the screens should come up. Steering wheel reboots are not preferred as they aren’t graceful restarts.

Preferred fix: ssh into the CID and restart softPanda, or troubleshoot what happened and then restart it.