@@ -42,69 +42,73 @@ void F9PSerialReadTask(void *e)
4242 {
4343 taskYIELD ();
4444
45- // Don't check UART if there is BT SPP congestion to prevent heap hits.
46- if (SerialBT.isCongested () == true )
45+ auto s = serialGNSS.readBytes (rBuffer, SERIAL_SIZE_RX);
46+
47+ // If we are actively survey-in then do not pass NMEA data from ZED to phone
48+ if (systemState == STATE_BASE_TEMP_SETTLE || systemState == STATE_BASE_TEMP_SURVEY_STARTED)
4749 {
48- log_d ( " ZED UART Read Blocked " );
50+ // Do nothing
4951 }
50- else
52+ else if (SerialBT. connected ())
5153 {
52- auto s = serialGNSS.readBytes (rBuffer, SERIAL_SIZE_RX);
53-
54- // If we are actively survey-in then do not pass NMEA data from ZED to phone
55- if (systemState == STATE_BASE_TEMP_SETTLE || systemState == STATE_BASE_TEMP_SURVEY_STARTED)
54+ if (SerialBT.isCongested () == false )
5655 {
57- // Do nothing
56+ SerialBT. write (rBuffer, s); // Push new data to BT SPP
5857 }
59- else if (SerialBT. connected () )
58+ else if (settings. throttleDuringSPPCongestion == false )
6059 {
61- SerialBT.write (rBuffer, s);
60+ SerialBT.write (rBuffer, s); // Push new data to SPP regardless of congestion
6261 }
62+ else
63+ {
64+ // Don't push data to BT SPP if there is congestion to prevent heap hits.
65+ log_d (" Dropped SPP Bytes: %d\n\r " , s);
66+ }
67+ }
6368
64- if (settings.enableTaskReports == true )
65- Serial.printf (" SerialReadTask High watermark: %d\n\r " , uxTaskGetStackHighWaterMark (NULL ));
69+ if (settings.enableTaskReports == true )
70+ Serial.printf (" SerialReadTask High watermark: %d\n\r " , uxTaskGetStackHighWaterMark (NULL ));
6671
67- // If user wants to log, record to SD
68- if (online.logging == true )
72+ // If user wants to log, record to SD
73+ if (online.logging == true )
74+ {
75+ // Check if we are inside the max time window for logging
76+ if ((systemTime_minutes - startLogTime_minutes) < settings.maxLogTime_minutes )
6977 {
70- // Check if we are inside the max time window for logging
71- if ((systemTime_minutes - startLogTime_minutes) < settings. maxLogTime_minutes )
78+ // Attempt to write to file system. This avoids collisions with file writing from other functions like recordSystemSettingsToFile()
79+ if (xSemaphoreTake (xFATSemaphore, fatSemaphore_shortWait_ms) == pdPASS )
7280 {
73- // Attempt to write to file system. This avoids collisions with file writing from other functions like recordSystemSettingsToFile()
74- if (xSemaphoreTake (xFATSemaphore, fatSemaphore_shortWait_ms) == pdPASS)
75- {
76- ubxFile.write (rBuffer, s);
81+ ubxFile.write (rBuffer, s);
7782
78- // Force file sync every 5000ms
79- if (millis () - lastUBXLogSyncTime > 5000 )
80- {
81- if (productVariant == RTK_SURVEYOR)
82- digitalWrite (pin_baseStatusLED, !digitalRead (pin_baseStatusLED)); // Blink LED to indicate logging activity
83-
84- long startWriteTime = micros ();
85- taskYIELD ();
86- ubxFile.sync ();
87- taskYIELD ();
88- long stopWriteTime = micros ();
89- totalWriteTime += stopWriteTime - startWriteTime; // Used to calculate overall write speed
83+ // Force file sync every 5000ms
84+ if (millis () - lastUBXLogSyncTime > 5000 )
85+ {
86+ if (productVariant == RTK_SURVEYOR)
87+ digitalWrite (pin_baseStatusLED, !digitalRead (pin_baseStatusLED)); // Blink LED to indicate logging activity
9088
91- if (productVariant == RTK_SURVEYOR)
92- digitalWrite (pin_baseStatusLED, !digitalRead (pin_baseStatusLED)); // Return LED to previous state
89+ long startWriteTime = micros ();
90+ taskYIELD ();
91+ ubxFile.sync ();
92+ taskYIELD ();
93+ long stopWriteTime = micros ();
94+ totalWriteTime += stopWriteTime - startWriteTime; // Used to calculate overall write speed
9395
94- updateDataFileAccess (&ubxFile); // Update the file access time & date
96+ if (productVariant == RTK_SURVEYOR)
97+ digitalWrite (pin_baseStatusLED, !digitalRead (pin_baseStatusLED)); // Return LED to previous state
9598
96- lastUBXLogSyncTime = millis ();
97- }
99+ updateDataFileAccess (&ubxFile); // Update the file access time & date
98100
99- xSemaphoreGive (xFATSemaphore);
100- } // End xFATSemaphore
101- else
102- {
103- log_d (" F9SerialRead: Semaphore failed to yield" );
101+ lastUBXLogSyncTime = millis ();
104102 }
105- } // End maxLogTime
106- } // End logging
107- } // End SPP Congestion check
103+
104+ xSemaphoreGive (xFATSemaphore);
105+ } // End xFATSemaphore
106+ else
107+ {
108+ log_d (" F9SerialRead: Semaphore failed to yield" );
109+ }
110+ } // End maxLogTime
111+ } // End logging
108112 }
109113
110114 taskYIELD ();
0 commit comments