]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/src/rpp/sdr.c
Corrected SDR non-echoed command processor and other minor changes of style.
[pes-rpp/rpp-lib.git] / rpp / src / rpp / sdr.c
index 7b170e2ad60129ad7978281642a08182b63f8b63..e630dbb145473780142d70c62e5583d8f730a20c 100644 (file)
 
 #if rppCONFIG_DRV == 1
 #include "drv/drv.h"
-#elif defined(FREERTOS_POSIX)
-#include <stdlib.h> // malloc()
+#endif
+
+#ifndef FREERTOS_POSIX
+#define echo(x) rpp_sci_putc(x)
+#else
+#define echo(x) (void)(x)
 #endif
 
 static const char* prompt  = "--> ";
@@ -148,7 +152,7 @@ void rpp_sdr_cmdproc(void *p)
             (rpp_sdr_available() / 1024)
         );
     rpp_sci_printf((const char*)
-            "========================================\r\n"
+            "===========================================================\r\n"
         );
     rpp_sci_printf((const char*)"%s", prompt);
 
@@ -178,11 +182,16 @@ void rpp_sdr_cmdproc(void *p)
         if(input == 8 || input == 127) {
             if(buff_index > 0) {
                 buff_index--;
+                echo('\b');
+                echo(' ' );
+                echo('\b');
             }
 
         // Line feed or Carriage return
         } else if(input == 10 || input == 13) {
             flush = TRUE;
+            echo('\r');
+            echo('\n');
 
         // If is any printable character
         } else if(isprint(input)) {
@@ -190,6 +199,7 @@ void rpp_sdr_cmdproc(void *p)
             // Store character and increment buffer index
             in_buffer[buff_index] = input;
             buff_index++;
+            echo(input);
 
             // Check if buffer is full and force flush
             if(buff_index == BUF_SIZE - 1) {
@@ -212,12 +222,21 @@ void rpp_sdr_cmdproc(void *p)
 
             // Help command
             } else if(strncmp(in_buffer, "help", BUF_SIZE) == 0) {
+
+                rpp_sci_printf((const char*)
+                        "Available commands:\r\n"
+                    );
+                rpp_sci_printf((const char*)
+                        "\tlog       - Show the log.\r\n"
+                    );
+                rpp_sci_printf((const char*)
+                        "\tclear     - Clear the log.\r\n"
+                    );
+                rpp_sci_printf((const char*)
+                        "\tavailable - Display amount of memory left.\r\n"
+                    );
                 rpp_sci_printf((const char*)
-                        "Available commands: \r\n"
-                            "\tlog\r\n"
-                            "\tclear\r\n"
-                            "\tavailable\r\n"
-                            "\texit\r\n"
+                        "\texit      - Exit this command processor.\r\n"
                     );
 
                 rpp_sci_printf((const char*)"%s", newline);
@@ -349,13 +368,15 @@ int8_t rpp_sdr_setup(boolean_t enable)
 
     // Startup is requested
     } else {
-        if(xTaskCreate(rpp_sdr_showtask, (const signed char*)"rpp_sdr_showtask",
+        if(xTaskCreate(rpp_sdr_showtask,
+                    (const signed char*)"rpp_sdr_showtask",
                     256, NULL, 2, &show_handle) != pdPASS) {
             return FAILURE;
         }
         tasks_running++;
 
-        if(xTaskCreate(rpp_sdr_cmdproc , (const signed char*)"rpp_sdr_cmdproc" ,
+        if(xTaskCreate(rpp_sdr_cmdproc ,
+                    (const signed char*)"rpp_sdr_cmdproc" ,
                     512, NULL, 2, &cmdproc_handle) != pdPASS) {
             wait_tasks_to_finish();
             return FAILURE;