Skip to content

Commit

Permalink
feat: add support to set PTP profile
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
manato committed Jun 19, 2024
1 parent 0f081d2 commit 885ed3b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 885ed3b

Please sign in to comment.