Compute down track RTT.
This commit is contained in:
+5
-1
@@ -10,7 +10,7 @@ func FromDuration(d time.Duration, hz uint32) uint64 {
|
||||
return uint64(d) * uint64(hz) / uint64(time.Second)
|
||||
}
|
||||
|
||||
func toDuration(tm uint64, hz uint32) time.Duration {
|
||||
func ToDuration(tm uint64, hz uint32) time.Duration {
|
||||
return time.Duration(tm * uint64(time.Second) / uint64(hz))
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ func Jiffies() uint64 {
|
||||
return Now(JiffiesPerSec)
|
||||
}
|
||||
|
||||
func TimeToJiffies(tm time.Time) uint64 {
|
||||
return FromDuration(tm.Sub(epoch), JiffiesPerSec)
|
||||
}
|
||||
|
||||
var ntpEpoch = time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
func NTPToTime(ntp uint64) time.Time {
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestDuration(t *testing.T) {
|
||||
t.Errorf("Expected 48000, got %v", a)
|
||||
}
|
||||
|
||||
b := toDuration(48000, 48000)
|
||||
b := ToDuration(48000, 48000)
|
||||
if b != time.Second {
|
||||
t.Errorf("Expected %v, got %v", time.Second, b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user