Merge pull request #4600 from kaspar030/remove_test_vtimer_msg
tests: remove vtimer tests
This commit is contained in:
commit
26f9f7fa2d
@ -1,6 +0,0 @@
|
||||
APPLICATION = vtimer_msg
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += vtimer
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 INRIA
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Thread test application
|
||||
*
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "vtimer.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
|
||||
#define MSG_QUEUE_SIZE 1
|
||||
|
||||
char timer_stack[THREAD_STACKSIZE_MAIN];
|
||||
char timer_stack_local[THREAD_STACKSIZE_MAIN];
|
||||
|
||||
struct timer_msg {
|
||||
vtimer_t timer;
|
||||
timex_t interval;
|
||||
char *msg;
|
||||
};
|
||||
|
||||
timex_t now;
|
||||
|
||||
struct timer_msg msg_a = { .interval = { .seconds = 2, .microseconds = 0}, .msg = "Hello World" };
|
||||
struct timer_msg msg_b = { .interval = { .seconds = 5, .microseconds = 0}, .msg = "This is a Test" };
|
||||
|
||||
void *timer_thread(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
printf("This is thread %" PRIkernel_pid "\n", thread_getpid());
|
||||
|
||||
/* we need a queue if the second message arrives while the first is still processed */
|
||||
/* without a queue, the message would get lost */
|
||||
/* because of the way this timer works, there can be max 1 queued message */
|
||||
msg_t msgq[MSG_QUEUE_SIZE];
|
||||
msg_init_queue(msgq, MSG_QUEUE_SIZE);
|
||||
|
||||
while (1) {
|
||||
msg_t m;
|
||||
msg_receive(&m);
|
||||
struct timer_msg *tmsg = (struct timer_msg *) m.content.ptr;
|
||||
vtimer_now(&now);
|
||||
printf("now=%" PRIu32 ":%" PRIu32 " -> every %" PRIu32 ".%" PRIu32 "s: %s\n",
|
||||
now.seconds,
|
||||
now.microseconds,
|
||||
tmsg->interval.seconds,
|
||||
tmsg->interval.microseconds,
|
||||
tmsg->msg);
|
||||
|
||||
vtimer_set_msg(&tmsg->timer, tmsg->interval, thread_getpid(), MSG_TIMER, tmsg);
|
||||
}
|
||||
}
|
||||
|
||||
void *timer_thread_local(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
printf("This is thread %" PRIkernel_pid "\n", thread_getpid());
|
||||
|
||||
while (1) {
|
||||
msg_t m;
|
||||
msg_receive(&m);
|
||||
|
||||
struct tm t;
|
||||
vtimer_get_localtime(&t);
|
||||
printf("sec=%d min=%d hour=%d\n", t.tm_sec, t.tm_min, t.tm_hour);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
msg_t m;
|
||||
kernel_pid_t pid = thread_create(
|
||||
timer_stack,
|
||||
sizeof(timer_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread,
|
||||
NULL,
|
||||
"timer");
|
||||
|
||||
puts("sending 1st msg");
|
||||
m.content.ptr = (char *) &msg_a;
|
||||
msg_try_send(&m, pid);
|
||||
|
||||
puts("sending 2nd msg");
|
||||
m.content.ptr = (char *) &msg_b;
|
||||
msg_try_send(&m, pid);
|
||||
|
||||
kernel_pid_t pid2 = thread_create(
|
||||
timer_stack_local,
|
||||
sizeof(timer_stack_local),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread_local,
|
||||
NULL,
|
||||
"timer local");
|
||||
|
||||
timex_t sleep = timex_set(1, 0);
|
||||
|
||||
while (1) {
|
||||
vtimer_sleep(sleep);
|
||||
msg_try_send(&m, pid2);
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
APPLICATION = vtimer_msg_diff
|
||||
include ../Makefile.tests_common
|
||||
|
||||
BOARD_INSUFFICIENT_MEMORY := mbed_lpc1768 stm32f0discovery nrf6310 pca10000 pca10005 \
|
||||
weio
|
||||
|
||||
USEMODULE += vtimer
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 INRIA
|
||||
* Copyright (C) 2014 Kaspar Schleiser
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Thread test application
|
||||
*
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "vtimer.h"
|
||||
#include "thread.h"
|
||||
#include "msg.h"
|
||||
|
||||
#define MAXCOUNT 100
|
||||
#define MAXDIFF 10000
|
||||
|
||||
#define MSG_QUEUE_SIZE 16
|
||||
|
||||
char timer_stack[THREAD_STACKSIZE_MAIN*4];
|
||||
|
||||
struct timer_msg {
|
||||
vtimer_t timer;
|
||||
timex_t interval;
|
||||
char *msg;
|
||||
timex_t start;
|
||||
int count;
|
||||
};
|
||||
|
||||
timex_t now;
|
||||
|
||||
struct timer_msg timer_msgs[] = { { .interval = { .seconds = 0, .microseconds = 100000}, .msg = "T1", .start={0, 0}, .count=0 },
|
||||
{ .interval = { .seconds = 0, .microseconds = 200000}, .msg = "T2", .start={0, 0}, .count=0 },
|
||||
{ .interval = { .seconds = 0, .microseconds = 300000}, .msg = "T3", .start={0, 0}, .count=0 },
|
||||
{ .interval = { .seconds = 0, .microseconds = 500000}, .msg = "T4", .start={0, 0}, .count=0 },
|
||||
{ .interval = { .seconds = 0, .microseconds = 700000}, .msg = "T5", .start={0, 0}, .count=0 },
|
||||
{ .interval = { .seconds = 1, .microseconds = 100000}, .msg = "T6", .start={0, 0}, .count=0 },
|
||||
};
|
||||
|
||||
void *timer_thread(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
printf("This is thread %" PRIkernel_pid "\n", thread_getpid());
|
||||
|
||||
msg_t msgq[MSG_QUEUE_SIZE];
|
||||
msg_init_queue(msgq, MSG_QUEUE_SIZE);
|
||||
|
||||
while (1) {
|
||||
msg_t m;
|
||||
msg_receive(&m);
|
||||
struct timer_msg *tmsg = (struct timer_msg *) m.content.ptr;
|
||||
|
||||
vtimer_now(&now);
|
||||
|
||||
if (tmsg->start.seconds==0 && tmsg->start.microseconds == 0) {
|
||||
printf("Initializing \"%s\".\n", tmsg->msg);
|
||||
tmsg->start = now;
|
||||
} else {
|
||||
tmsg->count++;
|
||||
}
|
||||
|
||||
uint64_t should = timex_uint64(tmsg->interval)*tmsg->count+timex_uint64(tmsg->start);
|
||||
int64_t diff = should - timex_uint64(now);
|
||||
|
||||
printf("now=%02" PRIu32 ":%02" PRIu32 " -> every %" PRIu32 ".%" PRIu32 "s: %s diff=%" PRId64 "\n",
|
||||
now.seconds,
|
||||
now.microseconds,
|
||||
tmsg->interval.seconds,
|
||||
tmsg->interval.microseconds,
|
||||
tmsg->msg, diff);
|
||||
|
||||
if (diff > MAXDIFF || diff < -MAXDIFF) {
|
||||
printf("WARNING: timer difference %" PRId64 "us exceeds MAXDIFF(%d)!\n", diff, MAXDIFF);
|
||||
}
|
||||
|
||||
vtimer_set_msg(&tmsg->timer, tmsg->interval, thread_getpid(), MSG_TIMER, tmsg);
|
||||
|
||||
if (tmsg->count >= MAXCOUNT) {
|
||||
printf("Maximum count reached. (%d) Exiting.\n", MAXCOUNT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
msg_t m;
|
||||
kernel_pid_t pid = thread_create(
|
||||
timer_stack,
|
||||
sizeof(timer_stack),
|
||||
THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST,
|
||||
timer_thread,
|
||||
NULL,
|
||||
"timer");
|
||||
|
||||
for (unsigned i = 0; i < sizeof(timer_msgs)/sizeof(struct timer_msg); i++) {
|
||||
printf("Sending timer msg %u...\n", i);
|
||||
m.content.ptr = (char *) &timer_msgs[i];
|
||||
msg_try_send(&m, pid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user