DCMD_PTPD_DELAYMS
QNX SDP8.0Devctl and Ioctl CommandsDeveloper
Get the master-to-slave delay
Synopsis:
#include <dcmd_ptpd.h>
#define DCMD_PTPD_DELAYMS __DIOF(_DCMD_NET, 10, MyTimeInternal )
Arguments to devctl():
Argument | Value |
---|---|
filedes | A file descriptor that you obtained by opening ${SOCK}/dev/ptpd/interface_name |
dcmd | DCMD_PTPD_DELAYMS |
dev_data_ptr | A pointer to a MyTimeInternal structure |
n_bytes | sizeof(MyTimeInternal) |
dev_info_ptr | NULL |
Description:
The DCMD_PTPD_DELAYMS command gets the network latency in the direction from the master to the slave for the Precision Time Protocol.
Note:
To use this command, you must specify the -K option when you start
ptpd2.
Input:
None
Output:
A filled-in MyTimeInternal structure, which is defined in <dcmd_ptpd.h> as follows:
typedef struct {
uint32_t seconds;
uint32_t nanoseconds;
} MyTimeInternal;
Example:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <devctl.h>
#include <dcmd_ptpd.h>
int main(int argc, char **argv) {
int fd, ret;
MyTimeInternal delayMS, delaySM, currTime;
MyStatusInternal status = PTPD_STATUS_NO_ERROR;
MyPTPDINFOInternal info;
MyTAIUTCInternal utcOffset;
if ((fd = open( DEFAULT_PTPD_PATH, O_RDONLY)) == -1) {
fprintf( stderr,"open failed\n");
return(1);
}
/* Find out what the value is set to initially */
if ( (ret = devctl(fd, DCMD_PTPD_DELAYMS, &delayMS, sizeof(delayMS), NULL)) != 0 ) {
fprintf( stderr,"devctl returned error %x", ret );
exit( -1 );
}
printf("ptpd delayMS is %d sec, %d nanosec\n", delayMS.seconds, delayMS.nanoseconds);
if ( (ret = devctl(fd, DCMD_PTPD_DELAYSM, &delaySM, sizeof(delaySM), NULL)) != 0 ) {
fprintf( stderr,"devctl returned error %x", ret );
exit( -1 );
}
printf("ptpd delaySM is %d sec, %d nanosec\n", delaySM.seconds, delaySM.nanoseconds);
if ( (ret = devctl(fd, DCMD_PTPD_STATUS, &status, sizeof(status), NULL)) != 0 ) {
fprintf( stderr,"devctl returned error %x", ret );
exit( -1 );
}
printf("ptpd status is %d \n", status);
if ( (ret = devctl(fd, DCMD_PTPD_INFO, &info, sizeof(info), NULL)) != 0 ) {
fprintf( stderr,"devctl returned error %x", ret );
exit( -1 );
}
printf("ptpd peerdelay is %llu \n", info.peerdelay);
if (info.neighborrateratio_valid) {
printf("ptpd neighborrateratio %d\n", info.neighborrateratio);
} else
printf("ptpd neighborrateratio invalid\n");
if ( (ret = devctl(fd, DCMD_PTPD_GET_TAI_UTC_OFFSET, &utcOffset, sizeof(utcOffset), NULL)) != 0 ) {
fprintf( stderr, "devctl returned error %x", ret );
exit ( -1 );
}
if (utcOffset.currentUtcOffsetValid) {
printf("current UTC Offset is %d\n", utcOffset.currentUtcOffset);
} else {
printf("current UTC offset is invalid\n");
}
return(0);
}
See also:
DCMD_PTPD_DELAYSM, DCMD_PTPD_GET_PDELAY_INTERVAL, DCMD_PTPD_GET_TAI_UTC_OFFSET, DCMD_PTPD_GET_TIME, DCMD_PTPD_INFO, DCMD_PTPD_SEND_SIGNALING_MSG, DCMD_PTPD_SET_PDELAY_INTERVAL, DCMD_PTPD_STATUS
devctl() in the QNX OS C Library Reference
ptpd2 in the Utilities Reference
Page updated: