Skip to content

Commit 7472d17

Browse files
committed
CLI: Report the number of lines in the list response, instead of bytes
1 parent 00413d3 commit 7472d17

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
char otaOutcome[21] = {0}; // Modified by otaUpdate(), used to respond to rtkRemoteFirmwareVersion commands
2-
int systemWriteLength = 0; // Modified by systemWrite(), used to calculate the size of LIST command for CLI
2+
int systemWriteCounts =
3+
0; // Modified by systemWrite(), used to calculate the number of items in the LIST command for CLI
34

45
void menuCommands()
56
{
@@ -268,22 +269,16 @@ t_cliResult processCommand(char *cmdBuffer)
268269
{
269270
// Respond with a list of variables, types, and current value
270271

271-
// First calculate the size of the LIST response
272+
// First calculate the lines in the LIST response
272273
PrintEndpoint originalPrintEndpoint = printEndpoint;
273274
printEndpoint = PRINT_ENDPOINT_COUNT;
274-
systemWriteLength = 0;
275+
systemWriteCounts = 0;
275276
printAvailableSettings();
276277
printEndpoint = originalPrintEndpoint;
277278

278-
// Use log10 to find the number of digits in systemWriteLength
279-
int systemWriteLengthDigits = floor(log10(systemWriteLength)) + 1;
280-
281-
// Adjust systemWriteLength to include the length of the list entry
282-
systemWriteLength = systemWriteLength + sizeof("$SPLST,list,int,*2A") + systemWriteLengthDigits;
283-
284-
// Print the list entry
285-
char settingValue[6]; // 12345
286-
snprintf(settingValue, sizeof(settingValue), "%d", systemWriteLength);
279+
// Print the list entry with the number of items in the list, including the list entry
280+
char settingValue[6]; // 12345
281+
snprintf(settingValue, sizeof(settingValue), "%d", systemWriteCounts + 1); // Add list command
287282
commandSendExecuteListResponse("list", "int", settingValue);
288283

289284
// Now actually print the list
@@ -679,8 +674,8 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
679674
settingValue = 0;
680675

681676
bool knownSetting = false;
682-
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command response.
683-
// Generally char arrays but some others.
677+
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command
678+
// response. Generally char arrays but some others.
684679

685680
// Loop through the valid command entries
686681
i = commandLookupSettingName(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix, sizeof(suffix));
@@ -807,8 +802,8 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
807802

808803
// Update the profile name in the file system if necessary
809804
if (strcmp(settingName, "profileName") == 0)
810-
setProfileName(profileNumber); // Copy the current settings.profileName into the array of profile names
811-
// at location profileNumber
805+
setProfileName(profileNumber); // Copy the current settings.profileName into the array of profile
806+
// names at location profileNumber
812807
settingIsString = true;
813808
}
814809
break;
@@ -1919,9 +1914,9 @@ void createSettingsString(char *newSettings)
19191914
break;
19201915
case tUmConst: {
19211916
// Record UM980 Constellations
1922-
// um980Constellations are uint8_t, but here we have to convert to bool (true / false) so the web page
1923-
// check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer will
1924-
// probably fail...)
1917+
// um980Constellations are uint8_t, but here we have to convert to bool (true / false) so the web
1918+
// page check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer
1919+
// will probably fail...)
19251920
for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++)
19261921
{
19271922
char tempString[50]; // um980Constellations.GLONASS=true
@@ -2086,9 +2081,9 @@ void createSettingsString(char *newSettings)
20862081
break;
20872082
case tLgConst: {
20882083
// Record LG290P Constellations
2089-
// lg290pConstellations are uint8_t, but here we have to convert to bool (true / false) so the web page
2090-
// check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer will
2091-
// probably fail...)
2084+
// lg290pConstellations are uint8_t, but here we have to convert to bool (true / false) so the web
2085+
// page check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer
2086+
// will probably fail...)
20922087
for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++)
20932088
{
20942089
char tempString[50]; // lg290pConstellations.GLONASS=true
@@ -2487,8 +2482,8 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
24872482
void *var;
24882483

24892484
bool knownSetting = false;
2490-
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command response.
2491-
// Generally char arrays but some others.
2485+
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command
2486+
// response. Generally char arrays but some others.
24922487

24932488
// Loop through the valid command entries - but skip the priority settings and use the GNSS-specific types
24942489
i = commandLookupSettingNameAfterPriority(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix,

Firmware/RTK_Everywhere/support.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void systemWrite(const uint8_t *buffer, uint16_t length)
6464
// We're just adding up the size of the list, don't pass along to serial port
6565
else if (printEndpoint == PRINT_ENDPOINT_COUNT)
6666
{
67-
systemWriteLength += length;
67+
systemWriteCounts++;
6868
}
6969
}
7070

0 commit comments

Comments
 (0)