Hi,

I downloaded, build and run linuxptp without any issue, however when I check 
the phc and the system time of the slave and master I see the big offset, 
bellow is the program I use to check the time:
#include <stdio.h>
#include <time.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define CLOCKFD 3
#define FD_TO_CLOCKID(fd)      ((clockid_t) ((((unsigned int) ~fd) << 3) | 
CLOCKFD))

int main(){

    struct timespec tm ,tm2 ,pretm ,pretm2 ;
    char phc_device[19];
    int clkid, sysid=CLOCK_REALTIME;
    sprintf(phc_device, "/dev/ptp0");
    int fd = open(phc_device, O_RDWR);
    clkid = FD_TO_CLOCKID(fd);



    while(1){
        clock_gettime(CLOCK_REALTIME, &tm2);
        clock_gettime(clkid, &tm);
        printf("tm(phc): %ds. %ldns tm: %ds. %ldns  \n",(int)tm.tv_sec 
,tm.tv_nsec ,(int)tm2.tv_sec ,tm2.tv_nsec );
              sleep(5);


    }
}

And the result I got from slave is (the phc is syn with the system clock as 
expected):
tm(phc): 1581497899s. 585511733ns tm: 1581497899s. 585502195ns
tm(phc): 1581497904s. 585796341ns tm: 1581497904s. 585781109ns
tm(phc): 1581497909s. 586014309ns tm: 1581497909s. 586004264ns
tm(phc): 1581497914s. 586284373ns tm: 1581497914s. 586269703ns
tm(phc): 1581497919s. 586499317ns tm: 1581497919s. 586488155ns
tm(phc): 1581497924s. 586687509ns tm: 1581497924s. 586672700ns
tm(phc): 1581497929s. 586881621ns tm: 1581497929s. 586871635ns
tm(phc): 1581497934s. 587038901ns tm: 1581497934s. 587032275ns
tm(phc): 1581497939s. 587183413ns tm: 1581497939s. 587172194ns
tm(phc): 1581497944s. 587360853ns tm: 1581497944s. 587346347ns
tm(phc): 1581497949s. 587602789ns tm: 1581497949s. 587593025ns
tm(phc): 1581497954s. 587805557ns tm: 1581497954s. 587788973ns
tm(phc): 1581497959s. 587983669ns tm: 1581497959s. 587970310ns
tm(phc): 1581497964s. 588145957ns tm: 1581497964s. 588133126ns
tm(phc): 1581497969s. 588318437ns tm: 1581497969s. 588304533ns
tm(phc): 1581497974s. 588526293ns tm: 1581497974s. 588514492ns
tm(phc): 1581497979s. 588699765ns tm: 1581497979s. 588688263ns
tm(phc): 1581497984s. 588898597ns tm: 1581497984s. 588883844ns
tm(phc): 1581497989s. 589117637ns tm: 1581497989s. 589105596ns
tm(phc): 1581497994s. 589383205ns tm: 1581497994s. 589371514ns
tm(phc): 1581497999s. 589546629ns tm: 1581497999s. 589536523ns
tm(phc): 1581498004s. 589754149ns tm: 1581498004s. 589744840ns
tm(phc): 1581498009s. 589929253ns tm: 1581498009s. 589919545ns
tm(phc): 1581498014s. 590102293ns tm: 1581498014s. 590091734ns
tm(phc): 1581498019s. 590259941ns tm: 1581498019s. 590249776ns

vs master:
tm(phc): 1581497921s. 917364508ns tm: 1581497926s. 475748646ns
tm(phc): 1581497927s. 472749779ns tm: 1581497931s. 475809970ns
tm(phc): 1581497933s. 28131578ns tm: 1581497936s. 475869132ns
tm(phc): 1581497938s. 583512050ns tm: 1581497941s. 475926155ns
tm(phc): 1581497944s. 138891193ns tm: 1581497950s. 71860023ns
tm(phc): 1581497949s. 694290768ns tm: 1581497955s. 71934477ns
tm(phc): 1581497955s. 249668199ns tm: 1581497960s. 71989465ns
tm(phc): 1581497960s. 805067358ns tm: 1581497965s. 72063804ns
tm(phc): 1581497966s. 360450757ns tm: 1581497970s. 72124120ns
tm(phc): 1581497971s. 915849004ns tm: 1581497975s. 72197747ns
tm(phc): 1581497977s. 471251587ns tm: 1581497983s. 655329245ns
tm(phc): 1581497983s. 26628058ns tm: 1581497988s. 655383035ns
tm(phc): 1581497988s. 582001842ns tm: 1581497993s. 655434830ns
tm(phc): 1581497994s. 137375465ns tm: 1581497998s. 655485786ns
tm(phc): 1581497999s. 692745665ns tm: 1581498003s. 655535078ns
tm(phc): 1581498005s. 248121112ns tm: 1581498008s. 655587636ns
tm(phc): 1581498010s. 803519903ns tm: 1581498013s. 655661569ns
tm(phc): 1581498016s. 358886071ns tm: 1581498022s. 238674144ns
tm(phc): 1581498021s. 914261854ns tm: 1581498027s. 238727116ns
tm(phc): 1581498027s. 469666725ns tm: 1581498032s. 238807079ns
tm(phc): 1581498033s. 25070380ns tm: 1581498037s. 238885351ns

as you can see the nano sec of the slave side add up nicely, however the nano 
sec of the master side jumps randomly, is this behaviour expected? And is the 
offset expected ?
_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to