50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
/**
|
|
* \file
|
|
* \brief Hello world application
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2016 ETH Zurich.
|
|
* All rights reserved.
|
|
*
|
|
* This file is distributed under the terms in the attached LICENSE file.
|
|
* If you do not find this file, copies can be found by writing to:
|
|
* ETH Zurich D-INFK, CAB F.78, Universitaetstr. 6, CH-8092 Zurich,
|
|
* Attn: Systems Group.
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/time.h>
|
|
|
|
#include <aos/aos.h>
|
|
|
|
#define HELLO_CATCH_COMMAND "catch"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct timespec tt;
|
|
|
|
if (clock_gettime(CLOCK_REALTIME, &tt) < 0) return 1;
|
|
double time = tt.tv_sec + tt.tv_nsec / 1000000000.0;
|
|
|
|
printf("Hello, world! I am %lfs\n", time);
|
|
|
|
printf("argv:\n");
|
|
for(int i = 0; i < argc; ++i) {
|
|
printf(" %d -> %s\n", i, argv[i]);
|
|
}
|
|
|
|
// if we receive the catch command, RUN!
|
|
if (argc > 1 && !strncmp(argv[1], HELLO_CATCH_COMMAND, sizeof(HELLO_CATCH_COMMAND))) {
|
|
while(1) {
|
|
printf("Catch %lf if you can!\n", time);
|
|
// wait for 1 second
|
|
for(volatile int j = 0; j < 50000000; ++j);
|
|
}
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|