mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-17 12:02:59 +00:00
Antenna Calculator: fix out-of-range handling + add Comet W100RX (#3321)
* Antenna Calculator: handle out-of-range frequencies Fix an out-of-bounds read in update_result(): when the required quarter-wave length was shorter than the fully-collapsed antenna, the element interpolation indexed elements[-1]. Guard the frequency range and report 'retracted' (above the fundamental range; a wideband RX whip still receives here via harmonics) or 'fully ext.' (below range) instead of a garbage element count. * Add Comet W100RX to the sample WHIPCALC/ANTENNAS.TXT Comet W100RX telescopic RX whip, segment lengths (mm) from the Comet W100RX instruction sheet: 200/300/400/510/615/800/986.
This commit is contained in:
@@ -73,6 +73,26 @@ void WhipCalcView::update_result() {
|
||||
uint8_t ant_count = 9; // Shown antennas counter
|
||||
length *= 1000; // Get length in mm needed to extend the antenna
|
||||
for (antenna_entry antenna : antenna_db) { // go thru all antennas available
|
||||
if (antenna.elements.empty())
|
||||
continue;
|
||||
|
||||
// Needed quarter-wave length is shorter than the fully-collapsed antenna:
|
||||
// above its fundamental range. Report it as retracted (shortest setting);
|
||||
// a wideband RX whip still receives here via harmonics, but this
|
||||
// quarter-wave model cannot compute those positions. This also avoids an
|
||||
// out-of-bounds read of elements[-1] in the interpolation below.
|
||||
if (length < antenna.elements.front()) {
|
||||
console.write(antenna.label + ": retracted\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Needed length is longer than the fully-extended antenna: already maxed
|
||||
// out, so the frequency is below this antenna's range.
|
||||
if (length > antenna.elements.back()) {
|
||||
console.write(antenna.label + ": fully ext.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
uint16_t element, refined_quarter = 0;
|
||||
for (element = 0; element < antenna.elements.size(); element++) {
|
||||
if (length == antenna.elements[element]) // Exact element in length
|
||||
|
||||
Reference in New Issue
Block a user