Skip to content

Commit e2fd3b2

Browse files
committed
Change test of ZED<->ESP over UART. Don't display tests that are not on a given platform.
1 parent 2e54076 commit e2fd3b2

File tree

6 files changed

+82
-115
lines changed

6 files changed

+82
-115
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,12 +1371,15 @@ void paintSystemTest()
13711371
else
13721372
oled.print(F("FAIL"));
13731373

1374-
oled.setCursor(xOffset, yOffset + (1 * charHeight) ); //x, y
1375-
oled.print(F("Accel:"));
1376-
if (online.accelerometer == true)
1377-
oled.print(F("OK"));
1378-
else
1379-
oled.print(F("FAIL"));
1374+
if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET)
1375+
{
1376+
oled.setCursor(xOffset, yOffset + (1 * charHeight) ); //x, y
1377+
oled.print(F("Accel:"));
1378+
if (online.accelerometer == true)
1379+
oled.print(F("OK"));
1380+
else
1381+
oled.print(F("FAIL"));
1382+
}
13801383

13811384
oled.setCursor(xOffset, yOffset + (2 * charHeight) ); //x, y
13821385
oled.print(F("Batt:"));
@@ -1389,7 +1392,7 @@ void paintSystemTest()
13891392
oled.setCursor(xOffset, yOffset + (3 * charHeight) ); //x, y
13901393
oled.print(F("GNSS:"));
13911394
int satsInView = i2cGNSS.getSIV();
1392-
if (online.gnss == true && satsInView > 8)
1395+
if (online.gnss == true && satsInView > 5)
13931396
{
13941397
oled.print(F("OK"));
13951398
oled.print(F("/"));
@@ -1398,38 +1401,38 @@ void paintSystemTest()
13981401
else
13991402
oled.print(F("FAIL"));
14001403

1401-
oled.setCursor(xOffset, yOffset + (4 * charHeight) ); //x, y
1402-
oled.print(F("Mux:"));
1404+
if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET)
1405+
{
1406+
oled.setCursor(xOffset, yOffset + (4 * charHeight) ); //x, y
1407+
oled.print(F("Mux:"));
14031408

1404-
//Set mux to channel 3 and toggle pin and verify with loop back jumper wire inserted by test technician
1409+
//Set mux to channel 3 and toggle pin and verify with loop back jumper wire inserted by test technician
14051410

1406-
setMuxport(MUX_ADC_DAC); //Set mux to DAC so we can toggle back/forth
1407-
pinMode(pin_dac26, OUTPUT);
1408-
pinMode(pin_adc39, INPUT_PULLUP);
1411+
setMuxport(MUX_ADC_DAC); //Set mux to DAC so we can toggle back/forth
1412+
pinMode(pin_dac26, OUTPUT);
1413+
pinMode(pin_adc39, INPUT_PULLUP);
14091414

1410-
digitalWrite(pin_dac26, HIGH);
1411-
if (digitalRead(pin_adc39) == HIGH)
1412-
{
1413-
digitalWrite(pin_dac26, LOW);
1414-
if (digitalRead(pin_adc39) == LOW)
1415-
oled.print(F("OK"));
1415+
digitalWrite(pin_dac26, HIGH);
1416+
if (digitalRead(pin_adc39) == HIGH)
1417+
{
1418+
digitalWrite(pin_dac26, LOW);
1419+
if (digitalRead(pin_adc39) == LOW)
1420+
oled.print(F("OK"));
1421+
else
1422+
oled.print(F("FAIL"));
1423+
}
14161424
else
14171425
oled.print(F("FAIL"));
14181426
}
1419-
else
1420-
oled.print(F("FAIL"));
14211427

14221428
//Display MAC address
14231429
oled.setCursor(xOffset, yOffset + (5 * charHeight) ); //x, y
14241430
oled.print(macAddress);
14251431
oled.print(":");
1426-
if (incomingBTTest == 0)
1432+
if (zedUartPassed == false)
14271433
oled.print(F("FAIL"));
14281434
else
1429-
{
1430-
oled.write(incomingBTTest);
1431-
oled.print(F("-OK"));
1432-
}
1435+
oled.print(F("OK"));
14331436
}
14341437
}
14351438

