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

Fix 1wire pass through for F3 + target config changes

This commit is contained in:
4712 2015-11-05 00:40:11 +01:00
parent 42523e4bcb
commit ce743d3acc
5 changed files with 47 additions and 34 deletions

View file

@ -1799,13 +1799,32 @@ static bool processInCommand(void)
headSerialReply(0);
tailSerialReply();
// wait for all data to send
while (!isSerialTransmitBufferEmpty(mspSerialPort)) {
delay(50);
}
waitForSerialPortToFinishTransmitting(currentPort->port);
// Start to activate here
// motor 1 => index 0
// search currentPort portIndex
/* next lines seems to be unnecessary, because the currentPort always point to the same mspPorts[portIndex]
uint8_t portIndex;
for (portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
if (currentPort == &mspPorts[portIndex]) {
break;
}
}
*/
mspReleasePortIfAllocated(mspSerialPort); // CloseSerialPort also marks currentPort as UNUSED_PORT
usb1WirePassthrough(i);
// MPS uart is active again
// Wait a bit more to let App read the 0 byte and switch baudrate
// 2ms will most likely do the job, but give some grace time
delay(10);
// rebuild/refill currentPort structure, does openSerialPort if marked UNUSED_PORT - used ports are skiped
mspAllocateSerialPorts(&masterConfig.serialConfig);
/* restore currentPort and mspSerialPort
setCurrentPort(&mspPorts[portIndex]); // not needed same index will be restored
*/
// former used MSP uart is active again
// restore MSP_SET_1WIRE as current command for correct headSerialReply(0)
currentPort->cmdMSP = MSP_SET_1WIRE;
} else {
// ESC channel higher than max. allowed
// rem: BLHeliSuite will not support more than 8
@ -1909,10 +1928,7 @@ void mspProcess(void)
}
if (isRebootScheduled) {
// pause a little while to allow response to be sent
while (!isSerialTransmitBufferEmpty(candidatePort->port)) {
delay(50);
}
waitForSerialPortToFinishTransmitting(candidatePort->port);
stopMotors();
handleOneshotFeatureChangeOnRestart();
systemReset();