rainbowRave.py
is a Python script that communicates with the CAN bus of a Ford Mach-E to change the colors of its interior lighting. It is designed to send a sequence of CAN messages that alter the light colors, creating a "rave" or cycling effect. The script utilizes the python-can
library for CAN bus interaction.
- Python 3.x
python-can
library- SocketCAN interface on a Linux system (e.g., Raspberry Pi, PC with CAN interface)
- A CAN transceiver connected to the vehicle's CAN bus
-
Ensure Python is installed:
sudo apt-get install python3
-
Install the
python-can
library:pip install python-can
-
Set up the CAN interface (e.g., SocketCAN):
sudo ip link set can0 up type can bitrate 500000 sudo ifconfig can0 up
- Imports: The script imports the required modules:
time
,can
, and sets up theBus
interface. send_message()
function: Sends a single CAN message with a specified arbitration ID and data payload.send_one()
function: Sends a series of predefined CAN messages that change the interior color.spam()
function: Continuously sends CAN messages in a loop with a brief delay to create a continuous lighting effect.
-
Ensure that your CAN transceiver is properly connected to the vehicle and configured on
can0
. -
Run the script:
python rainbowRave.py
-
The script will execute the
spam()
function by default, continuously sending color-change messages to the CAN bus to cycle through colors.
- Purpose: Sends a CAN message to the bus.
- Parameters:
arbitration_id
: The CAN ID for the message.data
: An array of bytes representing the payload.
- Returns: None. Prints a confirmation if successful or an error message if not.
- Purpose: Sends a predefined set of messages with different data payloads that correspond to color changes.
- Message Details:
- Arbitration ID:
0x3DA
- Data payloads: Different sets that adjust the color values.
- Arbitration ID:
- Returns: None. Calls
send_message()
iteratively for each data payload.
- Purpose: Continuously calls
send_one()
to create a cycling color effect. - Behavior: Runs indefinitely with a slight delay (
time.sleep(0.001)
) between iterations to avoid overwhelming the CAN bus.
- Safety First: This script interacts with the vehicle's CAN bus. Improper use can lead to unexpected behavior. Ensure you are familiar with CAN bus communication and its implications.
- Test Environment: Always test on a simulated environment or bench setup before running on a live vehicle.
- CAN Bus Integrity: Avoid spamming messages too rapidly as it may interfere with other vehicle systems.
To customize the color sequences or behavior:
- Modify the
messages
array insend_one()
with different data payloads to experiment with different color outputs. - Adjust the delay in the
spam()
function to modify the speed of the color cycling.
This script is provided as-is for educational and experimental purposes. Use at your own risk. Ensure compliance with local laws and regulations regarding vehicle modifications.
Manipulating the CAN bus of a vehicle should be performed with caution. The author is not responsible for any damages, legal implications, or issues resulting from the use of this script.