### Initialize ETS2 Telemetry Client Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Initializes the main telemetry client which starts a background thread for polling shared memory. Accesses general game telemetry like time, pause state, and truck information. Ensure to stop the polling thread when done. ```python from ets2sdktelemetry import Ets2SdkTelemetry # Initialize the telemetry client (starts background polling at 25ms intervals) telemetry_client = Ets2SdkTelemetry() # Access the current telemetry data telemetry = telemetry_client.ets2telemetry # Check game state print(f"Game Time: {telemetry.Time}") print(f"Game Paused: {telemetry.Pause}") print(f"Truck: {telemetry.Manufacturer} {telemetry.Truck}") # Stop the background polling when done telemetry_client.threading_event.set() ``` -------------------------------- ### Retrieving SDK and Game Version Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Fetches the telemetry plugin revision and the current ETS2 game version. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() version = client.ets2telemetry.Version print(f"SDK Plugin Revision: {version.SdkPlugin}") print(f"ETS2 Version: {version.Ets2Major}.{version.Ets2Minor}") ``` -------------------------------- ### Build Real-time ETS2 Telemetry Dashboard Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt This script initializes the Ets2SdkTelemetry client and enters a continuous loop to fetch and display truck physics, drivetrain status, and active job details. It includes error handling for keyboard interrupts and utilizes a threading event to ensure clean resource cleanup. ```python import time from ets2sdktelemetry import Ets2SdkTelemetry def run_dashboard(): """Real-time ETS2 telemetry dashboard.""" client = Ets2SdkTelemetry() try: while True: t = client.ets2telemetry # Clear screen (platform dependent) print("\033[2J\033[H", end="") # Header print(f"=== {t.Manufacturer} {t.Truck} ===") print(f"Game Time: {t.Time} | Paused: {t.Pause}") print() # Speed and engine print(f"Speed: {t.Physics.SpeedKmh:6.1f} km/h | RPM: {t.DriveTrain.EngineRpm:5.0f}") print(f"Gear: {t.DriveTrain.GearDashboard:3d} | Fuel: {t.DriveTrain.Fuel:6.1f}L") print() # Job info if t.Job.OnJob: print(f"Job: {t.Job.CitySource} -> {t.Job.CityDestination}") print(f"Cargo: {t.Job.Cargo} ({t.Job.Mass:.0f} kg)") print(f"Distance: {t.Job.NavigationDistanceLeft/1000:.1f} km | Income: €{t.Job.Income}") else: print("No active job") print() # Warnings warnings = [] if t.Auxiliary.BatteryVoltageWarning: warnings.append("BATTERY") if t.Auxiliary.AirPressureWarning: warnings.append("AIR") if t.Auxiliary.OilPressureWarning: warnings.append("OIL") if t.Auxiliary.WaterTemperatureWarning: warnings.append("TEMP") if t.DriveTrain.FuelWarningLight: warnings.append("FUEL") if warnings: print(f"⚠ WARNINGS: {', '.join(warnings)}") time.sleep(0.1) except KeyboardInterrupt: print("\nStopping dashboard...") finally: client.threading_event.set() if __name__ == "__main__": run_dashboard() ``` -------------------------------- ### Version Data - SDK and Game Version Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Access version information for the telemetry plugin and game. ```APIDOC ## Version Data - SDK and Game Version ### Description Access version information for the telemetry plugin and game. ### Method GET ### Endpoint /ets2telemetry/Version ### Parameters None ### Request Example None ### Response #### Success Response (200) - **SdkPlugin** (string) - Revision number of the SDK plugin. - **Ets2Major** (integer) - Major version of the ETS2 game. - **Ets2Minor** (integer) - Minor version of the ETS2 game. #### Response Example ```json { "SdkPlugin": "1.2.3.4", "Ets2Major": 1, "Ets2Minor": 45 } ``` ``` -------------------------------- ### Accessing Raw Telemetry Data in Python Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Demonstrates how to directly access raw telemetry values like speed, engine RPM, and coordinates from the shared memory. It also shows how to manually extract specific fields using offsets and retrieve arrays of data, such as gear ratios. ```python from sharedmemory import SharedMemory shared_mem = SharedMemory() raw_data = shared_mem.update() # Access raw values directly print(f"Raw Speed: {raw_data.speed}") print(f"Raw Engine RPM: {raw_data.engineRpm}") print(f"Raw Coordinates: ({raw_data.coordinateX}, {raw_data.coordinateY}, {raw_data.coordinateZ})") # Manual field extraction (for custom offsets) # Format codes: 'I' = unsigned int, 'f' = float, 'b' = signed byte custom_value = shared_mem.retrieve_field("f", 24, 28) # Speed at offset 24-28 print(f"Custom extracted speed: {custom_value}") # Extract array of values gear_ratios = shared_mem.retrieve_array("24f", 884, 980) # 24 floats for forward gear ratios print(f"Gear ratios: {gear_ratios}") ``` -------------------------------- ### Reading Auxiliary Systems and Warnings Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Retrieves the state of wipers and various warning indicators such as battery voltage, air pressure, and oil pressure. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() auxiliary = client.ets2telemetry.Auxiliary print(f"Wipers Active: {auxiliary.Wipers}") print(f"Battery Warning: {auxiliary.BatteryVoltageWarning}") ``` -------------------------------- ### Querying Boolean Flags with Ets2SdkBoolean in Python Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Shows how to use the Ets2SdkBoolean enumeration to query specific boolean states from the ETS2 telemetry data. This includes checking states like cruise control, wipers, park brake, and various light statuses. ```python from ets2sdkdata import Ets2SdkBoolean, Ets2SdkData from sharedmemory import SharedMemory # Available boolean flags boolean_flags = [ Ets2SdkBoolean.CRUISE_CONTROL, Ets2SdkBoolean.WIPERS, Ets2SdkBoolean.PARK_BRAKE, Ets2SdkBoolean.MOTOR_BRAKE, Ets2SdkBoolean.ELECTRIC_ENABLED, Ets2SdkBoolean.ENGINE_ENABLED, Ets2SdkBoolean.BLINKER_LEFT_ACTIVE, Ets2SdkBoolean.BLINKER_RIGHT_ACTIVE, Ets2SdkBoolean.BLINKER_LEFT_ON, Ets2SdkBoolean.BLINKER_RIGHT_ON, Ets2SdkBoolean.LIGHTS_PARKING, Ets2SdkBoolean.LIGHTS_BEAM_LOW, Ets2SdkBoolean.LIGHTS_BEAM_HIGH, Ets2SdkBoolean.LIGHTS_AUX_FRONT, Ets2SdkBoolean.LIGHTS_AUX_ROOF, Ets2SdkBoolean.LIGHTS_BEACON, Ets2SdkBoolean.LIGHTS_BRAKE, Ets2SdkBoolean.LIGHTS_REVERSE, Ets2SdkBoolean.BATTERY_VOLTAGE_WARNING, Ets2SdkBoolean.AIR_PRESSURE_WARNING, Ets2SdkBoolean.AIR_PRESSURE_EMERGENCY, Ets2SdkBoolean.ADBLUE_WARNING, Ets2SdkBoolean.OIL_PRESSURE_WARNING, Ets2SdkBoolean.WATER_TEMPERATURE_WARNING, Ets2SdkBoolean.TRAILER_ATTACHED, ] # Query boolean flags from raw data shared_mem = SharedMemory() raw_data = shared_mem.update() # Check specific boolean state engine_on = raw_data.get_boolean(Ets2SdkBoolean.ENGINE_ENABLED) cruise_on = raw_data.get_boolean(Ets2SdkBoolean.CRUISE_CONTROL) trailer_attached = raw_data.get_boolean(Ets2SdkBoolean.TRAILER_ATTACHED) print(f"Engine: {engine_on}, Cruise: {cruise_on}, Trailer: {trailer_attached}") ``` -------------------------------- ### Auxiliary Data - Warning Lights and Systems Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Access warning indicators and auxiliary system states. ```APIDOC ## Auxiliary Data - Warning Lights and Systems ### Description Access warning indicators and auxiliary system states. ### Method GET ### Endpoint /ets2telemetry/Auxiliary ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Wipers** (boolean) - Wipers are active. - **BatteryVoltageWarning** (boolean) - Battery voltage warning light is on. - **AirPressureWarning** (boolean) - Air pressure warning light is on. - **AirPressureEmergency** (boolean) - Air pressure emergency warning light is on. - **AdblueWarning** (boolean) - AdBlue warning light is on. - **OilPressureWarning** (boolean) - Oil pressure warning light is on. - **WaterTemperatureWarning** (boolean) - Water temperature warning light is on. #### Response Example ```json { "Wipers": true, "BatteryVoltageWarning": false, "AirPressureWarning": false, "AirPressureEmergency": false, "AdblueWarning": false, "OilPressureWarning": false, "WaterTemperatureWarning": false } ``` ``` -------------------------------- ### Accessing Lighting System State Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Provides the status of turn signals, headlights, auxiliary lights, and dashboard backlighting. Useful for building external dashboards or monitoring systems. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() lights = client.ets2telemetry.Lights print(f"Low Beam: {lights.LowBeam}") print(f"High Beam: {lights.HighBeam}") print(f"Beacon: {lights.Beacon}") ``` -------------------------------- ### Accessing User and Game Input Controls Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Retrieves steering, throttle, brake, and clutch values. It differentiates between direct user input and game-processed values after physics and assists are applied. ```python print(f"User Steering: {controls.UserSteer:.3f}") print(f"User Throttle: {controls.UserThrottle:.3f}") print(f"User Brake: {controls.UserBrake:.3f}") print(f"User Clutch: {controls.UserClutch:.3f}") print(f"Game Steering: {controls.GameSteer:.3f}") print(f"Game Throttle: {controls.GameThrottle:.3f}") print(f"Game Brake: {controls.GameBrake:.3f}") print(f"Game Clutch: {controls.GameClutch:.3f}") ``` -------------------------------- ### Retrieving Delivery Job Information Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Fetches current job status, trailer details, cargo information, and navigation data. Useful for tracking delivery progress and financial statistics. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() job = client.ets2telemetry.Job print(f"On Job: {job.OnJob}") print(f"Cargo: {job.Cargo}") print(f"Income: €{job.Income}") print(f"Distance Remaining: {job.NavigationDistanceLeft:.1f} m") ``` -------------------------------- ### Read Vehicle Physics Data Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Accesses real-time vehicle physics data, including speed in various units (m/s, km/h, mph), acceleration forces along X, Y, Z axes, world position coordinates, and vehicle rotation angles (pitch, yaw, roll). ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() physics = client.ets2telemetry.Physics # Speed in different units (raw is m/s) print(f"Speed: {physics.Speed:.2f} m/s") print(f"Speed: {physics.SpeedKmh:.2f} km/h") print(f"Speed: {physics.SpeedMph:.2f} mph") # Acceleration forces (X = lateral, Y = vertical, Z = longitudinal) print(f"Acceleration X: {physics.AccelerationX:.3f}") print(f"Acceleration Y: {physics.AccelerationY:.3f}") print(f"Acceleration Z: {physics.AccelerationZ:.3f}") # World position coordinates print(f"Position: ({physics.CoordinateX:.1f}, {physics.CoordinateY:.1f}, {physics.CoordinateZ:.1f})") # Vehicle rotation (pitch, yaw, roll) print(f"Rotation: ({physics.RotationX:.3f}, {physics.RotationY:.3f}, {physics.RotationZ:.3f})") ``` -------------------------------- ### Read Controls Data Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Accesses user input and game-calculated values for steering, throttle, brake, and clutch. This data is crucial for understanding player input and the game's interpretation of it. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() controls = client.ets2telemetry.Controls ``` -------------------------------- ### Lights Data - Lighting System Status Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Access the state of all truck lighting including headlights, indicators, and auxiliary lights. ```APIDOC ## Lights Data - Lighting System Status ### Description Access the state of all truck lighting including headlights, indicators, and auxiliary lights. ### Method GET ### Endpoint /ets2telemetry/Lights ### Parameters None ### Request Example None ### Response #### Success Response (200) - **BlinkerLeftActive** (boolean) - Left blinker is active. - **BlinkerRightActive** (boolean) - Right blinker is active. - **BlinkerLeftOn** (boolean) - Left blinker is actually blinking. - **BlinkerRightOn** (boolean) - Right blinker is actually blinking. - **ParkingLights** (boolean) - Parking lights are on. - **LowBeam** (boolean) - Low beam headlights are on. - **HighBeam** (boolean) - High beam headlights are on. - **FrontAux** (boolean) - Front auxiliary lights are on. - **RoofAux** (boolean) - Roof auxiliary lights are on. - **Beacon** (boolean) - Beacon light is on. - **BrakeLights** (boolean) - Brake lights are on. - **ReverseLights** (boolean) - Reverse lights are on. - **DashboardLights** (float) - Dashboard backlight intensity (0.0 to 1.0). #### Response Example ```json { "BlinkerLeftActive": false, "BlinkerRightActive": true, "BlinkerLeftOn": false, "BlinkerRightOn": true, "ParkingLights": true, "LowBeam": true, "HighBeam": false, "FrontAux": false, "RoofAux": false, "Beacon": false, "BrakeLights": false, "ReverseLights": false, "DashboardLights": 0.75 } ``` ``` -------------------------------- ### Job Data - Delivery Information Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Access current job details including cargo, route, income, deadline, and source/destination information. ```APIDOC ## Job Data - Delivery Information ### Description Access current job details including cargo, route, income, deadline, and source/destination information. ### Method GET ### Endpoint /ets2telemetry/Job ### Parameters None ### Request Example None ### Response #### Success Response (200) - **OnJob** (boolean) - Indicates if the player is currently on a job. - **JobFinished** (boolean) - Indicates if the current job has been finished. - **TrailerAttached** (boolean) - Indicates if a trailer is attached. - **TrailerId** (string) - Unique identifier for the trailer. - **TrailerName** (string) - Name of the trailer. - **Cargo** (string) - Name of the cargo being transported. - **Mass** (float) - Mass of the cargo in kilograms. - **Income** (integer) - Income earned from the job. - **Deadline** (datetime) - Job deadline. - **NavigationDistanceLeft** (float) - Remaining distance to destination in meters. - **NavigationTimeLeft** (float) - Remaining time to destination in seconds. - **CompanySource** (string) - Name of the source company. - **CitySource** (string) - Name of the source city. - **CompanyDestination** (string) - Name of the destination company. - **CityDestination** (string) - Name of the destination city. #### Response Example ```json { "OnJob": true, "JobFinished": false, "TrailerAttached": true, "TrailerId": "trailer_001", "TrailerName": "Reefer Trailer", "Cargo": "Frozen Food", "Mass": 15000.5, "Income": 1200, "Deadline": "2023-10-27T10:00:00Z", "NavigationDistanceLeft": 50000.0, "NavigationTimeLeft": 3600.0, "CompanySource": "Volks", "CitySource": "Dortmund", "CompanyDestination": "Scanian", "CityDestination": "Malmö" } ``` ``` -------------------------------- ### Monitoring Vehicle Damage Status Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Accesses wear percentages for engine, transmission, cabin, chassis, wheels, and trailers. Allows for calculating average vehicle health. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() damage = client.ets2telemetry.Damage print(f"Engine Wear: {damage.WearEngine * 100:.1f}%") print(f"Trailer Wear: {damage.WearTrailer * 100:.1f}%") ``` -------------------------------- ### Low-Level Shared Memory Access Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Directly interfaces with the shared memory region for custom data parsing. This is the underlying mechanism for the SDK. ```python from sharedmemory import SharedMemory shared_mem = SharedMemory() raw_data = shared_mem.update() ``` -------------------------------- ### Read Drivetrain Data Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Retrieves comprehensive drivetrain information such as engine RPM, gear states, fuel levels and consumption, fluid temperatures, brake system status, AdBlue levels, and cruise control settings. Also includes truck odometer readings. ```python from ets2sdktelemetry import Ets2SdkTelemetry client = Ets2SdkTelemetry() drivetrain = client.ets2telemetry.DriveTrain # Engine status print(f"Engine Enabled: {drivetrain.EngineEnabled}") print(f"Electric Enabled: {drivetrain.ElectricEnabled}") print(f"Engine RPM: {drivetrain.EngineRpm:.0f} / {drivetrain.EngineRpmMAX:.0f}") # Transmission print(f"Current Gear: {drivetrain.Gear}") print(f"Dashboard Gear: {drivetrain.GearDashboard}") print(f"Forward Gears: {drivetrain.GearsForward}") print(f"Reverse Gears: {drivetrain.GearsReverse}") print(f"Gear Ratios Forward: {drivetrain.GearRatiosForward}") print(f"Differential Ratio: {drivetrain.GearRatioDifferential}") # Fuel system print(f"Fuel: {drivetrain.Fuel:.1f} / {drivetrain.FuelMax:.1f} L") print(f"Fuel Rate: {drivetrain.FuelRate:.3f}") print(f"Avg Consumption: {drivetrain.FuelAvgConsumption:.2f}") print(f"Fuel Range: {drivetrain.FuelRange:.1f} km") print(f"Fuel Warning: {drivetrain.FuelWarningLight}") # Temperatures and pressures print(f"Oil Pressure: {drivetrain.OilPressure:.1f}") print(f"Oil Temperature: {drivetrain.OilTemperature:.1f}°C") print(f"Water Temperature: {drivetrain.WaterTemperature:.1f}°C") print(f"Air Pressure: {drivetrain.AirPressure:.1f}") print(f"Brake Temperature: {drivetrain.BrakeTemperature:.1f}°C") print(f"Battery Voltage: {drivetrain.BatteryVoltage:.1f}V") # AdBlue (DEF) print(f"AdBlue: {drivetrain.Adblue:.1f}") print(f"AdBlue Consumption: {drivetrain.AdblueConsumption:.3f}") # Braking and cruise control print(f"Cruise Control: {drivetrain.CruiseControl}") print(f"Cruise Speed: {drivetrain.CruiseControlSpeedKmh:.1f} km/h") print(f"Motor Brake: {drivetrain.MotorBrake}") print(f"Parking Brake: {drivetrain.ParkingBrake}") print(f"Retarder: {drivetrain.Retarder}") print(f"Odometer: {drivetrain.TruckOdometer:.1f} km") ``` -------------------------------- ### Damage Data - Vehicle Wear Status Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Access wear/damage percentages for all major truck and trailer components. ```APIDOC ## Damage Data - Vehicle Wear Status ### Description Access wear/damage percentages for all major truck and trailer components. ### Method GET ### Endpoint /ets2telemetry/Damage ### Parameters None ### Request Example None ### Response #### Success Response (200) - **WearEngine** (float) - Engine wear percentage (0.0 to 1.0). - **WearTransmission** (float) - Transmission wear percentage (0.0 to 1.0). - **WearCabin** (float) - Cabin wear percentage (0.0 to 1.0). - **WearChassis** (float) - Chassis wear percentage (0.0 to 1.0). - **WearWheels** (float) - Wheels wear percentage (0.0 to 1.0). - **WearTrailer** (float) - Trailer wear percentage (0.0 to 1.0). #### Response Example ```json { "WearEngine": 0.05, "WearTransmission": 0.02, "WearCabin": 0.01, "WearChassis": 0.03, "WearWheels": 0.04, "WearTrailer": 0.06 } ``` ``` -------------------------------- ### SharedMemory - Low-Level Memory Access Source: https://context7.com/madricas/ets2-python-telemetry/llms.txt Direct access to the shared memory region for custom data extraction. This class handles the memory-mapped file connection and binary data parsing. ```APIDOC ## SharedMemory - Low-Level Memory Access ### Description Direct access to the shared memory region for custom data extraction. This class handles the memory-mapped file connection and binary data parsing. ### Method GET ### Endpoint /sharedmemory/update ### Parameters None ### Request Example None ### Response #### Success Response (200) - **raw_data** (bytes) - Raw telemetry data from shared memory. #### Response Example ```json { "raw_data": "0x..." } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.