A Python project to receive and parse live UDP telemetry from Project CARS 2 (and Automobilista 2) and save it as JSON or display the data live.
Prerequisites
- Python 3.10+ (uses match/case syntax)
- Optional packages:
matplotlib(for live plotting) andbinio(required by packet formatting)
Install dependencies (example):
python -m pip install matplotlibRun the program
- Make sure your game is configured to send UDP telemetry to this machine's IP and port 5606 (default). PC listens on
0.0.0.0:5606. - Start the program:
python mainProgram.py- When you want to stop and export the captured data to JSON, type
stopat the prompt. The program will write a file named like<timestamp>.json.
Note: the program listens on port 5606 by default. If you need a different port, modify the
PCarsStreamReceiver(port=<your_port>)call inmainProgram.py.
To display live telemetry data as plots, you can use the LiveDisplay class in pcars2/extraModules.py.
It is currently set up to plot the players world position.
Top-level files
UDP_Definitions.hpp,projectcar1 UDP.hpp— C/C++ header dumps of UDP packet formats (reference only).mainProgram.py— Example entrypoint. Starts the UDP listener, collects packets into aLatestDatalistener, and exports captured data to a JSON file when stopped.extra info.txt— Links and references for related projects and packet specifications.
pcars2/ package
server.py— UDP server/receiver (classPCarsStreamReceiver). Listens on UDP, converts raw bytes into packet structures and dispatches them to listeners.packets.py—ctypesdefinitions of the raw packet binary structures (headers, telemetry, race, etc.).digestion.py— Functions that transformctypesraw structures into convenient Python objects/dicts.enums.py— Enumerations for game/session/flag/tyre values used throughout the parser.extraModules.py— Extra utilities (e.g.,LiveDisplayfor plotting telemetry usingmatplotlib, andremoveObjectsused to clean up data before JSON export).
For information on the UDP telemetry protocol used by Project Cars 1, see projectcar1 UDP.hpp. I cant verify if the code or the data format in this repository works with Project Cars 1, but it should be possible with minor modifications.
For extra information on Project CARS 1 UDP telemetry, see:
- Project CARS 1 Shared Memory API forum post (archived)
- Companion App UDP streaming forum post (archived)
For information on the UDP telemetry protocol used by Project CARS 2, see UDP_Definitions.hpp. For extra information on Project CARS 2 UDP telemetry, see:
- Project CARS 2 Telemetry viewer by Winzarten
- PC2 UDP File From sailDeep - pcar2-udp
- Additional references from jkowa - pcars2