apps/system and wireless: Applications should use the standard clock() interface, not the internal NuttX clock_systimer() interface.
This commit is contained in:
parent
b36ac8df0a
commit
139b008fc9
@ -24,7 +24,7 @@
|
||||
*
|
||||
* Adapted to NuttX and re-released under a 3-clause BSD license:
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved.
|
||||
* Authors: Alan Carvalho de Assis <Alan Carvalho de Assis>
|
||||
* Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
@ -1922,9 +1922,7 @@ static struct Value *fn_tan(struct Value *v, struct Auto *stack)
|
||||
|
||||
static struct Value *fn_timei(struct Value *v, struct Auto *stack)
|
||||
{
|
||||
return Value_new_INTEGER(v,
|
||||
(unsigned long)(clock_systimer() /
|
||||
(CLK_TCK / 100.0)));
|
||||
return Value_new_INTEGER(v, (unsigned long)(clock() / (CLK_TCK / 100.0)));
|
||||
}
|
||||
|
||||
static struct Value *fn_times(struct Value *v, struct Auto *stack)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/system/ping/ping.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -45,6 +45,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <poll.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -183,7 +184,7 @@ static void icmp_ping(FAR struct ping_info_s *info)
|
||||
struct pollfd recvfd;
|
||||
FAR uint8_t *ptr;
|
||||
int32_t elapsed;
|
||||
systime_t start;
|
||||
clock_t start;
|
||||
socklen_t addrlen;
|
||||
ssize_t nsent;
|
||||
ssize_t nrecvd;
|
||||
@ -231,7 +232,7 @@ static void icmp_ping(FAR struct ping_info_s *info)
|
||||
}
|
||||
}
|
||||
|
||||
start = clock_systimer();
|
||||
start = clock();
|
||||
outsize = sizeof(struct icmp_hdr_s) + ICMP_PING_DATALEN;
|
||||
nsent = sendto(info->sockfd, info->iobuffer, outsize, 0,
|
||||
(FAR struct sockaddr*)&destaddr,
|
||||
@ -296,7 +297,7 @@ static void icmp_ping(FAR struct ping_info_s *info)
|
||||
return;
|
||||
}
|
||||
|
||||
elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (unsigned int)TICK2MSEC(clock() - start);
|
||||
inhdr = (FAR struct icmp_hdr_s *)info->iobuffer;
|
||||
|
||||
if (inhdr->type == ICMP_ECHO_REPLY)
|
||||
@ -388,7 +389,7 @@ static void icmp_ping(FAR struct ping_info_s *info)
|
||||
|
||||
/* Wait if necessary to preserved the requested ping rate */
|
||||
|
||||
elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (unsigned int)TICK2MSEC(clock() - start);
|
||||
if (elapsed < info->delay)
|
||||
{
|
||||
struct timespec rqt;
|
||||
@ -449,7 +450,7 @@ int ping_main(int argc, char **argv)
|
||||
{
|
||||
FAR struct ping_info_s *info;
|
||||
FAR char *endptr;
|
||||
systime_t start;
|
||||
clock_t start;
|
||||
int32_t elapsed;
|
||||
int exitcode;
|
||||
int option;
|
||||
@ -537,12 +538,12 @@ int ping_main(int argc, char **argv)
|
||||
goto errout_with_info;
|
||||
}
|
||||
|
||||
start = clock_systimer();
|
||||
start = clock();
|
||||
icmp_ping(info);
|
||||
|
||||
/* Get the total elapsed time */
|
||||
|
||||
elapsed = (int32_t)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (int32_t)TICK2MSEC(clock() - start);
|
||||
|
||||
if (info->nrequests > 0)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* apps/system/ping/ping.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -45,6 +45,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <poll.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -189,7 +190,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info)
|
||||
struct pollfd recvfd;
|
||||
FAR uint8_t *ptr;
|
||||
int32_t elapsed;
|
||||
systime_t start;
|
||||
clock_t start;
|
||||
socklen_t addrlen;
|
||||
ssize_t nsent;
|
||||
ssize_t nrecvd;
|
||||
@ -235,7 +236,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info)
|
||||
}
|
||||
}
|
||||
|
||||
start = clock_systimer();
|
||||
start = clock();
|
||||
outsize = SIZEOF_ICMPV6_ECHO_REPLY_S(0) + ICMPv6_PING6_DATALEN;
|
||||
nsent = sendto(info->sockfd, info->iobuffer, outsize, 0,
|
||||
(FAR struct sockaddr*)&destaddr,
|
||||
@ -299,7 +300,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info)
|
||||
return;
|
||||
}
|
||||
|
||||
elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (unsigned int)TICK2MSEC(clock() - start);
|
||||
inhdr = (FAR struct icmpv6_echo_reply_s *)info->iobuffer;
|
||||
|
||||
if (inhdr->type == ICMPv6_ECHO_REPLY)
|
||||
@ -389,7 +390,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info)
|
||||
|
||||
/* Wait if necessary to preserved the requested ping rate */
|
||||
|
||||
elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (unsigned int)TICK2MSEC(clock() - start);
|
||||
if (elapsed < info->delay)
|
||||
{
|
||||
struct timespec rqt;
|
||||
@ -450,7 +451,7 @@ int ping6_main(int argc, char **argv)
|
||||
{
|
||||
FAR struct ping6_info_s *info;
|
||||
FAR char *endptr;
|
||||
systime_t start;
|
||||
clock_t start;
|
||||
int32_t elapsed;
|
||||
int exitcode;
|
||||
int option;
|
||||
@ -538,12 +539,12 @@ int ping6_main(int argc, char **argv)
|
||||
goto errout_with_info;
|
||||
}
|
||||
|
||||
start = clock_systimer();
|
||||
start = clock();
|
||||
icmpv6_ping(info);
|
||||
|
||||
/* Get the total elapsed time */
|
||||
|
||||
elapsed = (int32_t)TICK2MSEC(clock_systimer() - start);
|
||||
elapsed = (int32_t)TICK2MSEC(clock() - start);
|
||||
|
||||
if (info->nrequests > 0)
|
||||
{
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
@ -321,7 +322,7 @@ static int i8shark_daemon(int argc, FAR char *argv[])
|
||||
struct mac802154dev_rxframe_s frame;
|
||||
enum ieee802154_frametype_e ftype;
|
||||
uint8_t zepframe[I8SHARK_MAX_ZEPFRAME];
|
||||
systime_t systime;
|
||||
clock_t systime;
|
||||
int ind = 0;
|
||||
int nbytes;
|
||||
|
||||
@ -390,7 +391,7 @@ static int i8shark_daemon(int argc, FAR char *argv[])
|
||||
|
||||
/* Need to use NTP to get time, but for now, include the system time */
|
||||
|
||||
systime = clock_systimer();
|
||||
systime = clock();
|
||||
memcpy(&zepframe[ind], &systime, 8);
|
||||
ind += 8;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user