mbed-rtos test programs for DISCO_F746NG. #Test for thread, mutex, semaphore, signals, queues, mail, ISR

Dependencies:   BSP_DISCO_F746NG HC06Bluetooth I2Cdev LCD_DISCO_F746NG MCP2515 MD25 MPU9150 TS_DISCO_F746NG emwin mbed-dev mbed-rtos pca9685 ppCANOpen ros_lib_kinetic

Fork of DISCO-F746NG_rtos_test by sabme ua

Committer:
mzta
Date:
Wed Nov 11 07:53:46 2015 +0000
Revision:
0:225c1da086a1
Initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mzta 0:225c1da086a1 1 #include "test_env.h"
mzta 0:225c1da086a1 2
mzta 0:225c1da086a1 3 // Const strings used in test_end
mzta 0:225c1da086a1 4 const char* TEST_ENV_START = "start";
mzta 0:225c1da086a1 5 const char* TEST_ENV_SUCCESS = "success";
mzta 0:225c1da086a1 6 const char* TEST_ENV_FAILURE = "failure";
mzta 0:225c1da086a1 7 const char* TEST_ENV_MEASURE = "measure";
mzta 0:225c1da086a1 8 const char* TEST_ENV_END = "end";
mzta 0:225c1da086a1 9
mzta 0:225c1da086a1 10
mzta 0:225c1da086a1 11 static void led_blink(PinName led, float delay)
mzta 0:225c1da086a1 12 {
mzta 0:225c1da086a1 13 if (led != NC) {
mzta 0:225c1da086a1 14 DigitalOut myled(led);
mzta 0:225c1da086a1 15 while (1) {
mzta 0:225c1da086a1 16 myled = !myled;
mzta 0:225c1da086a1 17 wait(delay);
mzta 0:225c1da086a1 18 }
mzta 0:225c1da086a1 19 }
mzta 0:225c1da086a1 20 while(1);
mzta 0:225c1da086a1 21 }
mzta 0:225c1da086a1 22
mzta 0:225c1da086a1 23 void notify_start()
mzta 0:225c1da086a1 24 {
mzta 0:225c1da086a1 25 printf("{{%s}}" NL, TEST_ENV_START);
mzta 0:225c1da086a1 26 }
mzta 0:225c1da086a1 27
mzta 0:225c1da086a1 28 void notify_performance_coefficient(const char* measurement_name, const int value)
mzta 0:225c1da086a1 29 {
mzta 0:225c1da086a1 30 printf("{{%s;%s;%d}}" RCNL, TEST_ENV_MEASURE, measurement_name, value);
mzta 0:225c1da086a1 31 }
mzta 0:225c1da086a1 32
mzta 0:225c1da086a1 33 void notify_performance_coefficient(const char* measurement_name, const unsigned int value)
mzta 0:225c1da086a1 34 {
mzta 0:225c1da086a1 35 printf("{{%s;%s;%u}}" RCNL, TEST_ENV_MEASURE, measurement_name, value);
mzta 0:225c1da086a1 36 }
mzta 0:225c1da086a1 37
mzta 0:225c1da086a1 38 void notify_performance_coefficient(const char* measurement_name, const double value)
mzta 0:225c1da086a1 39 {
mzta 0:225c1da086a1 40 printf("{{%s;%s;%f}}" RCNL, TEST_ENV_MEASURE, measurement_name, value);
mzta 0:225c1da086a1 41 }
mzta 0:225c1da086a1 42
mzta 0:225c1da086a1 43 void notify_completion(bool success)
mzta 0:225c1da086a1 44 {
mzta 0:225c1da086a1 45 printf("{{%s}}" NL "{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE, TEST_ENV_END);
mzta 0:225c1da086a1 46 led_blink(LED1, success ? 1.0 : 0.1);
mzta 0:225c1da086a1 47 }
mzta 0:225c1da086a1 48
mzta 0:225c1da086a1 49 bool notify_completion_str(bool success, char* buffer)
mzta 0:225c1da086a1 50 {
mzta 0:225c1da086a1 51 bool result = false;
mzta 0:225c1da086a1 52 if (buffer) {
mzta 0:225c1da086a1 53 sprintf(buffer, "{{%s}}" NL "{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE, TEST_ENV_END);
mzta 0:225c1da086a1 54 result = true;
mzta 0:225c1da086a1 55 }
mzta 0:225c1da086a1 56 return result;
mzta 0:225c1da086a1 57 }
mzta 0:225c1da086a1 58
mzta 0:225c1da086a1 59 // Host test auto-detection API
mzta 0:225c1da086a1 60 void notify_host_test_name(const char *host_test) {
mzta 0:225c1da086a1 61 if (host_test) {
mzta 0:225c1da086a1 62 printf("{{host_test_name;%s}}" NL, host_test);
mzta 0:225c1da086a1 63 }
mzta 0:225c1da086a1 64 }
mzta 0:225c1da086a1 65
mzta 0:225c1da086a1 66 void notify_timeout(int timeout) {
mzta 0:225c1da086a1 67 printf("{{timeout;%d}}" NL, timeout);
mzta 0:225c1da086a1 68 }
mzta 0:225c1da086a1 69
mzta 0:225c1da086a1 70 void notify_test_id(const char *test_id) {
mzta 0:225c1da086a1 71 if (test_id) {
mzta 0:225c1da086a1 72 printf("{{test_id;%s}}" NL, test_id);
mzta 0:225c1da086a1 73 }
mzta 0:225c1da086a1 74 }
mzta 0:225c1da086a1 75
mzta 0:225c1da086a1 76 void notify_test_description(const char *description) {
mzta 0:225c1da086a1 77 if (description) {
mzta 0:225c1da086a1 78 printf("{{description;%s}}" NL, description);
mzta 0:225c1da086a1 79 }
mzta 0:225c1da086a1 80 }
mzta 0:225c1da086a1 81
mzta 0:225c1da086a1 82
mzta 0:225c1da086a1 83 // -DMBED_BUILD_TIMESTAMP=1406208182.13
mzta 0:225c1da086a1 84 unsigned int testenv_randseed()
mzta 0:225c1da086a1 85 {
mzta 0:225c1da086a1 86 unsigned int seed = 0;
mzta 0:225c1da086a1 87 #ifdef MBED_BUILD_TIMESTAMP
mzta 0:225c1da086a1 88 long long_seed = static_cast<long>(MBED_BUILD_TIMESTAMP);
mzta 0:225c1da086a1 89 seed = long_seed & 0xFFFFFFFF;
mzta 0:225c1da086a1 90 #endif /* MBED_BUILD_TIMESTAMP */
mzta 0:225c1da086a1 91 return seed;
mzta 0:225c1da086a1 92 }
mzta 0:225c1da086a1 93