added synchronization check for invalid timestamps
This commit is contained in:
parent
d16dd61863
commit
dfde29ed10
@ -9,8 +9,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: adapt HNR-INS data to continue orientation stream
|
|
||||||
|
|
||||||
type Processor interface {
|
type Processor interface {
|
||||||
Process(data *Sensordata) error
|
Process(data *Sensordata) error
|
||||||
}
|
}
|
||||||
@ -125,11 +123,16 @@ func (p *pipeline) refreshDelay() error {
|
|||||||
p.agr.serialMutex.Unlock()
|
p.agr.serialMutex.Unlock()
|
||||||
p.agr.tcpMutex.Unlock()
|
p.agr.tcpMutex.Unlock()
|
||||||
if tcpTime.UnixNano() == 0 || serTime.UnixNano() == 0 {
|
if tcpTime.UnixNano() == 0 || serTime.UnixNano() == 0 {
|
||||||
return errors.New("no sync possible. no data to compare")
|
return errors.New("no sync possible. check if both collectors running. otherwise check GPS fix")
|
||||||
|
}
|
||||||
|
currentDelay := tcpTime.Sub(serTime).Milliseconds()
|
||||||
|
if currentDelay > 5000 || currentDelay < -5000 {
|
||||||
|
p.syn.tcpSerialDelayMs = 0
|
||||||
|
return errors.New("skipping synchronisation! time not properly configured or facing network problems.")
|
||||||
}
|
}
|
||||||
log.Println("TCP", tcpTime.String())
|
log.Println("TCP", tcpTime.String())
|
||||||
log.Println("SER", serTime.String())
|
log.Println("SER", serTime.String())
|
||||||
log.Println("Difference", tcpTime.Sub(serTime).Milliseconds())
|
log.Println("Difference", tcpTime.Sub(serTime).Milliseconds(), "ms")
|
||||||
delay := tcpTime.Sub(serTime).Milliseconds()
|
delay := tcpTime.Sub(serTime).Milliseconds()
|
||||||
p.syn.tcpSerialDelayMs += delay
|
p.syn.tcpSerialDelayMs += delay
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user