@@ -246,11 +246,28 @@ bool GNSS_LG290P::configureOnce()
246246 if (settings.debugGnss && response == false )
247247 systemPrintln (" configureOnce: Enter config mode failed" );
248248
249- response &= setDataBaudRate (settings.dataPortBaud ); // LG290P UART1 is connected to CH342 (Port B)
250- response &= _lg290p->setPortBaudrate (2 , 115200 * 4 ); // LG290P UART2 is connected to the ESP32 UART1
251- response &= setRadioBaudRate (settings.radioPortBaud ); // LG290P UART3 is connected to the locking JST connector
252- if (settings.debugGnss && response == false )
253- systemPrintln (" configureOnce: setBauds failed" );
249+ // Check baud settings. LG290P has a limited number of allowable bauds
250+ if (baudIsAllowed (settings.dataPortBaud ) == false )
251+ settings.dataPortBaud = 460800 ;
252+ if (baudIsAllowed (settings.radioPortBaud ) == false )
253+ settings.radioPortBaud = 115200 ;
254+
255+ // Set the baud rate for the three UARTs
256+ if (response == true )
257+ {
258+ if (getDataBaudRate () != settings.dataPortBaud )
259+ response &= setDataBaudRate (settings.dataPortBaud ); // LG290P UART1 is connected to CH342 (Port B)
260+
261+ if (getCommBaudRate () != (115200 * 4 ))
262+ response &= setBaudrate (115200 * 4 ); // LG290P UART2 is connected to the ESP32 UART1
263+
264+ if (getRadioBaudRate () != settings.radioPortBaud )
265+ response &=
266+ setRadioBaudRate (settings.radioPortBaud ); // LG290P UART3 is connected to the locking JST connector
267+
268+ if (settings.debugGnss )
269+ systemPrintln (" configureOnce: setBauds failed." );
270+ }
254271
255272 // Enable PPS signal with a width of 200ms
256273 response &= _lg290p->setPPS (200 , false , true ); // duration time ms, alwaysOutput, polarity
@@ -1097,14 +1114,14 @@ uint8_t GNSS_LG290P::getCarrierSolution()
10971114// ----------------------------------------
10981115uint32_t GNSS_LG290P::getDataBaudRate ()
10991116{
1117+ uint32_t baud = 0 ;
11001118 if (online.gnss )
11011119 {
1102- uint32_t baud;
11031120 uint8_t dataBits, parity, stop, flowControl;
1104- if (_lg290p-> getPortInfo ( 1 , baud, dataBits, parity, stop, flowControl) == true )
1105- return baud ;
1121+
1122+ _lg290p-> getPortInfo ( 1 , baud, dataBits, parity, stop, flowControl, 250 ) ;
11061123 }
1107- return (0 );
1124+ return (baud );
11081125}
11091126
11101127// ----------------------------------------
@@ -1116,7 +1133,7 @@ bool GNSS_LG290P::setDataBaudRate(uint32_t baud)
11161133{
11171134 if (online.gnss )
11181135 {
1119- return (_lg290p->setPortBaudrate (1 , baud) == true );
1136+ return (_lg290p->setPortBaudrate (1 , baud, 250 ) );
11201137 }
11211138 return (0 );
11221139}
@@ -1125,22 +1142,21 @@ bool GNSS_LG290P::setDataBaudRate(uint32_t baud)
11251142// ----------------------------------------
11261143uint32_t GNSS_LG290P::getRadioBaudRate ()
11271144{
1145+ uint32_t baud = 0 ;
11281146 if (online.gnss )
11291147 {
1130- uint32_t baud;
11311148 uint8_t dataBits, parity, stop, flowControl;
11321149
1133- if (_lg290p->getPortInfo (3 , baud, dataBits, parity, stop, flowControl) == true )
1134- return baud;
1150+ _lg290p->getPortInfo (3 , baud, dataBits, parity, stop, flowControl, 250 );
11351151 }
1136- return (0 );
1152+ return (baud );
11371153}
11381154
11391155// Set the baud rate for UART3, connected to the locking JST connector
11401156// ----------------------------------------
11411157bool GNSS_LG290P::setRadioBaudRate (uint32_t baud)
11421158{
1143- return (_lg290p->setPortBaudrate (3 , baud));
1159+ return (_lg290p->setPortBaudrate (3 , baud, 250 ));
11441160}
11451161
11461162// ----------------------------------------
@@ -1949,16 +1965,30 @@ bool GNSS_LG290P::saveConfiguration()
19491965// ----------------------------------------
19501966// Set the baud rate on the GNSS port that interfaces between the ESP32 and the GNSS
19511967// This just sets the GNSS side
1952- // Used during Bluetooth testing
19531968// ----------------------------------------
1954- bool GNSS_LG290P::setBaudrate (uint32_t baudRate )
1969+ bool GNSS_LG290P::setBaudrate (uint32_t baud )
19551970{
19561971 if (online.gnss )
19571972 // Set the baud rate on UART2 of the LG290P
1958- return _lg290p->setPortBaudrate (2 , baudRate );
1973+ return ( _lg290p->setPortBaudrate (2 , baud, 250 ) );
19591974 return false ;
19601975}
19611976
1977+ // ----------------------------------------
1978+ // Return the baud rate of UART2, connected to the ESP32 UART1
1979+ // ----------------------------------------
1980+ uint32_t GNSS_LG290P::getCommBaudRate ()
1981+ {
1982+ uint32_t baud = 0 ;
1983+ if (online.gnss )
1984+ {
1985+ uint8_t dataBits, parity, stop, flowControl;
1986+
1987+ _lg290p->getPortInfo (2 , baud, dataBits, parity, stop, flowControl, 250 );
1988+ }
1989+ return (baud);
1990+ }
1991+
19621992// ----------------------------------------
19631993// Enable all the valid constellations and bands for this platform
19641994// Band support varies between platforms and firmware versions
0 commit comments