#!/bin/bash # # wake.sh -- wake the CAN bus by simulating a center-dash button press. # # Usage: # wake.sh # # Originally created: 01.2022 by jmccorm # Last updated: 05.2026 (polish by magikh0e) # # WHAT IT DOES # Sends a Network Management (NM) wake frame on CAN-IHS that # mimics the press of a fictitious center-dash button. ECUs in # low-power state see traffic on $2D3 and bring themselves back # to operational, which makes the CAN bus carry traffic again so # other scripts (mute.sh, 3rd_brakelight.sh, etc.) have something # to read or write against. # # FRAME FORMAT # $2D3 07 00 00 00 00 00 00 X0 # # byte 0 = 0x07 NM frame type / source identifier # byte 1 = 0x00 # byte 2 = 0x00 on a real button press, would be the # button bitmap (0x01 = mute, etc.); 0x00 # here means "no button" # bytes 3-6 = 0x00 # byte 7 high nibble = random 0..F per invocation # low nibble = 0 # # The random high nibble of byte 7 keeps repeated wake calls from # looking identical to the BCM. Without it, the BCM may interpret # N identical $2D3 frames in a row as a stuck button and either # filter them or trigger an error condition. A fresh random value # on every call defeats that detection. # # REQUIRES # - can-utils (cansend) apt install can-utils # - CAN-IHS up at 125 kbps on can0 in this script # # WHO CALLS IT # - mute.sh uses an inlined copy of this logic in its # wake_bus() function (the polished version on this site dropped # the external dependency on /home/pi/bin/wake to stay # self-contained). # - Any script that needs the bus carrying traffic before its # candump listener has something to read can call this first. # # REVISION NOTES (2026-05-16) # - Added header explaining the frame format and the random-nibble # stuck-button-avoidance rationale (the original 2-line script # was correct but cryptic). FAKE=$(printf "%x" $(( $RANDOM & 15 ))) cansend can0 2D3#07000000000000${FAKE}0