mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
CF/BF - Reduce flash usage of cliSerialPassthrough.
Minimize string duplication, be less verbose, use shorter words, avoid duplicate id parameter code.
This commit is contained in:
parent
53edcba0d8
commit
297f362257
1 changed files with 7 additions and 7 deletions
|
@ -1908,11 +1908,12 @@ static void cliSerialPassthrough(char *cmdline)
|
||||||
tok = strtok_r(NULL, " ", &saveptr);
|
tok = strtok_r(NULL, " ", &saveptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Port %d ", id);
|
||||||
serialPort_t *passThroughPort;
|
serialPort_t *passThroughPort;
|
||||||
serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);
|
serialPortUsage_t *passThroughPortUsage = findSerialPortUsageByIdentifier(id);
|
||||||
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
|
if (!passThroughPortUsage || passThroughPortUsage->serialPort == NULL) {
|
||||||
if (!baud) {
|
if (!baud) {
|
||||||
printf("Port %d is closed, must specify baud.\r\n", id);
|
printf("closed, specify baud.\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mode)
|
if (!mode)
|
||||||
|
@ -1922,29 +1923,28 @@ static void cliSerialPassthrough(char *cmdline)
|
||||||
baud, mode,
|
baud, mode,
|
||||||
SERIAL_NOT_INVERTED);
|
SERIAL_NOT_INVERTED);
|
||||||
if (!passThroughPort) {
|
if (!passThroughPort) {
|
||||||
printf("Port %d could not be opened.\r\n", id);
|
printf("could not be opened.\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Port %d opened, baud = %d.\r\n", id, baud);
|
printf("opened, baud = %d.\r\n", baud);
|
||||||
} else {
|
} else {
|
||||||
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.
|
||||||
printf("Port %d already open.\r\n", id);
|
printf("already open.\r\n");
|
||||||
if (mode && passThroughPort->mode != mode) {
|
if (mode && passThroughPort->mode != mode) {
|
||||||
printf("Adjusting mode from %d to %d.\r\n",
|
printf("mode changed from %d to %d.\r\n",
|
||||||
passThroughPort->mode, mode);
|
passThroughPort->mode, mode);
|
||||||
serialSetMode(passThroughPort, mode);
|
serialSetMode(passThroughPort, mode);
|
||||||
}
|
}
|
||||||
// If this port has a rx callback associated we need to remove it now.
|
// If this port has a rx callback associated we need to remove it now.
|
||||||
// Otherwise no data will be pushed in the serial port buffer!
|
// Otherwise no data will be pushed in the serial port buffer!
|
||||||
if (passThroughPort->rxCallback) {
|
if (passThroughPort->rxCallback) {
|
||||||
printf("Removing rxCallback\r\n");
|
|
||||||
passThroughPort->rxCallback = 0;
|
passThroughPort->rxCallback = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Forwarding data to %d, power cycle to exit.\r\n", id);
|
printf("forwarding, power cycle to exit.\r\n");
|
||||||
|
|
||||||
serialPassthrough(cliPort, passThroughPort, NULL, NULL);
|
serialPassthrough(cliPort, passThroughPort, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue