diff --git a/core/pipeline.go b/core/pipeline.go index c677c5f..524a0f9 100644 --- a/core/pipeline.go +++ b/core/pipeline.go @@ -9,8 +9,6 @@ import ( "time" ) -// TODO: adapt HNR-INS data to continue orientation stream - type Processor interface { Process(data *Sensordata) error } @@ -125,11 +123,16 @@ func (p *pipeline) refreshDelay() error { p.agr.serialMutex.Unlock() p.agr.tcpMutex.Unlock() 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("SER", serTime.String()) - log.Println("Difference", tcpTime.Sub(serTime).Milliseconds()) + log.Println("Difference", tcpTime.Sub(serTime).Milliseconds(), "ms") delay := tcpTime.Sub(serTime).Milliseconds() p.syn.tcpSerialDelayMs += delay return nil