Firmware/RTK_Surveyor/Form.ino

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ void startConfigAP()
7878
ws.onEvent(onWsEvent);
7979
server.addHandler(&ws);
8080

81-
// * index.html (not gz'd)
82-
// * favicon.ico
83-
84-
// * /src/bootstrap.bundle.min.js - Needed for popper
85-
// * /src/bootstrap.min.css
86-
// * /src/bootstrap.min.js
87-
// * /src/jquery-3.6.0.min.js
88-
// * /src/main.js (not gz'd)
89-
// * /src/rtk-setup.png
90-
// * /src/style.css
91-
92-
// * /src/fonts/icomoon.eot
93-
// * /src/fonts/icomoon.svg
94-
// * /src/fonts/icomoon.ttf
95-
// * /src/fonts/icomoon.woof
81+
// * index.html (not gz'd)
82+
// * favicon.ico
83+
84+
// * /src/bootstrap.bundle.min.js - Needed for popper
85+
// * /src/bootstrap.min.css
86+
// * /src/bootstrap.min.js
87+
// * /src/jquery-3.6.0.min.js
88+
// * /src/main.js (not gz'd)
89+
// * /src/rtk-setup.png
90+
// * /src/style.css
91+
92+
// * /src/fonts/icomoon.eot
93+
// * /src/fonts/icomoon.svg
94+
// * /src/fonts/icomoon.ttf
95+
// * /src/fonts/icomoon.woof
9696

9797
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
9898
request->send_P(200, "text/html", index_html);
@@ -168,11 +168,10 @@ void startConfigAP()
168168
request->send(response);
169169
});
170170

171-
172171
//Handler for the /update form POST
173-
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request){
174-
request->send(200);
175-
}, handleFirmwareFileUpload);
172+
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest * request) {
173+
request->send(200);
174+
}, handleFirmwareFileUpload);
176175

177176
server.begin();
178177
#endif
@@ -184,12 +183,12 @@ void startConfigAP()
184183
#ifdef COMPILE_WIFI
185184
static void handleFirmwareFileUpload(AsyncWebServerRequest *request, String fileName, size_t index, uint8_t *data, size_t len, bool final)
186185
{
187-
if(online.microSD == false)
186+
if (online.microSD == false)
188187
{
189188
Serial.println(F("No SD card available"));
190189
return;
191190
}
192-
191+
193192
//Attempt to write to file system. This avoids collisions with file writing in F9PSerialReadTask()
194193
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_longWait_ms) != pdPASS) {
195194
Serial.println(F("Failed to get file system lock on firmware file"));
@@ -238,8 +237,6 @@ static void handleFirmwareFileUpload(AsyncWebServerRequest *request, String file
238237
}
239238

240239
xSemaphoreGive(xFATSemaphore);
241-
242-
243240
}
244241
#endif
245242

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ BluetoothSerial SerialBT;
211211

212212
char platformPrefix[40] = "Surveyor"; //Sets the prefix for broadcast names
213213

214-
HardwareSerial serialGNSS(2);
215-
#define RXD2 16
216-
#define TXD2 17
214+
HardwareSerial serialGNSS(2); //TX on 17, RX on 16
217215

218216
#define SERIAL_SIZE_RX (1024 * 6) //Should match buffer size in BluetoothSerial.cpp. Reduced from 16384 to make room for WiFi/NTRIP server capabilities
219217
uint8_t rBuffer[SERIAL_SIZE_RX]; //Buffer for reading from F9P to SPP
@@ -232,7 +230,7 @@ volatile bool uart2pinned = false; //This variable is touched by core 0 but chec
232230
const int readTaskStackSize = 2500;
233231
const int writeTaskStackSize = 2000;
234232

