• Category Archives Computers
  • Installing TunerStudio on Raspbian with autostart and push button clean shutdown!

    NO LONGER SUPPORTED. GO TO THE WIKI AND DOWNLOAD THE LATEST IMAGE.

    Requirements:

    1. Raspberry Pi 3 or 4
    2. Raspbian Linux
    3. TunerStudio
    4. Header to plug into the GPIO pins
    5. Push button

    Basic Concept:

    1. Start up the Raspberry Pi
    2. Boot into Raspbian
    3. Start TunerStudio automatically
    4. Exit TunerStudio clean with a push button
    5. Shutdown Raspbian clean after TS exits

    Download Raspbian here:
    https://www.raspberrypi.org/downloads/

    Installation notes for Linux, Mac OS, Windows images to SD Card here:
    https://www.raspberrypi.org/documentation/installation/installing-images/

    In Linux, my command was below. Be absolutely certain that /dev/sda is the location of your SD CARD!!!

    dd bs=4M status=progress if=2019-09-26-raspbian-buster-full.img of=/dev/sda

    Download TunerStudio or copy it to your SD Card. You can also boot into Raspbian and do this. My example will use Raspbian to do all of the work.

    Insert the SD card into your Raspberry Pi and power up. It may take a little bit to go thru the startup sequence for the first time. Once its booted up into Raspbian you’ll see the following screen, click Next and answer the questions. You’ll be asked for your locale, network config, change the password etc.

    Once complete, head over to download TunerStudio. Click on the blue globe on the top left to open your browser and go to this URL. Scroll to the bottom and download the latest TunerStudio for Linux version.
    http://www.tunerstudio.com/index.php/downloads

    Once the download is complete, open up a terminal session. Top left corner, looks like a >_ sign in a black box.

    Now we need to install TunerStudio, so you’ll do the following commands to decompress the file. At the time of this article, the version is 3.0.28 and the filename is TunerStudioMS_v3.0.28.tar.gz. The below commands will get you to your Downloads directory and show you the contents. If your file has a different name, use that instead of the one I just typed.

    cd Downloads
    ls -lsrth

    Lets move that file from our Downloads directory to the main directory and extract the contents.

    mv TunerStudioMS_v3.0.28.tar.gz /home/pi
    cd
    tar xf TunerStudioMS_v3.0.28.tar.gz
    ls -lsrth

    Now you should have a TunerStudioMS directory. Lets run TunerStudio and see if it works. You should see output saying something about it not being registered and then the awesome TS pops up. Once you do that, just exit. Time to get to work.

    cd TunerStudioMS
    ./TunerStudio.sh

    You should be back at the terminal screen. Lets create a script that starts up TunerStudio. We will be using the editor called nano. Paste the EXACT commands in the file and then save. If you screw up you can delete the file “del startts.sh” and start again.

    nano /home/pi/startts.sh

    Put this in the script and then save:

    #!/bin/bash
    cd /home/pi/TunerStudioMS
    ./TunerStudio.sh

    Make the script executable once you get to the prompt:

    chmod +x startts.sh

    Now lets run that script to see if TunerStudio starts up.

    ./startts.sh

    You should see the same TunerStudio screen. Exit. More work.

    Lets modify the boot up to start TunerStudio automatically. The following will change directory to the autostart directory where you will create a script to run TS.

    cd /etc/xdg/autostart
    sudo nano StartTS.desktop

    In the editor type this EXACTLY and when you’re done, save.

    [Desktop Entry]
    Type=Application
    Name=TunerStudioMS
    Comment=ts
    NoDisplay=false
    Exec=/usr/bin/lxterminal -e “/home/pi/startts.sh; read -n 1 -s”

    At this point you should be able to reboot and then TunerStudio should start up automagically. You should be sitting at a terminal prompt. Type the following to reboot:

    init 6

    Once rebooted, a terminal screen will pop up and then TunerStudio will start. Exit TunerStudio, hit return and then the terminal session will disappear.

    Lets set up the auto shutdown script. Click on the terminal icon which looks like a black box on the top left with a >_ in it. Then type the following two commands. The first copies the necessary commands you’ll need and the second installs it:

    git clone https://github.com/Howchoo/pi-power-button.git
    ./pi-power-button/script/install

    Now this is the interesting part. Once installed it runs some python code and starts waiting, listening for you to select the power off by hitting a button. Here is where it is on your Raspberry Pi, 3rd from the right. If you hook up a push button, once you press it, by default this will cleanly shut down the Pi but YOU’RE NOT DONE YET. The jumper was off of some old computer parts I had. You can do the same or make one. The other end of those two wires, I do not have a button on it yet. Need to order some since I lost my pack of buttons. If you’re like me and just want to test, expose the wire off of the red and black and then touch them together briefly. Your Pi will clean shutdown. Go ahead and power back on. We need to modify the python code and TunerStudio startup script that comes with TunerStudio.

    Exit TunerStudio and open a terminal session. Lets modify the original startup script TunerStudio comes with. We’ll create a backup in case you have a typo.

    cd TunerStudioMS
    cp TunerStudio.sh TunerStudio.sh.bak

    Here is the TunerStudio script. What is in BOLD RED is what you will ADD at the EXACT SPOT PICTURED!!! If you do this wrong you will screw up the TunerStudio startup script, but we have a backup. Scroll to the bottom of the script with your arrow keys and look for the line pictured. Add what is in BOLD RED. Once done, save.

    nano TunerStudio.sh

    cd “$BASE_PATH” && java -Djava.library.path=${SERIAL_DRIVER}lib -cp “.:lib:plugins” -jar TunerStudioMS.jar $1 &
    RESULT=$?

    echo $! > /tmp/ts.pid
    echo “kill -s TERM `cat /tmp/ts.pid`” >/home/pi/stopts.sh
    chmod +x /home/pi/stopts.sh


    if [ -d “$LAST_PATH” ]; then
    cd “$LAST_PATH”
    fi

    exit $RESULT

    At this point you should be back at the terminal prompt. We should be able to run TunerStudio and it should still start up the same. Lets give it a shot. Exit TS after it pops up.

    cd
    ./startts.sh

    If TunerStudio came up, no typos, you’ve done well. Last but not least, lets modify the python code to shut down TunerStudio and the Pi.

    Here is the original code:

    #!/usr/bin/env python

    import RPi.GPIO as GPIO
    import subprocess

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.wait_for_edge(3, GPIO.FALLING)

    subprocess.call([‘shutdown’, ‘-h’, ‘now’], shell=False)

    Edit the file :

    sudo nano /usr/local/bin/listen-for-shutdown.py

    Insert the lines in BOLD RED:

    !/usr/bin/env python

    import RPi.GPIO as GPIO
    import subprocess
    import os
    import time

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.wait_for_edge(3, GPIO.FALLING)

    os.system(‘/home/pi/stopts.sh’)
    time.sleep(15)


    subprocess.call([‘shutdown’,’-h’,’now’], shell=False)

    You can now reboot. Once booted into Raspbian, TunerStudio will start up and in the background you will have a process monitoring to see if you hit the “power button”. Once you do, TunerStudio will exit, 15 second time out, then the Raspberry Pi will shut down clean.

    If there is a way to improve on this, do so and reply back. Here’s a video of this done with my instructions.


  • Raspberry Pi Dash

    If you’re like me, the default gauge package you install is probably real gauges. I’m running the SpeedHut gauge package that was around $700 or so with a GPS speedo.

    With technology and an ECU like the one I’m running, the EFI Source Gold Box you’re able to run TunerStudio and take advantage of making your own gauges or modifying the gauges that come with it. TunerStudio is written in Java, so most newer operating systems like Linux and Windows are able to run this natively. Hell, you can even replace ALL OF YOUR GAUGES for about $135.

    Here comes the Raspberry PI. Its a small computer that many have used for things such as retro-gaming, small computing and various projects. What I’m doing is setting up a Raspberry Pi 3B+ with a 7″ touch screen display, 64GB microSD card, Raspbian Linux, GPS and of course, TunerStudio.
    In one pic you’ll see my gauges in full screen mode. I’ll make a video reviewing this setup soon.

    Here are some pics:

    7″ Touchscreen 1024×600 display, car power supply.
    Raspberry Pi 3B+
    TunerStudio running under Raspbian Linux and a small USB keyboard/touchpad combo.
    GPS Configured!
    The current dash I’ll use in TunerStudio
    Crusing around town in my Turbo LS powered Camaro!