Sponsored
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Nerds eh? MUTE!

After a remote-start, one of the side-effects of turning on the HVAC system is that it also turns on the uConnect radio. "THUMP THUMP THUMP THUMP." My neighbors don't need a wicked thumping bass line in the morning (or, well, probably ever).

The following script "mute" will report if the vehicle is currently muted or not (ON or OFF). You can mute and unmute the uConnect radio by saying "mute on" or "mute off". Those commands intelligently use the mute toggle button (only if needed) to achieve the desired result.

The latest iteration of my REMOTE-SMART auto-HVAC code will mute the stereo after the vehicle is started and unmutes it when the driver puts his hands on the keyless entry door handle. (Or unlocks the door. Or opens the door. Or hits the ignition button to unlock from remote-start mode.)

Code follows for the cool nerds. And Jeepeto. 😄
Code:
#!/bin/bash

# The script either detects or modifies the radio's mute setting.

usage() {
  echo ""
  echo "USAGE: $(basename $0) [on/off]"
  echo ""
  exit 1
}

TRIES=0
MAXTRIES=3
DEBUG=false
DELAY=1.1
MUTEID=99
MUTEWANTED=$(echo $1 | tr '[:lower:]' '[:upper:]')
[ "$MUTEWANTED" == "" ]    && MUTEWANTED=XX
[ "$MUTEWANTED" == "ON" ]  && MUTEWANTED=03
[ "$MUTEWANTED" == "OFF" ] && MUTEWANTED=00
[ "$MUTEWANTED" != "00" ] && [ "$MUTEWANTED" != "03" ] && [ "$MUTEWANTED" != "XX" ] && usage

read_error() {
  echo "FAILURE: Could not read the mute status."
  echo ""
  # Exit with a failure result code
  exit 1
}

write_error() {
  echo "FAILURE: Could not change the mute status."
  echo ""
  # Exit with a failure result code
  exit 1
}

