Skip to content

Commit 88a47b4

Browse files
committed
Delay switching of USB output behavior until setup and menuMain exits
1 parent 9153c23 commit 88a47b4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,22 @@ float batteryChargingPercentPerHour;
445445
#include "bluetoothSelect.h"
446446
#endif // COMPILE_BT
447447

448+
// This value controls the data that is output from the USB serial port
449+
// to the host PC. By default (false) status and debug messages are output
450+
// to the USB serial port. When this value is set to true then the status
451+
// and debug messages are discarded and only GNSS data is output to USB
452+
// serial.
453+
//
454+
// Switching from status and debug messages to GNSS output is done in two
455+
// places, at the end of setup and at the end of maenuMain. In both of
456+
// these places the new value comes from settings.enableGnssToUsbSerial.
457+
// Upon boot status and debug messages are output at least until the end
458+
// of setup. Upon entry into menuMain, this value is set false to again
459+
// output menu output, status and debug messages to be output. At the end
460+
// of setup the value is updated and if enabled GNSS data is sent to the
461+
// USB serial port and PC.
462+
volatile bool forwardGnssDataToUsbSerial;
463+
448464
#define platformPrefix platformPrefixTable[productVariant] // Sets the prefix for broadcast names
449465

450466
#include <driver/uart.h> //Required for uart_set_rx_full_threshold() on cores <v2.0.5
@@ -1113,6 +1129,10 @@ void setup()
11131129
systemPrintf("%8d mSec: Total boot time\r\n", bootTime[bootTimeIndex]);
11141130
systemPrintln();
11151131
}
1132+
1133+
// If necessary, switch to sending GNSS data out the USB serial port
1134+
// to the PC
1135+
forwardGnssDataToUsbSerial = settings.enableGnssToUsbSerial;
11161136
}
11171137

11181138
void loop()

Firmware/RTK_Everywhere/menuMain.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ void terminalUpdate()
2828
// Display the main menu configuration options
2929
void menuMain()
3030
{
31+
// Redirect menu output, status and debug messages to the USB serial port
32+
forwardGnssDataToUsbSerial = false;
33+
3134
inMainMenu = true;
3235
displaySerialConfig(); // Display 'Serial Config' while user is configuring
3336

@@ -259,6 +262,9 @@ void menuMain()
259262
clearBuffer(); // Empty buffer of any newline chars
260263
btPrintEchoExit = false; // We are out of the menu system
261264
inMainMenu = false;
265+
266+
// Change the USB serial output behavior if necessary
267+
forwardGnssDataToUsbSerial = settings.enableGnssToUsbSerial;
262268
}
263269

264270
// Change system wide settings based on current user profile

0 commit comments

Comments
 (0)