fixed nanotime
This commit is contained in:
parent
3f108fcc13
commit
511956531e
@ -91,6 +91,7 @@ int main(int _U_ argc, char _U_ **argv){
|
|||||||
if(MCC_E_OK != Mount.init(Config)) ERRX("Can't init mount");
|
if(MCC_E_OK != Mount.init(Config)) ERRX("Can't init mount");
|
||||||
coordval_pair_t M, E;
|
coordval_pair_t M, E;
|
||||||
if(!getPos(&M, &E)) ERRX("Can't get current position");
|
if(!getPos(&M, &E)) ERRX("Can't get current position");
|
||||||
|
printf("Current time: %.10f\n", Mount.currentT());
|
||||||
DBG("xt: %g, x: %g", M.X.t, M.X.val);
|
DBG("xt: %g, x: %g", M.X.t, M.X.val);
|
||||||
if(G.coordsoutput){
|
if(G.coordsoutput){
|
||||||
if(!G.wait) green("When logging I should wait until moving ends; added '-w'\n");
|
if(!G.wait) green("When logging I should wait until moving ends; added '-w'\n");
|
||||||
|
|||||||
@ -51,18 +51,16 @@ static mcc_errcodes_t shortcmd(short_command_t *cmd);
|
|||||||
* @return time in seconds
|
* @return time in seconds
|
||||||
*/
|
*/
|
||||||
double nanotime(){
|
double nanotime(){
|
||||||
//static struct timespec *start = NULL;
|
static double t0 = -1.;
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
/*if(!start){
|
|
||||||
start = malloc(sizeof(struct timespec));
|
|
||||||
if(!start) return -1.;
|
|
||||||
if(clock_gettime(CLOCK_MONOTONIC, start)) return -1.;
|
|
||||||
}*/
|
|
||||||
if(clock_gettime(CLOCK_MONOTONIC, &now)) return -1.;
|
if(clock_gettime(CLOCK_MONOTONIC, &now)) return -1.;
|
||||||
/*double nd = ((double)now.tv_nsec - (double)start->tv_nsec) * 1e-9;
|
if(t0 < 0.){
|
||||||
double sd = (double)now.tv_sec - (double)start->tv_sec;
|
struct timespec start;
|
||||||
return sd + nd;*/
|
if(clock_gettime(CLOCK_REALTIME, &start)) return -1.;
|
||||||
return (double)now.tv_sec + (double)now.tv_nsec * 1e-9;
|
t0 = (double)start.tv_sec + (double)start.tv_nsec * 1e-9
|
||||||
|
- (double)now.tv_sec + (double)now.tv_nsec * 1e-9;
|
||||||
|
}
|
||||||
|
return (double)now.tv_sec + (double)now.tv_nsec * 1e-9 + t0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user