[riot-notifications] [RIOT-OS/RIOT] drivers/periph/ptp_clock (#15074)

Marian Buschsieweke notifications at github.com
Mon Nov 30 20:45:31 CET 2020


`NS_PER_SEC` is quite a footgun. Reducing the width of the second part of the PTP timestamp struct resulted in a precision loss when converting seconds to nanoseconds and a failing test :-/ Maybe we should have `NS_PER_SEC` defines as `1000000000ULL` and not as `1000000000U`?

After fixing the precision loss bug, test output is:

<details><summary>`tests/periph_ptp_clock`</summary>

```
READY
s
START
main(): This is RIOT! (Version: 2021.01-devel-931-gd3273-ptp-clock)
Testing clock at speed 0 (~100.000 % of nominal speed): SUCCEEDED
Testing clock at speed 32767 (~149.999 % of nominal speed): SUCCEEDED
Testing clock at speed -32768 (~50.000 % of nominal speed): SUCCEEDED
Testing clock at speed 1337 (~102.040 % of nominal speed): SUCCEEDED
Testing clock at speed -1337 (~97.961 % of nominal speed): SUCCEEDED
Testing clock at speed 42 (~100.064 % of nominal speed): SUCCEEDED
Testing clock at speed -42 (~99.937 % of nominal speed): SUCCEEDED
Testing clock at speed 665 (~101.015 % of nominal speed): SUCCEEDED
Testing clock at speed -665 (~98.986 % of nominal speed): SUCCEEDED
Testing clock adjustments for offset 0: SUCCEEDED
Statistics: avg = -1, min = -70, max = 90, σ² = 3319
Testing clock adjustments for offset -1337: SUCCEEDED
Statistics: avg = -1, min = -70, max = 80, σ² = 2834
Testing clock adjustments for offset 1337: SUCCEEDED
Statistics: avg = -1, min = -70, max = 90, σ² = 3319
Testing clock adjustments for offset 2147483647: SUCCEEDED
Statistics: avg = -1, min = -70, max = 90, σ² = 3319
TEST SUCCEEDED!
```

</details>

<details><summary>`tests/periph_ptp_timer`</summary>

```
READY
s
START
main(): This is RIOT! (Version: 2021.01-devel-1161-g82fbb-ptp-clock)
TEST SUCCEEDED!

```

</details>

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15074#issuecomment-736001117
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201130/726a17e5/attachment.htm>


More information about the notifications mailing list