]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Rework test-suite to be able to build for different platforms
authorMichal Horn <hornmich@fel.cvut.cz>
Fri, 17 Apr 2015 10:04:12 +0000 (12:04 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Fri, 17 Apr 2015 10:04:12 +0000 (12:04 +0200)
apps/rpp-test-suite/Debug/GNUmakefile
apps/rpp-test-suite/Makefile.var
apps/rpp-test-suite/POSIX/GNUmakefile
apps/rpp-test-suite/include/test.h
apps/rpp-test-suite/src/_linux/main.c [new file with mode: 0644]
apps/rpp-test-suite/src/_rm48_hdk/main.c [moved from apps/rpp-test-suite/src/main.c with 99% similarity]
apps/rpp-test-suite/src/ain.c
apps/rpp-test-suite/src/eth.c [new file with mode: 0644]
apps/rpp-test-suite/src/fr.c [new file with mode: 0644]
apps/rpp-test-suite/src/lin.c [new file with mode: 0644]

index 5e39928100ef09d647f4c2a8be76a1e296a95469..18ab0f7d14bae104776ef4fb3dcfce149619d246 100644 (file)
@@ -1,6 +1,5 @@
-include ../Makefile.var
-include ../../../Makefile.config
 include ../../../Makefile.var
+include ../Makefile.var
 
 # Code composer studio sets this variable when it invokes make. Let's use it
 # as a hint for where is the compiler installed.
index e2b01882fd206bb41108cba84a5c466af11be5fa..0d9b96995a85eb8a167c449cc32b055c2202516a 100644 (file)
@@ -1,5 +1,14 @@
-rpp-test-suite_SOURCES := \
-    src/ain.c             \
-    src/can.c             \
-    src/sci.c             \
-    src/main.c
+rpp-test-suite_SOURCES = \
+    $(rpp-test-suite_SOURCES_$(rpp_lib_OS)_$(TARGET))  \
+    src/sci.c                  \
+    src/_$(TARGET)/main.c
+
+rpp-test-suite_SOURCES_6.0.4_posix_linux =     \
+    src/can.c                  \
+    src/eth.c                  \
+    src/fr.c                   \
+    src/lin.c                  
+
+rpp-test-suite_SOURCES_7.0.2_rm48_hdk =        \
+    src/ain.c                  \
+    src/can.c                  \
index 577055ce4234cd4b57073945f847dd634f906dc7..85c14edc894fe3616a66851116284ea0f1ae96b3 100644 (file)
@@ -1,4 +1,5 @@
 rpp_lib_OS = 6.0.4_posix
+TARGET=linux
 
 include ../Makefile.var
 include ../../../Makefile.var
index ed14f54782c09e8a1605e72e2d9124aa4b955807..3a47022b5f4f09a86a3aef73e03c78439bfcce3a 100644 (file)
@@ -21,8 +21,19 @@ void busy_infinite_loop();
 
 
 void test_adc();
+void test_dac();
 void test_can();
+void test_din();
+void test_eth();
+void test_fr();
+void test_hbr();
+void test_hout();
+void test_lin();
+void test_lout();
+void test_mout();
 void test_sci();
+void test_sdc();
+void test_sdr();
 
 
 // SCI compatibility layer for POSIX
diff --git a/apps/rpp-test-suite/src/_linux/main.c b/apps/rpp-test-suite/src/_linux/main.c
new file mode 100644 (file)
index 0000000..e74afd5
--- /dev/null
@@ -0,0 +1,230 @@
+/* Copyright (C) 2013, 2014 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : main.c
+ * Abstract:
+ *     RPP test suite command processor.
+ *
+ * References:
+ *     test.h
+ */
+
+
+#include <ctype.h>  // isprint()
+#include <string.h> // strncmp()
+
+#include "rpp/rpp.h"
+#include "test.h"
+
+
+/// Command processor task -----------------------------------------------------
+#define INPUT_IDLE 50
+#define BUF_SIZE   80
+static char in_buffer[BUF_SIZE];
+static const char *prompt  = "--> ";
+static const char *newline = "\r\n";
+
+
+/**
+ * Compare user string and execute command.
+ */
+void execute_cmd(char *string)
+{
+       if (strncmp(string, "can", BUF_SIZE) == 0)
+               test_can();
+       else if (strncmp(string, "eth", BUF_SIZE) == 0)
+               test_eth();
+       else if (strncmp(string, "fr", BUF_SIZE) == 0)
+               test_fr();
+       else if (strncmp(string, "lin", BUF_SIZE) == 0)
+               test_lin();
+       else if (strncmp(string, "sci", BUF_SIZE) == 0)
+               test_sci();
+       else if (strncmp(string, "help", BUF_SIZE) == 0) {
+               rpp_sci_printf((const char *)"Available commands:\r\n");
+               rpp_sci_printf((const char *)"\thelp - Display this help.\r\n");
+               rpp_sci_printf((const char *)"\tcan  - Test CAN communication.\r\n");
+               rpp_sci_printf((const char *)"\teth  - Test Ethernet communication.\r\n");
+               rpp_sci_printf((const char *)"\tfr   - Test FlexRay communication.\r\n");
+               rpp_sci_printf((const char *)"\tlin  - Test LIN communication.\r\n");
+               rpp_sci_printf((const char *)"\tsci  - Test Serial Communication Interface.\r\n");
+       }
+       else
+               // Unknown command, print buffer back
+               rpp_sci_printf((const char *)
+                                          "ERROR: Unknown command \"%s\"\r\n", string
+                                          );
+}
+
+
+/**
+ * Test suite command processor.
+ */
+void test_cmdproc(void *par)
+{
+       // Print header
+       rpp_sci_printf((const char *)
+                                  "RPP Library Test Suite.\r\n"
+                                  );
+       rpp_sci_printf((const char *)
+                                  "===========================================================\r\n"
+                                  );
+       rpp_sci_printf((const char *)
+                                  "[Type a module to test or 'help']\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(INPUT_IDLE / portTICK_RATE_MS);
+                       continue;
+               }
+
+               // Backspace and Delete
+               if (input == 8 || input == 127) {
+                       if (buff_index > 0) {
+                               buff_index--;
+                               echo('\b');
+                               echo(' ' );
+                               echo('\b');
+                       }
+                       continue;
+               }
+               else if (input == 10 || input == 13) {
+                       // Line feed or Carriage return
+                       flush = TRUE;
+                       echo('\r');
+                       echo('\n');
+               }
+               else if (isprint(input)) {
+                       // If is any printable character
+
+                       // 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';
+
+                       // Execute command
+                       if (buff_index != 0)
+                               execute_cmd((char *)&in_buffer);
+                       rpp_sci_printf((const char *)"%s", newline);
+                       rpp_sci_printf((const char *)"%s", prompt);
+
+                       // Reset variables
+                       rpp_sci_flush(TRUE);
+                       buff_index = 0;
+                       flush = FALSE;
+               }
+       }
+}
+
+
+
+/// Utilities ------------------------------------------------------------------
+/**
+ * Wait for user input "q" to quit the loop.
+ */
+void wait_for_quit()
+{
+       while (rpp_sci_getc() < 0)
+               vTaskDelay(INPUT_IDLE / portTICK_RATE_MS);
+}
+
+
+/**
+ * Infinite busy loop.
+ *
+ * This function is called after an error has being detected to "stop"
+ * processing.
+ */
+void busy_infinite_loop()
+{
+       while (TRUE)
+               asm (" nop");
+}
+
+
+
+/// Main functions -------------------------------------------------------------
+/**
+ * Application main function
+ *
+ * This function is called after startup.
+ */
+int main(void)
+{
+       // Spawn tasks
+       portBASE_TYPE task_created =
+               xTaskCreate(test_cmdproc,
+                                       (const signed char *)"test_cmdproc",
+                                       1024, NULL, TEST_TASK_PRIORITY, NULL
+                                       );
+
+       if (task_created != pdPASS) {
+               rpp_sci_printf((const char *)
+                                          "ERROR: Problem allocating memory for command processor to "
+                                          "start. Error code: %d\r\n", (uint32_t)task_created
+                                          );
+               busy_infinite_loop();
+       }
+
+       // Start Scheduler
+       vTaskStartScheduler();
+
+       // Catch memory problems
+       rpp_sci_printf((const char *)
+                                  "ERROR: Problem allocating memory for scheduler to start.\r\n"
+                                  );
+       busy_infinite_loop();
+
+       return 0;
+}
+
+
+/**
+ * FreeRTOS malloc() failed hook.
+ */
+void vApplicationMallocFailedHook(void)
+{
+       rpp_sci_printf((const char *)
+                                  "ERROR: Manual memory allocation failed.\r\n"
+                                  );
+}
+
+
+/**
+ * FreeRTOS stack overflow hook.
+ */
+void vApplicationStackOverflowHook(xTaskHandle xTask,
+                                                                  signed portCHAR *pcTaskName)
+{
+       rpp_sci_printf((const char *)
+                                  "ERROR: Stack overflow : \"%s\".\r\n", pcTaskName
+                                  );
+}
similarity index 99%
rename from apps/rpp-test-suite/src/main.c
rename to apps/rpp-test-suite/src/_rm48_hdk/main.c
index 534fba335a6803e3d458588b32b0a88a386c5584..d035aaeeab73f285416b7a13c3a9718a9ca5cbff 100644 (file)
@@ -173,13 +173,11 @@ void busy_infinite_loop()
  */
 int main(void)
 {
-       #ifndef FREERTOS_POSIX
        // Initialize library
        rpp_init();
 
        // Speed up the SCI
        rpp_sci_setup(115200);
-       #endif
        // Spawn tasks
        portBASE_TYPE task_created =
                xTaskCreate(test_cmdproc,
index b909472e4ce72c4960cb7ed64884982fbd54b26f..f955c87c04cda428358a7be19a24e392e70cb95e 100644 (file)
 #define FREQ_MILLIS      100
 
 
-#ifndef FREERTOS_POSIX
 // Task control
 static boolean_t stop_tasks = FALSE;
 static uint8_t tasks_running = 0;
-#endif
 
 /**
  * FreeRTOS Task that read analog inputs and prints them on the SCI.
  */
 void adc_test_task(void *par)
 {
-       #ifndef FREERTOS_POSIX
        rpp_sci_printf((const char *)
                                   "Analog Inputs Test [1-12]:\r\n"
                                   );
@@ -88,7 +85,6 @@ void adc_test_task(void *par)
        // Delete myself
        tasks_running--;
        vTaskDelete(NULL);
-       #endif
 }
 
 
@@ -97,7 +93,6 @@ void adc_test_task(void *par)
  */
 void test_adc()
 {
-       #ifndef FREERTOS_POSIX
        /// Configure module
        // - Not needed
 
@@ -145,9 +140,6 @@ void test_adc()
 
 
        rpp_sci_printf((const char *)"\r\n");
-       #else
-       rpp_sci_printf((const char *)"ADC not supported on Linux target.\r\n");
-       #endif
 
        return;
 }
diff --git a/apps/rpp-test-suite/src/eth.c b/apps/rpp-test-suite/src/eth.c
new file mode 100644 (file)
index 0000000..f4522ac
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : eth.c
+ * Abstract:
+ *     RPP test suite - module for testing ETH.
+ *
+ * References:
+ *     test.h
+ */
+
+
+#include "rpp/rpp.h"
+#include "test.h"
+
+
+/**
+ * ETH Test entry point.
+ */
+void test_eth()
+{
+       rpp_sci_printf((const char *)
+                                  "ETH test is unimplemented. Press any key to continue...\r\n"
+                                  );
+       wait_for_quit();
+}
diff --git a/apps/rpp-test-suite/src/fr.c b/apps/rpp-test-suite/src/fr.c
new file mode 100644 (file)
index 0000000..ca4d84b
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : fr.c
+ * Abstract:
+ *     RPP test suite - module for testing FR.
+ *
+ * References:
+ *     test.h
+ */
+
+
+#include "rpp/rpp.h"
+#include "test.h"
+
+
+/**
+ * FR Test entry point.
+ */
+void test_fr()
+{
+       rpp_sci_printf((const char *)
+                                  "FR test is unimplemented. Press any key to continue...\r\n"
+                                  );
+       wait_for_quit();
+}
diff --git a/apps/rpp-test-suite/src/lin.c b/apps/rpp-test-suite/src/lin.c
new file mode 100644 (file)
index 0000000..3dfa8ff
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
+ *
+ * File : lin.c
+ * Abstract:
+ *     RPP test suite - module for testing LIN.
+ *
+ * References:
+ *     test.h
+ */
+
+
+#include "rpp/rpp.h"
+#include "test.h"
+
+
+/**
+ * LIN Test entry point.
+ */
+void test_lin()
+{
+       rpp_sci_printf((const char *)
+                                  "LIN test is unimplemented. Press any key to continue...\r\n"
+                                  );
+       wait_for_quit();
+}