mbgtools-lx  4.2.8
mbgdevio.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgdevio.h 1.47 2018/11/22 14:27:05 martin TRASH $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Definitions and prototypes used with Meinberg device driver I/O.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: mbgdevio.h $
13  * Revision 1.47 2018/11/22 14:27:05 martin
14  * Fixed pointer size problems in a mixed 32/64 bit Linux environment.
15  * Removed obolete preprocessor symbol MBG_USE_KERNEL_DRIVER
16  * and use new global symbol MBG_TGT_USE_IOCTL instead.
17  * Revision 1.46 2018/11/14 12:24:40 martin
18  * Renamed a preprocessor symbol to avoid a name clash.
19  * Revision 1.45 2018/09/21 08:59:17 martin
20  * New version code 0x0308, compatibility version still 0x0210.
21  * Account for a renamed library function.
22  * Updated function prototypes.
23  * Revision 1.44 2018/08/07 15:09:25Z martin
24  * New version code 0x0370, compatibility version still 0x0210.
25  * Revision 1.43 2018/07/05 08:50:48 martin
26  * Added missing linkage attribute for mbg_open_device().
27  * Reworked handling of IOCTL return codes.
28  * Modified test if cpu_set_t and associated definitions are available.
29  * Use standard errno conversion functions.
30  * Removed usage of obsolete symbol MBGDEVIO_SIMPLE.
31  * Updated function prototypes.
32  * Revision 1.42 2017/07/05 15:20:32 martin
33  * New MBGDEVIO_VERSION 0x0400, compatibility version unchanged.
34  * Account for MBG_ERROR_CODES returned by the ioctl functions.
35  * New type MBG_DEV_FN used for device file names, formerly often
36  * referred to as 'hardware ID'.
37  * New type MBG_DEV_NAME used for unique device names, composed of
38  * device type name and serial number appended after an underscore.
39  * Renamed and reworked list handling for device lists.
40  * Use functions from new module timeutil.
41  * windows.h is now included in mbg_tgt.h.
42  * Check for MBG_TGT_POSIX instead of MBG_TGT_UNIX.
43  * Account for PCPS_HRT_BIN_FRAC_SCALE renamed to MBG_FRAC32_UNITS_PER_SEC.
44  * Fixed macro definition syntax to avoid clang compiler warnings.
45  * Exclude mbg_chk_tstamp64_leap_sec() for BC builds for now.
46  * Lots of new doxygen comments and groups.
47  * Updated function prototypes.
48  * Revision 1.41 2013/09/26 08:54:54 martin
49  * Defined thread function type MBG_THREAD_FNC.
50  * Defined check-if-supported function type MBG_CHK_SUPP_FNC.
51  * Updated function prototypes.
52  * Revision 1.40 2012/10/02 18:40:30Z martin
53  * There are some g++ versions which fail to compile source code using
54  * the macros provided by Linux to define IOCTL codes. If only the API
55  * functions are called by an application then the IOCTL codes aren't
56  * required anyway, so we just avoid inclusion of mbgioctl.h.
57  * Updated doxygen comments.
58  * Updated function prototypes.
59  * Support on-board event logs.
60  * Fixed a bug which caused a crash when generic I/O calls
61  * were used under Windows.
62  * Changes for QNX.
63  * Workaround to make mbgmon (BC) build under Windows.
64  * Cleaned up CPU set support under Linux.
65  * Moved some macros here so they can be used by other modules.
66  * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
67  * Cleaned up handling of pragma pack().
68  * Cleaned up inclusion of header files.
69  * Moved mutex definitions to new mbgmutex.h.
70  * Renamed mutex stuff to critical sections.
71  * Updated function prototypes to support PTP unicast configuration
72  * Made xhrt leap second check an inline function.
73  * Fixed macro to avoid compiler warning.
74  * Revision 1.39 2009/12/15 15:34:59Z daniel
75  * Support reading the raw IRIG data bits for firmware versions
76  * which support this feature.
77  * Revision 1.38.1.2 2009/12/10 09:58:53Z daniel
78  * Revision 1.38.1.1 2009/12/10 09:45:29Z daniel
79  * Revision 1.38 2009/09/29 15:06:26Z martin
80  * Updated function prototypes.
81  * Revision 1.37 2009/08/12 14:31:51 daniel
82  * New version code 306, compatibility version still 210.
83  * Revision 1.36 2009/06/19 12:20:31Z martin
84  * Updated function prototypes.
85  * Revision 1.35 2009/06/09 08:57:09 daniel
86  * New version code 305, compatibility version still 210.
87  * Revision 1.34 2009/06/08 18:20:14Z daniel
88  * Updated function prototypes.
89  * Fixes for ARM target.
90  * Revision 1.33 2009/03/19 15:36:26 martin
91  * New version code 304, compatibility version still 210.
92  * Moved some inline functions dealing with MBG_PC_CYCLES
93  * from mbgdevio.h to pcpsdev.h.
94  * Include mbg_arch.h here.
95  * Removed unused doxygen comment.
96  * Updated function prototypes.
97  * Revision 1.32 2008/12/17 10:43:30Z martin
98  * New version code 303, compatibility version still 210.
99  * Increased MBG_MAX_DEVICES from 5 to 8.
100  * Added macros to read the time stamp counter (cycles), and
101  * added an inline rdtscll() call for user space Linux.
102  * Added some inline functions to deal with cycles and timestamps.
103  * Generic support for threads and process/thread affinity controlled
104  * by symbol MBGDEVIO_USE_THREAD_API.
105  * New preprocessor symbol MBGDEVIO_HAVE_THREAD_AFFINITY.
106  * Support extrapolated time stamps controlled
107  * by symbol MBGDEVIO_XHRT_API.
108  * Removed definition of MBG_TGT_SUPP_MMAP.
109  * Updated function prototypes and doxygen comments.
110  * Revision 1.31 2008/02/26 16:57:38Z martin
111  * Updated function prototypes and doxygen comments.
112  * Revision 1.30 2008/02/04 13:33:15Z martin
113  * New preprocessor symbol MBG_TGT_SUPP_MMAP.
114  * Revision 1.29 2008/01/31 08:55:39Z daniel
115  * Renamed functions related to mapped memory support
116  * Revision 1.28 2008/01/31 08:36:22Z martin
117  * Picked up changes from 1.24.1.1:
118  * Added default preprocessor symbol MBGDEVIO_SIMPLE.
119  * Revision 1.27 2008/01/17 15:56:37Z daniel
120  * New version code 302, compatibility version still 210.
121  * Added structure MBG_MAPPED_MEM_INFO.
122  * Updated function prototypes.
123  * Revision 1.26 2007/10/16 10:11:42Z daniel
124  * New version code 301, compatibility version still 210.
125  * Revision 1.25 2007/09/26 14:10:34Z martin
126  * New version code 300, compatibility version still 210.
127  * Added MBG_MAX_DEVICES.
128  * Added enum SELECTION_MODE.
129  * Added structures MBG_DEVICE_LIST and MBG_DEVICE_NAME_LIST.
130  * Updated function prototypes.
131  * Revision 1.24 2007/03/22 10:14:16Z martin
132  * New version code 219, compatibility version still 210.
133  * Revision 1.23 2007/03/02 10:18:10Z martin
134  * Updated function prototypes due to renamed data structures.
135  * Use new definitions of generic handle types.
136  * Preliminary support for *BSD.
137  * Revision 1.22 2006/08/09 13:47:29 martin
138  * New version code 218, compatibility version still 210.
139  * Revision 1.21 2006/06/08 12:30:22Z martin
140  * New version code 217, compatibility version still 210.
141  * Revision 1.20 2006/05/02 13:14:27Z martin
142  * New version code 216, compatibility version still 210.
143  * Updated function prototypes.
144  * Revision 1.19 2006/01/11 12:14:53Z martin
145  * New version code 215, compatibility version still 210.
146  * Revision 1.18 2005/12/15 09:38:39Z martin
147  * New version 214, compatibility version still 210.
148  * Revision 1.17 2005/06/02 11:54:40Z martin
149  * Updated function prototypes.
150  * Revision 1.16 2005/02/16 15:13:00Z martin
151  * New MBGDEVIO_VERSION 0x0212.
152  * Updated function prototypes.
153  * Revision 1.15 2005/01/14 10:22:44Z martin
154  * Updated function prototypes.
155  * Revision 1.14 2004/12/09 11:24:00Z martin
156  * Support configuration of on-board frequency synthesizer.
157  * Revision 1.13 2004/11/09 14:13:00Z martin
158  * Updated function prototypes.
159  * Revision 1.12 2004/08/17 11:13:46Z martin
160  * Account for renamed symbols.
161  * Revision 1.11 2004/04/14 09:34:23Z martin
162  * New definition MBGDEVIO_COMPAT_VERSION.
163  * Pack structures 1 byte aligned.
164  * Revision 1.10 2003/12/22 15:35:10Z martin
165  * New revision 2.03.
166  * Moved some definitions to pcpsdev.h.
167  * New structures to read device time together with associated
168  * PC high resolution timer cycles.
169  * Updated function prototypes.
170  * Revision 1.9 2003/06/19 08:50:05Z martin
171  * Definition of MBGDEVIO_VERSION number to allow DLL
172  * API version checking.
173  * Replaced some defines by typedefs.
174  * Renamed USE_DOS_TSR to MBG_USE_DOS_TSR.
175  * New preprocessor symbol MBG_USE_KERNEL_DRIVER which
176  * is defined only for targets which use IOCTLs.
177  * Don't include pcps_dos.h here.
178  * Updated function prototypes.
179  * Revision 1.8 2003/05/16 08:44:26 MARTIN
180  * Cleaned up inclusion of headers.
181  * Removed obsolete definitions.
182  * Changes for direct access targets.
183  * Revision 1.7 2003/04/25 10:16:00 martin
184  * Updated inclusion of headers.
185  * Made prototypes available for all targets.
186  * Revision 1.6 2003/04/15 19:38:05Z martin
187  * Updated function prototypes.
188  * Revision 1.5 2003/04/09 13:44:53Z martin
189  * Use new common IOCTL codes from mbgioctl.h.
190  * Updated function prototypes.
191  * Revision 1.4 2002/09/06 11:06:35Z martin
192  * Updated function prototypes for Win32 API..
193  * Win32 compatibility macros to use old APIs with new functions.
194  * Support targets OS/2 and NetWare.
195  * Revision 1.3 2002/02/28 10:08:54Z MARTIN
196  * Syntax cleanup for Win32.
197  * Revision 1.2 2002/02/26 14:40:47 MARTIN
198  * Source code cleanup.
199  * Changes for DOS with and without TSR.
200  * Revision 1.1 2002/02/19 13:48:21 MARTIN
201  * Initial revision
202  *
203  **************************************************************************/
204 
205 #ifndef _MBGDEVIO_H
206 #define _MBGDEVIO_H
207 
208 
209 /* Other headers to be included */
210 
211 #include <mbg_tgt.h>
212 #include <mbg_arch.h>
213 #include <cfg_hlp.h>
214 #include <timeutil.h>
215 #include <mbgmutex.h>
216 #include <mbgerror.h>
217 #include <mbggeo.h>
218 #include <pcpsdev.h>
219 #include <pci_asic.h>
220 #include <use_pack.h>
221 
222 #include <time.h>
223 #include <stdio.h>
224 #include <errno.h>
225 
226 
227 #define MBGDEVIO_VERSION 0x0308
228 
229 #define MBGDEVIO_COMPAT_VERSION 0x0210
230 
231 
232 #if defined( MBG_TGT_WIN32 )
233 
234  #if !defined( MBGDEVIO_XHRT_API )
235  #define MBGDEVIO_XHRT_API 1
236  #endif
237 
238  #if !defined( MBGDEVIO_USE_THREAD_API )
239  #define MBGDEVIO_USE_THREAD_API 1
240  #endif
241 
242  #if !defined( MBGDEVIO_HAVE_THREAD_AFFINITY )
243  #define MBGDEVIO_HAVE_THREAD_AFFINITY 1
244  #endif
245 
246  #define MBGDEVIO_RET_VAL DWORD
247 
248 #elif defined( MBG_TGT_LINUX )
249 
250  #if !defined( MBGDEVIO_XHRT_API )
251  #define MBGDEVIO_XHRT_API 1
252  #endif
253 
254  // Thread support under Linux depends strongly on
255  // the versions of some libraries, so the symbols
256  // MBGDEVIO_USE_THREAD_API and MBGDEVIO_HAVE_THREAD_AFFINITY
257  // should be set in the project's Makefile, depending on the
258  // target envionment. Otherwise thread support is disabled
259  // as per default.
260 
261  #include <sys/ioctl.h>
262  #include <fcntl.h>
263  #include <sched.h>
264 
265  #if MBGDEVIO_USE_THREAD_API
266  #include <pthread.h>
267  #endif
268 
269 #elif defined( MBG_TGT_BSD )
270 
271  #include <sys/ioctl.h>
272  #include <fcntl.h>
273 
274 #elif defined( MBG_TGT_OS2 )
275 
276 #elif defined( MBG_TGT_QNX_NTO )
277 
278  #include <sys/types.h>
279  #include <sys/stat.h>
280  #include <fcntl.h>
281 
282  #include <pcpsdrvr.h>
283 
284 #elif defined( MBG_TGT_DOS )
285 
286  #if !defined( MBG_USE_DOS_TSR )
287  #define MBG_USE_DOS_TSR 1
288  #endif
289 
290  #include <pcpsdrvr.h>
291 
292 #else // other target OSs which access the hardware directly
293 
294  #include <pcpsdrvr.h>
295 
296 #endif
297 
298 
299 #if MBG_TGT_USE_IOCTL
300 
301  #include <mbgioctl.h>
302 
303  #include <stdlib.h>
304  #include <string.h>
305 
306 #endif
307 
308 
309 #if !defined( MBGDEVIO_XHRT_API )
310  #define MBGDEVIO_XHRT_API 0
311 #endif
312 
313 #if !defined( MBGDEVIO_USE_THREAD_API )
314  #define MBGDEVIO_USE_THREAD_API 0
315 #endif
316 
317 #if !defined( MBGDEVIO_HAVE_THREAD_AFFINITY )
318  #define MBGDEVIO_HAVE_THREAD_AFFINITY 0
319 #endif
320 
321 #if ( 0 && defined( DEBUG ) )
322  #define DEBUG_IOCTL_CALLS 1
323 #else
324  #define DEBUG_IOCTL_CALLS 0
325 #endif
326 
327 
328 #ifdef _MBGDEVIO
329  #define _ext
330  #define _DO_INIT
331 #else
332  #define _ext extern
333 #endif
334 
335 
336 /* Start of header body */
337 
338 #if defined( _USE_PACK )
339  #pragma pack( 1 ) // set byte alignment
340  #define _USING_BYTE_ALIGNMENT
341 #endif
342 
343 
344 #ifdef __cplusplus
345 extern "C" {
346 #endif
347 
348 #if MBG_TGT_USE_IOCTL // TODO should we use a different symbol to control this?
349 
350  typedef MBG_HANDLE MBG_DEV_HANDLE;
351 
352  #define MBG_INVALID_DEV_HANDLE MBG_INVALID_HANDLE
353 
354 #else // other target OSs which access the hardware directly
355 
357 
358  #define MBG_INVALID_DEV_HANDLE NULL
359 
360 #endif
361 
362 
363 #if !defined( MBGDEVIO_RET_VAL )
364  #define MBGDEVIO_RET_VAL int
365 #endif
366 
367 
368 #if !defined( _mbgdevio_cnv_ret_val )
369  #define _mbgdevio_cnv_ret_val( _v ) (_v)
370 #endif
371 
372 
387 typedef char MBG_DEV_FN[260]; // Conforming to MAX_PATH in Windows
388 
389 
390 #if MBG_TGT_HAS_DEV_FN_BASE
391 
392 #define MBGCLOCK_DEV_FN_BASE "/dev/mbgclock"
393 #define MBGCLOCK_DEV_FN_FMT MBGCLOCK_DEV_FN_BASE "%i"
394 
395 _ext const char mbg_dev_fn_base[]
396 #ifdef _DO_INIT
398 #endif
399 ;
400 
401 _ext const char mbg_dev_fn_fmt[]
402 #ifdef _DO_INIT
404 #endif
405 ;
406 
407 #endif
408 
409 
410 
411 // Definitions specific to the target OS
412 
413 #if defined( MBG_TGT_LINUX )
414 
415  #define MBG_PROCESS_ID pid_t
416  #define _mbg_get_current_process() 0
417 
418  // __cpu_set_t_defined used to be defined by GNU's glibc.
419  // However, at least with glibc-2.26 this doesn't seem to be
420  // the case anymore, so we test alternatively if CPU_SETSIZE
421  // is defined.
422  #if defined( __cpu_set_t_defined ) || defined( CPU_SETSIZE )
423  #define MBG_CPU_SET cpu_set_t
424  #define MBG_CPU_SET_SIZE CPU_SETSIZE
425  #define _mbg_cpu_clear( _ps ) CPU_ZERO( (_ps) )
426  #define _mbg_cpu_set( _i, _ps ) CPU_SET( (_i), (_ps) )
427  #define _mbg_cpu_isset( _i, _ps ) CPU_ISSET( (_i), (_ps) )
428  #endif
429 
430  #if MBGDEVIO_USE_THREAD_API
431  #define MBG_THREAD_ID pthread_t
432  #define _mbg_get_current_thread() 0
433  #define MBG_THREAD_FNC_ATTR // empty
434  #define MBG_THREAD_FNC_RET_VAL void *
435  #define _mbg_thread_exit( _v ) return (void *) (_v)
436  #endif
437 
438 #elif defined( MBG_TGT_WIN32 )
439 
440  #define MBG_PROCESS_ID HANDLE
441  #define _mbg_get_current_process() GetCurrentProcess()
442 
443  #define MBG_CPU_SET DWORD_PTR // Attention: this is not used as pointer!
444  #define MBG_CPU_SET_SIZE ( sizeof( MBG_CPU_SET ) * 8 )
445 
446  #define MBG_THREAD_ID HANDLE
447  #define _mbg_get_current_thread() GetCurrentThread()
448  #define MBG_THREAD_FNC_ATTR WINAPI
449  #define MBG_THREAD_FNC_RET_VAL DWORD
450  #define _mbg_thread_exit( _v ) ExitThread( _v ); return (_v)
451 
452 #endif // target specific
453 
454 
455 #if !defined( MBG_TGT_WIN32 )
456  #define FILETIME int // just a dummy to avoid build errors
457 #endif
458 
459 #if !defined( MBG_PROCESS_ID )
460  #define MBG_PROCESS_ID int
461 #endif
462 
463 #if !defined( _mbg_get_current_process )
464  #define _mbg_get_current_process() 0
465 #endif
466 
467 #if !defined( MBG_CPU_SET )
468  #define MBG_CPU_SET int
469 #endif
470 
471 #if !defined( MBG_CPU_SET_SIZE )
472  #define MBG_CPU_SET_SIZE ( sizeof( MBG_CPU_SET ) * 8 )
473 #endif
474 
475 #if !defined( _mbg_cpu_clear )
476  #define _mbg_cpu_clear( _ps ) ( *(_ps) = 0 )
477 #endif
478 
479 #if !defined( _mbg_cpu_set )
480  #define _mbg_cpu_set( _i, _ps ) ( *(_ps) |= ( (MBG_CPU_SET) 1UL << (_i) ) )
481 #endif
482 
483 #if !defined( _mbg_cpu_isset )
484  #define _mbg_cpu_isset( _i, _ps ) ( *(_ps) & ( 1UL << (_i) ) )
485 #endif
486 
487 
488 #if !defined( MBG_THREAD_ID )
489  #define MBG_THREAD_ID int
490 #endif
491 
492 #if !defined( _mbg_get_current_thread )
493  #define _mbg_get_current_thread() 0
494 #endif
495 
496 #if !defined( MBG_THREAD_FNC_ATTR )
497  #define MBG_THREAD_FNC_ATTR // empty
498 #endif
499 
500 #if !defined( MBG_THREAD_FNC_RET_VAL )
501  #define MBG_THREAD_FNC_RET_VAL void
502 #endif
503 
504 #if !defined( _mbg_thread_exit )
505  #define _mbg_thread_exit( _v ) _nop_macro_fnc()
506 #endif
507 
508 
509 
513 typedef struct
514 {
516  #if defined( MBG_TGT_WIN32 )
517  HANDLE exit_request;
518  #endif
519 
521 
522 
523 
527 typedef MBG_THREAD_FNC_RET_VAL MBG_THREAD_FNC_ATTR MBG_THREAD_FNC( void * );
528 
529 
530 
541 typedef struct
542 {
545 
546 } MBG_XHRT_VARS;
547 
548 
549 
560 typedef struct
561 {
566  int sleep_ms;
568  MBG_DEV_HANDLE dh;
569 
570 } MBG_XHRT_INFO;
571 
572 
573 
583 typedef struct
584 {
587 
589 
590 
591 
599 {
604 };
605 
606 
607 
616 
617 
629 {
630  char *dev_fn_ptr;
633 };
634 
635 
636 
648 
649 
661 {
662  char dev_name[40];
664 };
665 
666 
667 
845 typedef int _MBG_API MBG_CHK_SUPP_FNC( MBG_DEV_HANDLE dh );
846 
847 
848 
849 
850 /* ----- function prototypes begin ----- */
851 
852 /* This section was generated automatically */
853 /* by MAKEHDR, do not remove the comments. */
854 
870 
888  _MBG_API_ATTR int _MBG_API mbgdevio_check_version( int header_version ) ;
889 
911  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_receiver_info( MBG_DEV_HANDLE dh ) ;
912 
930  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_gps_data( MBG_DEV_HANDLE dh ) ;
931 
948  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_generic_io( MBG_DEV_HANDLE dh ) ;
949 
967  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_asic_version( MBG_DEV_HANDLE dh ) ;
968 
986  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_asic_features( MBG_DEV_HANDLE dh ) ;
987 
1009  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_xmr( MBG_DEV_HANDLE dh ) ;
1010 
1021  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_isa( MBG_DEV_HANDLE dh ) ;
1022 
1033  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_mca( MBG_DEV_HANDLE dh ) ;
1034 
1045  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_pci( MBG_DEV_HANDLE dh ) ;
1046 
1057  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_pci_express( MBG_DEV_HANDLE dh ) ;
1058 
1069  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_usb( MBG_DEV_HANDLE dh ) ;
1070 
1090  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_gnss( MBG_DEV_HANDLE dh ) ;
1091 
1108  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_gps( MBG_DEV_HANDLE dh ) ;
1109 
1129  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_dcf( MBG_DEV_HANDLE dh ) ;
1130 
1153  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_pzf( MBG_DEV_HANDLE dh ) ;
1154 
1169  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_msf( MBG_DEV_HANDLE dh ) ;
1170 
1185  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_wwvb( MBG_DEV_HANDLE dh ) ;
1186 
1198  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_jjy( MBG_DEV_HANDLE dh ) ;
1199 
1219  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_lwr( MBG_DEV_HANDLE dh ) ;
1220 
1238  _MBG_API_ATTR int _MBG_API mbg_chk_dev_is_tcr( MBG_DEV_HANDLE dh ) ;
1239 
1257  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_lan_intf( MBG_DEV_HANDLE dh ) ;
1258 
1277  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_ptp( MBG_DEV_HANDLE dh ) ;
1278 
1301  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_ptp_unicast( MBG_DEV_HANDLE dh ) ;
1302 
1319  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_hr_time( MBG_DEV_HANDLE dh ) ;
1320 
1337  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_fast_hr_timestamp( MBG_DEV_HANDLE dh ) ;
1338 
1357  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_time_scale( MBG_DEV_HANDLE dh ) ;
1358 
1359  /* (Intentionally excluded from Doxygen)
1360  * @brief Check if a device supports setting an event time
1361  *
1362  * This feature is only supported by some special custom firmware
1363  * to preset a %UTC time at which the clock is to generate an output signal.
1364  *
1365  * @note This function should be preferred over ::mbg_dev_has_event_time,
1366  * which has been deprecated.
1367  *
1368  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
1369  *
1370  * @return ::MBG_SUCCESS if the requested feature is supported, ::MBG_ERR_NOT_SUPP_BY_DEV
1371  * if not supported, or one of the other @ref MBG_ERROR_CODES
1372  *
1373  * @ingroup mbgdevio_chk_supp_fncs
1374  * @see ::mbg_set_event_time
1375  */
1376  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_event_time( MBG_DEV_HANDLE dh ) ;
1377 
1399  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_ucap( MBG_DEV_HANDLE dh ) ;
1400 
1419  _MBG_API_ATTR int _MBG_API mbg_chk_dev_can_clr_ucap_buff( MBG_DEV_HANDLE dh ) ;
1420 
1437  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_tzdl( MBG_DEV_HANDLE dh ) ;
1438 
1455  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_pcps_tzdl( MBG_DEV_HANDLE dh ) ;
1456 
1473  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_tzcode( MBG_DEV_HANDLE dh ) ;
1474 
1491  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_tz( MBG_DEV_HANDLE dh ) ;
1492 
1508  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_irig( MBG_DEV_HANDLE dh ) ;
1509 
1528  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_irig_tx( MBG_DEV_HANDLE dh ) ;
1529 
1544  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_irig_ctrl_bits( MBG_DEV_HANDLE dh ) ;
1545 
1561  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_raw_irig_data( MBG_DEV_HANDLE dh ) ;
1562 
1577  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_irig_time( MBG_DEV_HANDLE dh ) ;
1578 
1595  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_signal( MBG_DEV_HANDLE dh ) ;
1596 
1612  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_mod( MBG_DEV_HANDLE dh ) ;
1613 
1614  /* (Intentionally excluded from Doxygen)
1615  * @brief Check if a device supports higher baud rates than usual
1616  *
1617  * Check if a device provides a serial output that supports
1618  * higher baud rates than older cards, i.e. ::DEFAULT_BAUD_RATES_DCF_HS
1619  * rather than ::DEFAULT_BAUD_RATES_DCF.
1620  *
1621  * The call ::mbg_get_serial_settings takes care of this, so applications
1622  * which use that call as suggested don't need to use this call directly.
1623  *
1624  * @note This function should be preferred over ::mbg_dev_has_serial_hs,
1625  * which has been deprecated.
1626  *
1627  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
1628  *
1629  * @return ::MBG_SUCCESS if the requested feature is supported, ::MBG_ERR_NOT_SUPP_BY_DEV
1630  * if not supported, or one of the other @ref MBG_ERROR_CODES
1631  *
1632  * @ingroup mbgdevio_chk_supp_fncs
1633  * @see ::mbg_get_serial_settings
1634  */
1635  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_serial_hs( MBG_DEV_HANDLE dh ) ;
1636 
1652  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_synth( MBG_DEV_HANDLE dh ) ;
1653 
1671  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_gpio( MBG_DEV_HANDLE dh ) ;
1672 
1688  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_cab_len( MBG_DEV_HANDLE dh ) ;
1689 
1708  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_ref_offs( MBG_DEV_HANDLE dh ) ;
1709 
1728  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_opt_flags( MBG_DEV_HANDLE dh ) ;
1729 
1757  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_utc_parm( MBG_DEV_HANDLE dh ) ;
1758 
1779  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_corr_info( MBG_DEV_HANDLE dh ) ;
1780 
1800  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_tr_distance( MBG_DEV_HANDLE dh ) ;
1801 
1816  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_debug_status( MBG_DEV_HANDLE dh ) ;
1817 
1835  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_evt_log( MBG_DEV_HANDLE dh ) ;
1836 
1847  _MBG_API_ATTR int _MBG_API mbg_chk_dev_has_dac_ctrl( MBG_DEV_HANDLE dh ) ;
1848 
1863  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_receiver_info" ) _MBG_API mbg_dev_has_receiver_info( MBG_DEV_HANDLE dh, int *p ) ;
1864 
1879  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_gps_data" ) _MBG_API mbg_dev_has_gps_data( MBG_DEV_HANDLE dh, int *p ) ;
1880 
1895  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_generic_io" ) _MBG_API mbg_dev_has_generic_io( MBG_DEV_HANDLE dh, int *p ) ;
1896 
1911  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_asic_version" ) _MBG_API mbg_dev_has_asic_version( MBG_DEV_HANDLE dh, int *p ) ;
1912 
1928  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_asic_features" ) _MBG_API mbg_dev_has_asic_features( MBG_DEV_HANDLE dh, int *p ) ;
1929 
1945  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_xmr" ) _MBG_API mbg_dev_has_xmr( MBG_DEV_HANDLE dh, int *p ) ;
1946 
1961  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_gnss" ) _MBG_API mbg_dev_is_gnss( MBG_DEV_HANDLE dh, int *p ) ;
1962 
1977  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_gps" ) _MBG_API mbg_dev_is_gps( MBG_DEV_HANDLE dh, int *p ) ;
1978 
1993  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_dcf" ) _MBG_API mbg_dev_is_dcf( MBG_DEV_HANDLE dh, int *p ) ;
1994 
2009  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_pzf" ) _MBG_API mbg_dev_has_pzf( MBG_DEV_HANDLE dh, int *p ) ;
2010 
2025  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_msf" ) _MBG_API mbg_dev_is_msf( MBG_DEV_HANDLE dh, int *p ) ;
2026 
2041  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_wwvb" ) _MBG_API mbg_dev_is_wwvb( MBG_DEV_HANDLE dh, int *p ) ;
2042 
2057  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_lwr" ) _MBG_API mbg_dev_is_lwr( MBG_DEV_HANDLE dh, int *p ) ;
2058 
2073  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_tcr" ) _MBG_API mbg_dev_is_irig_rx( MBG_DEV_HANDLE dh, int *p ) ;
2074 
2089  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_lan_intf" ) _MBG_API mbg_dev_has_lan_intf( MBG_DEV_HANDLE dh, int *p ) ;
2090 
2105  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ptp" ) _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p ) ;
2106 
2121  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ptp_unicast" ) _MBG_API mbg_dev_has_ptp_unicast( MBG_DEV_HANDLE dh, int *p ) ;
2122 
2137  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_hr_time" ) _MBG_API mbg_dev_has_hr_time( MBG_DEV_HANDLE dh, int *p ) ;
2138 
2153  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_fast_hr_timestamp" ) _MBG_API mbg_dev_has_fast_hr_timestamp( MBG_DEV_HANDLE dh, int *p ) ;
2154 
2169  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_time_scale" ) _MBG_API mbg_dev_has_time_scale( MBG_DEV_HANDLE dh, int *p ) ;
2170 
2187  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_event_time" ) _MBG_API mbg_dev_has_event_time( MBG_DEV_HANDLE dh, int *p ) ;
2188 
2203  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ucap" ) _MBG_API mbg_dev_has_ucap( MBG_DEV_HANDLE dh, int *p ) ;
2204 
2218  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_can_clr_ucap_buff" ) _MBG_API mbg_dev_can_clr_ucap_buff( MBG_DEV_HANDLE dh, int *p ) ;
2219 
2234  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tzdl" ) _MBG_API mbg_dev_has_tzdl( MBG_DEV_HANDLE dh, int *p ) ;
2235 
2250  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_pcps_tzdl" ) _MBG_API mbg_dev_has_pcps_tzdl( MBG_DEV_HANDLE dh, int *p ) ;
2251 
2266  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tzcode" ) _MBG_API mbg_dev_has_tzcode( MBG_DEV_HANDLE dh, int *p ) ;
2267 
2282  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tz" ) _MBG_API mbg_dev_has_tz( MBG_DEV_HANDLE dh, int *p ) ;
2283 
2298  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_irig" ) _MBG_API mbg_dev_has_irig( MBG_DEV_HANDLE dh, int *p ) ;
2299 
2314  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_irig_tx" ) _MBG_API mbg_dev_has_irig_tx( MBG_DEV_HANDLE dh, int *p ) ;
2315 
2330  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_irig_ctrl_bits" ) _MBG_API mbg_dev_has_irig_ctrl_bits( MBG_DEV_HANDLE dh, int *p ) ;
2331 
2345  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_raw_irig_data" ) _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p ) ;
2346 
2361  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_irig_time" ) _MBG_API mbg_dev_has_irig_time( MBG_DEV_HANDLE dh, int *p ) ;
2362 
2377  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_signal" ) _MBG_API mbg_dev_has_signal( MBG_DEV_HANDLE dh, int *p ) ;
2378 
2393  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_mod" ) _MBG_API mbg_dev_has_mod( MBG_DEV_HANDLE dh, int *p ) ;
2394 
2395  /* (Intentionally excluded from Doxygen)
2396  * @brief Check if a device supports higher baud rates than usual
2397  *
2398  * Check if a device provides a serial output that supports
2399  * higher baud rates than older cards, i.e. ::DEFAULT_BAUD_RATES_DCF_HS
2400  * rather than ::DEFAULT_BAUD_RATES_DCF.
2401  *
2402  * @deprecated This function is deprecated, use ::mbg_chk_dev_has_serial_hs preferably.
2403  *
2404  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2405  * @param[out] p Pointer to an int which is updated if the API call succeeds.
2406  * The flag is set != 0 if the requested feature is supported, else 0.
2407  *
2408  * @return ::MBG_SUCCESS on success, if *p has been updated, else one of the @ref MBG_ERROR_CODES
2409  *
2410  * @ingroup mbgdevio_chk_supp_fncs_deprecated
2411  * @see ::mbg_chk_dev_has_serial_hs
2412  */
2413  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_serial_hs" ) _MBG_API mbg_dev_has_serial_hs( MBG_DEV_HANDLE dh, int *p ) ;
2414 
2429  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_synth" ) _MBG_API mbg_dev_has_synth( MBG_DEV_HANDLE dh, int *p ) ;
2430 
2445  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_gpio" ) _MBG_API mbg_dev_has_gpio( MBG_DEV_HANDLE dh, int *p ) ;
2446 
2461  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_cab_len" ) _MBG_API mbg_dev_has_cab_len( MBG_DEV_HANDLE dh, int *p ) ;
2462 
2477  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ref_offs" ) _MBG_API mbg_dev_has_ref_offs( MBG_DEV_HANDLE dh, int *p ) ;
2478 
2493  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_opt_flags" ) _MBG_API mbg_dev_has_opt_flags( MBG_DEV_HANDLE dh, int *p ) ;
2494 
2509  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_utc_parm" ) _MBG_API mbg_dev_has_utc_parm( MBG_DEV_HANDLE dh, int *p ) ;
2510 
2525  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_corr_info" ) _MBG_API mbg_dev_has_corr_info( MBG_DEV_HANDLE dh, int *p ) ;
2526 
2541  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tr_distance" ) _MBG_API mbg_dev_has_tr_distance( MBG_DEV_HANDLE dh, int *p ) ;
2542 
2557  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_debug_status" ) _MBG_API mbg_dev_has_debug_status( MBG_DEV_HANDLE dh, int *p ) ;
2558 
2573  _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_evt_log" ) _MBG_API mbg_dev_has_evt_log( MBG_DEV_HANDLE dh, int *p ) ;
2574 
2600  _MBG_API_ATTR int _MBG_API mbg_dev_fn_from_dev_idx( char *s, int max_len, int dev_idx ) ;
2601 
2618  _MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device( int dev_idx ) ;
2619 
2640  _MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device_by_dev_fn( const char *dev_fn ) ;
2641 
2665  _MBG_API_ATTR MBG_DEV_HANDLE _DEPRECATED_BY( "mbg_open_device_by_dev_fn" ) _MBG_API mbg_open_device_by_hw_id( const char *dev_fn ) ;
2666 
2680 
2704 
2716 
2737  _MBG_API_ATTR void _MBG_API mbg_split_dev_name( const MBG_DEV_NAME dev_name, char *type_name, size_t type_name_size, char *sernum, size_t sernum_size ) ;
2738 
2760  _MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device_by_name( const MBG_DEV_NAME srch_name, int selection_mode ) ;
2761 
2769  _MBG_API_ATTR void _MBG_API mbg_close_device( MBG_DEV_HANDLE *dev_handle ) ;
2770 
2779  _MBG_API_ATTR int _MBG_API mbg_get_drvr_info( MBG_DEV_HANDLE dh, PCPS_DRVR_INFO *p ) ;
2780 
2789  _MBG_API_ATTR int _MBG_API mbg_get_device_info( MBG_DEV_HANDLE dh, PCPS_DEV *p ) ;
2790 
2805  _MBG_API_ATTR int _MBG_API mbg_get_status_port( MBG_DEV_HANDLE dh, PCPS_STATUS_PORT *p ) ;
2806 
2807  /* (Intentionally excluded from Doxygen)
2808  * Generic read function which writes a command code to a device
2809  * and reads a number of replied data to a generic buffer.
2810  *
2811  * <b>Warning</b>: This is for debugging purposes only!
2812  * The specialized API calls should be used preferably.
2813  * Not all devices support each of the ::PC_GPS_COMMANDS.
2814  *
2815  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2816  * @param[in] cmd Can be any @ref PCPS_CMD_CODES "command code" supported by the device
2817  * @param[out] p Pointer to a buffer to be filled up
2818  * @param[in] size Size of the output buffer
2819  *
2820  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
2821  *
2822  * @see ::mbg_generic_write
2823  * @see ::mbg_generic_read_gps
2824  * @see ::mbg_generic_write_gps
2825  * @see ::mbg_generic_io
2826  */
2827  _MBG_API_ATTR int _MBG_API mbg_generic_read( MBG_DEV_HANDLE dh, int cmd, void *p, int size ) ;
2828 
2829  /* (Intentionally excluded from Doxygen)
2830  * Generic read function which writes a GPS command code to a device
2831  * and reads a number of data bytes back into a generic buffer.
2832  * The function ::mbg_chk_dev_has_gps_data can be used to check
2833  * whether this call is supported by a device.
2834  *
2835  * <b>Warning</b>: This is for debugging purposes only!
2836  * The specialized API calls should be used preferably.
2837  * Not all devices support each of the ::PC_GPS_COMMANDS.
2838  *
2839  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2840  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
2841  * @param[out] p Pointer to a buffer to be filled up
2842  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
2843  *
2844  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
2845  *
2846  * @see ::mbg_chk_dev_has_gps_data
2847  * @see ::mbg_generic_write_gps
2848  * @see ::mbg_generic_read
2849  * @see ::mbg_generic_write
2850  * @see ::mbg_generic_io
2851  */
2852  _MBG_API_ATTR int _MBG_API mbg_generic_read_gps( MBG_DEV_HANDLE dh, int cmd, void *p, int size ) ;
2853 
2854  /* (Intentionally excluded from Doxygen)
2855  * Generic write function which writes a command code plus an
2856  * associated number of data bytes to a device.
2857  *
2858  * <b>Warning</b>: This is for debugging purposes only!
2859  * The specialized API calls should be used preferably.
2860  * Not all devices support each of the ::PC_GPS_COMMANDS.
2861  *
2862  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2863  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
2864  * @param[in] p Pointer to a buffer of data to be written
2865  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
2866  *
2867  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
2868  *
2869  * @see ::mbg_generic_read
2870  * @see ::mbg_generic_read_gps
2871  * @see ::mbg_generic_write_gps
2872  * @see ::mbg_generic_io
2873  */
2874  _MBG_API_ATTR int _MBG_API mbg_generic_write( MBG_DEV_HANDLE dh, int cmd, const void *p, int size ) ;
2875 
2876  /* (Intentionally excluded from Doxygen)
2877  * Generic write function which writes a GPS command code plus an
2878  * associated number of data bytes to a device.
2879  * The function ::mbg_chk_dev_has_gps_data can be used to check
2880  * whether this call is supported by a device.
2881  *
2882  * <b>Warning</b>: This is for debugging purposes only!
2883  * The specialized API calls should be used preferably.
2884  * Not all devices support each of the ::PC_GPS_COMMANDS.
2885  *
2886  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2887  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
2888  * @param[in] p Pointer to a buffer of data to be written
2889  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
2890  *
2891  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
2892  *
2893  * @see ::mbg_chk_dev_has_gps_data
2894  * @see ::mbg_generic_read_gps
2895  * @see ::mbg_generic_read
2896  * @see ::mbg_generic_write
2897  * @see ::mbg_generic_io
2898  */
2899  _MBG_API_ATTR int _MBG_API mbg_generic_write_gps( MBG_DEV_HANDLE dh, int cmd, const void *p, int size ) ;
2900 
2901  /* (Intentionally excluded from Doxygen)
2902  * Write and/or read generic data to/from a device.
2903  * The function ::mbg_chk_dev_has_generic_io checks
2904  * whether this call is supported by a device.
2905  *
2906  * <b>Warning</b>: This call is for debugging purposes and internal use only!
2907  *
2908  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
2909  *
2910  * @see ::mbg_chk_dev_has_generic_io
2911  * @see ::mbg_generic_read
2912  * @see ::mbg_generic_write
2913  * @see ::mbg_generic_read_gps
2914  * @see ::mbg_generic_write_gps
2915  */
2916  _MBG_API_ATTR int _MBG_API mbg_generic_io( MBG_DEV_HANDLE dh, int type, const void *in_p, int in_sz, void *out_p, int out_sz ) ;
2917 
2939  _MBG_API_ATTR int _MBG_API mbg_get_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
2940 
2956  _MBG_API_ATTR int _MBG_API mbg_set_time( MBG_DEV_HANDLE dh, const PCPS_STIME *p ) ;
2957 
2982  _MBG_API_ATTR int _MBG_API mbg_get_sync_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
2983 
3002  _MBG_API_ATTR int _MBG_API mbg_get_time_sec_change( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
3003 
3025  _MBG_API_ATTR int _MBG_API mbg_get_hr_time( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p ) ;
3026 
3027  /* (Intentionally excluded from Doxygen )
3028  * Write a high resolution time stamp ::PCPS_TIME_STAMP to a device
3029  * to configure a %UTC time when the clock shall generate an event.
3030  * The API call ::mbg_chk_dev_has_event_time checks whether
3031  * this call is supported by a device.
3032  *
3033  * <b>Note:</b> This is only supported by some special firmware.
3034  *
3035  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
3036  * @param[in] p Pointer to a ::PCPS_TIME_STAMP structure to be written.
3037  *
3038  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
3039  *
3040  * @see ::mbg_chk_dev_has_event_time
3041  */
3042  _MBG_API_ATTR int _MBG_API mbg_set_event_time( MBG_DEV_HANDLE dh, const PCPS_TIME_STAMP *p ) ;
3043 
3061  _MBG_API_ATTR int _MBG_API mbg_get_serial( MBG_DEV_HANDLE dh, PCPS_SERIAL *p ) ;
3062 
3080  _MBG_API_ATTR int _MBG_API mbg_set_serial( MBG_DEV_HANDLE dh, const PCPS_SERIAL *p ) ;
3081 
3105  _MBG_API_ATTR int _MBG_API mbg_get_tzcode( MBG_DEV_HANDLE dh, PCPS_TZCODE *p ) ;
3106 
3130  _MBG_API_ATTR int _MBG_API mbg_set_tzcode( MBG_DEV_HANDLE dh, const PCPS_TZCODE *p ) ;
3131 
3155  _MBG_API_ATTR int _MBG_API mbg_get_pcps_tzdl( MBG_DEV_HANDLE dh, PCPS_TZDL *p ) ;
3156 
3179  _MBG_API_ATTR int _MBG_API mbg_set_pcps_tzdl( MBG_DEV_HANDLE dh, const PCPS_TZDL *p ) ;
3180 
3199  _MBG_API_ATTR int _MBG_API mbg_get_ref_offs( MBG_DEV_HANDLE dh, MBG_REF_OFFS *p ) ;
3200 
3219  _MBG_API_ATTR int _MBG_API mbg_set_ref_offs( MBG_DEV_HANDLE dh, const MBG_REF_OFFS *p ) ;
3220 
3238  _MBG_API_ATTR int _MBG_API mbg_get_opt_info( MBG_DEV_HANDLE dh, MBG_OPT_INFO *p ) ;
3239 
3257  _MBG_API_ATTR int _MBG_API mbg_set_opt_settings( MBG_DEV_HANDLE dh, const MBG_OPT_SETTINGS *p ) ;
3258 
3281  _MBG_API_ATTR int _MBG_API mbg_get_irig_rx_info( MBG_DEV_HANDLE dh, IRIG_INFO *p ) ;
3282 
3307  _MBG_API_ATTR int _MBG_API mbg_set_irig_rx_settings( MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p ) ;
3308 
3325  _MBG_API_ATTR int _MBG_API mbg_get_all_irig_rx_info( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info ) ;
3326 
3348  _MBG_API_ATTR int _MBG_API mbg_save_all_irig_rx_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings ) ;
3349 
3380  _MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p ) ;
3381 
3400  _MBG_API_ATTR int _MBG_API mbg_get_raw_irig_data( MBG_DEV_HANDLE dh, MBG_RAW_IRIG_DATA *p ) ;
3401 
3425 
3444  _MBG_API_ATTR int _MBG_API mbg_get_irig_time( MBG_DEV_HANDLE dh, PCPS_IRIG_TIME *p ) ;
3445 
3460  _MBG_API_ATTR int _MBG_API mbg_clr_ucap_buff( MBG_DEV_HANDLE dh ) ;
3461 
3481  _MBG_API_ATTR int _MBG_API mbg_get_ucap_entries( MBG_DEV_HANDLE dh, PCPS_UCAP_ENTRIES *p ) ;
3482 
3508  _MBG_API_ATTR int _MBG_API mbg_get_ucap_event( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p ) ;
3509 
3534  _MBG_API_ATTR int _MBG_API mbg_get_gps_tzdl( MBG_DEV_HANDLE dh, TZDL *p ) ;
3535 
3560  _MBG_API_ATTR int _MBG_API mbg_set_gps_tzdl( MBG_DEV_HANDLE dh, const TZDL *p ) ;
3561 
3584  _MBG_API_ATTR int _MBG_API mbg_get_gps_sw_rev( MBG_DEV_HANDLE dh, SW_REV *p ) ;
3585 
3612  _MBG_API_ATTR int _MBG_API mbg_get_gps_bvar_stat( MBG_DEV_HANDLE dh, BVAR_STAT *p ) ;
3613 
3631  _MBG_API_ATTR int _MBG_API mbg_get_gps_time( MBG_DEV_HANDLE dh, TTM *p ) ;
3632 
3649  _MBG_API_ATTR int _MBG_API mbg_set_gps_time( MBG_DEV_HANDLE dh, const TTM *p ) ;
3650 
3671  _MBG_API_ATTR int _MBG_API mbg_get_gps_port_parm( MBG_DEV_HANDLE dh, PORT_PARM *p ) ;
3672 
3693  _MBG_API_ATTR int _MBG_API mbg_set_gps_port_parm( MBG_DEV_HANDLE dh, const PORT_PARM *p ) ;
3694 
3712  _MBG_API_ATTR int _MBG_API mbg_get_gps_ant_info( MBG_DEV_HANDLE dh, ANT_INFO *p ) ;
3713 
3734  _MBG_API_ATTR int _MBG_API mbg_get_gps_ucap( MBG_DEV_HANDLE dh, TTM *p ) ;
3735 
3759  _MBG_API_ATTR int _MBG_API mbg_get_gps_enable_flags( MBG_DEV_HANDLE dh, ENABLE_FLAGS *p ) ;
3760 
3784  _MBG_API_ATTR int _MBG_API mbg_set_gps_enable_flags( MBG_DEV_HANDLE dh, const ENABLE_FLAGS *p ) ;
3785 
3802  _MBG_API_ATTR int _MBG_API mbg_get_gps_stat_info( MBG_DEV_HANDLE dh, STAT_INFO *p ) ;
3803 
3817  _MBG_API_ATTR int _MBG_API mbg_set_gps_cmd( MBG_DEV_HANDLE dh, const GPS_CMD *p ) ;
3818 
3838  _MBG_API_ATTR int _MBG_API mbg_get_gps_pos( MBG_DEV_HANDLE dh, POS *p ) ;
3839 
3857  _MBG_API_ATTR int _MBG_API mbg_set_gps_pos_xyz( MBG_DEV_HANDLE dh, const XYZ p ) ;
3858 
3876  _MBG_API_ATTR int _MBG_API mbg_set_gps_pos_lla( MBG_DEV_HANDLE dh, const LLA p ) ;
3877 
3896  _MBG_API_ATTR int _MBG_API mbg_get_gps_ant_cable_len( MBG_DEV_HANDLE dh, ANT_CABLE_LEN *p ) ;
3897 
3920  _MBG_API_ATTR int _MBG_API mbg_set_gps_ant_cable_len( MBG_DEV_HANDLE dh, const ANT_CABLE_LEN *p ) ;
3921 
3940  _MBG_API_ATTR int _MBG_API mbg_get_gps_receiver_info( MBG_DEV_HANDLE dh, RECEIVER_INFO *p ) ;
3941 
3961  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_str_type_info( MBG_DEV_HANDLE dh, STR_TYPE_INFO_IDX stii[], const RECEIVER_INFO *p_ri ) ;
3962 
3982  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_port_info( MBG_DEV_HANDLE dh, PORT_INFO_IDX pii[], const RECEIVER_INFO *p_ri ) ;
3983 
4006  _MBG_API_ATTR int _MBG_API mbg_set_gps_port_settings_idx( MBG_DEV_HANDLE dh, const PORT_SETTINGS_IDX *p ) ;
4007 
4031  _MBG_API_ATTR int _MBG_API mbg_set_gps_port_settings( MBG_DEV_HANDLE dh, const PORT_SETTINGS *p, int idx ) ;
4032 
4056  _MBG_API_ATTR int _MBG_API mbg_setup_receiver_info( MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_INFO *p ) ;
4057 
4071  _MBG_API_ATTR int _MBG_API mbg_get_asic_version( MBG_DEV_HANDLE dh, PCI_ASIC_VERSION *p ) ;
4072 
4086  _MBG_API_ATTR int _MBG_API mbg_get_asic_features( MBG_DEV_HANDLE dh, PCI_ASIC_FEATURES *p ) ;
4087 
4107  _MBG_API_ATTR int _MBG_API mbg_get_time_scale_info( MBG_DEV_HANDLE dh, MBG_TIME_SCALE_INFO *p ) ;
4108 
4131  _MBG_API_ATTR int _MBG_API mbg_set_time_scale_settings( MBG_DEV_HANDLE dh, const MBG_TIME_SCALE_SETTINGS *p ) ;
4132 
4149  _MBG_API_ATTR int _MBG_API mbg_get_utc_parm( MBG_DEV_HANDLE dh, UTC *p ) ;
4150 
4172  _MBG_API_ATTR int _MBG_API mbg_set_utc_parm( MBG_DEV_HANDLE dh, const UTC *p ) ;
4173 
4206  _MBG_API_ATTR int _MBG_API mbg_get_time_cycles( MBG_DEV_HANDLE dh, PCPS_TIME_CYCLES *p ) ;
4207 
4244  _MBG_API_ATTR int _MBG_API mbg_get_hr_time_cycles( MBG_DEV_HANDLE dh, PCPS_HR_TIME_CYCLES *p ) ;
4245 
4283  _MBG_API_ATTR int _MBG_API mbg_get_hr_time_comp( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p, int32_t *hns_latency ) ;
4284 
4305  _MBG_API_ATTR int _MBG_API mbg_get_irig_tx_info( MBG_DEV_HANDLE dh, IRIG_INFO *p ) ;
4306 
4324  _MBG_API_ATTR int _MBG_API mbg_set_irig_tx_settings( MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p ) ;
4325 
4345  _MBG_API_ATTR int _MBG_API mbg_get_synth( MBG_DEV_HANDLE dh, SYNTH *p ) ;
4346 
4366  _MBG_API_ATTR int _MBG_API mbg_set_synth( MBG_DEV_HANDLE dh, const SYNTH *p ) ;
4367 
4384  _MBG_API_ATTR int _MBG_API mbg_get_synth_state( MBG_DEV_HANDLE dh, SYNTH_STATE *p ) ;
4385 
4401 
4420  _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_comp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p, int32_t *hns_latency ) ;
4421 
4442  _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p ) ;
4443 
4469  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_pout_info( MBG_DEV_HANDLE dh, POUT_INFO_IDX pii[], const RECEIVER_INFO *p_ri ) ;
4470 
4490  _MBG_API_ATTR int _MBG_API mbg_set_gps_pout_settings_idx( MBG_DEV_HANDLE dh, const POUT_SETTINGS_IDX *p ) ;
4491 
4513  _MBG_API_ATTR int _MBG_API mbg_set_gps_pout_settings( MBG_DEV_HANDLE dh, const POUT_SETTINGS *p, int idx ) ;
4514 
4529  _MBG_API_ATTR int _MBG_API mbg_get_irq_stat_info( MBG_DEV_HANDLE dh, PCPS_IRQ_STAT_INFO *p ) ;
4530 
4547  _MBG_API_ATTR int _MBG_API mbg_get_lan_if_info( MBG_DEV_HANDLE dh, LAN_IF_INFO *p ) ;
4548 
4565  _MBG_API_ATTR int _MBG_API mbg_get_ip4_state( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
4566 
4583  _MBG_API_ATTR int _MBG_API mbg_get_ip4_settings( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
4584 
4600  _MBG_API_ATTR int _MBG_API mbg_set_ip4_settings( MBG_DEV_HANDLE dh, const IP4_SETTINGS *p ) ;
4601 
4619  _MBG_API_ATTR int _MBG_API mbg_get_ptp_state( MBG_DEV_HANDLE dh, PTP_STATE *p ) ;
4620 
4638  _MBG_API_ATTR int _MBG_API mbg_get_ptp_cfg_info( MBG_DEV_HANDLE dh, PTP_CFG_INFO *p ) ;
4639 
4657  _MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p ) ;
4658 
4677 
4697 
4716 
4742  _MBG_API_ATTR int _MBG_API mbg_get_time_info_hrt( MBG_DEV_HANDLE dh, MBG_TIME_INFO_HRT *p ) ;
4743 
4761 
4776  _MBG_API_ATTR int _MBG_API mbg_get_corr_info( MBG_DEV_HANDLE dh, CORR_INFO *p ) ;
4777 
4796  _MBG_API_ATTR int _MBG_API mbg_get_tr_distance( MBG_DEV_HANDLE dh, TR_DISTANCE *p ) ;
4797 
4816  _MBG_API_ATTR int _MBG_API mbg_set_tr_distance( MBG_DEV_HANDLE dh, const TR_DISTANCE *p ) ;
4817 
4837  _MBG_API_ATTR int _MBG_API mbg_get_debug_status( MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p ) ;
4838 
4854  _MBG_API_ATTR int _MBG_API mbg_clr_evt_log( MBG_DEV_HANDLE dh ) ;
4855 
4877 
4900 
4924 
4945  _MBG_API_ATTR int _MBG_API mbg_get_gps_gnss_mode_info( MBG_DEV_HANDLE dh, MBG_GNSS_MODE_INFO *p_mi ) ;
4946 
4970  _MBG_API_ATTR int _MBG_API mbg_set_gps_gnss_mode_settings( MBG_DEV_HANDLE dh, const MBG_GNSS_MODE_SETTINGS *p_ms ) ;
4971 
4988  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_gnss_sat_info( MBG_DEV_HANDLE dh, GNSS_SAT_INFO_IDX gsii[], const MBG_GNSS_MODE_INFO *p_mi ) ;
4989 
5007  _MBG_API_ATTR int _MBG_API mbg_get_gpio_cfg_limits( MBG_DEV_HANDLE dh, MBG_GPIO_CFG_LIMITS *p ) ;
5008 
5027  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_gpio_info( MBG_DEV_HANDLE dh, MBG_GPIO_INFO_IDX gii[], const MBG_GPIO_CFG_LIMITS *p_gcl ) ;
5028 
5049  _MBG_API_ATTR int _MBG_API mbg_set_gps_gpio_settings_idx( MBG_DEV_HANDLE dh, const MBG_GPIO_SETTINGS_IDX *p ) ;
5050 
5065  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_gpio_status( MBG_DEV_HANDLE dh, MBG_GPIO_STATUS_IDX gsi[], const MBG_GPIO_CFG_LIMITS *p_gcl ) ;
5066 
5081  _MBG_API_ATTR int _MBG_API mbg_get_xmr_instances( MBG_DEV_HANDLE dh, XMULTI_REF_INSTANCES *p ) ;
5082 
5098  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_xmr_status( MBG_DEV_HANDLE dh, XMULTI_REF_STATUS_IDX xmrsi[], const XMULTI_REF_INSTANCES *p_xmri ) ;
5099 
5115  _MBG_API_ATTR int _MBG_API mbg_get_gps_all_xmr_info( MBG_DEV_HANDLE dh, XMULTI_REF_INFO_IDX xmrii[], const XMULTI_REF_INSTANCES *p_xmri ) ;
5116 
5137  _MBG_API_ATTR int _MBG_API mbg_set_gps_xmr_settings_idx( MBG_DEV_HANDLE dh, const XMULTI_REF_SETTINGS_IDX *p ) ;
5138 
5157  _MBG_API_ATTR int _MBG_API mbg_get_xmr_holdover_status( MBG_DEV_HANDLE dh, XMR_HOLDOVER_STATUS *p, const XMULTI_REF_INSTANCES *p_xmri ) ;
5158 
5174 
5190 
5204 
5221 
5238 
5259 
5278 
5302  _MBG_API_ATTR int _MBG_API mbg_xhrt_poll_thread_create( MBG_POLL_THREAD_INFO *p_pti, MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY freq_hz, int sleep_ms ) ;
5303 
5319 
5344 
5370 
5394 
5408 
5421 
5422 
5423 /* ----- function prototypes end ----- */
5424 
5425 
5426 #if defined( MBG_TGT_WIN32 )
5427 
5428 static __mbg_inline
5429 MBGDEVIO_RET_VAL do_mbg_ioctl( MBG_DEV_HANDLE dh, int ioctl_code,
5430  const void *in_p, int in_sz, void *out_p, int out_sz )
5431 {
5432  DWORD ReturnedLength = 0;
5433 
5434  if ( !DeviceIoControl( dh, ioctl_code,
5435  (LPVOID) in_p, in_sz, out_p, out_sz,
5436  &ReturnedLength,
5437  NULL
5438  ) )
5439  {
5440  DWORD last_error = GetLastError();
5441  int rc = mbg_win32_sys_err_to_mbg( last_error, NULL );
5442 
5443  #if 0 //### TODO FIXME
5444  // We can't call mbgsvctl_log_mbgdevio_error() here (for now).
5445  // Is is defined in mbgsvctl.h, and including mbgsvctl.h here,
5446  // or copying the prototype here results in DLL import/export
5447  // mismatch errors.
5448 
5449  // do not report a USB device timeout error
5450  if ( rc != MBG_ERR_USB_ACCESS )
5451  mbgsvctl_log_mbgdevio_error( ioctl_code, rc );
5452  #endif
5453 
5454  return rc;
5455  }
5456 
5457  return MBG_SUCCESS;
5458 
5459 } // do_mbg_ioctl
5460 
5461  #define _do_mbg_ioctl( _dh, _ioctl, _p, _in_sz, _out_sz ) \
5462  do_mbg_ioctl( _dh, _ioctl, (LPVOID) _p, _in_sz, (LPVOID) _p, _out_sz )
5463 
5464 #elif defined( MBG_HAS_POSIX_IOCTL )
5465 
5466  // In case of an error ioctl returns -1, and errno has been set
5467  // to a *positive* POSIX error code.
5468 
5469  static __mbg_inline
5470  MBGDEVIO_RET_VAL do_mbg_ioctl( MBG_DEV_HANDLE dh, unsigned long ioctl_code, const void *p )
5471  {
5472  int sys_rc = ioctl( dh, ioctl_code, (void *) p );
5473 
5474  if ( sys_rc == -1 ) // error
5475  {
5476  int sys_errno = errno;
5477  int rc = mbg_posix_errno_to_mbg( sys_errno, NULL );
5478 
5479  #if DEBUG_IOCTL_CALLS
5480  fprintf( stderr, "IOCTL %s (0x%08lX) error: %s (errno: %i) --> %s (rc: %i)\n",
5481  mbgioctl_get_name( ioctl_code ), (ulong) ioctl_code,
5482  strerror( sys_errno ), sys_errno,
5483  mbg_strerror( rc ), rc );
5484  #endif
5485 
5486  return rc;
5487  }
5488 
5489  return MBG_SUCCESS;
5490  }
5491 
5492  #define _do_mbg_ioctl( _dh, _ioctl, _p, _in_sz, _out_sz ) \
5493  do_mbg_ioctl( _dh, _ioctl, _p )
5494 
5495 #endif
5496 
5497 
5498 
5499 // The code below depends on whether the target device is accessed via
5500 // IOCTLs to a device driver, or the hardware is accessed directly.
5501 
5502 #if MBG_TGT_USE_IOCTL
5503 
5523  static __mbg_inline
5524  int mbgdevio_do_gen_io( MBG_DEV_HANDLE dh, int info, unsigned int ioctl_code,
5525  const void *in_p, int in_sz,
5526  void *out_p, int out_sz )
5527  {
5528  MBGDEVIO_RET_VAL rc;
5529 
5530  // Generic IOCTL calls always need to pass some info beside
5531  // the I/O buffers down to the driver, which usually is
5532  // the command code for the device.
5533  // Thus we must always use one of the control structures
5534  // IOCTL_GENERIC_REQ or IOCTL_GENERIC_BUFFER, whichever
5535  // is appropriate for the target OS.
5536 
5537  #if USE_IOCTL_GENERIC_REQ
5538 
5539  IOCTL_GENERIC_REQ req = { 0 };
5540 
5541  req.in_p = (uintptr_t) in_p;
5542  req.out_p = (uintptr_t) out_p;
5543  req.in_sz = in_sz;
5544  req.out_sz = out_sz;
5545  req.info = info;
5546 
5547  #if DEBUG_IOCTL_CALLS
5548  printf( "inp: %p --> 0x%" PRIx64 " (%lu)\n", in_p, req.in_p, (ulong) req.in_sz );
5549  printf( "outp: %p --> 0x%" PRIx64 " (%lu)\n", out_p, req.out_p, (ulong) req.out_sz );
5550  #endif
5551 
5552  rc = _do_mbg_ioctl( dh, ioctl_code, &req, sizeof( req ), 0 );
5553 
5554  #else
5555 
5556  IOCTL_GENERIC_BUFFER *p_buff;
5557  int buff_size = sizeof( p_buff->ctl )
5558  + ( ( in_sz > out_sz ) ? in_sz : out_sz );
5559 
5560  p_buff = (IOCTL_GENERIC_BUFFER *) malloc( buff_size );
5561 
5562  if ( p_buff == NULL )
5563  return MBG_ERR_NO_MEM;
5564 
5565  p_buff->ctl.info = info;
5566  p_buff->ctl.data_size_in = in_sz;
5567  p_buff->ctl.data_size_out = out_sz;
5568 
5569  if ( in_p )
5570  memcpy( p_buff->data, in_p, in_sz );
5571 
5572  rc = _do_mbg_ioctl( dh, ioctl_code, p_buff,
5573  sizeof( IOCTL_GENERIC_CTL ) + in_sz,
5574  sizeof( IOCTL_GENERIC_CTL ) + out_sz );
5575 
5576  if ( out_p && ( rc == MBG_SUCCESS ) )
5577  memcpy( out_p, p_buff->data, out_sz );
5578 
5579  free( p_buff );
5580 
5581  #endif
5582 
5583  return _mbgdevio_cnv_ret_val( rc );
5584 
5585  } // mbgdevio_do_gen_io
5586 
5587 
5588 
5589  #define _do_mbgdevio_read( _dh, _cmd, _ioctl, _p, _sz ) \
5590  _do_mbg_ioctl( _dh, _ioctl, _p, 0, _sz )
5591 
5592  #define _do_mbgdevio_write( _dh, _cmd, _ioctl, _p, _sz ) \
5593  _do_mbg_ioctl( _dh, _ioctl, _p, _sz, 0 )
5594 
5595  #define _do_mbgdevio_read_gps _do_mbgdevio_read
5596 
5597  #define _do_mbgdevio_write_gps _do_mbgdevio_write
5598 
5599 
5600 
5601  #define _mbgdevio_read_var( _dh, _cmd, _ioctl, _p ) \
5602  _do_mbgdevio_read( _dh, _cmd, _ioctl, _p, sizeof( *(_p) ) )
5603 
5604  #define _mbgdevio_write_var( _dh, _cmd, _ioctl, _p ) \
5605  _do_mbgdevio_write( _dh, _cmd, _ioctl, _p, sizeof( *(_p) ) )
5606 
5607  #define _mbgdevio_write_cmd( _dh, _cmd, _ioctl ) \
5608  _do_mbgdevio_write( _dh, _cmd, _ioctl, NULL, 0 )
5609 
5610  #define _mbgdevio_read_gps _do_mbgdevio_read
5611  #define _mbgdevio_read_gps_var _mbgdevio_read_var
5612 
5613  #define _mbgdevio_write_gps _do_mbgdevio_write
5614  #define _mbgdevio_write_gps_var _mbgdevio_write_var
5615 
5616 
5617  #define _mbgdevio_gen_read( _dh, _cmd, _p, _sz ) \
5618  mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_READ, NULL, 0, _p, _sz )
5619 
5620  #define _mbgdevio_gen_write( _dh, _cmd, _p, _sz ) \
5621  mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_WRITE, _p, _sz, NULL, 0 )
5622 
5623  #define _mbgdevio_gen_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz ) \
5624  mbgdevio_do_gen_io( _dh, _type, IOCTL_PCPS_GENERIC_IO, _in_p, _in_sz, _out_p, _out_sz )
5625 
5626  #define _mbgdevio_gen_read_gps( _dh, _cmd, _p, _sz ) \
5627  mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_READ_GPS, NULL, 0, _p, _sz )
5628 
5629  #define _mbgdevio_gen_write_gps( _dh, _cmd, _p, _sz ) \
5630  mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_WRITE_GPS, _p, _sz, NULL, 0 )
5631 
5632 
5633 #else // !MBG_TGT_USE_IOCTL, accessing hardware device directly
5634 
5635  #define _mbgdevio_chk_cond( _cond ) \
5636  { \
5637  if ( !(_cond) ) \
5638  return MBG_ERR_NOT_SUPP_BY_DEV; \
5639  }
5640 
5641  #define _mbgdevio_read( _dh, _cmd, _ioctl, _p, _sz ) \
5642  pcps_read_safe( _dh, _cmd, _p, _sz )
5643 
5644  #define _mbgdevio_write( _dh, _cmd, _ioctl, _p, _sz ) \
5645  pcps_write_safe( _dh, _cmd, _p, _sz )
5646 
5647  #define _do_mbgdevio_read_gps( _dh, _cmd, _ioctl, _p, _sz ) \
5648  pcps_read_gps_safe( _dh, _cmd, _p, _sz )
5649 
5650  #define _mbgdevio_write_gps( _dh, _cmd, _ioctl, _p, _sz ) \
5651  pcps_write_gps_safe( _dh, _cmd, _p, _sz )
5652 
5653 
5654 
5655 //##+++++++++++++++++++
5656  #define _mbgdevio_read_var( _dh, _cmd, _ioctl, _p ) \
5657  _pcps_read_var_safe( _dh, _cmd, *(_p) )
5658 
5659  #define _mbgdevio_write_var( _dh, _cmd, _ioctl, _p ) \
5660  _pcps_write_var_safe( _dh, _cmd, *(_p) )
5661 
5662  #define _mbgdevio_write_cmd( _dh, _cmd, _ioctl ) \
5663  _pcps_write_byte_safe( _dh, _cmd );
5664 
5665  #define _mbgdevio_read_gps_var( _dh, _cmd, _ioctl, _p ) \
5666  _pcps_read_gps_var_safe( _dh, _cmd, *(_p) )
5667 
5668  #define _mbgdevio_write_gps_var( _dh, _cmd, _ioctl, _p ) \
5669  _pcps_write_gps_var_safe( _dh, _cmd, *(_p) )
5670 
5671 
5672  #define _mbgdevio_gen_read( _dh, _cmd, _p, _sz ) \
5673  _mbgdevio_read( _dh, _cmd, -1, _p, _sz )
5674 
5675  #define _mbgdevio_gen_write( _dh, _cmd, _p, _sz ) \
5676  _mbgdevio_write( _dh, _cmd, -1, _p, _sz )
5677 
5678  #define _mbgdevio_gen_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz ) \
5679  pcps_generic_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz );
5680 
5681  #define _mbgdevio_gen_read_gps( _dh, _cmd, _p, _sz ) \
5682  _do_mbgdevio_read_gps( _dh, _cmd, -1, _p, _sz )
5683 
5684  #define _mbgdevio_gen_write_gps( _dh, _cmd, _p, _sz ) \
5685  _mbgdevio_write_gps( _dh, _cmd, -1, _p, _sz )
5686 
5687 #endif // !MBG_TGT_USE_IOCTL
5688 
5689 
5690 
5691 #define _mbg_generic_read_var( _dh, _cmd, _s ) \
5692  mbg_generic_read( _dh, _cmd, &(_s), sizeof( (_s) ) )
5693 
5694 #define _mbg_generic_write_var( _dh, _cmd, _s ) \
5695  mbg_generic_write( _dh, _cmd, &(_s), sizeof( (_s) ) )
5696 
5697 #define _mbg_generic_read_gps_var( _dh, _cmd, _s ) \
5698  mbg_generic_read_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
5699 
5700 #define _mbg_generic_write_gps_var( _dh, _cmd, _s ) \
5701  mbg_generic_write_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
5702 
5703 
5704 
5705 #define _mbgdevio_gen_read_var( _dh, _cmd, _s ) \
5706  _mbgdevio_gen_read( _dh, _cmd, &(_s), sizeof( (_s) ) )
5707 
5708 #define _mbgdevio_gen_write_var( _dh, _cmd, _s ) \
5709  _mbgdevio_gen_write( _dh, _cmd, &(_s), sizeof( (_s) ) )
5710 
5711 #define _mbgdevio_gen_read_gps_var( _dh, _cmd, _s ) \
5712  _mbgdevio_gen_read_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
5713 
5714 #define _mbgdevio_gen_write_gps_var( _dh, _cmd, _s ) \
5715  _mbgdevio_gen_write_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
5716 
5717 
5718 
5719 #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_POSIX )
5720 
5721 // NOTE
5722 // For some reason the code below causes an internal compiler error
5723 // with Borland C++Builder 5.0 release builds. Since we don't need
5724 // this function in the BC5 projects anyway we simply exclude it
5725 // from build.
5726 
5727 #if !defined( __BORLANDC__ )
5728 
5729 static __mbg_inline
5731 {
5732  if ( *status & ( PCPS_LS_ANN | PCPS_LS_ENB ) )
5733  {
5734  struct tm tm = { 0 };
5735  time_t t = cvt_to_time_t( (uint32_t) ( (*tstamp64) >> 32 ) );
5736  int rc = mbg_gmtime( &tm, &t );
5737 
5738  if ( mbg_rc_is_success( rc ) )
5739  {
5740  // Handle leap second and status
5741  if ( tm.tm_hour == 0 && tm.tm_min == 0 && tm.tm_sec == 0 )
5742  {
5743  if ( *status & PCPS_LS_ANN )
5744  {
5745  // Set leap second enabled flag on rollover to the leap second and clear announce flag
5746  *status &= ~PCPS_LS_ANN;
5747  *status |= PCPS_LS_ENB;
5748 
5749  // Decrement interpolated second to avoid automated overflow during the leap second.
5750  // Second 59 appears for the second time.
5751  *tstamp64 -= MBG_FRAC32_UNITS_PER_SEC;
5752  }
5753  else
5754  if ( *status & PCPS_LS_ENB ) // Clear bits when leap second expires and 0:00:00 UTC is reached
5755  *status &= ~( PCPS_LS_ANN | PCPS_LS_ENB );
5756  }
5757  }
5758  }
5759 
5760 } // mbg_chk_tstamp64_leap_sec
5761 
5762 #endif // !defined( __BORLANDC__ )
5763 
5764 #endif // defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_POSIX )
5765 
5766 
5767 
5768 static __mbg_inline
5770 {
5771  if ( *p == 0 )
5773 
5774 } // mbg_init_pc_cycles_frequency
5775 
5776 
5777 
5778 #if MBG_TGT_HAS_64BIT_TYPES
5779 
5780 static __mbg_inline
5781 uint64_t pcps_time_stamp_to_uint64( const PCPS_TIME_STAMP *ts )
5782 {
5783  return ( ( (uint64_t) ts->sec ) << 32 ) + ts->frac;
5784 
5785 } // pcps_time_stamp_to_uint64
5786 
5787 
5788 
5789 static __mbg_inline
5790 void uint64_to_pcps_time_stamp( PCPS_TIME_STAMP *ts, uint64_t n )
5791 {
5792  ts->sec = (uint32_t) ( n >> 32 );
5793  ts->frac = (uint32_t) ( n & 0xFFFFFFFFUL );
5794 
5795 } // uint64_to_pcps_time_stamp
5796 
5797 #endif
5798 
5799 
5800 #ifdef __cplusplus
5801 }
5802 #endif
5803 
5804 #if defined( _USING_BYTE_ALIGNMENT )
5805  #pragma pack() // set default alignment
5806  #undef _USING_BYTE_ALIGNMENT
5807 #endif
5808 
5809 /* End of header body */
5810 
5811 
5812 #undef _ext
5813 #undef _DO_INIT
5814 
5815 #endif /* _MBGDEVIO_H */
5816 
#define _ext
Definition: mbgdevio.h:332
int mbg_set_event_time(MBG_DEV_HANDLE dh, const PCPS_TIME_STAMP *p)
Definition: mbgdevio.c:4653
A generic thread info structure.
Definition: mbgdevio.h:513
int mbg_dev_has_raw_irig_data(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_raw_irig_data call.
Definition: mbgdevio.c:2851
A structure to used to read the status of the PTP protocol stack.
Definition: gpsdefs.h:13184
uint16_t TR_DISTANCE
Receiver distance from transmitter [km].
Definition: pcpsdefs.h:1553
_MBG_API_ATTR int _MBG_API mbg_dev_is_irig_rx(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a configurable IRIG input.
Definition: mbgdevio.c:2460
Configuration settings for a specific PTP unicast master.
Definition: gpsdefs.h:14329
void mbg_free_device_name_list(MBG_DEV_NAME_LIST_ENTRY *list)
Free the memory allocated for a list of MBG_DEV_NAME_LIST_ENTRY entries.
Definition: mbgdevio.c:3981
MBG_PC_CYCLES_FREQUENCY mbg_get_default_cycles_frequency(void)
Retrieve the system&#39;s default cycles counter frequency.
Definition: mbgdevio.c:9229
int mbg_set_gps_ant_cable_len(MBG_DEV_HANDLE dh, const ANT_CABLE_LEN *p)
Write the GPS antenna cable length configuration to a device.
Definition: mbgdevio.c:6054
Number of event log entries that can be stored and yet have been saved.
Definition: gpsdefs.h:9540
uint8_t PCPS_TZCODE
Type of variable to hold a TZ code.
Definition: pcpsdefs.h:1432
Configuration settings of a specific serial port.
Definition: gpsdefs.h:3594
int mbg_set_gps_gnss_mode_settings(MBG_DEV_HANDLE dh, const MBG_GNSS_MODE_SETTINGS *p_ms)
Write the GNSS mode configuration to a device.
Definition: mbgdevio.c:7993
High resolution device time, system time, and associated cycles counts.
Definition: pcpsdev.h:1418
void mbg_split_dev_name(const MBG_DEV_NAME dev_name, char *type_name, size_t type_name_size, char *sernum, size_t sernum_size)
Split an MBG_DEV_NAME into the &#39;type name&#39; and &#39;serial number&#39; components.
Definition: mbgdevio.c:4016
_MBG_API_ATTR int _MBG_API mbg_dev_has_gps_data(MBG_DEV_HANDLE dh, int *p)
Check if a device supports large configuration data structures.
Definition: mbgdevio.c:2182
uint32_t info
E.g. cmd code for the device.
Definition: mbgioctl.h:423
MBG_CHK_SUPP_FNC mbg_chk_dev_has_cab_len
Check if a device supports configuration of antenna cable length.
Definition: mbgdevio.c:1909
MBG_CHK_SUPP_FNC mbg_chk_dev_is_msf
Check if a device is a MSF receiver.
Definition: mbgdevio.c:1117
int mbg_get_debug_status(MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p)
Read a debug status word from a device.
Definition: mbgdevio.c:7790
int mbg_get_gps_gnss_mode_info(MBG_DEV_HANDLE dh, MBG_GNSS_MODE_INFO *p_mi)
Read the current GNSS mode info including current settings.
Definition: mbgdevio.c:7956
int mbg_get_gps_ucap(MBG_DEV_HANDLE dh, TTM *p)
Read a time capture event from the on-board FIFO buffer using a TTM structure.
Definition: mbgdevio.c:5741
const char * mbgioctl_get_name(long code)
int mbg_get_gps_all_str_type_info(MBG_DEV_HANDLE dh, STR_TYPE_INFO_IDX stii[], const RECEIVER_INFO *p_ri)
Read a STR_TYPE_INFO_IDX array of supported string types.
Definition: mbgdevio.c:6125
int mbg_thread_create(MBG_THREAD_INFO *p_ti, MBG_THREAD_FNC fnc, void *arg)
Create a new execution thread for the current process.
int mbgdevio_check_version(int header_version)
Check if the DLL/shared library is compatible with a given version.
Definition: mbgdevio.c:641
int mbg_get_gps_all_xmr_info(MBG_DEV_HANDLE dh, XMULTI_REF_INFO_IDX xmrii[], const XMULTI_REF_INSTANCES *p_xmri)
Read all XMR settings and capabilities.
Definition: mbgdevio.c:8342
uint64_t pcps_hr_tstamp64
Time stamp read from a device.
Definition: mbgdevio.h:544
int mbg_get_synth_state(MBG_DEV_HANDLE dh, SYNTH_STATE *p)
Read the current status of the on-board frequency synthesizer.
Definition: mbgdevio.c:6954
int mbg_get_sync_time(MBG_DEV_HANDLE dh, PCPS_TIME *p)
Read the time when the device has last recently synchronized.
Definition: mbgdevio.c:4555
static char * dev_name
Definition: mbgctrl.c:131
int mbg_get_gpio_cfg_limits(MBG_DEV_HANDLE dh, MBG_GPIO_CFG_LIMITS *p)
Read common GPIO configuration limits.
Definition: mbgdevio.c:8082
int mbg_get_gps_ant_info(MBG_DEV_HANDLE dh, ANT_INFO *p)
Read an ANT_INFO structure to retrieve an extended GPS antenna status.
Definition: mbgdevio.c:5709
uint32_t in_sz
Size of the input buffer.
Definition: mbgioctl.h:421
Settings of an IPv4-only network interface.
Definition: gpsdefs.h:11239
int mbg_thread_set_affinity(MBG_THREAD_INFO *p_ti, int *p)
Set the CPU affinity of a single thread.
GPS UTC correction parameters.
Definition: gpsdefs.h:18564
MBG_CHK_SUPP_FNC mbg_chk_dev_is_mca
Check if the device is connected via the MCA bus.
Definition: mbgdevio.c:897
int mbg_set_gps_port_settings_idx(MBG_DEV_HANDLE dh, const PORT_SETTINGS_IDX *p)
Write the configuration for a single serial port to a device.
Definition: mbgdevio.c:6248
MBG_THREAD_INFO ti
Definition: mbgdevio.h:586
A structure used to configure a PTP port.
Definition: gpsdefs.h:13278
static __mbg_inline void mbg_chk_tstamp64_leap_sec(uint64_t *tstamp64, PCPS_TIME_STATUS_X *status)
Definition: mbgdevio.h:5730
int mbg_clr_ucap_buff(MBG_DEV_HANDLE dh)
Clear a device&#39;s on-board time capture FIFO buffer.
Definition: mbgdevio.c:5331
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tzdl
Check if a device supports timezone configuration using the TZDL structure.
Definition: mbgdevio.c:1532
The structure behind the MBG_DEV_NAME_LIST_ENTRY type.
Definition: mbgdevio.h:660
A The structure used to store the configuration of two serial ports.
Definition: gpsdefs.h:3929
Time scale configuration settings plus capabilities.
Definition: gpsdefs.h:5519
uint64_t in_p
Address of the input buffer.
Definition: mbgioctl.h:419
int mbg_get_tr_distance(MBG_DEV_HANDLE dh, TR_DISTANCE *p)
Read configurable "distance from transmitter" parameter from a device.
Definition: mbgdevio.c:7722
int mbg_get_gps_receiver_info(MBG_DEV_HANDLE dh, RECEIVER_INFO *p)
Read the RECEIVER_INFO structure from a device.
Definition: mbgdevio.c:6091
MBG_XHRT_VARS prv_vars
Definition: mbgdevio.h:563
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_tx(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a configurable IRIG output.
Definition: mbgdevio.c:2806
int mbg_get_ref_offs(MBG_DEV_HANDLE dh, MBG_REF_OFFS *p)
Read the UTC offset configuration of the reference time from a device.
Definition: mbgdevio.c:4893
Status information on a ref time source at a specific priority level.
Definition: gpsdefs.h:6885
int mbg_get_gps_ant_cable_len(MBG_DEV_HANDLE dh, ANT_CABLE_LEN *p)
Read the configured antenna cable length from a device.
Definition: mbgdevio.c:6018
A structure used to control a poll thread function.
Definition: mbgdevio.h:583
int mbg_set_gps_port_settings(MBG_DEV_HANDLE dh, const PORT_SETTINGS *p, int idx)
Write the configuration for a single serial port to a device.
Definition: mbgdevio.c:6290
int mbg_generic_write_gps(MBG_DEV_HANDLE dh, int cmd, const void *p, int size)
Definition: mbgdevio.c:4419
int mbg_get_ucap_event(MBG_DEV_HANDLE dh, PCPS_HR_TIME *p)
Retrieve a single time capture event from the on-board FIFO buffer.
Definition: mbgdevio.c:5401
#define MBG_THREAD_ID
Definition: mbgdevio.h:489
use the next device available on the system
Definition: mbgdevio.h:600
Current IRIG settings and supported codes.
Definition: gpsdefs.h:5054
PCPS_DDEV * MBG_DEV_HANDLE
Definition: mbgdevio.h:356
Configuration settings of a serial port.
Definition: gpsdefs.h:3507
int mbg_get_status_port(MBG_DEV_HANDLE dh, PCPS_STATUS_PORT *p)
Read the current state of the on-board PCPS_STATUS_PORT.
Definition: mbgdevio.c:4273
A structure used to configure optional settings.
Definition: gpsdefs.h:5342
PCPS_SECONDS sec
seconds since 1970, usually UTC scale
Definition: pcpsdefs.h:974
_MBG_API_ATTR int _MBG_API mbg_dev_has_corr_info(MBG_DEV_HANDLE dh, int *p)
Check if a device supports reading correlation info.
Definition: mbgdevio.c:3108
XMR holdover status.
Definition: gpsdefs.h:7157
_MBG_API_ATTR int _MBG_API mbg_dev_has_ref_offs(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a configurable ref time offset.
Definition: mbgdevio.c:3039
#define MBGCLOCK_DEV_FN_FMT
Definition: mbgdevio.h:393
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_time(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_irig_time call.
Definition: mbgdevio.c:2874
int mbg_get_all_ptp_uc_master_info(MBG_DEV_HANDLE dh, PTP_UC_MASTER_INFO_IDX pii[], const PTP_UC_MASTER_CFG_LIMITS *p_umsl)
Read PTP Unicast master settings and configuration options.
Definition: mbgdevio.c:7527
#define MBGDEVIO_RET_VAL
Definition: mbgdevio.h:364
int mbg_get_next_evt_log_entry(MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p)
Read the next event log entry from a device.
Definition: mbgdevio.c:7922
An event log entry.
Definition: gpsdefs.h:9564
_MBG_API_ATTR int _MBG_API mbg_dev_has_cab_len(MBG_DEV_HANDLE dh, int *p)
Check if a device supports configuration of antenna cable length.
Definition: mbgdevio.c:3016
_MBG_API_ATTR int _MBG_API mbg_dev_has_tz(MBG_DEV_HANDLE dh, int *p)
Check if a device supports any kind of timezone configuration.
Definition: mbgdevio.c:2760
#define MBG_THREAD_FNC_RET_VAL
Definition: mbgdevio.h:501
uint8_t PCPS_STATUS_PORT
Type of the status register port.
Definition: pcpsdefs.h:431
_MBG_API_ATTR int _MBG_API mbg_dev_has_generic_io(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_generic_io API call.
Definition: mbgdevio.c:2205
_MBG_API_ATTR int _MBG_API mbg_get_time(MBG_DEV_HANDLE dh, PCPS_TIME *p)
Read a PCPS_TIME structure returning the current date/time/status.
Definition: mbgdevio.c:4491
MBG_CHK_SUPP_FNC mbg_chk_dev_has_ptp
Check if a device supports PTP configuration/status calls.
Definition: mbgdevio.c:1300
MBG_XHRT_VARS vars
Definition: mbgdevio.h:562
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig
Check if a device provides either an IRIG input or output.
Definition: mbgdevio.c:1639
_MBG_API_ATTR int _MBG_API mbg_get_hr_time_cycles(MBG_DEV_HANDLE dh, PCPS_HR_TIME_CYCLES *p)
Read the current high resolution time plus the associated PC cycles from a device.
Definition: mbgdevio.c:6682
Current settings and general capabilities of a specific unicast master.
Definition: gpsdefs.h:14382
int mbg_get_device_info(MBG_DEV_HANDLE dh, PCPS_DEV *p)
Read detailed device information.
Definition: mbgdevio.c:4242
_MBG_API_ATTR int _MBG_API mbg_get_hr_time(MBG_DEV_HANDLE dh, PCPS_HR_TIME *p)
Read the card&#39;s current time with high resolution, including status.
Definition: mbgdevio.c:4625
int mbg_get_gps_port_parm(MBG_DEV_HANDLE dh, PORT_PARM *p)
Read a PORT_PARM structure with a device&#39;s serial port configuration.
Definition: mbgdevio.c:5644
int mbg_set_gps_pout_settings(MBG_DEV_HANDLE dh, const POUT_SETTINGS *p, int idx)
Write the configuration for a single programmable pulse output.
Definition: mbgdevio.c:7209
int mbg_set_opt_settings(MBG_DEV_HANDLE dh, const MBG_OPT_SETTINGS *p)
Write a MBG_OPT_SETTINGS structure containing optional device settings.
Definition: mbgdevio.c:4988
int mbg_find_devices(void)
Get the number of devices installed on the computer.
Definition: mbgdevio.c:3503
MBG_CHK_SUPP_FNC mbg_chk_dev_has_asic_features
Check if a device supports the mbg_get_asic_features call.
Definition: mbgdevio.c:793
int mbg_set_ip4_settings(MBG_DEV_HANDLE dh, const IP4_SETTINGS *p)
Write LAN IPv4 settings to a device.
Definition: mbgdevio.c:7360
int mbg_get_all_irig_rx_info(MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, IRIG_INFO *p_irig_info, MBG_REF_OFFS *p_ref_offs, MBG_OPT_INFO *p_opt_info)
Read all IRIG input configuration information from a device.
Definition: mbgdevio.c:5099
#define mbg_rc_is_success(_rc)
Definition: mbgerror.h:618
MBG_CHK_SUPP_FNC mbg_chk_dev_has_gpio
Check if a device provides GPIO signal inputs and/or outputs.
Definition: mbgdevio.c:1883
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp(MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p)
Read a high resolution PCPS_TIME_STAMP structure via memory mapped access.
Definition: mbgdevio.c:7066
uint8_t PCPS_SERIAL
Legacy definitions used to configure a device&#39;s serial port.
Definition: pcpsdefs.h:1342
MBG_CHK_SUPP_FNC mbg_chk_dev_has_ptp_unicast
Check if a device supports PTP unicast feature/configuration.
Definition: mbgdevio.c:1333
uint16_t GPS_CMD
The type of a GPS command code.
Definition: gpsdefs.h:719
MBG_CHK_SUPP_FNC mbg_chk_dev_is_gps
Check if a device is a GPS receiver.
Definition: mbgdevio.c:1029
int mbg_set_utc_parm(MBG_DEV_HANDLE dh, const UTC *p)
Write a UTC parameter structure to a device.
Definition: mbgdevio.c:6573
MBG_CHK_SUPP_FNC mbg_chk_dev_has_ucap
Check if a device supports the mbg_get_ucap_entries and mbg_get_ucap_event calls. ...
Definition: mbgdevio.c:1476
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_version(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_asic_version call.
Definition: mbgdevio.c:2228
MBG_CHK_SUPP_FNC mbg_chk_dev_is_pci
Check if the device is connected via the PCI bus.
Definition: mbgdevio.c:918
int mbg_get_raw_irig_data_on_sec_change(MBG_DEV_HANDLE dh, MBG_RAW_IRIG_DATA *p)
Wait for second changeover then read raw IRIG data from an IRIG receiver.
Definition: mbgdevio.c:5268
MBG_CHK_SUPP_FNC mbg_chk_dev_has_hr_time
Check if a device supports the mbg_get_hr_time... functions.
Definition: mbgdevio.c:1360
General GPIO config info to be read from a device.
Definition: gpsdefs.h:7608
Time read from a device plus associated system cycles count.
Definition: pcpsdev.h:1354
int mbg_get_tzcode(MBG_DEV_HANDLE dh, PCPS_TZCODE *p)
Read time zone/daylight saving configuration code from a device.
Definition: mbgdevio.c:4751
int mbg_get_drvr_info(MBG_DEV_HANDLE dh, PCPS_DRVR_INFO *p)
Read information about the driver handling a given device.
Definition: mbgdevio.c:4216
_MBG_API_ATTR int _MBG_API mbg_get_time_cycles(MBG_DEV_HANDLE dh, PCPS_TIME_CYCLES *p)
Read the current time plus the associated PC cycles from a device.
Definition: mbgdevio.c:6629
int mbg_dev_has_serial_hs(MBG_DEV_HANDLE dh, int *p)
Definition: mbgdevio.c:2947
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device_by_name(const MBG_DEV_NAME srch_name, int selection_mode)
Return a handle to a device with a particular device name.
Definition: mbgdevio.c:4112
High resolution time stamp plus associated system cycles count.
Definition: pcpsdev.h:1369
Status of the time capture FIFO buffer.
Definition: pcpsdefs.h:1529
MBG_MATCH_MODES
Device matching modes.
Definition: mbgdevio.h:598
Configuration settings for a single programmable pulse output.
Definition: gpsdefs.h:5692
int mbg_set_gps_pos_xyz(MBG_DEV_HANDLE dh, const XYZ p)
Set the GPS receiver position using XYZ coordinates.
Definition: mbgdevio.c:5935
int mbg_find_devices_with_names(MBG_DEV_NAME_LIST_ENTRY **p_list, int max_devices)
Allocate memory and set up a list of installed and supported devices.
Definition: mbgdevio.c:3897
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_features(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_asic_features call.
Definition: mbgdevio.c:2252
uint16_t BVAR_STAT
Status flags of battery buffered data.
Definition: gpsdefs.h:770
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_comp(MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p, int32_t *hns_latency)
Read a high resolution timestamp and compensate the latency of the call.
Definition: mbgdevio.c:7017
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_cycles(MBG_DEV_HANDLE dh, PCPS_TIME_STAMP_CYCLES *p)
Read a high resolution PCPS_TIME_STAMP_CYCLES structure via memory mapped access. ...
Definition: mbgdevio.c:6981
MBG_CHK_SUPP_FNC mbg_chk_dev_is_gnss
Check if a device supports GNSS configuration.
Definition: mbgdevio.c:1002
int mbg_get_xmr_instances(MBG_DEV_HANDLE dh, XMULTI_REF_INSTANCES *p)
Read XMULTI_REF_INSTANCES.
Definition: mbgdevio.c:8261
int mbg_get_irq_stat_info(MBG_DEV_HANDLE dh, PCPS_IRQ_STAT_INFO *p)
Read a device&#39;s IRQ status information.
Definition: mbgdevio.c:7238
Time scale configuration settings.
Definition: gpsdefs.h:5505
number of known modes
Definition: mbgdevio.h:603
_MBG_API_ATTR int _MBG_API mbg_dev_has_xmr(MBG_DEV_HANDLE dh, int *p)
Check if a device provides extended multi ref (XMR) inputs.
Definition: mbgdevio.c:2276
MBG_CHK_SUPP_FNC mbg_chk_dev_has_utc_parm
Check if a device support reading/writing of UTC parameters.
Definition: mbgdevio.c:2005
_MBG_API_ATTR int _MBG_API mbg_dev_is_lwr(MBG_DEV_HANDLE dh, int *p)
Check if a device is any long wave signal receiver.
Definition: mbgdevio.c:2437
#define _MBG_API_ATTR
Definition: mbg_tgt.h:1024
Specification of a local time zone.
Definition: pcpsdefs.h:1504
int mbg_posix_errno_to_mbg(int posix_errno, const char *info)
Translate a POSIX errno error code to one of the MBG_ERROR_CODES.
Definition: mbgerror.c:920
int mbg_get_gps_all_pout_info(MBG_DEV_HANDLE dh, POUT_INFO_IDX pii[], const RECEIVER_INFO *p_ri)
Read current configuraton and features provided by the programmable pulse outputs.
Definition: mbgdevio.c:7109
_MBG_API_ATTR int _MBG_API mbg_dev_has_gpio(MBG_DEV_HANDLE dh, int *p)
Check if a device provides GPIO signal inputs and/or outputs.
Definition: mbgdevio.c:2993
A structure used to pass generic IOCTL requests to the kernel driver.
Definition: mbgioctl.h:417
int mbg_get_xhrt_cycles_frequency(MBG_XHRT_INFO *p, MBG_PC_CYCLES_FREQUENCY *p_freq_hz)
Retrieve the frequency of the system&#39;s cycles counter.
_MBG_API_ATTR int _MBG_API mbg_dev_has_ucap(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_ucap_entries and mbg_get_ucap_event calls. ...
Definition: mbgdevio.c:2646
A structure holding a time stamp / cycles count pair.
Definition: mbgdevio.h:541
A GPIO port&#39;s current settings and limits, plus port index.
Definition: gpsdefs.h:9273
static __mbg_inline time_t cvt_to_time_t(mbg_time_t t)
Definition: timeutil.h:108
int mbg_get_time_scale_info(MBG_DEV_HANDLE dh, MBG_TIME_SCALE_INFO *p)
Read the current time scale settings and which time scales are supported.
Definition: mbgdevio.c:6466
current second is leap second
Definition: pcpsdefs.h:1272
MBG_CHK_SUPP_FNC mbg_chk_dev_has_corr_info
Check if a device supports reading correlation info.
Definition: mbgdevio.c:2036
Information on a specific supported string format.
Definition: gpsdefs.h:3733
int mbg_setup_receiver_info(MBG_DEV_HANDLE dh, const PCPS_DEV *p_dev, RECEIVER_INFO *p)
Set up a RECEIVER_INFO structure for a device.
Definition: mbgdevio.c:6329
Reference source configuration for a specific priority level.
Definition: gpsdefs.h:6749
_MBG_API_ATTR int _MBG_API mbg_dev_has_tr_distance(MBG_DEV_HANDLE dh, int *p)
Check if a device supports configurable distance from transmitter.
Definition: mbgdevio.c:3131
uint64_t out_p
Address of the output buffer.
Definition: mbgioctl.h:420
int mbg_get_gps_sw_rev(MBG_DEV_HANDLE dh, SW_REV *p)
Retrieve the software revision of a GPS receiver.
Definition: mbgdevio.c:5513
Date time and status used with the PCPS_SET_TIME command.
Definition: pcpsdefs.h:1156
_MBG_API_ATTR int _MBG_API mbg_dev_has_fast_hr_timestamp(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_fast_hr_timestamp_...() calls.
Definition: mbgdevio.c:2575
use the next available device of the same type
Definition: mbgdevio.h:601
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tr_distance
Check if a device supports configurable distance from transmitter.
Definition: mbgdevio.c:2066
use only exactly the excat matching device, otherwise fail
Definition: mbgdevio.h:602
MBG_CHK_SUPP_FNC mbg_chk_dev_is_tcr
Check if a device provides a configurable IRIG input.
Definition: mbgdevio.c:1243
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp_unicast(MBG_DEV_HANDLE dh, int *p)
Check if a device supports PTP unicast feature/configuration.
Definition: mbgdevio.c:2529
int mbg_clr_evt_log(MBG_DEV_HANDLE dh)
Clear the device&#39;s on-board event log.
Definition: mbgdevio.c:7819
MBG_DEV_NAME_LIST_ENTRY * next
Definition: mbgdevio.h:663
MBG_XHRT_INFO xhrt_info
Definition: mbgdevio.h:585
A status structure provided by the time polling thread function.
Definition: mbgdevio.h:560
uint16_t ANT_CABLE_LEN
A data type used to configure the length of an antenna cable [m].
Definition: gpsdefs.h:11012
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device(int dev_idx)
Open a device by index number.
Definition: mbgdevio.c:3352
A structure to used to query the current configuration and capabilities of a PTP port.
Definition: gpsdefs.h:13342
_MBG_API_ATTR int _MBG_API mbg_dev_has_opt_flags(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the MBG_OPT_INFO/MBG_OPT_SETTINGS.
Definition: mbgdevio.c:3062
double XYZ[N_XYZ]
A position in cartesian coordinates.
Definition: gpsdefs.h:2742
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig(MBG_DEV_HANDLE dh, int *p)
Check if a device provides either an IRIG input or output.
Definition: mbgdevio.c:2783
_MBG_API_ATTR int _MBG_API mbg_chk_dev_is_wwvb(MBG_DEV_HANDLE dh)
Check if a device is a WWVB receiver.
Definition: mbgdevio.c:1136
A structure used to report the synthesizer state.
Definition: gpsdefs.h:2890
MBG_CHK_SUPP_FNC mbg_chk_dev_is_isa
Check if the device is connected via the ISA bus.
Definition: mbgdevio.c:876
High resolution device time stamp, system time, and associated cycles counts.
Definition: pcpsdev.h:1445
A structure used to transmit information on date and time.
Definition: gpsdefs.h:2713
_MBG_API_ATTR int _MBG_API mbg_dev_has_event_time(MBG_DEV_HANDLE dh, int *p)
Check if a device supports setting an event time.
Definition: mbgdevio.c:2623
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig_time
Check if a device supports the mbg_get_irig_time call.
Definition: mbgdevio.c:1744
int mbg_generic_read(MBG_DEV_HANDLE dh, int cmd, void *p, int size)
Definition: mbgdevio.c:4311
MBG_CHK_SUPP_FNC mbg_chk_dev_has_ref_offs
Check if a device provides a configurable ref time offset.
Definition: mbgdevio.c:1938
GNSS mode settings.
Definition: gpsdefs.h:10677
int mbg_set_gps_cmd(MBG_DEV_HANDLE dh, const GPS_CMD *p)
Send one of the PC_GPS_COMMANDS to a GPS receiver device.
Definition: mbgdevio.c:5871
MBG_CHK_SUPP_FNC mbg_chk_dev_has_lan_intf
Check if a device supports simple LAN interface API calls.
Definition: mbgdevio.c:1271
A GPIO port&#39;s current settings, plus port index.
Definition: gpsdefs.h:9184
PCPS_FRAC_32 frac
binary fractions of second, see PCPS_FRAC_32
Definition: pcpsdefs.h:975
_MBG_API_ATTR int _MBG_API mbg_dev_has_receiver_info(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the RECEIVER_INFO structure and related calls.
Definition: mbgdevio.c:2159
MBG_CHK_SUPP_FNC mbg_chk_dev_has_pcps_tzdl
Check if a device supports timezone configuration using the PCPS_TZDL structure.
Definition: mbgdevio.c:1559
int mbgdevio_get_version(void)
Get the version number of the precompiled DLL/shared object library.
Definition: mbgdevio.c:615
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp(MBG_DEV_HANDLE dh, int *p)
Check if a device supports PTP configuration/status calls.
Definition: mbgdevio.c:2506
Limits to be considered when specifying PTP unicast masters.
Definition: gpsdefs.h:14231
The structure behind the MBG_DEV_FN_LIST_ENTRY type.
Definition: mbgdevio.h:628
int mbg_get_opt_info(MBG_DEV_HANDLE dh, MBG_OPT_INFO *p)
Read a MBG_OPT_INFO structure containing optional settings, controlled by flags.
Definition: mbgdevio.c:4958
uint32_t PCI_ASIC_FEATURES
A data type to hold the PCI ASIC feature flags mask.
Definition: pci_asic.h:162
MBG_CHK_SUPP_FNC mbg_chk_dev_has_gps_data
Check if a device supports large configuration data structures.
Definition: mbgdevio.c:708
int MBG_CHK_SUPP_FNC(MBG_DEV_HANDLE dh)
The type of functions to check if a feature is supported.
Definition: mbgdevio.h:845
int mbg_get_ptp_state(MBG_DEV_HANDLE dh, PTP_STATE *p)
Read PTP/IEEE1588 status from a device.
Definition: mbgdevio.c:7396
int mbg_get_default_cycles_frequency_from_dev(MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p)
Retrieve the system&#39;s default cycles counter frequency from the kernel driver.
Definition: mbgdevio.c:9161
Configuration settings for a specific programmable pulse output.
Definition: gpsdefs.h:6249
int mbg_get_num_evt_log_entries(MBG_DEV_HANDLE dh, MBG_NUM_EVT_LOG_ENTRIES *p)
Read details about a device&#39;s on-board event log buffer.
Definition: mbgdevio.c:7851
#define MBG_CPU_SET
Definition: mbgdevio.h:468
void mbg_close_device(MBG_DEV_HANDLE *dev_handle)
Close a device handle and set the handle value to MBG_INVALID_DEV_HANDLE.
Definition: mbgdevio.c:4190
A structure used to configure optional settings.
Definition: gpsdefs.h:5323
_MBG_API_ATTR int _MBG_API mbg_dev_has_tzdl(MBG_DEV_HANDLE dh, int *p)
Check if a device supports timezone configuration using the TZDL structure.
Definition: mbgdevio.c:2691
int16_t MBG_REF_OFFS
A data type used to configure the ref offset.
Definition: gpsdefs.h:5297
int mbg_generic_read_gps(MBG_DEV_HANDLE dh, int cmd, void *p, int size)
Definition: mbgdevio.c:4348
int mbg_get_gps_all_gpio_info(MBG_DEV_HANDLE dh, MBG_GPIO_INFO_IDX gii[], const MBG_GPIO_CFG_LIMITS *p_gcl)
Get all GPIO settings and capabilities.
Definition: mbgdevio.c:8115
_MBG_API_ATTR int _MBG_API mbg_dev_has_synth(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a programmable frequency synthesizer.
Definition: mbgdevio.c:2970
int mbg_get_gps_all_gnss_sat_info(MBG_DEV_HANDLE dh, GNSS_SAT_INFO_IDX gsii[], const MBG_GNSS_MODE_INFO *p_mi)
Read a GNSS_SAT_INFO_IDX array of satellite status information.
Definition: mbgdevio.c:8028
int mbg_set_ptp_cfg_settings(MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p)
Write PTP/IEEE1588 configuration settings to a device.
Definition: mbgdevio.c:7458
int mbg_thread_stop(MBG_THREAD_INFO *p_ti)
Stop a thread which has been created by mbg_thread_create.
int mbg_set_process_affinity(pid_t pid, int *p)
Set the CPU affinity of a process.
General info on supported XMR sources and instances.
Definition: gpsdefs.h:7054
_MBG_API_ATTR int _MBG_API mbg_dev_has_hr_time(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the HR_TIME functions.
Definition: mbgdevio.c:2552
char MBG_DEV_NAME[10+(16+1)+1]
A string buffer for a unique device ID.
Definition: pcpsdev.h:1524
int mbg_set_tr_distance(MBG_DEV_HANDLE dh, const TR_DISTANCE *p)
Write configurable "distance from transmitter" parameter to a device.
Definition: mbgdevio.c:7754
int mbg_get_gps_all_gpio_status(MBG_DEV_HANDLE dh, MBG_GPIO_STATUS_IDX gsi[], const MBG_GPIO_CFG_LIMITS *p_gcl)
Read the status of all GPIO signal ports.
Definition: mbgdevio.c:8205
int mbg_get_asic_version(MBG_DEV_HANDLE dh, PCI_ASIC_VERSION *p)
Read the version code of the on-board PCI/PCIe interface ASIC.
Definition: mbgdevio.c:6385
int mbg_get_irig_rx_info(MBG_DEV_HANDLE dh, IRIG_INFO *p)
Read the current IRIG input settings plus capabilities.
Definition: mbgdevio.c:5028
_MBG_API_ATTR int _MBG_API mbg_dev_is_dcf(MBG_DEV_HANDLE dh, int *p)
Check if a device is a DCF77 receiver.
Definition: mbgdevio.c:2345
int mbg_get_gps_all_xmr_status(MBG_DEV_HANDLE dh, XMULTI_REF_STATUS_IDX xmrsi[], const XMULTI_REF_INSTANCES *p_xmri)
Read the status of all XMR sources.
Definition: mbgdevio.c:8290
int mbg_get_synth(MBG_DEV_HANDLE dh, SYNTH *p)
Read the current frequency synthesizer settings from a device.
Definition: mbgdevio.c:6889
MBG_CHK_SUPP_FNC mbg_chk_dev_has_debug_status
Check if a device provides a debug status word to be read.
Definition: mbgdevio.c:2091
#define FILETIME
Definition: mbgdevio.h:456
MBG_CHK_SUPP_FNC mbg_chk_dev_can_clr_ucap_buff
Check if a device supports the mbg_clr_ucap_buff call.
Definition: mbgdevio.c:1505
int mbg_chk_dev_has_event_time(MBG_DEV_HANDLE dh)
Definition: mbgdevio.c:1438
int mbg_get_ptp_uc_master_cfg_limits(MBG_DEV_HANDLE dh, PTP_UC_MASTER_CFG_LIMITS *p)
Read PTP/IEEE1588 unicast master configuration limits from a device.
Definition: mbgdevio.c:7494
_MBG_API_ATTR int _MBG_API mbg_dev_is_wwvb(MBG_DEV_HANDLE dh, int *p)
Check if a device is a WWVB receiver.
Definition: mbgdevio.c:2414
#define MBG_ERR_NO_MEM
Failed to allocate memory.
Definition: mbgerror.h:282
int mbg_get_raw_irig_data(MBG_DEV_HANDLE dh, MBG_RAW_IRIG_DATA *p)
Read raw IRIG data from an IRIG receiver.
Definition: mbgdevio.c:5233
int mbg_set_tzcode(MBG_DEV_HANDLE dh, const PCPS_TZCODE *p)
Write time zone/daylight saving configuration code to a device.
Definition: mbgdevio.c:4787
MBG_CHK_SUPP_FNC mbg_chk_dev_has_raw_irig_data
Check if a device supports the mbg_get_raw_irig_data call.
Definition: mbgdevio.c:1719
One of several sets of satellite information for a particular GNSS type.
Definition: gpsdefs.h:10773
Raw IRIG time.
Definition: pcpsdefs.h:1207
Time zone / daylight saving parameters.
Definition: gpsdefs.h:2940
int mbg_get_gps_enable_flags(MBG_DEV_HANDLE dh, ENABLE_FLAGS *p)
Read the ENABLE_FLAGS structure controlling when outputs are to be enabled.
Definition: mbgdevio.c:5776
#define MBG_FRAC32_UNITS_PER_SEC
Constant used to convert e.g. PCPS_TIME_STAMP::frac values.
Definition: mbgtime.h:400
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
int mbg_set_serial(MBG_DEV_HANDLE dh, const PCPS_SERIAL *p)
Write the serial port configuration to an old type of device.
Definition: mbgdevio.c:4716
int ioctl_status
Definition: mbgdevio.h:565
int MBG_HANDLE
Definition: mbg_tgt.h:966
int mbg_set_gps_pout_settings_idx(MBG_DEV_HANDLE dh, const POUT_SETTINGS_IDX *p)
Write the configuration for a single programmable pulse output.
Definition: mbgdevio.c:7169
uint32_t PCPS_IRQ_STAT_INFO
Definition: pcpsdev.h:1468
Synthesizer configuration parameters.
Definition: gpsdefs.h:2856
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig_tx
Check if a device provides a configurable IRIG output.
Definition: mbgdevio.c:1668
MBG_CHK_SUPP_FNC mbg_chk_dev_has_fast_hr_timestamp
Check if a device supports the mbg_get_fast_hr_timestamp... calls.
Definition: mbgdevio.c:1387
MBG_CHK_SUPP_FNC mbg_chk_dev_has_mod
Check if a device provides a modulation signal.
Definition: mbgdevio.c:1797
Reference source capabilities and current configuration for a specific priority level.
Definition: gpsdefs.h:6839
int mbg_thread_sleep_interruptible(MBG_THREAD_INFO *p_ti, ulong sleep_ms)
Let the current thread sleep for a certain interval.
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_ctrl_bits(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_get_irig_ctrl_bits call.
Definition: mbgdevio.c:2829
static __mbg_inline int mbg_gmtime(struct tm *p_tm, const time_t *p_time)
Definition: timeutil.h:118
int mbg_get_asic_features(MBG_DEV_HANDLE dh, PCI_ASIC_FEATURES *p)
Read the features of the on-board PCI/PCIe interface ASIC.
Definition: mbgdevio.c:6420
A geographic position represented in different formats.
Definition: mbggeo.h:113
_MBG_API_ATTR int _MBG_API mbg_dev_has_utc_parm(MBG_DEV_HANDLE dh, int *p)
Check if a device support reading/writing of UTC parameters.
Definition: mbgdevio.c:3085
void MBG_THREAD_FNC(void *)
A generic type of a thread function.
Definition: mbgdevio.h:527
A buffer used to read raw IRIG data bits from an IRIG receiver.
Definition: gpsdefs.h:5423
Status information on a specific GPIO port.
Definition: gpsdefs.h:9317
_MBG_API_ATTR int _MBG_API mbg_dev_has_mod(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a modulation signal.
Definition: mbgdevio.c:2920
uint32_t DWORD
Definition: mbgerror.h:222
_MBG_API_ATTR int _MBG_API mbg_dev_is_msf(MBG_DEV_HANDLE dh, int *p)
Check if a device is a MSF receiver.
Definition: mbgdevio.c:2391
int mbg_get_gps_pos(MBG_DEV_HANDLE dh, POS *p)
Read the current geographic position from a GPS device.
Definition: mbgdevio.c:5905
MBG_CHK_SUPP_FNC mbg_chk_dev_has_xmr
Check if a device provides eXtended Multi Ref (XMR) inputs.
Definition: mbgdevio.c:825
int mbg_set_gps_xmr_settings_idx(MBG_DEV_HANDLE dh, const XMULTI_REF_SETTINGS_IDX *p)
Write a single XMR setting to a device.
Definition: mbgdevio.c:8399
MBG_CHK_SUPP_FNC mbg_chk_dev_is_usb
Check if the device is connected via the USB bus.
Definition: mbgdevio.c:972
const char mbg_dev_fn_fmt[]
MBG_CHK_SUPP_FNC mbg_chk_dev_has_time_scale
Check if a device supports configurable time scales.
Definition: mbgdevio.c:1416
uint64_t MBG_PC_CYCLES_FREQUENCY
Definition: mbgpccyc.h:98
MBG_CHK_SUPP_FNC mbg_chk_dev_is_pci_express
Check if the device is connected via the PCI Express bus.
Definition: mbgdevio.c:951
int mbg_set_gps_gpio_settings_idx(MBG_DEV_HANDLE dh, const MBG_GPIO_SETTINGS_IDX *p)
Write the configuration for a single GPIO port to a device.
Definition: mbgdevio.c:8172
int mbg_get_first_evt_log_entry(MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p)
Read the first (oldest) event log entry from a device.
Definition: mbgdevio.c:7886
int mbg_win32_sys_err_to_mbg(DWORD win32_sys_rc, const char *info)
Translate a Windows non-socket API return code to one of the MBG_RETURN_CODES.
int mbg_get_time_info_tstamp(MBG_DEV_HANDLE dh, MBG_TIME_INFO_TSTAMP *p)
Read both system time and associated device timestamp from the kernel driver.
Definition: mbgdevio.c:7659
int mbg_set_ptp_uc_master_settings_idx(MBG_DEV_HANDLE dh, const PTP_UC_MASTER_SETTINGS_IDX *p)
Write PTP/IEEE1588 unicast configuration settings to a device.
Definition: mbgdevio.c:7582
MBG_CHK_SUPP_FNC mbg_chk_dev_has_receiver_info
Check if a device supports the RECEIVER_INFO structure and related calls.
Definition: mbgdevio.c:680
PZF correlation status info.
Definition: pcpsdefs.h:1562
MBG_CHK_SUPP_FNC mbg_chk_dev_has_opt_flags
Check if a device supports the MBG_OPT_INFO/MBG_OPT_SETTINGS.
Definition: mbgdevio.c:1967
_MBG_API_ATTR int _MBG_API mbg_dev_is_gps(MBG_DEV_HANDLE dh, int *p)
Check if a device is a GPS receiver.
Definition: mbgdevio.c:2322
int mbg_set_irig_rx_settings(MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p)
Write an IRIG_SETTINGS structure to a device to configure an IRIG input.
Definition: mbgdevio.c:5065
MBG_CHK_SUPP_FNC mbg_chk_dev_has_signal
Check if a device provides the level of its inputs signal.
Definition: mbgdevio.c:1771
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tz
Check if a device supports any kind of timezone configuration.
Definition: mbgdevio.c:1613
MBG_CHK_SUPP_FNC mbg_chk_dev_has_generic_io
Check if a device supports the mbg_generic_io API call.
Definition: mbgdevio.c:735
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device_by_hw_id(const char *dev_fn)
Open a device specified by a device file name.
Definition: mbgdevio.c:3482
MBG_CHK_SUPP_FNC mbg_chk_dev_is_lwr
Check if a device is any long wave signal receiver.
Definition: mbgdevio.c:1215
_MBG_API_ATTR int _MBG_API mbg_dev_has_evt_log(MBG_DEV_HANDLE dh, int *p)
Check if a device provides an on-board event log.
Definition: mbgdevio.c:3177
#define _mbgdevio_cnv_ret_val(_v)
Definition: mbgdevio.h:369
High resolution time including status and local time offset.
Definition: pcpsdefs.h:1085
const char mbg_dev_fn_base[]
High resolution time plus associated system cycles count.
Definition: pcpsdev.h:1392
int mbg_get_xhrt_time_as_pcps_hr_time(MBG_XHRT_INFO *p, PCPS_HR_TIME *p_hrt)
Retrieve an extrapolated time stamp in PCPS_HR_TIME format.
int mbg_get_ucap_entries(MBG_DEV_HANDLE dh, PCPS_UCAP_ENTRIES *p)
Read information on a device&#39;s event capture buffer.
Definition: mbgdevio.c:5362
int mbg_set_gps_enable_flags(MBG_DEV_HANDLE dh, const ENABLE_FLAGS *p)
Write an ;;ENABLE_FLAGS structure to configure when outputs shall be enabled.
Definition: mbgdevio.c:5812
int mbg_get_corr_info(MBG_DEV_HANDLE dh, CORR_INFO *p)
Read PZF correlation info from a device.
Definition: mbgdevio.c:7690
Satellite receiver status information.
Definition: gpsdefs.h:10591
int mbg_set_gps_time(MBG_DEV_HANDLE dh, const TTM *p)
Set the time on a GPS receiver device.
Definition: mbgdevio.c:5608
_MBG_API_ATTR int _MBG_API mbg_dev_has_signal(MBG_DEV_HANDLE dh, int *p)
Check if a device provides the level of its inputs signal.
Definition: mbgdevio.c:2897
_MBG_API_ATTR int _MBG_API mbg_dev_is_gnss(MBG_DEV_HANDLE dh, int *p)
Check if a device supports GNSS configuration.
Definition: mbgdevio.c:2299
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig_ctrl_bits
Check if a device supports the mbg_get_irig_ctrl_bits call.
Definition: mbgdevio.c:1693
Software revision information.
Definition: gpsdefs.h:732
MBG_CHK_SUPP_FNC mbg_chk_dev_has_asic_version
Check if a device supports the mbg_get_asic_version API call.
Definition: mbgdevio.c:764
Current settings and general capabilities of a specific serial port.
Definition: gpsdefs.h:3677
uint32_t PCI_ASIC_VERSION
A data type to hold the PCI ASIC version code.
Definition: pci_asic.h:151
_MBG_API_ATTR int _MBG_API mbg_dev_has_pcps_tzdl(MBG_DEV_HANDLE dh, int *p)
Check if a device supports timezone configuration using the PCPS_TZDL structure.
Definition: mbgdevio.c:2714
#define MBGCLOCK_DEV_FN_BASE
Definition: mbgdevio.h:392
int mbg_get_irig_time(MBG_DEV_HANDLE dh, PCPS_IRIG_TIME *p)
Read the IRIG time and day-of-year number from an IRIG receiver.
Definition: mbgdevio.c:5304
int mbg_set_gps_tzdl(MBG_DEV_HANDLE dh, const TZDL *p)
Write the card&#39;s time zone/daylight saving parameters.
Definition: mbgdevio.c:5475
int mbg_get_lan_if_info(MBG_DEV_HANDLE dh, LAN_IF_INFO *p)
Read LAN interface information from a device.
Definition: mbgdevio.c:7271
int mbg_get_pcps_tzdl(MBG_DEV_HANDLE dh, PCPS_TZDL *p)
Read time zone/daylight saving parameters from a device.
Definition: mbgdevio.c:4823
int mbg_get_irig_ctrl_bits(MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p)
Read the control function bits received from an incoming IRIG signal.
Definition: mbgdevio.c:5202
Local calendar date and time, plus sync status.
Definition: pcpsdefs.h:1128
_MBG_API_ATTR int _MBG_API mbg_dev_has_lan_intf(MBG_DEV_HANDLE dh, int *p)
Check if a device supports simple LAN interface API calls.
Definition: mbgdevio.c:2483
uint16_t PCPS_TIME_STATUS_X
Extended status code.
Definition: pcpsdefs.h:1022
_MBG_API_ATTR int _MBG_API mbg_dev_has_pzf(MBG_DEV_HANDLE dh, int *p)
Check if a device supports demodulation of the DCF77 PZF code.
Definition: mbgdevio.c:2368
A high resolution time stamp.
Definition: pcpsdefs.h:972
double LLA[N_LLA]
A geographic position based on latitude, longitude, and altitude.
Definition: gpsdefs.h:2764
int mbg_set_time(MBG_DEV_HANDLE dh, const PCPS_STIME *p)
Set the device&#39;s on-board clock to a given date and time.
Definition: mbgdevio.c:4518
Configuration settings of an IRIG input or output.
Definition: gpsdefs.h:4999
int mbg_dev_fn_from_dev_idx(char *s, int max_len, int dev_idx)
Create a device file name associated with an index number.
Definition: mbgdevio.c:3319
char * dev_fn_ptr
Definition: mbgdevio.h:630
int mbg_chk_dev_has_serial_hs(MBG_DEV_HANDLE dh)
Definition: mbgdevio.c:1823
#define _MBG_API
Definition: mbg_tgt.h:1020
int mbg_get_irig_tx_info(MBG_DEV_HANDLE dh, IRIG_INFO *p)
Read the current IRIG output settings plus the supported settings.
Definition: mbgdevio.c:6787
MBG_DEV_FN_LIST_ENTRY * next
Definition: mbgdevio.h:632
int mbg_get_ip4_state(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 state from a device.
Definition: mbgdevio.c:7301
#define MBG_PROCESS_ID
Definition: mbgdevio.h:415
int mbg_get_xhrt_time_as_filetime(MBG_XHRT_INFO *p, int *p_ft)
Retrieve an extrapolated time stamp in FILETIME format.
MBG_CHK_SUPP_FNC mbg_chk_dev_has_dac_ctrl
Check if a device supports bus level DAC control commands.
Definition: mbgdevio.c:2140
int mbg_get_gps_bvar_stat(MBG_DEV_HANDLE dh, BVAR_STAT *p)
Retrieve the status of the battery buffered GPS variables.
Definition: mbgdevio.c:5551
int mbg_get_gps_tzdl(MBG_DEV_HANDLE dh, TZDL *p)
Read the card&#39;s time zone/daylight saving parameters.
Definition: mbgdevio.c:5439
uint32_t out_sz
Size of the output buffer.
Definition: mbgioctl.h:422
int mbg_get_gps_all_port_info(MBG_DEV_HANDLE dh, PORT_INFO_IDX pii[], const RECEIVER_INFO *p_ri)
Read a PORT_INFO_IDX array of supported serial port configurations.
Definition: mbgdevio.c:6185
uint32_t MBG_IRIG_CTRL_BITS
Bit coded return type for PCPS_GET_IRIG_CTRL_BITS.
Definition: gpsdefs.h:5392
int mbg_generic_write(MBG_DEV_HANDLE dh, int cmd, const void *p, int size)
Definition: mbgdevio.c:4382
int mbg_set_ref_offs(MBG_DEV_HANDLE dh, const MBG_REF_OFFS *p)
Write the UTC offset configuration of the reference time to a device.
Definition: mbgdevio.c:4924
int mbg_xhrt_poll_thread_stop(MBG_POLL_THREAD_INFO *p_pti)
Stop a polling thread started by mbg_xhrt_poll_thread_create.
MBG_CRIT_SECT crit_sect
Definition: mbgdevio.h:567
int mbg_set_gps_pos_lla(MBG_DEV_HANDLE dh, const LLA p)
Set the GPS receiver position using LLA coordinates.
Definition: mbgdevio.c:5976
_MBG_API_ATTR int _MBG_API mbg_get_hr_time_comp(MBG_DEV_HANDLE dh, PCPS_HR_TIME *p, int32_t *hns_latency)
Read the current high resolution time, and compensate the call&#39;s latency.
Definition: mbgdevio.c:6739
int mbg_set_irig_tx_settings(MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p)
Write an IRIG_SETTINGS structure to a device to configure the IRIG output.
Definition: mbgdevio.c:6833
const char * mbg_strerror(int mbg_errno)
Return an error string associated with the MBG_ERROR_CODES.
Definition: mbgerror.c:685
int mbg_get_xmr_holdover_status(MBG_DEV_HANDLE dh, XMR_HOLDOVER_STATUS *p, const XMULTI_REF_INSTANCES *p_xmri)
Read the current XMR holdover interval from a device.
Definition: mbgdevio.c:8436
Device driver information.
Definition: pcpsdev.h:1330
MBG_CHK_SUPP_FNC mbg_chk_dev_is_dcf
Check if a device is a DCF77 receiver.
Definition: mbgdevio.c:1059
Antenna status and error at reconnect information.
Definition: gpsdefs.h:3100
int mbg_get_gps_time(MBG_DEV_HANDLE dh, TTM *p)
Read the current board time using a TTM structure.
Definition: mbgdevio.c:5580
int mbg_set_pcps_tzdl(MBG_DEV_HANDLE dh, const PCPS_TZDL *p)
Write time zone/daylight saving parameters to a device.
Definition: mbgdevio.c:4858
unsigned __int64 uint64_t
Definition: words.h:250
MBG_PC_CYCLES_FREQUENCY freq_hz
Definition: mbgdevio.h:564
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tzcode
Check if a device supports timezone configuration using the PCPS_TZCODE type.
Definition: mbgdevio.c:1586
int mbg_set_gps_port_parm(MBG_DEV_HANDLE dh, const PORT_PARM *p)
Write a PORT_PARM structure to configure the on-board serial ports.
Definition: mbgdevio.c:5676
int mbg_xhrt_poll_thread_create(MBG_POLL_THREAD_INFO *p_pti, MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY freq_hz, int sleep_ms)
Set up a MBG_POLL_THREAD_INFO structure and start a new thread.
int mbg_get_serial(MBG_DEV_HANDLE dh, PCPS_SERIAL *p)
Read the serial port configuration from an old type of device.
Definition: mbgdevio.c:4687
int mbg_get_gps_stat_info(MBG_DEV_HANDLE dh, STAT_INFO *p)
Read the extended GPS receiver status from a device.
Definition: mbgdevio.c:5846
int mbg_save_all_irig_rx_settings(MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, const IRIG_SETTINGS *p_irig_settings, const MBG_REF_OFFS *p_ref_offs, const MBG_OPT_SETTINGS *p_opt_settings)
Write all IRIG input configuration settings to a device.
Definition: mbgdevio.c:5146
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device_by_dev_fn(const char *dev_fn)
Open a device specified by a device file name.
Definition: mbgdevio.c:3410
_MBG_API_ATTR int _MBG_API mbg_dev_has_debug_status(MBG_DEV_HANDLE dh, int *p)
Check if a device provides a debug status word to be read.
Definition: mbgdevio.c:3154
int mbg_set_synth(MBG_DEV_HANDLE dh, const SYNTH *p)
Write frequency synthesizer configuration settings to a device.
Definition: mbgdevio.c:6921
int mbg_get_process_affinity(pid_t pid, int *p)
Read the CPU affinity of a process.
int mbg_get_time_info_hrt(MBG_DEV_HANDLE dh, MBG_TIME_INFO_HRT *p)
Read both system time and associated device time from the kernel driver.
Definition: mbgdevio.c:7626
_MBG_API_ATTR int _MBG_API mbg_chk_dev_is_jjy(MBG_DEV_HANDLE dh)
Check if a device is a JJY receiver.
Definition: mbgdevio.c:1158
_MBG_API_ATTR int _MBG_API mbg_dev_has_time_scale(MBG_DEV_HANDLE dh, int *p)
Check if a device supports configurable time scales.
Definition: mbgdevio.c:2598
int mbg_generic_io(MBG_DEV_HANDLE dh, int type, const void *in_p, int in_sz, void *out_p, int out_sz)
Definition: mbgdevio.c:4448
MBG_DEV_HANDLE dh
Definition: mbgdevio.h:568
unsigned long ulong
Definition: words.h:292
int mbg_get_ip4_settings(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 settings from a device.
Definition: mbgdevio.c:7331
int mbg_get_utc_parm(MBG_DEV_HANDLE dh, UTC *p)
Read a UTC parameter structure from a device.
Definition: mbgdevio.c:6536
A structure used to identify a device type and supported features.
Definition: gpsdefs.h:873
PCPS_HR_TIME_CYCLES htc
Cycles count associated with the time stamp.
Definition: mbgdevio.h:543
MBG_CHK_SUPP_FNC mbg_chk_dev_has_synth
Check if a device provides a programmable frequency synthesizer.
Definition: mbgdevio.c:1855
char MBG_DEV_FN[260]
A string that can take a device file name.
Definition: mbgdevio.h:387
MBG_CHK_SUPP_FNC mbg_chk_dev_has_pzf
Check if a device supports demodulation of the DCF77 PZF code.
Definition: mbgdevio.c:1092
int mbg_dev_can_clr_ucap_buff(MBG_DEV_HANDLE dh, int *p)
Check if a device supports the mbg_clr_ucap_buff call.
Definition: mbgdevio.c:2668
int mbg_set_current_process_affinity_to_cpu(int cpu_num)
Set the CPU affinity of a process for a single CPU only.
Definition: mbgdevio.c:8552
MBG_CHK_SUPP_FNC mbg_chk_dev_has_evt_log
Check if a device provides an on-board event log.
Definition: mbgdevio.c:2119
uint32_t MBG_DEBUG_STATUS
A data type used to read the board&#39;s debug status.
Definition: gpsdefs.h:5204
MBG_MUTEX MBG_CRIT_SECT
Definition: mbgmutex.h:232
_MBG_API_ATTR int _MBG_API mbg_get_time_sec_change(MBG_DEV_HANDLE dh, PCPS_TIME *p)
Wait until the next second change, then return current time.
Definition: mbgdevio.c:4586
Simple LAN interface information.
Definition: gpsdefs.h:11274
int mbg_set_time_scale_settings(MBG_DEV_HANDLE dh, const MBG_TIME_SCALE_SETTINGS *p)
Write the time scale configuration to a device.
Definition: mbgdevio.c:6502
Device info structure.
Definition: pcpsdev.h:1043
int mbg_get_ptp_cfg_info(MBG_DEV_HANDLE dh, PTP_CFG_INFO *p)
Read PTP/IEEE1588 config info and current settings from a device.
Definition: mbgdevio.c:7427
_MBG_API_ATTR int _MBG_API mbg_dev_has_tzcode(MBG_DEV_HANDLE dh, int *p)
Check if a device supports timezone configuration using the PCPS_TZCODE type.
Definition: mbgdevio.c:2737
leap second announced, for very old clocks see REV_PCPS_LS_ANN_PC31PS31
Definition: pcpsdefs.h:1259
A structure controlling when output signals are enabled.
Definition: gpsdefs.h:3142
Current settings and general capabilities of a specific programmable pulse output.
Definition: gpsdefs.h:6351
static __mbg_inline void mbg_init_pc_cycles_frequency(MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p)
Definition: mbgdevio.h:5769