1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

gps passthrough cli command

This commit is contained in:
Kemal Hadimli 2013-10-29 19:35:13 +02:00
parent 77d455f82b
commit c4dd556f3d
3 changed files with 38 additions and 0 deletions

View file

@ -9,6 +9,7 @@ static void cliDefaults(char *cmdline);
static void cliDump(char *cmdLine);
static void cliExit(char *cmdline);
static void cliFeature(char *cmdline);
static void cliGpsPassthrough(char *cmdline);
static void cliHelp(char *cmdline);
static void cliMap(char *cmdline);
static void cliMixer(char *cmdline);
@ -73,6 +74,7 @@ const clicmd_t cmdTable[] = {
{ "dump", "print configurable settings in a pastable form", cliDump },
{ "exit", "", cliExit },
{ "feature", "list or -val or val", cliFeature },
{ "gpspassthrough", "passthrough gps to serial", cliGpsPassthrough },
{ "help", "", cliHelp },
{ "map", "mapping of rc channel order", cliMap },
{ "mixer", "mixer name or list", cliMixer },
@ -657,6 +659,15 @@ static void cliFeature(char *cmdline)
}
}
static void cliGpsPassthrough(char *cmdline)
{
cliPrint("Enabling GPS passthrough...");
if (gpsSetPassthrough() == -1) {
cliPrint("Error: Enable and plug in GPS first\r\n");
}
}
static void cliHelp(char *cmdline)
{
uint32_t i = 0;

View file

@ -521,6 +521,32 @@ void gpsSetPIDs(void)
navPID_PARAM.Imax = POSHOLD_RATE_IMAX * 100;
}
int8_t gpsSetPassthrough(void)
{
if (gpsData.state != GPS_RECEIVINGDATA)
return -1;
// get rid of callback
core.gpsport->callback = NULL;
LED0_OFF;
LED1_OFF;
while(1) {
if (serialTotalBytesWaiting(core.gpsport)) {
LED0_ON;
serialWrite(core.mainport, serialRead(core.gpsport));
LED0_OFF;
}
if (serialTotalBytesWaiting(core.mainport)) {
LED1_ON;
serialWrite(core.gpsport, serialRead(core.mainport));
LED1_OFF;
}
}
}
// OK here is the onboard GPS code
////////////////////////////////////////////////////////////////////////////////////

View file

@ -456,6 +456,7 @@ void cliProcess(void);
void gpsInit(uint8_t baudrate);
void gpsThread(void);
void gpsSetPIDs(void);
int8_t gpsSetPassthrough(void);
void GPS_reset_home_position(void);
void GPS_reset_nav(void);
void GPS_set_next_wp(int32_t* lat, int32_t* lon);