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

Increase Tramp retry count and fix lockup if VTX out-of-sync with band/channel settings

Some VTX don't respond to every request so it's necessary to retransmit. A previous PR fixed a bug that caused more retries than expected and made the actual retries only be 2 as configured. Unfortunately this exposed the problem with the non-responding VTX with cases of it not responding to both retries. The problem was accidentally masked by a previous bug with the retry counter causing many retries to actually occur.

This then exposed a secondary problem in `vtx_common` that lead to a "lockup" condition if the actual VTX channel didn't match our expectation of what the channel should be based on the settings. We were getting into this state because of the (now working) retry limit and cases where the VTX didn't respond and change channels as expected.

Increased the retry count to 20.

Fixed the logic that would prevent subsequent channel changes if the actual VTX channel didn't match the expected value based on the settings. Also fixed a problem where the channel change would not work if the VTX was on a frequency that was not defined in `vtxtable`.
This commit is contained in:
Bruce Luckcuck 2019-09-17 17:14:11 -04:00
parent e53ba96558
commit 7e04a9666c
3 changed files with 12 additions and 17 deletions

View file

@ -119,16 +119,11 @@ bool vtxCommonGetBandAndChannel(const vtxDevice_t *vtxDevice, uint8_t *pBand, ui
&& !vtxTableIsFactoryBand[selectedBand - 1]) {
uint16_t freq;
result = vtxCommonGetFrequency(vtxDevice, &freq);
if (!result || freq != vtxCommonLookupFrequency(vtxDevice, selectedBand, selectedChannel)) {
return false;
} else {
*pBand = selectedBand;
*pChannel = selectedChannel;
return true;
if (result) {
vtxCommonLookupBandChan(vtxDevice, freq, pBand, pChannel);
}
} else {
return result;
}
return result;
}
bool vtxCommonGetPowerIndex(const vtxDevice_t *vtxDevice, uint8_t *pIndex)
@ -174,8 +169,11 @@ const char *vtxCommonLookupChannelName(const vtxDevice_t *vtxDevice, int channel
}
//Converts frequency (in MHz) to band and channel values.
bool vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_t *pBand, uint8_t *pChannel)
//If frequency not found in the vtxtable then band and channel will return 0
void vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_t *pBand, uint8_t *pChannel)
{
*pBand = 0;
*pChannel = 0;
if (vtxDevice) {
// Use reverse lookup order so that 5880Mhz
// get Raceband 7 instead of Fatshark 8.
@ -184,16 +182,11 @@ bool vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_
if (vtxTableFrequency[band][channel] == freq) {
*pBand = band + 1;
*pChannel = channel + 1;
return true;
return;
}
}
}
}
*pBand = 0;
*pChannel = 0;
return false;
}
//Converts band and channel values to a frequency (in MHz) value.