235-
char incomingBTTest = 0; //Stores incoming text over BT when in test mode
233+
bool zedUartPassed = false; //Goes true during testing if ESP can communicate with ZED over UART
236234
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
237235

238236
//External Display
@@ -306,7 +304,6 @@ unsigned long timeSinceLastIncomingSetting = 0;
306304
uint8_t unitMACAddress[6]; //Use MAC address in BT broadcast and display
307305
char deviceName[20]; //The serial string that is broadcast. Ex: 'Surveyor Base-BC61'
308306
const byte menuTimeout = 15; //Menus will exit/timeout after this number of seconds
309-
bool inTestMode = false; //Used to re-route BT traffic while in test sub menu
310307
int systemTime_minutes = 0; //Used to test if logging is less than max minutes
311308
uint32_t powerPressedStartTime = 0; //Times how long user has been holding power button, used for power down
312309
uint8_t debounceDelay = 20; //ms to delay between button reads

Firmware/RTK_Surveyor/States.ino

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ void updateSystemState()
4545
return;
4646
}
4747

48-
inTestMode = false; //Reroutes bluetooth bytes
49-
5048
setMuxport(settings.dataPortChannel); //Return mux to original channel
5149

5250
i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 0); //Disable RTCM sentences
@@ -647,7 +645,19 @@ void updateSystemState()
647645
//even if there is no GPS fix. We use it to test serial output.
648646
i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 1); //Enable message every second
649647

650-
inTestMode = true; //Reroutes bluetooth bytes
648+
//Verify the ESP UART2 can communicate TX/RX to ZED UART1
649+
SFE_UBLOX_GNSS myGNSS;
650+
651+
//Attempt 3 connections
652+
for (int x = 0 ; x < 3 ; x++)
653+
{
654+
if (myGNSS.begin(serialGNSS) == true)
655+
{
656+
zedUartPassed = true;
657+
break;
658+
}
659+
delay(250);
660+
}
651661

652662
changeState(STATE_TESTING);
653663
}

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,15 @@ void F9PSerialWriteTask(void *e)
1313
{
1414
while (SerialBT.available())
1515
{
16-
if (inTestMode == false)
17-
{
18-
//Pass bytes to GNSS receiver
19-
auto s = SerialBT.readBytes(wBuffer, sizeof(wBuffer));
20-
serialGNSS.write(wBuffer, s);
16+
//Pass bytes to GNSS receiver
17+
auto s = SerialBT.readBytes(wBuffer, sizeof(wBuffer));
18+
serialGNSS.write(wBuffer, s);
2119

22-
if (settings.enableTaskReports == true)
23-
Serial.printf("SerialWriteTask High watermark: %d\n\r", uxTaskGetStackHighWaterMark(NULL));
24-
}
25-
else
26-
{
27-
char incoming = SerialBT.read();
28-
Serial.printf("I heard: %c\n", incoming);
29-
incomingBTTest = incoming; //Displayed during system test
30-
}
31-
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
32-
taskYIELD();
20+
if (settings.enableTaskReports == true)
21+
Serial.printf("SerialWriteTask High watermark: %d\n\r", uxTaskGetStackHighWaterMark(NULL));
3322
}
23+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
24+
taskYIELD();
3425
}
3526
#endif
3627

