From d96d2f701dbab55d4a0622442cbed34b1c0cf551 Mon Sep 17 00:00:00 2001
From: Michael Krisper <michael.krisper@tugraz.at>
Date: Tue, 17 May 2022 14:51:31 +0200
Subject: [PATCH] corrected null-exception error for powertrains without
 gearbox

---
 .../VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs
index ace92cb4be..5ba8a91b23 100644
--- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs
+++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs
@@ -144,7 +144,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
 		public IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity,
 			bool dryRun, double ratio)
 		{
-			var gear = DataBus.GearboxInfo.Gear;
+			var gear = DataBus.GearboxInfo?.Gear ?? new GearshiftPosition(0);
 			var voltage = DataBus.BatteryInfo.InternalVoltage;
 
 			var iceOn =  Position == PowertrainPosition.HybridP1 &&
-- 
GitLab