mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Added ESC info display for 'dshotprog 255 6' invocation (all ESCs).
This commit is contained in:
parent
b3898fa9d1
commit
779d3ceb0a
1 changed files with 31 additions and 26 deletions
|
@ -883,7 +883,7 @@ static void cliSerialPassthrough(char *cmdline)
|
|||
serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);
|
||||
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
|
||||
if (!baud) {
|
||||
cliPrint("closed, specify baud.\r\n");
|
||||
cliPrintLine("closed, specify baud.");
|
||||
return;
|
||||
}
|
||||
if (!mode)
|
||||
|
@ -893,7 +893,7 @@ static void cliSerialPassthrough(char *cmdline)
|
|||
baud, mode,
|
||||
SERIAL_NOT_INVERTED);
|
||||
if (!passThroughPort) {
|
||||
cliPrint("could not be opened.\r\n");
|
||||
cliPrintLine("could not be opened.");
|
||||
return;
|
||||
}
|
||||
cliPrintf("opened, baud = %d.\r\n", baud);
|
||||
|
@ -901,7 +901,7 @@ static void cliSerialPassthrough(char *cmdline)
|
|||
passThroughPort = passThroughPortUsage->serialPort;
|
||||
// If the user supplied a mode, override the port's mode, otherwise
|
||||
// leave the mode unchanged. serialPassthrough() handles one-way ports.
|
||||
cliPrint("already open.\r\n");
|
||||
cliPrintLine("already open.");
|
||||
if (mode && passThroughPort->mode != mode) {
|
||||
cliPrintf("mode changed from %d to %d.\r\n",
|
||||
passThroughPort->mode, mode);
|
||||
|
@ -914,7 +914,7 @@ static void cliSerialPassthrough(char *cmdline)
|
|||
}
|
||||
}
|
||||
|
||||
cliPrint("Forwarding, power cycle to exit.\r\n");
|
||||
cliPrintLine("Forwarding, power cycle to exit.");
|
||||
|
||||
serialPassthrough(cliPort, passThroughPort, NULL, NULL);
|
||||
}
|
||||
|
@ -2296,13 +2296,33 @@ void printEscInfo(const uint8_t *escInfoBytes, uint8_t bytesRead)
|
|||
cliPrintLinef("3D: %s", escInfoBytes[17] ? "on" : "off");
|
||||
}
|
||||
} else {
|
||||
cliPrint("Checksum error.");
|
||||
cliPrintLine("Checksum error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!escInfoReceived) {
|
||||
cliPrint("No info.");
|
||||
cliPrintLine("No info.");
|
||||
}
|
||||
}
|
||||
|
||||
static void writeDshotCommand(uint8_t escIndex, uint8_t command)
|
||||
{
|
||||
uint8_t escInfoBuffer[ESC_INFO_V2_EXPECTED_FRAME_SIZE];
|
||||
if (command == DSHOT_CMD_ESC_INFO) {
|
||||
cliPrintLinef("Info for ESC %d:", escIndex);
|
||||
|
||||
delay(10); // Wait for potential ESC telemetry transmission to finish
|
||||
|
||||
startEscDataRead(escInfoBuffer, ESC_INFO_V2_EXPECTED_FRAME_SIZE);
|
||||
}
|
||||
|
||||
pwmWriteDshotCommand(escIndex, command);
|
||||
|
||||
if (command == DSHOT_CMD_ESC_INFO) {
|
||||
delay(10);
|
||||
|
||||
printEscInfo(escInfoBuffer, getNumberEscBytesRead());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2334,34 +2354,19 @@ static void cliDshotProg(char *cmdline)
|
|||
if (command >= 0 && command < DSHOT_MIN_THROTTLE) {
|
||||
if (escIndex == ALL_MOTORS) {
|
||||
for (unsigned i = 0; i < getMotorCount(); i++) {
|
||||
pwmWriteDshotCommand(i, command);
|
||||
writeDshotCommand(i, command);
|
||||
}
|
||||
|
||||
cliPrintf("Command %d written.\r\n", command);
|
||||
} else {
|
||||
uint8_t escInfoBuffer[ESC_INFO_V2_EXPECTED_FRAME_SIZE];
|
||||
if (command == DSHOT_CMD_ESC_INFO) {
|
||||
delay(10); // Wait for potential ESC telemetry transmission to finish
|
||||
writeDshotCommand(escIndex, command);
|
||||
}
|
||||
|
||||
startEscDataRead(escInfoBuffer, ESC_INFO_V2_EXPECTED_FRAME_SIZE);
|
||||
}
|
||||
|
||||
pwmWriteDshotCommand(escIndex, command);
|
||||
|
||||
if (command == DSHOT_CMD_ESC_INFO) {
|
||||
delay(10);
|
||||
|
||||
printEscInfo(escInfoBuffer, getNumberEscBytesRead());
|
||||
} else {
|
||||
cliPrintf("Command %d written.\r\n", command);
|
||||
}
|
||||
}
|
||||
cliPrintLinef("Command %d written.", command);
|
||||
|
||||
if (command <= 5) {
|
||||
delay(10); // wait for sound output to finish
|
||||
}
|
||||
} else {
|
||||
cliPrintf("Invalid command, range 1 to %d.\r\n", DSHOT_MIN_THROTTLE - 1);
|
||||
cliPrintLinef("Invalid command, range 1 to %d.", DSHOT_MIN_THROTTLE - 1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue