Repository navigation
fix(bench): millisecond PTP epoch seeding and resilient SV session lease with diagnostic evidence #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(bench): millisecond PTP epoch seeding and resilient SV session lease with diagnostic evidence #283
Changes from all commits
3f4cb20
f4e4eb4
854c69e
62c92c7
bbe830a
3c99e06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,7 @@ void fill_kconfig_defaults(ar_ptp_lab_config_t& config) noexcept { | |
| config.current_utc_offset = static_cast<std::int16_t>(CONFIG_AR_PTP_CURRENT_UTC_OFFSET); | ||
| config.bench_global_gm = false; | ||
| config.bench_utc_epoch_seconds = 0U; | ||
| config.bench_utc_epoch_millisecond = 0U; | ||
| config.bench_epoch_received_mono_us = 0LL; | ||
|
|
||
| const std::string configured_identity{CONFIG_AR_PTP_CLOCK_IDENTITY}; | ||
|
|
@@ -288,6 +289,7 @@ void fill_kconfig_defaults(ar_ptp_lab_config_t& config) noexcept { | |
| // (seed_hardware_clock), not during a prior PTPROLE change. | ||
| if (config.role == AR_PTP_ROLE_LAB_SOURCE && config.bench_global_gm && | ||
| (config.bench_utc_epoch_seconds < 1577836800U || | ||
| config.bench_utc_epoch_millisecond >= 1000U || | ||
| config.bench_epoch_received_mono_us <= 0LL)) { | ||
| error = "BENCH GM requires a Studio UTC epoch"; | ||
| return false; | ||
|
|
@@ -421,16 +423,19 @@ void disable_hardware_ptp(const esp_eth_handle_t eth_handle) noexcept { | |
| ? static_cast<std::uint64_t>( | ||
| now_mono_us - config.bench_epoch_received_mono_us) | ||
| : 0ULL; | ||
| const std::uint64_t relative_epoch_us = elapsed_us + | ||
| (bench ? static_cast<std::uint64_t>( | ||
| config.bench_utc_epoch_millisecond) * 1000ULL : 0ULL); | ||
|
Comment on lines
+426
to
+428
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This protocol timing fix changes both the seconds-versus-milliseconds parser and the carry from a fractional seed into the next UTC second, but no deterministic regression exercises either branch. A case such as a AGENTS.md reference: AGENTS.md:L230-L234 Useful? React with 👍 / 👎. |
||
| const std::int64_t utc_seconds = bench | ||
| ? static_cast<std::int64_t>(config.bench_utc_epoch_seconds) + | ||
| static_cast<std::int64_t>(elapsed_us / 1000000ULL) | ||
| static_cast<std::int64_t>(relative_epoch_us / 1000000ULL) | ||
| : static_cast<std::int64_t>(std::time(nullptr)); | ||
| const auto tai_seconds = ar::iec61850::time_sync::try_seed_ptp_tai_seconds( | ||
| utc_seconds, config.current_utc_offset); | ||
| if (tai_seconds.has_value()) { | ||
| initial_time.seconds = *tai_seconds; | ||
| initial_time.nanoseconds = bench | ||
| ? static_cast<std::uint32_t>((elapsed_us % 1000000ULL) * 1000ULL) | ||
| ? static_cast<std::uint32_t>((relative_epoch_us % 1000000ULL) * 1000ULL) | ||
| : 0U; | ||
| } | ||
| const auto result = esp_eth_ioctl( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Studio or its USB transport disappears while SV is running, this raises the worst-case shutdown latency from roughly 2.75 seconds to 6.25 seconds, but the repository's operational contracts still require termination in approximately 2.5–3 seconds (
docs/SMV_STUDIO_DEVICE_SUPERVISOR_AUDIT.md:214anddocs/SMV_STUDIO_SMART_UX_PROGRESS.md:121). The documented hardware kill test will therefore fail, and operators can receive output for more than twice the promised interval; either preserve the existing bound or update and requalify every consumer and acceptance procedure that relies on it.AGENTS.md reference: AGENTS.md:L236-L236
Useful? React with 👍 / 👎.