Commit Graph

17 Commits (master)

Author SHA1 Message Date
Vladimir Oltean cef87c6f03 tmv: introduce an initializer from nanoseconds
Interestingly, although tmv_t is a wrapper over nanoseconds, there is no
initializer from a raw nanosecond value. So add one.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
2020-08-29 10:59:08 -07:00
Vladimir Oltean 6325880094 tmv: introduce a conversion helper from ptp_clock_time
This is useful when dealing with timestamps returned by various
ancillary PHC ioctl kernel APIs, such as extts.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
2020-08-29 10:59:08 -07:00
Richard Cochran b829580a33 Provide a method to convert a tmv_t into a timespec.
Currently there is a method to convert a timespec into a tmv_t, but
not the other way round.  This patch adds the missing function in
anticipation of a new feature that will need this conversion.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-03-21 04:48:16 -07:00
Anders Selhammer 14ac29b059 tmv: Avoid overflow when byte shift in tmv_to_TimeInterval
Added check so that convertion from a positive tmv not result in a negative TimeInterval and vice versa.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2019-01-06 20:09:39 -08:00
Richard Cochran 7a2013360a tmv: Add a method to convert to a struct Timestamp.
This will be needed in order to generate a TLV for the NSM protocol.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-08 07:20:42 -08:00
Michael Brown d432cdc52a tmv: Convert tmv_t to a non-scalar type
Enforce the use of the tmv_t wrapper functions by converting tmv_t
from an int64_t to a struct containing an int64_t.

Inspection of the disassembly shows that this change has essentially
no impact on the resulting object code, at least for x86_64 with
compiler optimisations enabled.

RC:
  - Fixed up after dropping one previous patch in the series.
  - Removed the new function, tmv_to_Timestamp, as that will
    be introduced later on.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 11:39:28 -08:00
Michael Brown ffc5b93f95 tmv: Add tmv_sign()
The sign of time values is tested in tsproc.c.  Add an abstraction
tmv_sign() to return the sign of a time value.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Michael Brown 1b7ff890be tmv: Generalise tmv_eq() to tmv_cmp()
Time values are compared using an inequality test in mmedian.c
Generalise tmv_eq() to tmv_cmp() (by analogy with memcmp()) and
replace existing uses of tmv_eq().

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-07 07:55:51 -08:00
Delio Brignoli bd001fdec7 port: adjust peer delay calculation using neighborRateRatio
Previouly the peer delay was not taking into account the
frequency offset between the local clock and the peer's clock.
Reset neighborRateRatio to 1.0 in port_nrate_initialize().

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-02-25 14:13:05 +01:00
Richard Cochran 4e09ff8585 Introduce a helper function to convert from tmv to nanoseconds.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-12 17:30:37 +02:00
Richard Cochran f3b0ca69d3 trivial: fix a spelling error in a comment.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-12 17:30:37 +02:00
Richard Cochran 8f5bd0edda Guard against divide by zero.
If a buggy driver or hardware delivers bogus time stamps, then we might
crash with a divide by zero exception.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-09-04 08:16:53 +02:00
Richard Cochran 95598b4fde Provide a conversion function from tmv to double.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-31 17:28:14 +02:00
Richard Cochran 92c6c9149d Maintain the current data set.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-22 07:36:33 +02:00
Richard Cochran e38488ae48 Add time value operations to clear to zero and test for zero.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 10:46:45 +01:00
Richard Cochran 56a5adc1cc Smooth the path delay estimate with a moving average.
This is really just a first attempt using a hard coded length. Probably
it will be necessary to let the length be configurable and/or adaptable.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-27 14:24:03 +01:00
Richard Cochran fc378711d8 Add an abstract time value type.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-12 13:58:28 +01:00