mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +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);
|
serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);
|
||||||
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
|
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
|
||||||
if (!baud) {
|
if (!baud) {
|
||||||
cliPrint("closed, specify baud.\r\n");
|
cliPrintLine("closed, specify baud.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mode)
|
if (!mode)
|
||||||
|
@ -893,7 +893,7 @@ static void cliSerialPassthrough(char *cmdline)
|
||||||
baud, mode,
|
baud, mode,
|
||||||
SERIAL_NOT_INVERTED);
|
SERIAL_NOT_INVERTED);
|
||||||
if (!passThroughPort) {
|
if (!passThroughPort) {
|
||||||
cliPrint("could not be opened.\r\n");
|
cliPrintLine("could not be opened.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cliPrintf("opened, baud = %d.\r\n", baud);
|
cliPrintf("opened, baud = %d.\r\n", baud);
|
||||||
|
@ -901,7 +901,7 @@ static void cliSerialPassthrough(char *cmdline)
|
||||||
passThroughPort = passThroughPortUsage->serialPort;
|
passThroughPort = passThroughPortUsage->serialPort;
|
||||||
// If the user supplied a mode, override the port's mode, otherwise
|
// If the user supplied a mode, override the port's mode, otherwise
|
||||||
// leave the mode unchanged. serialPassthrough() handles one-way ports.
|
// leave the mode unchanged. serialPassthrough() handles one-way ports.
|
||||||
cliPrint("already open.\r\n");
|
cliPrintLine("already open.");
|
||||||
if (mode && passThroughPort->mode != mode) {
|
if (mode && passThroughPort->mode != mode) {
|
||||||
cliPrintf("mode changed from %d to %d.\r\n",
|
cliPrintf("mode changed from %d to %d.\r\n",
|
||||||
passThroughPort->mode, mode);
|
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);
|
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");
|
cliPrintLinef("3D: %s", escInfoBytes[17] ? "on" : "off");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cliPrint("Checksum error.");
|
cliPrintLine("Checksum error.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!escInfoReceived) {
|
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 (command >= 0 && command < DSHOT_MIN_THROTTLE) {
|
||||||
if (escIndex == ALL_MOTORS) {
|
if (escIndex == ALL_MOTORS) {
|
||||||
for (unsigned i = 0; i < getMotorCount(); i++) {
|
for (unsigned i = 0; i < getMotorCount(); i++) {
|
||||||
pwmWriteDshotCommand(i, command);
|
writeDshotCommand(i, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
cliPrintf("Command %d written.\r\n", command);
|
|
||||||
} else {
|
} else {
|
||||||
uint8_t escInfoBuffer[ESC_INFO_V2_EXPECTED_FRAME_SIZE];
|
writeDshotCommand(escIndex, command);
|
||||||
if (command == DSHOT_CMD_ESC_INFO) {
|
}
|
||||||
delay(10); // Wait for potential ESC telemetry transmission to finish
|
|
||||||
|
|
||||||
startEscDataRead(escInfoBuffer, ESC_INFO_V2_EXPECTED_FRAME_SIZE);
|
cliPrintLinef("Command %d written.", command);
|
||||||
}
|
|
||||||
|
|
||||||
pwmWriteDshotCommand(escIndex, command);
|
|
||||||
|
|
||||||
if (command == DSHOT_CMD_ESC_INFO) {
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
printEscInfo(escInfoBuffer, getNumberEscBytesRead());
|
|
||||||
} else {
|
|
||||||
cliPrintf("Command %d written.\r\n", command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command <= 5) {
|
if (command <= 5) {
|
||||||
delay(10); // wait for sound output to finish
|
delay(10); // wait for sound output to finish
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue