diff --git a/Source/ElektronischeLast.cpp b/Source/ElektronischeLast.cpp index cf5eab5..844d742 100644 --- a/Source/ElektronischeLast.cpp +++ b/Source/ElektronischeLast.cpp @@ -8,6 +8,7 @@ #include <cstdint> #include <cstdio> #include <cstdlib> +#include <cstring> #include <cinttypes> #include <cmath> #include <stm32g0xx.h> @@ -167,20 +168,29 @@ uint16_t set_solltrom(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16 uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount) { static uint32_t last_call = 0U; - uint16_t recall = 0U; + bool recall = false; int32_t recall_time = 999; bool newline = false; if(u16ArgCount >= 1U) { - recall = (acCommands[0][0] == '-' && acCommands[0][1] == 'r' && acCommands[0][2] == '\0'); - } - if(u16ArgCount >= 2U) - { - recall_time = strtol(acCommands[1], NULL, 10); - newline = true; + for(uint32_t a = 0UL; a < u16ArgCount; a++) + { + if(strcmp(acCommands[a], "-r") == 0) + { + recall = 1U; + } + else if(strcmp(acCommands[a], "-p") == 0) + { + newline = true; + } + else if(strcmp(acCommands[a], "-t") == 0) + { + recall_time = strtol(acCommands[a + 1U], NULL, 10); + } + } } - if(((recall == 1U) && ((int32_t)(systick - last_call) > recall_time)) || recall == 0U) + if((recall && ((int32_t)(systick - last_call) > recall_time)) || !recall) { char buffer[64]; if(newline)