Skip to content

Commit a5d7754

Browse files
committed
Add commandLookupSettingNameAfterPriority
Add findEndOfPrioritySettings() Revert the latest tCmnCnst changes - it was OK as it was ;-)
1 parent 8e68d3f commit a5d7754

File tree

1 file changed

+97
-68
lines changed

1 file changed

+97
-68
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 97 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,29 @@ void commandSplitName(const char *settingName, char *truncatedName, int truncate
494494
}
495495

496496
// Using the settingName string, return the index of the setting within command array
497+
int commandLookupSettingNameAfterPriority(bool inCommands, const char *settingName, char *truncatedName, int truncatedNameLen,
498+
char *suffix, int suffixLen)
499+
{
500+
return commandLookupSettingNameSelective(inCommands, settingName, truncatedName, truncatedNameLen, suffix, suffixLen, true);
501+
}
497502
int commandLookupSettingName(bool inCommands, const char *settingName, char *truncatedName, int truncatedNameLen,
498503
char *suffix, int suffixLen)
504+
{
505+
return commandLookupSettingNameSelective(inCommands, settingName, truncatedName, truncatedNameLen, suffix, suffixLen, false);
506+
}
507+
int commandLookupSettingNameSelective(bool inCommands, const char *settingName, char *truncatedName, int truncatedNameLen,
508+
char *suffix, int suffixLen, bool usePrioritySettingsEnd)
499509
{
500510
const char *command;
501511

502-
// Loop through the valid command entries
503-
for (int i = 0; i < commandCount; i++)
512+
int prioritySettingsEnd = 0;
513+
if (usePrioritySettingsEnd)
514+
// Find "endOfPrioritySettings"
515+
prioritySettingsEnd = findEndOfPrioritySettings();
516+
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
517+
518+
// Loop through the valid command entries - starting at prioritySettingsEnd
519+
for (int i = prioritySettingsEnd; i < commandCount; i++)
504520
{
505521
// Verify that this command does not get split
506522
if ((commandIndex[i] >= 0) && (!rtkSettingsEntries[commandIndex[i]].useSuffix) &&
@@ -520,9 +536,10 @@ int commandLookupSettingName(bool inCommands, const char *settingName, char *tru
520536
commandSplitName(settingName, truncatedName, truncatedNameLen, suffix, suffixLen);
521537

522538
// Loop through the settings entries
539+
// This could be speeded up by
523540
// E.g. by storing the previous value of i and starting there.
524541
// Most of the time, the match will be i+1.
525-
for (int i = 0; i < commandCount; i++)
542+
for (int i = prioritySettingsEnd; i < commandCount; i++)
526543
{
527544
// Verify that this command gets split
528545
if ((commandIndex[i] >= 0) && rtkSettingsEntries[commandIndex[i]].useSuffix)
@@ -2364,8 +2381,8 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
23642381
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command response.
23652382
// Generally char arrays but some others.
23662383

2367-
// Loop through the valid command entries
2368-
i = commandLookupSettingName(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix, sizeof(suffix));
2384+
// Loop through the valid command entries - but skip the priority settings and use the GNSS-specific types
2385+
i = commandLookupSettingNameAfterPriority(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix, sizeof(suffix));
23692386

23702387
// Determine if settingName is in the command table
23712388
if (i >= 0)
@@ -2489,23 +2506,18 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
24892506
}
24902507
break;
24912508

2492-
case tCmnCnst: {
2493-
2494-
#ifdef COMPILE_MOSAICX5
2495-
for (int x = 0; x < MAX_MOSAIC_CONSTELLATIONS; x++)
2496-
{
2497-
if ((suffix[0] == mosaicSignalConstellations[x].configName[0]) &&
2498-
(strcmp(suffix, mosaicSignalConstellations[x].configName) == 0))
2499-
{
2500-
writeToString(settingValueStr, settings.mosaicConstellations[x]);
2501-
knownSetting = true;
2502-
break;
2503-
}
2504-
}
2505-
#endif // COMPILE_MOSAICX5
2509+
case tCmnCnst:
2510+
break; // Nothing to do here. Let each GNSS add its settings
2511+
case tCmnRtNm:
2512+
break; // Nothing to do here. Let each GNSS add its settings
2513+
case tCnRtRtB:
2514+
break; // Nothing to do here. Let each GNSS add its settings
2515+
case tCnRtRtR:
2516+
break; // Nothing to do here. Let each GNSS add its settings
25062517

25072518
#ifdef COMPILE_ZED
2508-
for (int x = 0; x < MAX_UBX_CONSTELLATIONS; x++)
2519+
case tUbxConst: {
2520+
for (int x = 0; x < qualifier; x++)
25092521
{
25102522
if ((suffix[0] == settings.ubxConstellations[x].textName[0]) &&
25112523
(strcmp(suffix, settings.ubxConstellations[x].textName) == 0))
@@ -2515,42 +2527,8 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
25152527
break;
25162528
}
25172529
}
2518-
#endif // COMPILE_ZED
2519-
2520-
#ifdef COMPILE_UM980
2521-
for (int x = 0; x < MAX_UM980_CONSTELLATIONS; x++)
2522-
{
2523-
if ((suffix[0] == um980ConstellationCommands[x].textName[0]) &&
2524-
(strcmp(suffix, um980ConstellationCommands[x].textName) == 0))
2525-
{
2526-
writeToString(settingValueStr, settings.um980Constellations[x]);
2527-
knownSetting = true;
2528-
break;
2529-
}
2530-
}
2531-
#endif // COMPILE_UM980
2532-
2533-
#ifdef COMPILE_LG290P
2534-
for (int x = 0; x < qualifier; x++)
2535-
{
2536-
if ((suffix[0] == lg290pConstellationNames[x][0]) && (strcmp(suffix, lg290pConstellationNames[x]) == 0))
2537-
{
2538-
writeToString(settingValueStr, settings.lg290pConstellations[x]);
2539-
knownSetting = true;
2540-
break;
2541-
}
2542-
}
2543-
#endif // COMPILE_LG290P
25442530
}
2545-
break; // Nothing to do here. Let each GNSS add its settings
2546-
case tCmnRtNm:
2547-
break; // Nothing to do here. Let each GNSS add its settings
2548-
case tCnRtRtB:
2549-
break; // Nothing to do here. Let each GNSS add its settings
2550-
case tCnRtRtR:
2551-
break; // Nothing to do here. Let each GNSS add its settings
2552-
2553-
#ifdef COMPILE_ZED
2531+
break;
25542532
case tUbxMsgRt: {
25552533
for (int x = 0; x < qualifier; x++)
25562534
{
@@ -2719,6 +2697,19 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
27192697
}
27202698
}
27212699
break;
2700+
case tUmConst: {
2701+
for (int x = 0; x < qualifier; x++)
2702+
{
2703+
if ((suffix[0] == um980ConstellationCommands[x].textName[0]) &&
2704+
(strcmp(suffix, um980ConstellationCommands[x].textName) == 0))
2705+
{
2706+
writeToString(settingValueStr, settings.um980Constellations[x]);
2707+
knownSetting = true;
2708+
break;
2709+
}
2710+
}
2711+
}
2712+
break;
27222713
#endif // COMPILE_UM980
27232714

27242715
case tCorrSPri: {
@@ -2745,6 +2736,19 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
27452736
break;
27462737

27472738
#ifdef COMPILE_MOSAICX5
2739+
case tMosaicConst: {
2740+
for (int x = 0; x < qualifier; x++)
2741+
{
2742+
if ((suffix[0] == mosaicSignalConstellations[x].configName[0]) &&
2743+
(strcmp(suffix, mosaicSignalConstellations[x].configName) == 0))
2744+
{
2745+
writeToString(settingValueStr, settings.mosaicConstellations[x]);
2746+
knownSetting = true;
2747+
break;
2748+
}
2749+
}
2750+
}
2751+
break;
27482752
case tMosaicMSNmea: {
27492753
for (int x = 0; x < qualifier; x++)
27502754
{
@@ -2875,7 +2879,18 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
28752879
}
28762880
}
28772881
break;
2878-
2882+
case tLgConst: {
2883+
for (int x = 0; x < qualifier; x++)
2884+
{
2885+
if ((suffix[0] == lg290pConstellationNames[x][0]) && (strcmp(suffix, lg290pConstellationNames[x]) == 0))
2886+
{
2887+
writeToString(settingValueStr, settings.lg290pConstellations[x]);
2888+
knownSetting = true;
2889+
break;
2890+
}
2891+
}
2892+
}
2893+
break;
28792894
#endif // COMPILE_LG290P
28802895

28812896
case tGnssReceiver: {
@@ -3546,6 +3561,22 @@ bool settingPossibleOnPlatform(int i)
35463561
return true;
35473562
}
35483563

3564+
int findEndOfPrioritySettings()
3565+
{
3566+
// Find "endOfPrioritySettings"
3567+
int prioritySettingsEnd = 0;
3568+
for (int i = 0; i < numRtkSettingsEntries; i++)
3569+
{
3570+
if (strcmp(rtkSettingsEntries[i].name, "endOfPrioritySettings") == 0)
3571+
{
3572+
prioritySettingsEnd = i;
3573+
break;
3574+
}
3575+
}
3576+
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
3577+
return prioritySettingsEnd;
3578+
}
3579+
35493580
// Allocate and fill the commandIndex table
35503581
bool commandIndexFillPossible()
35513582
{
@@ -3619,21 +3650,19 @@ bool commandIndexFill(bool usePossibleSettings)
36193650
commandIndex[commandCount++] = -i;
36203651

36213652
// Find "endOfPrioritySettings"
3622-
int prioritySettingsEnd = 0;
3623-
for (i = 0; i < numRtkSettingsEntries; i++)
3624-
{
3625-
if (strcmp(rtkSettingsEntries[i].name, "endOfPrioritySettings") == 0)
3626-
{
3627-
prioritySettingsEnd = i;
3628-
if (settings.debugSettings)
3629-
systemPrintf("endOfPrioritySettings found at entry %d\r\n", prioritySettingsEnd);
3630-
break;
3631-
}
3632-
}
3653+
int prioritySettingsEnd = findEndOfPrioritySettings();
36333654
// If "endOfPrioritySettings" is not found, prioritySettingsEnd will be zero
36343655
// and all settings will be sorted. Just like the good old days...
36353656

3636-
// Sort the commands - starting at
3657+
if (settings.debugSettings)
3658+
{
3659+
if (prioritySettingsEnd > 0)
3660+
systemPrintf("endOfPrioritySettings found at entry %d\r\n", prioritySettingsEnd);
3661+
else
3662+
systemPrintln("endOfPrioritySettings not found!");
3663+
}
3664+
3665+
// Sort the commands - starting at prioritySettingsEnd
36373666
for (i = prioritySettingsEnd; i < commandCount - 1; i++)
36383667
{
36393668
iCommandName = commandGetName(0, commandIndex[i]);

0 commit comments

Comments
 (0)