@@ -255,15 +255,12 @@ bool GNSS_LG290P::configureOnce()
255
255
// Set the baud rate for the three UARTs
256
256
if (response == true )
257
257
{
258
- if (getDataBaudRate () != settings.dataPortBaud )
259
- response &= setDataBaudRate (settings.dataPortBaud ); // LG290P UART1 is connected to CH342 (Port B)
258
+ response &= setDataBaudRate (settings.dataPortBaud ); // If available, set baud of DATA port
260
259
261
- if ( getCommBaudRate () != ( 115200 * 4 ))
262
- response &= setBaudrate (115200 * 4 ); // LG290P UART2 is connected to the ESP32 UART1
260
+ // This is redundant because to get this far, the comm interface must already be working
261
+ // response &= setCommBaudrate (115200 * 4); // Set baud for main comm channel
263
262
264
- if (getRadioBaudRate () != settings.radioPortBaud )
265
- response &=
266
- setRadioBaudRate (settings.radioPortBaud ); // LG290P UART3 is connected to the locking JST connector
263
+ response &= setRadioBaudRate (settings.radioPortBaud ); // If available, set baud of RADIO port
267
264
268
265
if (response == false && settings.debugGnss )
269
266
systemPrintln (" configureOnce: setBauds failed." );
@@ -1078,7 +1075,7 @@ uint8_t GNSS_LG290P::getActiveRtcmMessageCount()
1078
1075
}
1079
1076
1080
1077
// ----------------------------------------
1081
- // Returns the altitude in meters or zero if the GNSS is offline
1078
+ // Returns the altitude in meters or zero if the GNSS is offline
1082
1079
// ----------------------------------------
1083
1080
double GNSS_LG290P::getAltitude ()
1084
1081
{
@@ -1114,55 +1111,133 @@ uint8_t GNSS_LG290P::getCarrierSolution()
1114
1111
}
1115
1112
1116
1113
// ----------------------------------------
1117
- // UART1 of the LG290P is connected to USB CH342 (Port B)
1118
- // This is nicknamed the DATA port
1119
- // Return the baud rate of UART1
1114
+ // Return the baud rate of a given UART
1120
1115
// ----------------------------------------
1121
- uint32_t GNSS_LG290P::getDataBaudRate ( )
1116
+ uint32_t GNSS_LG290P::getBaudRate ( uint8_t uartNumber )
1122
1117
{
1118
+ if (uartNumber < 1 || uartNumber > 3 )
1119
+ {
1120
+ systemPrintln (" getBaudRate error: out of range" );
1121
+ return (0 );
1122
+ }
1123
+
1123
1124
uint32_t baud = 0 ;
1124
1125
if (online.gnss )
1125
1126
{
1126
1127
uint8_t dataBits, parity, stop, flowControl;
1127
1128
1128
- _lg290p->getPortInfo (1 , baud, dataBits, parity, stop, flowControl, 250 );
1129
+ _lg290p->getPortInfo (uartNumber , baud, dataBits, parity, stop, flowControl, 250 );
1129
1130
}
1130
1131
return (baud);
1131
1132
}
1132
1133
1133
1134
// ----------------------------------------
1134
- // UART1 of the LG290P is connected to USB CH342 (Port B)
1135
- // This is nicknamed the DATA port
1136
- // Return the baud rate of UART1
1135
+ // Set the baud rate of a given UART
1136
+ // ----------------------------------------
1137
+ bool GNSS_LG290P::setBaudRate (uint8_t uartNumber, uint32_t baudRate)
1138
+ {
1139
+ if (uartNumber < 1 || uartNumber > 3 )
1140
+ {
1141
+ systemPrintln (" setBaudRate error: out of range" );
1142
+ return (false );
1143
+ }
1144
+
1145
+ return (_lg290p->setPortBaudrate (uartNumber, baudRate, 250 ));
1146
+ }
1147
+
1148
+ // Used only for Bluetooth test
1149
+ bool GNSS_LG290P::setBaudrate (uint32_t baudRate)
1150
+ {
1151
+ return (setBaudRate (2 , baudRate));
1152
+ }
1153
+
1154
+ // ----------------------------------------
1155
+ // Return the baud rate of port nicknamed DATA
1156
+ // ----------------------------------------
1157
+ uint32_t GNSS_LG290P::getDataBaudRate ()
1158
+ {
1159
+ uint8_t dataUart = 0 ;
1160
+ if (productVariant == RTK_POSTCARD)
1161
+ {
1162
+ // UART1 of the LG290P is connected to USB CH342 (Port B)
1163
+ // This is nicknamed the DATA port
1164
+ dataUart = 1 ;
1165
+ }
1166
+ return (getBaudRate (dataUart));
1167
+ }
1168
+
1169
+ // ----------------------------------------
1170
+ // Set the baud rate of port nicknamed DATA
1137
1171
// ----------------------------------------
1138
1172
bool GNSS_LG290P::setDataBaudRate (uint32_t baud)
1139
1173
{
1140
1174
if (online.gnss )
1141
1175
{
1142
- return (_lg290p->setPortBaudrate (1 , baud, 250 ));
1176
+ if (productVariant == RTK_POSTCARD)
1177
+ {
1178
+ if (getDataBaudRate () != baud)
1179
+ {
1180
+ // UART1 of the LG290P is connected to USB CH342 (Port B)
1181
+ // This is nicknamed the DATA port
1182
+ return (setBaudRate (1 , baud));
1183
+ }
1184
+ }
1185
+ else
1186
+ {
1187
+ // On products that don't have a DATA port (Flex), act as if we have set the baud successfully
1188
+ return (true );
1189
+ }
1143
1190
}
1144
- return (0 );
1191
+ return (false );
1145
1192
}
1146
1193
1147
- // Return the baud rate of UART3, connected to the locking JST connector
1194
+ // ----------------------------------------
1195
+ // Return the baud rate of interface where a radio is connected
1148
1196
// ----------------------------------------
1149
1197
uint32_t GNSS_LG290P::getRadioBaudRate ()
1150
1198
{
1151
- uint32_t baud = 0 ;
1152
- if (online. gnss )
1199
+ uint8_t radioUart = 0 ;
1200
+ if (productVariant == RTK_POSTCARD )
1153
1201
{
1154
- uint8_t dataBits, parity, stop, flowControl;
1155
-
1156
- _lg290p->getPortInfo (3 , baud, dataBits, parity, stop, flowControl, 250 );
1202
+ // UART3 of the LG290P is connected to the locking JST connector labled RADIO
1203
+ radioUart = 3 ;
1157
1204
}
1158
- return (baud);
1205
+ else if (productVariant == RTK_FLEX)
1206
+ {
1207
+ // UART2 of the LG290P is connected to SW4, which is connected to LoRa UART0
1208
+ radioUart = 2 ;
1209
+ }
1210
+ return (getBaudRate (radioUart));
1159
1211
}
1160
1212
1161
- // Set the baud rate for UART3, connected to the locking JST connector
1213
+ // ----------------------------------------
1214
+ // Set the baud rate for the Radio connection
1162
1215
// ----------------------------------------
1163
1216
bool GNSS_LG290P::setRadioBaudRate (uint32_t baud)
1164
1217
{
1165
- return (_lg290p->setPortBaudrate (3 , baud, 250 ));
1218
+ if (online.gnss )
1219
+ {
1220
+ if (getRadioBaudRate () == baud)
1221
+ {
1222
+ return (true ); // Baud is set!
1223
+ }
1224
+ else
1225
+ {
1226
+ uint8_t radioUart = 0 ;
1227
+ if (productVariant == RTK_POSTCARD)
1228
+ {
1229
+ // UART3 of the LG290P is connected to the locking JST connector labled RADIO
1230
+ radioUart = 3 ;
1231
+ }
1232
+ else if (productVariant == RTK_FLEX)
1233
+ {
1234
+ // UART2 of the LG290P is connected to SW4, which is connected to LoRa UART0
1235
+ radioUart = 2 ;
1236
+ }
1237
+ return (setBaudRate (radioUart, baud));
1238
+ }
1239
+ }
1240
+ return (false );
1166
1241
}
1167
1242
1168
1243
// ----------------------------------------
@@ -1222,6 +1297,8 @@ uint8_t GNSS_LG290P::getHour()
1222
1297
return 0 ;
1223
1298
}
1224
1299
1300
+ // ----------------------------------------
1301
+ // Return the serial number of the LG290P
1225
1302
// ----------------------------------------
1226
1303
const char *GNSS_LG290P::getId ()
1227
1304
{
@@ -1972,27 +2049,50 @@ bool GNSS_LG290P::saveConfiguration()
1972
2049
// Set the baud rate on the GNSS port that interfaces between the ESP32 and the GNSS
1973
2050
// This just sets the GNSS side
1974
2051
// ----------------------------------------
1975
- bool GNSS_LG290P::setBaudrate (uint32_t baud)
2052
+ bool GNSS_LG290P::setCommBaudrate (uint32_t baud)
1976
2053
{
1977
2054
if (online.gnss )
1978
- // Set the baud rate on UART2 of the LG290P
1979
- return (_lg290p->setPortBaudrate (2 , baud, 250 ));
1980
- return false ;
2055
+ {
2056
+ if (getCommBaudRate () == baud)
2057
+ {
2058
+ return (true ); // Baud is set!
2059
+ }
2060
+ else
2061
+ {
2062
+ uint8_t commUart = 0 ;
2063
+ if (productVariant == RTK_POSTCARD)
2064
+ {
2065
+ // UART2 of the LG290P is connected to the ESP32 for the main config/comm
2066
+ commUart = 2 ;
2067
+ }
2068
+ else if (productVariant == RTK_FLEX)
2069
+ {
2070
+ // UART1 of the LG290P is connected to the ESP32 for the main config/comm
2071
+ commUart = 1 ;
2072
+ }
2073
+ return (setBaudRate (commUart, baud));
2074
+ }
2075
+ }
2076
+ return (false );
1981
2077
}
1982
2078
1983
2079
// ----------------------------------------
1984
- // Return the baud rate of UART2, connected to the ESP32 UART1
2080
+ // Return the baud rate of the UART connected to the ESP32 UART1
1985
2081
// ----------------------------------------
1986
2082
uint32_t GNSS_LG290P::getCommBaudRate ()
1987
2083
{
1988
- uint32_t baud = 0 ;
1989
- if (online. gnss )
2084
+ uint8_t commUart = 0 ;
2085
+ if (productVariant == RTK_POSTCARD )
1990
2086
{
1991
- uint8_t dataBits, parity, stop, flowControl;
1992
-
1993
- _lg290p->getPortInfo (2 , baud, dataBits, parity, stop, flowControl, 250 );
2087
+ // On the Postcard, the ESP32 UART1 is connected to LG290P UART2
2088
+ commUart = 2 ;
1994
2089
}
1995
- return (baud);
2090
+ else if (productVariant == RTK_FLEX)
2091
+ {
2092
+ // On the Flex, the ESP32 UART1 is connected to LG290P UART1
2093
+ commUart = 1 ;
2094
+ }
2095
+ return (getBaudRate (commUart));
1996
2096
}
1997
2097
1998
2098
// ----------------------------------------
@@ -2402,7 +2502,7 @@ bool lg290pIsPresent()
2402
2502
lg290p.enableDebugging (); // Print all debug to Serial
2403
2503
lg290p.enablePrintRxMessages (); // Print incoming processed messages from SEMP
2404
2504
}
2405
-
2505
+
2406
2506
if (lg290p.begin (serialTestGNSS) == true ) // Give the serial port over to the library
2407
2507
{
2408
2508
if (settings.debugGnss )
0 commit comments