Dear users,
[platform: Ubuntu]
I have a program witch collect information from a solar inverter. The C program makes a json data file, and a shell script send this to a server with a curl command.
It all works fine, until I tried to insert NTP_timestamps. My timer is to fast. (in no time i posted on 12 december)
I made a script witch called a C program [see below], and after that it called ntptime -r. (than a then seconds sleep) this was all in a while(1), so I could find out what the diffrence was. The code:
when I take the output and make them both decimal, i get this:Code:#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <sys/timex.h>
int main()
{
long int i=0;
srand(time(NULL));
struct ntptimeval start;
while(1)
{
ntp_gettime(&start);
i=start.time.tv_sec;
printf("i is %lu\r\n",i);
system("ntptime");
sleep(10);
}
return 0;
}
1530672002 8670001000 = 1354884676
1530672007 1640517000 = 1354884686
1530672015 7581455000 = 1354884706
The first 2 numbers have a relation 1 to 2 (7-2=5, 86-76=10,)
When we take the thirt number, we get a other relation! (15-7=8, 06-86= 20, so we get 1 to 2.5)
How can this be? help! The endgoal is to get the left number.
Kind regards,
Libpgeak