DNA/DNR-IRIG-650 IRIG Timing Layer
Chapter 3
42
Programming with the Low Level API
Tel: 508-921-4600
www.ueidaq.com
Vers:
4.6
Date: March 2019
DNx-IRIG-650 Chap3x.fm
© Copyright 2019
United Electronic Industries, Inc.
// Set error event to send packet once at error condition,
then re-enable error events in the
// error handle to avoid a flood of error notification
packets
ret = DqAdv650ConfigEvents(async_hd, DEVN, evt_chan_err,
DQEVENT_ONCE, EV650_ERROR, &error_mask);
Now, create a separate thread to receive events:
hThread = RunThread(async_thread, (void*)&a_handle);
where
void* async_thread(void* param)
is an actual thread function.
Receive events in the event thread:
while(!stop) {
pEvent = NULL;
ret = DqCmdReceiveEvent(handle->handle, 0, 1000*1000,
&pEvent, &size);
if ((ret < 0)&&(ret != DQ_TIMEOUT_ERROR)) {
printf("ERR: %s\n", DqTranslateError(ret));
}
if (ret >= 0) {
pEv650 = (pEV650_ID)pEvent->data;
// for this packet do conversion in place
ntoh_pEv650(pEv650);
if (print_msg) {
printf("Event=%x size=%d\n", pEvent->event,
pEv650->size);
}
switch(pEvent->event) {
case EV650_EVENT:
// data contains two uint32: SBS seconds, microseconds from TK
// this is where pacing and other types of events configured in
// DqAdv650SetEvents() should be processed
break;
case EV650_PPS_CLK:
// data contains two uint32: SBS seconds, microseconds from TK
// this is a precision once-a-second event
break;
case EV650_TIMERDY:
// data contains 16 TREG registers in uint32s
// and two uint32: SBS seconds and microseconds from TK
// If we start receiving time re-enable error messages
if (reenable_errors)
ret = DqAdv650ConfigEvents(handle-
>handle, DEVN, CT650_EVENT_CHERR, DQEVENT_ONCE,
EV650_ERROR, &error_mask);
reenable_errors = FALSE;
break;