@@ -166,7 +157,10 @@ void ButtonCheckTask(void *e)
166157
//If quick toggle is detected (less than 500ms), enter WiFi AP Config mode
167158
if (millis() - lastRockerSwitchChange < 500)
168159
{
169-
requestChangeState(STATE_WIFI_CONFIG_NOT_STARTED);
160+
if(systemState == STATE_ROVER_NOT_STARTED && online.display == true) //Catch during Power On
161+
requestChangeState(STATE_TEST); //If RTK Surveyor, with display attached, during Rover not started, then enter test mode
162+
else
163+
requestChangeState(STATE_WIFI_CONFIG_NOT_STARTED);
170164
}
171165
else
172166
{

Firmware/RTK_Surveyor/menuTest.ino

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
//Scan for display
44
void menuTest()
55
{
6-
inTestMode = true; //Reroutes bluetooth bytes
7-
86
//Enable RTCM 1230. This is the GLONASS bias sentence and is transmitted
97
//even if there is no GPS fix. We use it to test serial output.
108
i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 1); //Enable message every second
119

10+
//Go direct into test display
11+
if (online.display)
12+
changeState(STATE_TEST);
13+
1214
while (1)
1315
{
1416
Serial.println();
@@ -21,7 +23,7 @@ void menuTest()
2123

2224
if (settings.enableSD && online.microSD)
2325
{
24-
Serial.print(F("microSD card detected:"));
26+
Serial.print(F("microSD card detected"));
2527
if (createTestFile() == false)
2628
{
2729
Serial.print(F(" Failed to create test file. Format SD card with 'SD Card Formatter'."));
@@ -38,9 +40,8 @@ void menuTest()
3840
Serial.println(F("Any character received over Blueooth connection will be displayed here"));
3941

4042
Serial.println(F("1) Display microSD contents"));
41-
Serial.println(F("2) Turn on all messages on USB port"));
42-
Serial.println(F("3) Reset USB Messages to Defaults (NMEAx6)"));
43-
Serial.println(F("4) Duplicate UART messages to USB"));
43+
Serial.println(F("2) Duplicate UART messages to USB"));
44+
Serial.println(F("3) Enter Test Screen"));
4445

4546
Serial.println(F("x) Exit"));
4647

@@ -62,46 +63,13 @@ void menuTest()
6263
}
6364
else if (incoming == 2)
6465
{
65-
// ubxMsgs usbMessage; //Create temp struct
66-
// setGNSSMessageRates(usbMessage, 1); //Turn on all messages to report once per fix
67-
//
68-
// //Now send that struct
69-
// bool response = configureGNSSMessageRates(COM_PORT_USB, usbMessage); //Make sure the appropriate messages are enabled
70-
// if (response == false)
71-
// Serial.println(F("menuTest: Failed to enable USB messages"));
72-
// else
73-
// Serial.println(F("All messages enabled"));
74-
}
75-
else if (incoming == 3)
76-
{
77-
// ubxMsgs usbMessage; //Create temp struct
78-
// setGNSSMessageRates(usbMessage, 0); //Turn off all messages to report
79-
//
80-
// //Turn on default 6
81-
// usbMessage.nmea_gga.msgRate = 1;
82-
// usbMessage.nmea_gsa.msgRate = 1;
83-
// usbMessage.nmea_gst.msgRate = 1;
84-
// usbMessage.nmea_gsv.msgRate = 1;
85-
// usbMessage.nmea_rmc.msgRate = 1;
86-
// usbMessage.nmea_vtg.msgRate = 1;
87-
//
88-
// //Now send that struct
89-
// bool response = configureGNSSMessageRates(COM_PORT_USB, usbMessage); //Make sure the appropriate messages are enabled
90-
// if (response == false)
91-
// Serial.println(F("menuTest: Failed to enable USB messages"));
92-
// else
93-
// Serial.println(F("All messages enabled"));
94-
}
95-
else if (incoming == 4)
96-
{
9766
//Send the current settings to USB
9867
bool response = configureGNSSMessageRates(COM_PORT_USB, settings.ubxMessages); //Make sure the appropriate messages are enabled
9968
if (response == false)
10069
Serial.println(F("menuTest: Failed to enable USB messages"));
10170
else
10271
Serial.println(F("USB now matches UART messages"));
10372
}
104-
10573
else if (incoming == STATUS_PRESSED_X)
10674
break;
10775
else if (incoming == STATUS_GETNUMBER_TIMEOUT)
@@ -110,8 +78,6 @@ void menuTest()
11078
printUnknown(incoming);
11179
}
11280

113-
inTestMode = false; //Reroutes bluetooth bytes
114-
11581
//Disable RTCM sentences
11682
i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 0);
11783

0 commit comments

Comments
 (0)