request_mute () {

  # Collect fourth byte of message ID $25D on CAN-C.
  # After $DELAY seconds, stop collecting.

  COMMAND="timeout -s 1 $DELAY /usr/bin/candump -L can1,025D:0FFF"

  # Only collect messages which are a direct response to our own query.
  # All other messages will be ignored.

  RESPONSE=$( $COMMAND | cut -d# -f2 | cut -c7-8 | tail -1)
}

# MAIN PROGRAM LOOP BEGINS HERE ------------------------------------------
# Read the mute status. If it isn't what we want,
# hit the mute button!

while [ $MUTEID != $MUTEWANTED ]
  do

    # See what our mute status is (no actual request, just listening)
    request_mute

    # If no response was found, try again.
    if [ "$RESPONSE" == "" ] ; then
      DELAY=1.6
      /home/pi/bin/wake
      request_mute
    fi

    # If no response was found, try again.
    if [ "$RESPONSE" == "" ] ; then
      DELAY=2.2
      request_mute
      # If no response AGAIN, then exit with an error.
      if [ "$RESPONSE" == "" ] ; then read_error; fi
    fi

    MUTEID=$RESPONSE

    [ "$MUTEWANTED" == "XX" ] && {
      [ "$MUTEID" == "03" ] && { echo ON; exit 0; }
      [ "$MUTEID" == "00" ] && { echo OFF; exit 0; }
      echo UNKNOWN ; exit 1
    }


    # If the mute status isn't what we want, hit the mute toggle button.

    [ "$DEBUG" == "true" ] && echo MUTEID: $MUTEID   MUTEWANTED: $MUTEWANTED
    [ "$MUTEID" != "$MUTEWANTED" ] && {
      # It isn't what we want. We're hitting the MUTE toggle button.
      [ "$DEBUG" == "true" ] && echo TOGGLING MUTE
      cansend can0 2D3#0700010000000000 ; sleep 0.21
    }

    # We're going to try up to FIVE times to change the mute status.
    # After that, exit with an error.

    TRIES=$(( $TRIES + 1 ))
    [ "$TRIES" -gt $MAXTRIES ] && write_error

  done

# A clean exit. Either we reported a value, made a change, or was requested
# to make a change but no change was necessary.

exit 0
 

Jeepeto

Well-Known Member
First Name
Josh
Joined
Jul 24, 2021
Threads
36
Messages
2,244
Reaction score
5,631
Location
North Texas
Vehicle(s)
2021 JLUR XR
Build Thread
Link
Occupation
Sparky
Vehicle Showcase
2
Clubs
 
I’m just jealous 😂

I started reading the first page and quickly realized you guys were in a different league of DIY. Since I couldn’t understand WTH was going on I defaulted to “nerds”

It was so dense that I just skipped over the remaining 18 pages. What all have you been able to do? Sounds like maybe you are just using a raspberry pit to control everything? Pretty neat stuff.
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
It was so dense that I just skipped over the remaining 18 pages. What all have you been able to do? Sounds like maybe you are just using a raspberry pit to control everything? Pretty neat stuff.
Right now, we're reverse engineering CAN bus traffic and we're trying to figure out the brave new world of Unified Diagnostic Services. Those aren't the fun things. Those are two major pieces of homework which allows us to make fun things. That aside, we've started making progress towards our own projects.

RedRacer has mounted a touchscreen display above his uConnect radio that he's going to use for his own technical/infotainment/offroad/vehicle features. There are some really interesting sensors built into the Wrangler and there are any number of controls which can be taken over by a computer. The coolest things can sometimes be the riskiest things, but we're not there... yet.

My first project was to create a CAN bus black box recorder to help explain why my vehicle hesitates a full 1.6 seconds after you floor it. I don't yet have a complete answer, but using what we learned here, I narrowed the focus to the transmission, and I found that an incorrect tire size (programmed into the Wrangler) was responsible for 0.6 seconds of delayed rev-matching into gear.

My second project was to have the HVAC controls come on full when you remote start the vehicle. Right now, the HVAC will only turn on if it is below 40F, and even then, it barely does any cabin heating (more windshield heating, really) in a default automatic setting. I wanted the cabin fully heated in winter and chilled in summer, and I've got it working very nicely! At this point, I'm just adding bells and whistles.

We've discovered plenty of cool things so far, but I'm going to go back to more of the homework in the hopes of unlocking some really amazing new features.

PS: If someone has a hardware mod for the Wrangler that could better integrate with the vehicle's smarts, I think that's something that we'd like to help flesh out. There are some good hardware/software partnerships to be made here.
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
New Project? RGB *Smart* Halo Lights

I think I may have walked into a new project.

I pulled the trigger on an Amazon Lightning Deal for some budget 9" RGB LED headlights. As it turns out, the RGB elements are quite good. As you'd expect, you can choose a new default setting over bluetooth.






As long as I can snoop and reverse engineer the protocol they're using to set a pattern, I'm going to have the vehicle be able to change it anytime it wants to and for whatever reason. That means that I can have them react in direct response to virtually anything the vehicle is doing. I just need to write a rule to detect one of the many features we've learned so far:

Acceleration, braking, turning (with or without turn signals), rough road surfaces, sudden braking, turbo boost, loss of traction, keyless entry, panic alarm, radio volume, gear selector, seatbelt use, battery voltage, cabin lights, new song title (from the radio), time of day, date, compass heading, distance traveled...​

I don't think this is anything that anybody's doing right now. Any thoughts on what factors are going to make the best custom RGB halo events? Any experience sniffing and spoofing simple bluetooth device traffic?
 
Last edited:

Sponsored

OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
New Project? RGB *Smart* Halo Lights

I think I may have walked into a new project.
I just now noticed how much of the underlying technology was given away by one of their product images at Amazon.

Jeep Wrangler JL JEEP HACKING CAN-C / CAN-IHS / UDS ! (Reverse Engineering) 1642909096049


So it is a WS2811-compatible array of individually addressable LED chips? Okay. Now I know what that is. I'm assuming that their microcontroller addresses both halos simultaneously (with the same pattern) so there are a shared 36 LED elements per halo. That puts each one spaced 10 degrees apart.

There are quite a few libraries and projects for Arduino and Raspberry Pi which allow you to directly control arrays of WS2811 compatible lights. In fact, they typically control much larger arrays... hundreds of elements off of a single GPIO line.

My preference is still going to be to use this device's own built-in bluetooth controller like a subprocessor where I tell it the color or pattern I want it to play and let it handle all the work. But I've never reverse engineered a bluetooth device before, so I don't know how much trouble that's going to be.

At least this opens the door to a plan B where I can take control of the LED segments and pump whatever color pattern into them that I see fit.

EDIT: If I only had the time to burn, I'd create a CAN-aware WS2811 controller. Given the opportunity to spread RGB devices around a vehicle, that actually starts to make some sense.
 
Last edited:

redracer

Well-Known Member
First Name
Robert
Joined
Aug 22, 2017
Threads
20
Messages
558
Reaction score
619
Location
Manteca, CA
Vehicle(s)
2023 4xe Rubicon
EDIT: If I only had the time to burn, I'd create a CAN-aware WS2811 controller. Given the opportunity to spread RGB devices around a vehicle, that actually starts to make some sense.
This has been on my mind as well. small can devices that can be placed anywhere in the vehicle. for lights, relays, etc... Just use can addresses not used by the jeep and it's all good without the hassle of running wires..
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
This has been on my mind as well. small can devices that can be placed anywhere in the vehicle. for lights, relays, etc... Just use can addresses not used by the jeep and it's all good without the hassle of running wires..
Yes! And it works out two different ways. First, you can directly address them and tell multiple units at once (in a synchronized manner) what pattern to start playing. Second, you could have another set of commands that instructs these CAN devices to themselves listen to to existing CAN traffic for specific messages that they can take their own cues from.

For example: you could tell the undercarriage lights to run pattern #3 based off of vehicle speed. You could have the rear wheel wells run a reactive flashing pattern based upon X/Y/Z jolts to the rear axle (same idea for the front axle). You could have a different set of reactive lights in the engine bay which respond to RPM or intake manifold pressure. And then you could have whatever glowing patterns in the headlights (and/or the front grill), but they'd monitor the CAN bus for the vehicle's turn indicator so they'd know when to do some switchback signaling.

I may have oversold it. But the idea works really well for keeping light patterns in sync vehicle-wide, and then also for expressions based upon vehicle parameters.

Now I've caught myself looking at AliExpress for an outdoor LED matrix that might nicely fit behind the front grill while preserving enough airflow...

PS: I went ahead and bought a SP105E (bluetooth controller) and a SP108E (Wi-Fi controller) as an alternative means to control those RGB LED headlights. I've already found one project which manages to control the SP108E over an ad-hoc Wi-Fi network. But I'd feel more secure with the Wi-Fi transmitter powered down.
 

redracer

Well-Known Member
First Name
Robert
Joined
Aug 22, 2017
Threads
20
Messages
558
Reaction score
619
Location
Manteca, CA
Vehicle(s)
2023 4xe Rubicon
PS: I went ahead and bought a SP105E (bluetooth controller) and a SP108E (Wi-Fi controller) as an alternative means to control those RGB LED headlights. I've already found one project which manages to control the SP108E over an ad-hoc Wi-Fi network. But I'd feel more secure with the Wi-Fi transmitter powered down.
I'd suggest to avoid these canned controllers. heh, canned. lol...

Instead, use any arduino, esp32, etc... that you want. The libraries to talk to these are published and well known. I've done this at christmas time just wrapping the roll bar and inside of the spare tire with WS2811 strip hooked to an arduino with my own christmas patterns for a parade run. I've also loaded up a foam board RC wing with them and used an old arduino based flight controller to drive them based off an pwm input from the receiver, easy and lots of fun to fly at night.

This would be a great use of any of the embedded boards I posted earlier with onboard can.
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Read or Change the HVAC Fan Speed

We've got another HVAC control script, this one is called "fanspeed".

Without any arguments, it returns the actual speed (01 through 07) of the HVAC blower motor (even if the fan was set to AUTO). If the HVAC system is off, it will return a speed of 0 (OFF).

To change the HVAC fan speed, supply a number from 1 (lowest) to 7 (max). For example, "fanspeed 7" sets the fan to it's highest value. The script will wait until the new speed has been achieved before exiting. (Otherwise, it will attempt to adjust the controls up to five more times.)

For my work-in-progress, the Remote Smart device, I can use this to record the vehicle's initial fan speed setting, and then adjust it to MAX for as long as it takes for the vehicle to warm up (or cool down). Once the driver starts to enter the vehicle, then we can start restoring their original HVAC controls (or instead use an automatic setting).

An AUTO fan speed selection is not included in this script because the AUTO button sets both an automatic blower motor speed and an automatic vent selection. If you wish to engage both of those functions, use the "ventmode 0f" command instead.

Beware the hard-coded path to the "wake" script.

Script follows:
Code:
#!/bin/bash

# This script reads or sets the HVAC fan speed.

usage() {
  echo ""
  echo "USAGE: $(basename $0) [speed]"
  echo "  When setting values: 01 (low) through 07 (max)"
  echo "  When reading values: 00 (off), 01 (low) through 07 (max)"
  echo " "
  exit 1
}

TRIES=0
MAXTRIES=5
DEBUG=false
DELAY=1.1
SPEEDID=99
SPEEDWANTED="$1"

SHOWUSAGE=1
[ $SPEEDWANTED -gt 0 ] 2>/dev/null && [ $SPEEDWANTED -lt 8 ] 2>/dev/null && SHOWUSAGE=0
[ "$SPEEDWANTED" == "" ] && { SPEEDWANTED="XX"; SHOWUSAGE=0; }

[ $SHOWUSAGE -eq 1 ] && usage

read_error() {
  echo "FAILURE: Could not read a valid fan speed message."
  echo ""
  # Exit with a failure result code
  exit 1
}

write_error() {
  echo "FAILURE: Could not change the fan speed to the desired value."
  echo ""
  # Exit with a failure result code
  exit 1
}

request_fan_speed () {

  # Collect fan speed from message ID $2B1 on CAN-C
  # This message repeats one time per second.
  # After $DELAY seconds, stop collecting.

  COMMAND="timeout -s 1 $DELAY /usr/bin/candump -L can1,02B1:0FFF"

  # Only collect messages which are a direct response to our own query.
  # All other messages will be ignored.

  RESPONSE=$( $COMMAND | cut -d# -f2 | cut -c1-2 | tail -1)
}

# MAIN PROGRAM LOOP BEGINS HERE ------------------------------------------
# Read the HVAC fan speed. If it isn't what we want, hit the "FAN +" or
# the "FAN -" as many times as neeeded. Lather, rinse, repeat. Delays are
# introduced into each of these loops in order to avoid hysteresis.

while [ $SPEEDID != $SPEEDWANTED ]
  do

    # Read the HVAC fan speed from the CAN bus
    request_fan_speed

    # If no response was found, send a wakeup packet. Try again.
    if [ "$RESPONSE" == "" ] ; then
      DELAY=1.1
      /home/pi/bin/wake ; sleep 0.5
      request_fan_speed
    fi

    # If no response was found, send a wakeup packet. Try again.
    if [ "$RESPONSE" == "" ] ; then
      DELAY=1.8
      /home/pi/bin/wake
      request_fan_speed

      # If no response AGAIN, then exit with an error.
      if [ "$RESPONSE" == "" ] ; then read_error; fi
    fi

    SPEEDID=$( printf "%d" 0x$RESPONSE )
    # A speed of "127" means offline, so we'll treat it as fan speed 0.
    [ $SPEEDID -eq 127 ] && SPEEDID=0
    [ $SPEEDID -gt 7 ] && read_error

    # If the user supplied no arguments, print the fan speed and exit.
    [ "$SPEEDWANTED" == "XX" ] && {
      echo $SPEEDID
      exit 0
    }

    # If the current HVAC fan speed isn't what we want, then hit the
    # appropriate fan speed buttons to increase or decrease it.

    [ "$DEBUG" == "true" ] && echo SPEED: $SPEEDID   DESIRED: $SPEEDWANTED

    [ "$SPEEDID" -lt "$SPEEDWANTED" ] && {
        for i in $( seq $SPEEDID $(( $SPEEDWANTED -1 )) )
        do
          # Increase the fan speed
          # Use a larger delay to compensate for fan spin-up time
          [ "$DEBUG" == "true" ] && echo REQUESTING FAN SPEED INCREASE
          cansend can0 273#0000050000000000; sleep 0.73
        done
        # exit 0
      }
    [ "$SPEEDID" -gt "$SPEEDWANTED" ] && {
        for i in $( seq $SPEEDWANTED $(( $SPEEDID -1 )) )
        do
          # Decrease the fan speed
          # Use a short delay because fans wind-down quickly.
          [ "$DEBUG" == "true" ] && echo REQUESTING FAN SPEED DECREASE
          cansend can0 273#00000A0000000000; sleep 0.23
        done
        # exit 0
      }

    [ "$SPEEDID" -eq "$SPEEDWANTED" ] && exit 0

    # We're going to try up to FIVE times to change the HVAC fan speed.
    # After that, exit with an error.

    TRIES=$(( $TRIES + 1 ))
    [ "$TRIES" -gt $MAXTRIES ] && write_error

  done

# A clean exit. Either we reported a value, made a change, or was requested
# to make a change but no change was necessary.

exit 0
 

Sponsored

OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Improving the "Remote" Script

The "remote" script is used to monitor keyfob activity. So when the keyfob is used to lock and unlock the doors, it's also being used to lock and unlock access to the vehicle via WiFi. Simple enough, right?

But time and again, this control scheme really hasn't worked out well for me. I don't want to have to leave my vehicle unlocked in order to access it's server via WiFi. I want to be able to log into the vehicle while it's doors are still locked. So I'm making a change to how the controls work.

With this change, the only keyfob activity that does anything is a quick second tap of the unlock button. That button combo is now used to toggle the WiFi transmitter power off and on. As of today, it is now possible to power up the WiFi transmitter and log into the server regardless of if the vehicle's doors are locked or unlocked.

Unlock (2nd tap): DISABLES WIFI​
Unlock (2nd tap): ENABLES WIFI​
Unlock (2nd tap): DISABLES WIFI​
Unlock (2nd tap): ENABLES [...]​
Unlock (1st tap): UNLOCKS DOORS​
Lock (any number of taps): LOCKS DOORS​

I realize this isn't the most interesting thing, but I'm publishing my work as I go along and this is a real quality-of-life change that improves things for me.

New source code follows:
Code:
#!/bin/bash

touch /tmp/remote

# Do some quick WiFi Tuning (might produce errors, that's okay)
iwconfig wlan0 rate auto
iwconfig wlan0 rts 2304
iwconfig wlan0 frag 2304

# Monitors for *remote* door lock/unlock commands and uses
# those to disable/enable the Raspberry Pi's WiFi transmitter.
#
# Locked = WiFi Off (secure)
# Unlocked = WiFi On (less secure)

# Tunable variables:

# Name for the CAN-IHS interface (can0, can1, vcan0, etc)
CANIHS=can0
WIFIDEV=wlan0
DEBUG=false  # Values: true,false,raw
LOCKED=0

LASTREMOTE="1C0#FFFFFFFFFFFF"
sleep 5

candump -L $CANIHS,01C0:0FFFF | while read time bus REMOTE
do

[ $DEBUG == "raw" ] && echo CAN-IHS data: $REMOTE
HEADER="TIME  : $time $( date )\nDATA  : $REMOTE"

# LOCK COMMAND: WIFI TURNED OFF (SECURED)
if [ "$REMOTE" == "1C0#210000900000" ] ; then
  if [ "$REMOTE" != "$LASTREMOTE" ] ; then
    [ $DEBUG == "true" ] && echo -e "$HEADER"
    [ $DEBUG == "true" ] && echo "EVENT : KEYFOB LOCK COMMAND RECEIVED"
    [ $DEBUG == "true" ] && echo "ACTION: NONE"
    [ $DEBUG == "true" ] && echo ""
  fi
fi

# 1ST UNLOCK COMMAND: NO ACTION TAKEN
if [ $REMOTE == "1C0#230000900000" ] ; then
  if [ "$REMOTE" != "$LASTREMOTE" ] ; then
    [ $DEBUG == "true" ] && echo -e "$HEADER"
    [ $DEBUG == "true" ] && echo "EVENT : KEYFOB 1ST UNLOCK COMMAND RECEIVED"
    [ $DEBUG == "true" ] && echo "ACTION: NONE"
    [ $DEBUG == "true" ] && echo ""
  fi
fi

# 2ND UNLOCK COMMAND: WIFI TURNED ON (LESS SECURED)
if [ $REMOTE == "1C0#240000900000" ] ; then
  if [ "$REMOTE" != "$LASTREMOTE" ] ; then
    [ $DEBUG == "true" ] && echo -e "$HEADER"
    [ $DEBUG == "true" ] && echo "EVENT : KEYFOB 2ND UNLOCK COMMAND RECEIVED"

    # Flip between locked (LOCKED=1) and unlocked (LOCKED=0)
    LOCKED=$(( ! $LOCKED ))

    [ $LOCKED -eq 0 ] && {
      # ENABLING WIFI TRANSMITTER
      # All commands appear to be necessary even if they return errors.
      # Use extreme care when editing the following section.
      echo $(date) REMOTE: Turning on Wi-Fi Device
      iwconfig $WIFIDEV txpower on
      sleep 5
      iwconfig $WIFIDEV txpower auto
      sleep 2
      ifconfig $WIFIDEV up
    }

    [ $LOCKED -eq 1 ] && {
      # DISABLING WIFI TRANSMITTER
      echo $(date) REMOTE: Turning off Wi-Fi Device
      ifconfig $WIFIDEV down
      sleep 2
      iwconfig $WIFIDEV txpower off
    }

    [ $DEBUG == "true" ] && echo ""
  fi
fi

# IDLE (NO COMMANDS): NO ACTION
if [ $REMOTE == "1C0#000000800000" ] ; then
  if [ "$REMOTE" != "$LASTREMOTE" ] ; then
    [ $DEBUG == "true" ] && echo -e "$HEADER"
    [ $DEBUG == "true" ] && echo "EVENT : IDLE STATE (DEFAULT) HAS RESUMED"
    [ $DEBUG == "true" ] && echo "ACTION: NONE"
    [ $DEBUG == "true" ] && echo ""
  fi
fi

# KEEP TRACK OF WHAT THE PREVIOUS COMMAND WAS.
# THIS MAY BE USEFUL TO TRACK WHEN MONITORING OTHER CAN BUS IDs.
LASTREMOTE=$REMOTE

done
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Work in Progress: AutoHeat

If the "autohvac" script has been called (because the vehicle was remotely started), it checks the cabin temperature and either launches an "autocool" or an "autoheat" script. This is "autoheat" script.

It turns on the blower to full, splits the air between the windshield and the floor, syncs the driver and passenger temperature to MAX, enables air recirculation, and mutes the radio. After this runs for ten minutes (or the driver enters the vehicle), another script takes control and further tweaks the HVAC settings.

Script follows:
Bash:
#!/bin/bash

STARTED=$( date +%s )

# Sets HVAC preferences when vehicle has been remotely started.
echo "$(date) AUTOHEAT: Initializing."

procs="$( ps -eaf | grep autoheat | grep -v grep | grep -v " $$ " | wc -l )"
if [ $procs -gt 0 ]
  then
    echo "$(date) AUTOHEAT: ERROR - more than one process running! Exiting."
    exit 1
  fi

# If the blower motor is off, turn on the HVAC system.
FANSPEED=$( /home/pi/bin/fanspeed )
[ "$FANSPEED" == "0" ] && {
  echo "$(date) AUTOHEAT: turning on HVAC system"
  cansend can0 2D3#0700000000010000
  sleep 4.1
}

# Store settings
VENTMODE=$(/home/pi/bin/ventmode)
FANSPEED=$(/home/pi/bin/fanspeed)
echo "$(date) AUTOHEAT: Current VENT: $VENTMODE and SPEED: $FANSPEED"

# Mute the stereo
echo "$(date) AUTOHEAT: Muting the radio"
/home/pi/bin/mute ON  ; sleep 0.31

# Turn the fan all the way up
echo "$(date) AUTOHEAT: setting fan to MAX"
/home/pi/bin/fanspeed 7

# Turn on the HVAC front defroster
# This also turns OFF the air conditioner and turns OFF air recirculation.
echo "$(date) AUTOHEAT: clearing modes via the front defroster"
/home/pi/bin/ventmode 00 ; sleep 1.12

# Select a vent combination of windshield and floor
echo "$(date) AUTOHEAT: directing air to windshield and floor"
ventmode 02 ; sleep 1.12

# Turn on air recirculation.
# This automatically causes the A/C to engage, so we'll need to undo that.
echo "$(date) AUTOHEAT: recirculating air"
cansend can0 2D3#0700000000000200
sleep 1.1

# Start setting the driver side to maximum heat setting
# Just 8 steps at first.
for i in `seq 1 8`
do
  cansend can0 2D3#0700000000040000
  sleep 0.36
done
sleep 0.6

echo "$(date) AUTOHEAT: turning OFF the AC system"
# Turn off the A/C cooling (was turned on with recirculate mode)
cansend can0 2D3#0700000000000100
sleep 0.6

echo "$(date) AUTOHEAT: setting temperature to MAX"
# Finish setting the driver side to maximum heat setting
# Now 18 more steps.
for i in `seq 1 18`
do
  cansend can0 2D3#0700000000040000
  sleep 0.36
done
sleep 0.6

# Alter the passenger temperature up and down to break any temperature sync
echo "$(date) AUTOHEAT: Syncing driver/passenger settings"
cansend can0 2D3#0700000000100000
sleep 0.36
cansend can0 2D3#0700000000200000
sleep 1.93

# Engage the Driver / Passenger temperature Sync
  cansend can0 342#0000000400
  sleep 1.61

echo "$(date) AUTOHEAT: exiting normally."
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Work In Progress: AutoCool

This is the opposite of the AutoHeat script.

If necessary, it turns on the HVAC system. It mutes the radio, sets the fan speed to maximum, focuses all the air through the front (and rear) dash vents, sets the temperature to MIN, turns on the AC compressor, turns OFF air recirculation, and then syncs the driver and passenger HVAC settings.

When the driver enters the vehicle, another script takes control to normalize the environment so it isn't blasting the driver with an unrelenting flow of cool air.

Script follows:
Bash:
#!/bin/bash

STARTED=$( date +%s )

# Sets HVAC preferences when vehicle has been remotely started.
echo "$(date) AUTOCOOL: Initializing."

procs="$( ps -eaf | grep autoheat | grep -v grep | grep -v " $$ " | wc -l )"
if [ $procs -gt 0 ]
  then
    echo "$(date) AUTOCOOL: ERROR - more than one process running! Exiting."
    exit 1
  fi

# ALL PREFLIGHT CHECKS HAVE ALREADY BEEN DONE.
# WE CAN BEGIN OUR WORK IMMEDIATELY.

# If the blower motor is off, turn on the HVAC system.
FANSPEED=$( /home/pi/bin/fanspeed )
[ "$FANSPEED" == "0" ] && {
   echo "$(date) AUTOCOOL: turning on HVAC system"
   cansend can0 2D3#0700000000010000
   sleep 4.1
}

# Store settings
VENTMODE=$(/home/pi/bin/ventmode)
FANSPEED=$(/home/pi/bin/fanspeed)
echo "$(date) AUTOCOOL: Active VENT $VENTMODE and SPEED $FANSPEED"

# Mute the stereo
echo "$(date) AUTOCOOL: Muting the radio"
/home/pi/bin/mute ON  ; sleep 0.31

# Set the fan speed to maximum
echo "$(date) AUTOCOOL: setting fan to MAX"
/home/pi/bin/fanspeed 7

# Set the front defroster (which deactivates recirculation mode and AC mode)
echo "$(date) AUTOCOOL: clearing modes with front defroster"
/home/pi/bin/ventmode 00
sleep 1.12

# Now, select the exact blower we want (the main vents)
echo "$(date) AUTOCOOL: directing air to panel vents"
ventmode 08

# Start setting the driver side to maximum cool setting
# Just 8 steps at first.
for i in `seq 1 8`
do
  cansend can0 2D3#0700000000080000
  sleep 0.36
done
sleep 0.6

# Turn on the A/C cooling (turns on with recirculate mode)
echo "$(date) AUTOCOOL: Turning on AC system"
cansend can0 2D3#0700000000000100
sleep 0.6

echo "$(date) AUTOCOOL: setting temperature to LOW"
# Finish setting the driver side to maximum cool setting
# Now 18 more steps.
for i in `seq 1 18`
do
  cansend can0 2D3#0700000000080000
  sleep 0.36
done
sleep 0.6

# Turn OFF air recirculation (which came on with the AC)
echo "$(date) AUTOCOOL: Turning OFF air recirculation"
cansend can0 2D3#0700000000000200

echo "$(date) AUTOCOOL: Syncing driver/passenger settings"
# Alter the passenger temperature down and up to break any
# existing temperature sync
  cansend can0 2D3#0700000000200000
  sleep 0.36
  cansend can0 2D3#0700000000100000
  sleep 0.63

sleep 1.3

## Sync the driver/passenger HVAC controls
cansend can0 342#0000000400
sleep 0.61

echo "$(date) AUTOCOOL: exiting normally."
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
This can also be big news for Diesel owners wanting to be able to manually initiate a regen as it can be as simple as sending a single canbus command, given we can figure out what that is.
Okay, now I'm seeing the connection. More powerful OBD-II tools also provide for Unified Diagnostic Services commands do assist in things such as bleeding the brakes, (electronically) centering the steering wheel, and purging the DPF (diesel) filter.

I'll be keeping my eyes out for this, now that I know that it is "a thing".
 
OP
OP
jmccorm

jmccorm

Well-Known Member
First Name
Josh
Joined
Sep 15, 2021
Threads
54
Messages
1,153
Reaction score
1,275
Location
Tulsa, OK
Vehicle(s)
2021 JLUR
Build Thread
Link
Occupation
Systems Engineering
Printing a String to EVIC

I'll need someone to test this because I can't so easily go back-and-forth between my PC and my vehicle. I created a script called 'evic' where you supply a line number (3=title line, 2=artist line,1=device name) and a text message, and it displays that on the music screen of the dash (kind of like a Taser does).

Can someone try it out and let me know if it works okay? (Just don't let the messages get too long.) You give it the line number and then the string you want to say. Also remember that one of them (I think it is the Device Name or #1) clears the screen. Examples:

evic 1 Inet Radio
evic 2 jmccorm
evic 3 Songs about EVIC
UPDATE: It works!
Jeep Wrangler JL JEEP HACKING CAN-C / CAN-IHS / UDS ! (Reverse Engineering) 1643063178010

Source code follows:
Bash:
#!/bin/bash

# This script turns text into an EVIC dash message
# STRING TIPS: https://linuxhandbook.com/bash-string-length/
# ARRAY  TIPS: https://www.shell-tips.com/bash/arrays/

[ "$2" == "" ] && {
  echo "USAGE: $(basename $0) [line] [text]"
  echo "  Displays [text] on the EVIC music information page"
  echo "  Valid line numbers are: 2 (artist), 3 (title) 1 (input name)"
  echo ""
  exit 1
}

FUNCTION=$1
shift
declare -a message
string="$@"
length=${#string}
remainder=$(( ( 3 - ( $length % 3 ) ) % 3 ))
POSITION=1
for i in $( seq 1 $length)
do
  message[$POSITION]='00'
  POSITION=$(( $POSITION + 1 ))
  message[$POSITION]=$(printf "%02X" "'${string:$(( i - 1 )):1}'")
  POSITION=$(( $POSITION + 1 ))
done
for i in $( seq 1 $remainder )
do
  message[$POSITION]=00
  POSITION=$(( $POSITION + 1 ))
  message[$POSITION]=00
  POSITION=$(( $POSITION + 1 ))
  length=$(( $length + 1 ))
done
lines=$(( $length / 3 ))
[ "$DEBUG" == "true" ] && echo "FUNCTION: $function"
[ "$DEBUG" == "true" ] && echo "STRING  : $string"
[ "$DEBUG" == "true" ] && echo "LENGTH  : $length characters ($lines lines)"
[ "$DEBUG" == "true" ] && echo "ENCODED : ${message[*]}"

POSITION=1;INIT=4
for i in $( seq $(( $lines -1 )) -1 0 )
do
  LINE=$(printf "%x" $i)
  COMMAND="cansend can0 328#${LINE}0.${INIT}${FUNCTION}"
  for j in 1 2 3 4 5 6
  do
    COMMAND="$COMMAND.${message[$POSITION]}"
    POSITION=$(( $POSITION + 1 ))
  done
  $COMMAND ; sleep 0.002
  INIT=0
done
cansend can0 328#00.00.00.00.00.00.00.00
sleep 0.005
This is going to be a really big help to me because now I can print debug information to the dash and see what's going on without hooking up a keyboard and mouse to the vehicle.

UPDATE: I reduced some of the sleep values which allows this to run faster. I also changed the final message to all zeros, as it should have been.
Sponsored

 
Last edited:
 



Top