Skip to content

Commit bf76853

Browse files
authored
Merge pull request #1888 from db4ple/active-devel
Fix for #1887 (machine crashes with 2.11.93)
2 parents 1c96d5e + d3f4969 commit bf76853

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

mchf-eclipse/drivers/ui/radio_management.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ typedef struct
201201

202202
extern const BandInfoSet bandInfos[];
203203
extern const int BAND_INFO_SET_NUM;
204+
#define BAND_INFO_SET_DEFAULT 0 // first entry is default, this is a "catch all region"
204205
extern uint8_t bandinfo_idx;
205206

206207
typedef const BandInfo BandInfo_c;

mchf-eclipse/drivers/ui/ui_configuration.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const ConfigEntryDescriptor ConfigEntryInfo[] =
275275
{ ConfigEntry_UInt8, EEPROM_VSWR_PROTECTION_THRESHOLD,&ts.vswr_protection_threshold,1,1,10},
276276
{ ConfigEntry_UInt16, EEPROM_EXPFLAGS1,&ts.expflags1,EXPFLAGS1_CONFIG_DEFAULT,0,0xffff},
277277
{ ConfigEntry_UInt16, EEPROM_CW_DECODER_FLAGS,&cw_decoder_config.flags,CW_DECODER_FLAGS_DEFAULT,0,0x7fff},
278-
{ ConfigEntry_UInt8, EEPROM_BAND_REGION,&bandinfo_idx,0,0,0x7f},
278+
{ ConfigEntry_UInt8, EEPROM_BAND_REGION, &bandinfo_idx, BAND_INFO_SET_DEFAULT, 0, 0x7f}, // we need to validate the range later as we cannot do it here due to C shortcomings
279279

280280
// the entry below MUST be the last entry, and only at the last position Stop is allowed
281281
{
@@ -888,6 +888,12 @@ void UiConfiguration_LoadEepromValues(bool load_freq_mode_defaults, bool load_ee
888888
load_eeprom_defaults);
889889

890890
// restore the bandInfo for a given band info set and band memory index
891+
if (bandinfo_idx >= BAND_INFO_SET_NUM)
892+
{
893+
// if the stored band index is not available, we need to handle this
894+
// we cannot do this during reading as C does not allow us to use a const int as initializer constant
895+
bandinfo_idx = BAND_INFO_SET_DEFAULT; // reset to default
896+
}
891897
bandInfo = bandInfos[bandinfo_idx].bands;
892898
ts.band = RadioManagement_GetBandInfo(band_mem_idx);
893899

0 commit comments

Comments
 (0)