mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-22 10:30:13 +00:00
Clock seconds since startup on minimal-net
This commit is contained in:
parent
0bb585fd60
commit
05c11d362b
@ -41,6 +41,16 @@
|
||||
#include "sys/clock.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
static long startsecs=0,startmsecs=0;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
clock_init(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL) ;
|
||||
startmsecs=tv.tv_usec/1000;
|
||||
startsecs=tv.tv_sec;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
clock_time_t
|
||||
clock_time(void)
|
||||
@ -56,6 +66,19 @@ clock_time(void)
|
||||
unsigned long
|
||||
clock_seconds(void)
|
||||
{
|
||||
/* Returne seconds since startup */
|
||||
long secs,msecs;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL) ;
|
||||
msecs=tv.tv_usec/1000;
|
||||
secs=tv.tv_sec;
|
||||
secs -=startsecs;
|
||||
msecs-=startmsecs;
|
||||
if (msecs<0) secs--;
|
||||
return secs;
|
||||
}
|
||||
#if 0
|
||||
/* Return seconds since midnight*/
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
@ -63,6 +86,7 @@ clock_seconds(void)
|
||||
|
||||
return tv.tv_sec;
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
clock_delay(unsigned int d)
|
||||
|
@ -163,6 +163,7 @@ sprint_ip6(uip_ip6addr_t addr)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
clock_init();
|
||||
#if UIP_CONF_IPV6
|
||||
/* A hard coded address overrides the stack default MAC address to allow multiple instances.
|
||||
* uip6.c defines it as {0x00,0x06,0x98,0x00,0x02,0x32} giving an ipv6 address of [fe80::206:98ff:fe00:232]
|
||||
@ -265,6 +266,8 @@ main(void)
|
||||
/* Make standard output unbuffered. */
|
||||
setvbuf(stdout, (char *)NULL, _IONBF, 0);
|
||||
|
||||
printf("\n*******%s online*******\n",CONTIKI_VERSION_STRING);
|
||||
|
||||
while(1) {
|
||||
fd_set fds;
|
||||
int n;
|
||||
|
Loading…
Reference in New Issue
Block a user