From 885ed3bb9dab2acdd012f223ff1e1040a55aa104 Mon Sep 17 00:00:00 2001 From: Manato HIRABAYASHI Date: Wed, 19 Jun 2024 22:37:19 +0900 Subject: [PATCH] feat: add support to set PTP profile This implementation supports configuring IEEE1588v2 or gPTP only. PTP domain, PTP transport type, and PTP switch type configuration are not available. Signed-off-by: Manato HIRABAYASHI --- .../seyond_hw_interface.hpp | 6 ++++ .../seyond_hw_interface.cpp | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_seyond/seyond_hw_interface.hpp b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_seyond/seyond_hw_interface.hpp index eb2da3190..5fce7f062 100644 --- a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_seyond/seyond_hw_interface.hpp +++ b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_seyond/seyond_hw_interface.hpp @@ -131,6 +131,12 @@ class SeyondHwInterface /// @return Resulting status Status SetReturnMode(int return_mode); + + /// @brief Setting PTP profile + /// @param profile profile to be set + /// @return Resulting status + Status SetPtpMode(PtpProfile profile); + /// @brief validate the current settings then set them /// @return Resulting status Status CheckAndSetConfig(); diff --git a/nebula_hw_interfaces/src/nebula_seyond_hw_interfaces/seyond_hw_interface.cpp b/nebula_hw_interfaces/src/nebula_seyond_hw_interfaces/seyond_hw_interface.cpp index 014d1792b..d0f70be55 100644 --- a/nebula_hw_interfaces/src/nebula_seyond_hw_interfaces/seyond_hw_interface.cpp +++ b/nebula_hw_interfaces/src/nebula_seyond_hw_interfaces/seyond_hw_interface.cpp @@ -236,6 +236,30 @@ Status SeyondHwInterface::SetReturnMode(int return_mode) return Status::OK; } +Status SeyondHwInterface::SetPtpMode(PtpProfile profile) +{ + std::string command = "set_i_config time ntp_en 0"; // Disable NTP first just in case + SendCommand(command); + + command = "set_i_config time ptp_en 1"; + SendCommand(command); + + // Show messages regarding support status + if (profile != PtpProfile::IEEE_1588v2 && profile != PtpProfile::IEEE_802_1AS_AUTO) { + PrintInfo("Unsupported PTP profile was selected. Falling back to IEEE 1588v2"); + } else if (profile == PtpProfile::IEEE_802_1AS_AUTO) { + PrintInfo("\"automotive\" was specified as PTP profile. " + "Currently, (PTP domain | PTP transport type | PTP switch type) " + "specification is not supported."); + } + + int is_gptp = (profile == PtpProfile::IEEE_802_1AS_AUTO); + command = "set_i_config time ptp_automotive " + std::to_string(is_gptp); + SendCommand(command); + + return Status::OK; +} + Status SeyondHwInterface::CheckAndSetConfig() { Status ret = Status::ERROR_1; @@ -254,6 +278,13 @@ Status SeyondHwInterface::CheckAndSetConfig() if (ret != Status::OK) { return ret; } + + // Set PTP mode + ret = SetPtpMode(sensor_configuration_->ptp_profile); + if (ret != Status::OK) { + return ret; + } + return Status::OK; }