From 634d560ee1b7a596c9e41aa0dd48b03ee594bb3a Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 18 Jun 2025 15:38:46 +0200 Subject: [PATCH] Fix crash when updating DRV8833 Diff Drive --- Arduino/Things/DRV8833.cpp | 12 +++++------- Arduino/Things/DRV8833.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Arduino/Things/DRV8833.cpp b/Arduino/Things/DRV8833.cpp index 77dbbbc..7421e73 100644 --- a/Arduino/Things/DRV8833.cpp +++ b/Arduino/Things/DRV8833.cpp @@ -8,7 +8,6 @@ namespace Arduino { #pragma region DRV8833 DRV8833::DRV8833(Configuration config, Thing* parent) : Thing(parent) { - std::cout << "DRV8833\n"; this->type = Type::Undetermined; this->name = "DRV8833"; this->pinStandby = config.standby; @@ -27,16 +26,15 @@ DRV8833::DRV8833(Configuration config, Thing* parent) : Thing(parent) { DRV8833::DifferentialDrive::DifferentialDrive(DRV8833::Configuration config, Thing* parent) - : drv8833(config, this), - RoboidControl::DifferentialDrive(nullptr, nullptr, parent) { - this->drv8833 = DRV8833(config, this); - this->leftWheel = this->drv8833.motorA; - this->rightWheel = this->drv8833.motorB; + : RoboidControl::DifferentialDrive(nullptr, nullptr, parent) { + this->drv8833 = new DRV8833(config, this); + this->leftWheel = this->drv8833->motorA; + this->rightWheel = this->drv8833->motorB; } void DRV8833::DifferentialDrive::Update(bool recurse) { RoboidControl::DifferentialDrive::Update(recurse); - this->drv8833.Update(false); + this->drv8833->Update(false); } #pragma endregion Differential drive diff --git a/Arduino/Things/DRV8833.h b/Arduino/Things/DRV8833.h index a4cbd9f..9cc7d1a 100644 --- a/Arduino/Things/DRV8833.h +++ b/Arduino/Things/DRV8833.h @@ -45,7 +45,7 @@ class DRV8833::DifferentialDrive : public RoboidControl::DifferentialDrive { virtual void Update(bool recurse = false) override; protected: - DRV8833 drv8833; + DRV8833* drv8833 = nullptr; }; #pragma endregion Differential drive