QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
qnx_getclock() message structure |
Ref. No. |
QNX.000006537 |
Category(ies) |
Development |
Issue |
We need further details on the qnx_getclock() function. We use qnx_getclock() to pass time and date info over the Ethernet to client nodes, and we would like to be able to capture and view the bits that carry this info.
|
Solution |
qnx_getclock() is merely a message to Proc, which fills in the second and nanosecond fields. Here's what it does:
#include <sys/proc_msg.h> #include <sys/kernel.h> #include <errno.h> #include <time.h> #include <sys/timers.h>
int clock_gettime(clockid_t clock_id, struct timespec *tp)x09/* 1003.4/D12 */ x09{ x09return(qnx_getclock(0, clock_id, tp)); x09}
int qnx_getclock(pid_t proc_pid, clockid_t clock_id, struct timespec *tp) x09{ union { struct _proc_time s; struct _proc_time_reply r; } msg; clock_id = clock_id; msg.s.type = _PROC_TIME; msg.s.seconds = -1; msg.s.nsec = -1; msg.s.zero1 = 0; if( Send( proc_pid ? proc_pid : PROC_PID, x09x09x09x09&msg.s, &msg.r, sizeof( msg.s ), sizeof( msg.r ) ) == -1 ) return( -1 );
tp->tv_sec = msg.s.seconds; tp->tv_nsec = msg.s.nsec;
if( msg.r.status != EOK ) { errno = msg.r.status; return( -1 ); }
return( 0 ); x09}
/* qnx 4.01 compat */ int getclock(clock_type, tp) int clock_type; register struct timespec *tp; x09{
x09return(qnx_getclock(0, clock_type, tp)); x09}
|
|