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

Escserial test

This commit is contained in:
Sami Korhonen 2016-10-22 16:50:35 +03:00 committed by borisbstyle
parent f19b508cd4
commit ec923b6180
5 changed files with 999 additions and 0 deletions

View file

@ -55,6 +55,7 @@ uint8_t cliMode = 0;
#include "drivers/pwm_rx.h"
#include "drivers/sdcard.h"
#include "drivers/buf_writer.h"
#include "drivers/serial_escserial.h"
#include "fc/config.h"
#include "fc/rc_controls.h"
@ -153,6 +154,9 @@ static void cliResource(char *cmdline);
#ifdef GPS
static void cliGpsPassthrough(char *cmdline);
#endif
#ifdef USE_ESCSERIAL
static void cliEscPassthrough(char *cmdline);
#endif
static void cliHelp(char *cmdline);
static void cliMap(char *cmdline);
@ -304,6 +308,9 @@ const clicmd_t cmdTable[] = {
"[name]", cliGet),
#ifdef GPS
CLI_COMMAND_DEF("gpspassthrough", "passthrough gps to serial", NULL, cliGpsPassthrough),
#endif
#ifdef USE_ESCSERIAL
CLI_COMMAND_DEF("escprog", "passthrough esc to serial", "<mode [sk/bl]> <index>", cliEscPassthrough),
#endif
CLI_COMMAND_DEF("help", NULL, NULL, cliHelp),
#ifdef LED_STRIP
@ -2944,6 +2951,60 @@ static void cliGpsPassthrough(char *cmdline)
}
#endif
#ifdef USE_ESCSERIAL
static void cliEscPassthrough(char *cmdline)
{
uint8_t mode = 0;
int index = 0;
int i = 0;
char *pch = NULL;
char *saveptr;
if (isEmpty(cmdline)) {
cliShowParseError();
return;
}
pch = strtok_r(cmdline, " ", &saveptr);
while (pch != NULL) {
switch (i) {
case 0:
if(strncasecmp(pch, "sk", strlen(pch)) == 0)
{
mode = 0;
}
else if(strncasecmp(pch, "bl", strlen(pch)) == 0)
{
mode = 1;
}
else if(strncasecmp(pch, "ki", strlen(pch)) == 0)
{
mode = 2;
}
else
{
cliShowParseError();
return;
}
break;
case 1:
index = atoi(pch);
if ((index >= 0) && (index < USABLE_TIMER_CHANNEL_COUNT)) {
printf("passthru at pwm output %d enabled\r\n", index);
}
else {
printf("invalid pwm output, valid range: 0 to %d\r\n", USABLE_TIMER_CHANNEL_COUNT);
return;
}
break;
}
i++;
pch = strtok_r(NULL, " ", &saveptr);
}
escEnablePassthrough(cliPort,index,mode);
}
#endif
static void cliHelp(char *cmdline)
{
UNUSED(cmdline);