mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
cli - fix gpspassthrouh when GPS port is not open (#13878)
- return status from gpsPassthrough - test gpsPort
This commit is contained in:
parent
f0e1deb932
commit
952ccb68c4
3 changed files with 17 additions and 4 deletions
|
@ -3603,7 +3603,9 @@ static void cliGpsPassthrough(const char *cmdName, char *cmdline)
|
||||||
UNUSED(cmdName);
|
UNUSED(cmdName);
|
||||||
UNUSED(cmdline);
|
UNUSED(cmdline);
|
||||||
|
|
||||||
gpsEnablePassthrough(cliPort);
|
if (!gpsPassthrough(cliPort)) {
|
||||||
|
cliPrintErrorLinef(cmdName, "GPS forwarding failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2486,13 +2486,22 @@ static void gpsHandlePassthrough(uint8_t data)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
|
// forward GPS data to specified port (used by CLI)
|
||||||
|
// return false if forwarding failed
|
||||||
|
// curently only way to stop forwarding is to reset the board
|
||||||
|
bool gpsPassthrough(serialPort_t *gpsPassthroughPort)
|
||||||
{
|
{
|
||||||
|
if (!gpsPort) {
|
||||||
|
// GPS port is not open for some reason - no GPS, MSP GPS, ..
|
||||||
|
return false;
|
||||||
|
}
|
||||||
waitForSerialPortToFinishTransmitting(gpsPort);
|
waitForSerialPortToFinishTransmitting(gpsPort);
|
||||||
waitForSerialPortToFinishTransmitting(gpsPassthroughPort);
|
waitForSerialPortToFinishTransmitting(gpsPassthroughPort);
|
||||||
|
|
||||||
if (!(gpsPort->mode & MODE_TX))
|
if (!(gpsPort->mode & MODE_TX)) {
|
||||||
|
// try to switch TX mode on
|
||||||
serialSetMode(gpsPort, gpsPort->mode | MODE_TX);
|
serialSetMode(gpsPort, gpsPort->mode | MODE_TX);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_DASHBOARD
|
#ifdef USE_DASHBOARD
|
||||||
if (featureIsEnabled(FEATURE_DASHBOARD)) {
|
if (featureIsEnabled(FEATURE_DASHBOARD)) {
|
||||||
|
@ -2502,6 +2511,8 @@ void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serialPassthrough(gpsPort, gpsPassthroughPort, &gpsHandlePassthrough, NULL);
|
serialPassthrough(gpsPort, gpsPassthroughPort, &gpsHandlePassthrough, NULL);
|
||||||
|
// allow exitting passthrough mode in future
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GPS_cosLat = 1.0f; // this is used to offset the shrinking longitude as we go towards the poles
|
float GPS_cosLat = 1.0f; // this is used to offset the shrinking longitude as we go towards the poles
|
||||||
|
|
|
@ -386,7 +386,7 @@ void gpsUpdate(timeUs_t currentTimeUs);
|
||||||
bool gpsNewFrame(uint8_t c);
|
bool gpsNewFrame(uint8_t c);
|
||||||
bool gpsIsHealthy(void); // Returns true when the gps state is RECEIVING_DATA
|
bool gpsIsHealthy(void); // Returns true when the gps state is RECEIVING_DATA
|
||||||
struct serialPort_s;
|
struct serialPort_s;
|
||||||
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);
|
bool gpsPassthrough(struct serialPort_s *gpsPassthroughPort);
|
||||||
void onGpsNewData(void);
|
void onGpsNewData(void);
|
||||||
void GPS_reset_home_position(void);
|
void GPS_reset_home_position(void);
|
||||||
void GPS_calc_longitude_scaling(int32_t lat);
|
void GPS_calc_longitude_scaling(int32_t lat);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue