diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 971e5d76..018b5907 100755 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -676,7 +676,6 @@ func isCPUTempValid() bool { func cpuTempMonitor() { timer := time.NewTicker(1 * time.Second) for { - <-timer.C // Update CPUTemp. temp, err := ioutil.ReadFile("/sys/class/thermal/thermal_zone0/temp") @@ -695,6 +694,7 @@ func cpuTempMonitor() { if t >= -99.0 { // Only update if valid value was obtained. globalStatus.CPUTemp = t } + <-timer.C } } diff --git a/main/managementinterface.go b/main/managementinterface.go index 6aa28f82..8ed2dfd8 100755 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -159,7 +159,6 @@ func handleStatusWS(conn *websocket.Conn) { */ // Send status. - <-timer.C update, _ := json.Marshal(&globalStatus) _, err := conn.Write(update) @@ -167,19 +166,20 @@ func handleStatusWS(conn *websocket.Conn) { // log.Printf("Web client disconnected.\n") break } + <-timer.C } } func handleSituationWS(conn *websocket.Conn) { timer := time.NewTicker(100 * time.Millisecond) for { - <-timer.C situationJSON, _ := json.Marshal(&mySituation) _, err := conn.Write(situationJSON) if err != nil { break } + <-timer.C } diff --git a/main/network.go b/main/network.go index 06db05b1..d511c89e 100644 --- a/main/network.go +++ b/main/network.go @@ -536,7 +536,6 @@ func networkStatsCounter() { var previousNetworkMessagesSent, previousNetworkBytesSent, previousNetworkMessagesSentNonqueueable, previousNetworkBytesSentNonqueueable uint64 for { - <-timer.C globalStatus.NetworkDataMessagesSentLastSec = globalStatus.NetworkDataMessagesSent - previousNetworkMessagesSent globalStatus.NetworkDataBytesSentLastSec = globalStatus.NetworkDataBytesSent - previousNetworkBytesSent globalStatus.NetworkDataMessagesSentNonqueueableLastSec = globalStatus.NetworkDataMessagesSentNonqueueable - previousNetworkMessagesSentNonqueueable @@ -549,6 +548,7 @@ func networkStatsCounter() { previousNetworkBytesSent = globalStatus.NetworkDataBytesSent previousNetworkMessagesSentNonqueueable = globalStatus.NetworkDataMessagesSentNonqueueable previousNetworkBytesSentNonqueueable = globalStatus.NetworkDataBytesSentNonqueueable + <-timer.C } diff --git a/main/ry835ai.go b/main/ry835ai.go index 5343b52e..056c151c 100644 --- a/main/ry835ai.go +++ b/main/ry835ai.go @@ -1398,7 +1398,6 @@ func initI2C() error { func tempAndPressureReader() { timer := time.NewTicker(5 * time.Second) for globalStatus.RY835AI_connected && globalSettings.AHRS_Enabled { - <-timer.C // Read temperature and pressure altitude. temp, alt, err_bmp180 := readBMP180() // Process. @@ -1410,6 +1409,7 @@ func tempAndPressureReader() { mySituation.Pressure_alt = alt mySituation.LastTempPressTime = stratuxClock.Time } + <-timer.C } globalStatus.RY835AI_connected = false } @@ -1464,7 +1464,6 @@ func makeAHRSGDL90Report() { func attitudeReaderSender() { timer := time.NewTicker(100 * time.Millisecond) // ~10Hz update. for globalStatus.RY835AI_connected && globalSettings.AHRS_Enabled { - <-timer.C // Read pitch and roll. pitch, roll, err_mpu6050 := readMPU6050() @@ -1488,6 +1487,7 @@ func attitudeReaderSender() { makeAHRSGDL90Report() mySituation.mu_Attitude.Unlock() + <-timer.C } globalStatus.RY835AI_connected = false } @@ -1587,7 +1587,6 @@ func pollRY835AI() { readyToInitGPS = true //TO-DO: Implement more robust method (channel control) to kill zombie serial readers timer := time.NewTicker(4 * time.Second) for { - <-timer.C // GPS enabled, was not connected previously? if globalSettings.GPS_Enabled && !globalStatus.GPS_connected && readyToInitGPS { //TO-DO: Implement more robust method (channel control) to kill zombie serial readers globalStatus.GPS_connected = initGPSSerial() @@ -1603,6 +1602,7 @@ func pollRY835AI() { globalStatus.RY835AI_connected = false } } + <-timer.C } }