- rpp_sci_printf(
- (const char*)"Log control: %dkB available.\r\n",
- (rpp_sdr_available() / 1024)
- );
- rpp_sci_printf(
- (const char*)"========================================\r\n"
- );
- rpp_sci_printf((const char*)"%s", prompt);
-
- uint8_t input = 0;
- uint8_t buff_index = 0;
- boolean_t flush = FALSE;
- while(TRUE) {
-
- // Get one character from the user
- if(rpp_sci_read_nb(1, &input) != SUCCESS) {
- vTaskDelay(100 / portTICK_RATE_MS);
- continue;
- }
-
- // Stop flushing if one character is received
- if(show_flushing) {
- rpp_sdr_show(FALSE);
- vTaskDelay(100 / portTICK_RATE_MS);
- rpp_sci_printf("%s", newline);
- rpp_sci_printf("%s", prompt);
- continue;
- }
-
- // Backspace and Delete
- if(input == 8 || input == 127) {
- if(buff_index > 0) {
- buff_index--;
- }
-
- // Line feed or Carriage return
- } else if(input == 10 || input == 13) {
- flush = TRUE;
-
- // If is any printable character
- } else if(isprint(input)) {
-
- // Store character and increment buffer index
- in_buffer[buff_index] = input;
- buff_index++;
-
- // Check if buffer is full and force flush
- if(buff_index == BUF_SIZE - 1) {
- flush = TRUE;
- }
- }
- // All other character are ignored
-
- // Flush buffer
- if(flush) {
-
- // Terminate string
- in_buffer[buff_index] = '\0';
-
-
- // Re-prompt
- if(buff_index == 0) {
- rpp_sci_printf("%s", newline);
- rpp_sci_printf("%s", prompt);
-
- // Help command
- } else if(strncmp(in_buffer, "help", BUF_SIZE) == 0) {
- rpp_sci_printf((const char*)
- "Available commands: \r\n"
- " log\r\n"
- " clear\r\n"
- " available\r\n"
- );
-
- // Log command
- } else if(strncmp(in_buffer, "log", BUF_SIZE) == 0) {
- rpp_sdr_show(TRUE);
-
- // Clear command
- } else if(strncmp(in_buffer, "clear", BUF_SIZE) == 0) {
- rpp_sdr_clear();
- rpp_sci_printf((const char*)"Done.\r\n");
- rpp_sci_printf("%s", prompt);
-
- // Available command
- } else if(strncmp(in_buffer, "available", BUF_SIZE) == 0) {
- rpp_sci_printf(
- (const char*)"%d kB of %d kB available.\r\n",
- rpp_sdr_available() / 1024,
- memory_size / 1024
- );
-
- // Unknown command, print buffer back
- } else {
- rpp_sci_printf(
- (const char*)"ERROR: Unknown command \"%s\"\r\n",
- (char*)&in_buffer);
- rpp_sci_printf("%s", prompt);
- }
-
- // Reset variables
- rpp_sci_flush(TRUE);
- buff_index = 0;
- flush = FALSE;
- }
- }
+ rpp_sci_printf((const char *)
+ "Log control: %dkB available.\r\n",
+ (rpp_sdr_available() / 1024)
+ );
+ rpp_sci_printf((const char *)
+ "===========================================================\r\n"
+ );
+ rpp_sci_printf((const char *)"%s", prompt);
+
+ uint8_t input = 0;
+ uint8_t buff_index = 0;
+ boolean_t flush = FALSE;
+ while (!stop_tasks) {
+
+ // Get one character from the user
+ if (rpp_sci_read_nb(1, &input) != SUCCESS) {
+ if (!stop_tasks)
+ vTaskDelay(50 / portTICK_RATE_MS);
+ continue;
+ }
+
+ // Stop flushing if one character is received
+ if (show_flushing) {
+ rpp_sdr_show(FALSE);
+ vTaskDelay(100 / portTICK_RATE_MS);
+ rpp_sci_printf("%s", newline);
+ rpp_sci_printf("%s", prompt);
+ continue;
+ }
+
+ // Backspace and Delete
+ 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)) {
+
+ // 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)
+ flush = TRUE;
+ }
+ // All other character are ignored
+
+ // Flush buffer
+ if (flush) {
+
+ // Terminate string
+ in_buffer[buff_index] = '\0';
+
+
+ // Re-prompt
+ if (buff_index == 0) {
+ rpp_sci_printf((const char *)"%s", newline);
+ rpp_sci_printf((const char *)"%s", prompt);
+
+ }
+ // 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 *)
+ "\texit - Exit this command processor.\r\n"
+ );
+
+ rpp_sci_printf((const char *)"%s", newline);
+ rpp_sci_printf((const char *)"%s", prompt);
+ }
+ // Log command
+ else if (strncmp(in_buffer, "log", BUF_SIZE) == 0)
+ rpp_sdr_show(TRUE);
+
+ // Clear command
+ else if (strncmp(in_buffer, "clear", BUF_SIZE) == 0) {
+ rpp_sdr_clear();
+ rpp_sci_printf((const char *)"Done.\r\n");
+ rpp_sci_printf((const char *)"%s", newline);
+ rpp_sci_printf((const char *)"%s", prompt);
+
+ }
+ // Available command
+ else if (strncmp(in_buffer, "available", BUF_SIZE) == 0) {
+ rpp_sci_printf(
+ (const char *)"%d kB of %d kB available.\r\n",
+ rpp_sdr_available() / 1024,
+ memory_size / 1024
+ );
+ rpp_sci_printf((const char *)"%s", newline);
+ rpp_sci_printf((const char *)"%s", prompt);
+
+ }
+ // Exit command
+ else if (strncmp(in_buffer, "exit", BUF_SIZE) == 0) {
+ xSemaphoreGive(rpp_sdr_cmdproc_semaphore);
+ tasks_running--;
+ vTaskDelete(NULL);
+
+ }
+ // Unknown command, print buffer back
+ else {
+ rpp_sci_printf(
+ (const char *)"ERROR: Unknown command \"%s\"\r\n",
+ (char *)&in_buffer);
+ rpp_sci_printf((const char *)"%s", prompt);
+ }
+
+ // Reset variables
+ rpp_sci_flush(TRUE);
+ buff_index = 0;
+ flush = FALSE;
+ }
+ }
+
+ // Delete myself
+ tasks_running--;
+ vTaskDelete(NULL);