diff --git a/examples/open_trunk_example/bs_vehicletrunk/bs_vehicletrunk.cpp b/examples/open_trunk_example/bs_vehicletrunk/bs_vehicletrunk.cpp index 3fa49ac..d6f567d 100644 --- a/examples/open_trunk_example/bs_vehicletrunk/bs_vehicletrunk.cpp +++ b/examples/open_trunk_example/bs_vehicletrunk/bs_vehicletrunk.cpp @@ -11,6 +11,11 @@ #include #include "bs_vehicletrunk.h" +namespace +{ +constexpr float kMovingSpeedThresholdKmh = 0.0F; +} + /** * @brief Constructor */ @@ -41,7 +46,8 @@ CBasicServiceVehicleTrunk::CBasicServiceVehicleTrunk() */ bool CBasicServiceVehicleTrunk::SetOpen(bool value) { - if (m_Speed) + // Block only opening requests while vehicle is moving; closing must always be allowed. + if (value && (m_Speed > kMovingSpeedThresholdKmh)) return false; return m_ptrOpen->WriteOpen(value); } @@ -49,4 +55,10 @@ bool CBasicServiceVehicleTrunk::SetOpen(bool value) void CBasicServiceVehicleTrunk::SetSpeed(float value) { m_Speed = value; + + // Safety fallback: if vehicle starts moving, force trunk to closed state. + if (m_Speed > kMovingSpeedThresholdKmh) + { + (void)m_ptrOpen->WriteOpen(false); + } } diff --git a/examples/open_trunk_example/open_trunk_app/console.cpp b/examples/open_trunk_example/open_trunk_app/console.cpp index 89bc528..1975242 100644 --- a/examples/open_trunk_example/open_trunk_app/console.cpp +++ b/examples/open_trunk_example/open_trunk_app/console.cpp @@ -108,7 +108,7 @@ void CConsole::PrintHeader(uint32_t uiInstance) PrintText(g_sSeparator4, "============================================================================"); PrintText(g_sComment1, "The Open Trunk signal has a safety request."); PrintText(g_sComment2, "Therefore the speed value is required and must be checked."); - PrintText(g_sComment3, "If the car is moving the open trunk is blocked."); + PrintText(g_sComment3, "If the car is moving, open is blocked and trunk is closed automatically."); PrintText(g_sSeparator5, "============================================================================"); PrintText(g_sOpenViaDevice, "Vehicle Device Interface not available."); PrintText(g_sOpenViaService, "Basic Service Interface not available."); @@ -237,11 +237,18 @@ void CConsole::WriteSpeed(float value) void CConsole::SetSpeed(float value) { + const bool bIsMoving = (value > 0.0F); if (m_SpeedBS != value) { m_SpeedBS = value; PrintValue(g_sBasicServiceSpeed, "Vehicle Speed RX", m_SpeedBS, "km/h"); } + + if (bIsMoving && !m_bWasMovingBS) + { + PrintText(g_sOpenViaService, "Safety active: speed > 0, trunk close command sent."); + } + m_bWasMovingBS = bIsMoving; } bool CConsole::KeyHit() @@ -310,7 +317,7 @@ void CConsole::RunUntilBreak() if (m_pTrunkService) { if (m_pTrunkService->SetOpen(true)) - PrintText(g_sOpenViaService, "Trunk opened safely."); + PrintText(g_sOpenViaService, "Trunk opened safely (auto-close if vehicle starts moving)."); else PrintText(g_sOpenViaService, "Open trunk failed, car is moving."); } diff --git a/examples/open_trunk_example/open_trunk_app/console.h b/examples/open_trunk_example/open_trunk_app/console.h index 2e64043..326e833 100644 --- a/examples/open_trunk_example/open_trunk_app/console.h +++ b/examples/open_trunk_example/open_trunk_app/console.h @@ -161,6 +161,7 @@ private: float m_SpeedDL = 0.0; ///< Speed Data Link float m_SpeedVD = 0.0; ///< Speed Vehicle Device float m_SpeedBS = 0.0; ///< Speed Basic Service + bool m_bWasMovingBS = false; ///< Transition flag for movement status. vss::Vehicle::Body::TrunkService::IVSS_SetOpen* m_pTrunkService = nullptr; ///< trunk (basic service) vss::Vehicle::Body::TrunkDevice::IVSS_WriteOpen* m_pTrunkDevice = nullptr; ///< trunk (vehicle device) diff --git a/sdv_services/core/installation_composer.cpp b/sdv_services/core/installation_composer.cpp index e8e6d0f..ce518b0 100644 --- a/sdv_services/core/installation_composer.cpp +++ b/sdv_services/core/installation_composer.cpp @@ -1246,7 +1246,7 @@ sdv::installation::SPackageBLOB CInstallComposer::DeserializeBLOB(std::ifstream& // Extend the buffer and read the BLOB data (after the resize, the psPartialBLOB pointer could be invalidated). uint32_t uiBLOBSize = psPartialBLOB->uiBLOBSize; - if (uiBLOBSize > 24*1024*1024) + if (uiBLOBSize > 26*1024*1024) // 26 instead of 24 becasue of door example throw sdv::installation::XIncompatiblePackage(); // Safety ptrBLOB.resize(uiBLOBSize); if (!ptrBLOB)