mbgtools-lx  4.2.8
mbgdevio.c
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgdevio.c 1.42 2018/11/22 14:21:19 martin REL_M $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Functions called from user space to access Meinberg device drivers.
10  *
11  * -----------------------------------------------------------------------
12  * $Log: mbgdevio.c $
13  * Revision 1.42 2018/11/22 14:21:19 martin
14  * Use new preprocessor symbol MBG_TGT_USE_IOCTL instead of
15  * obsolete MBG_USE_KERNEL_DRIVER.
16  * Revision 1.41 2018/09/21 08:57:32 martin
17  * Updated some comments.
18  * Revision 1.40 2018/07/05 08:46:20Z martin
19  * Fixed function mbg_open_device_by_name() which failed
20  * with short device names.
21  * Fixed function mbg_chk_dev_is_lwr().
22  * Open all device nodes with FILE_FLAG_OVERLAPPED under Windows.
23  * mbg_dev_fn_from_dev_idx() returns a generic device name
24  * instead of the hardware ID string under Windows.
25  * Added missing linkage attribute for mbg_open_device().
26  * Added function mbg_split_dev_name().
27  * Added function mbg_chk_dev_has_dac_ctrl().
28  * Also accept '?' in S/N of uninitialized devices.
29  * Refactored implementation of deprecated feature check functions.
30  * Updated naming for device feature stuff.
31  * Removed obsolete size_t to int conversion code.
32  * Account for changes in mbgmutex.h.
33  * Removed usage of obsolete symbol MBGDEVIO_SIMPLE.
34  * Moved checking of the receiver info to an extra function.
35  * Updated and added some comments.
36  * Revision 1.39 2017/07/05 15:02:47 martin
37  * Lots of new API functions provided by thomas-b, philipp, and martin.
38  * Fixed a potential buffer overflow in mbg_open_device_by_name().
39  * Fixed a bug where XYZ and LLA were not written properly
40  * under target systems not using a kernel driver.
41  * Proper return codes from thread functions.
42  * PCPS_DEV * parameter for mbg_setup_receiver_info may now be NULL.
43  * New set of functions to determine if a specific feature is supported.
44  * The functions are named mbg_chk_dev_...(), are combined in a group
45  * mbgdevio_chk_supp_fncs, and replace and deprecate a set of older
46  * functions named mbg_chk_dev_(), which are collected in a group
47  * mbgdevio_chk_supp_fncs_deprecated. The new functions are much easier
48  * to be handled, and return a single, distinct return code which clearly
49  * tells if a feature is not supported, or an error occurred while trying
50  * to find this out.
51  * Older defines N_SUPP_DEV, PCPS_MAX_DDEVS, and MBG_MAX_DEVICES
52  * have been obsoleted by new defines N_SUPP_DEV_BUS, N_SUPP_DEV_EXT,
53  * and N_SUPP_DEV_TOTAL.
54  * Defined many macros in a safer way, and replaced some macros
55  * by inline functions.
56  * Improved doxygen comments.
57  * Revision 1.38 2013/11/08 15:04:54 martin
58  * Fixes for big endian targets.
59  * Revision 1.37 2013/09/26 08:54:22 martin
60  * Support GNSS API.
61  * Support mbg_open_device_by_name() on Unix.
62  * Updated doxygen comments.
63  * Revision 1.36 2012/10/02 18:37:09Z martin
64  * There are some g++ versions which fail to compile source code using
65  * the macros provided by Linux to define IOCTL codes. If only the API
66  * functions are called by an application then the IOCTL codes aren't
67  * required anyway, so we just avoid inclusion of mbgioctl.h in
68  * general and but include it when this module is built.
69  * Updated doxygen comments.
70  * New functions mbg_get_all_irig_rx_info() and
71  * mbg_save_all_irig_rx_settings().
72  * Account for renamed macros.
73  * Support on-board event logs.
74  * New functions mbg_dev_has_debug_status() and
75  * mbg_get_debug_status().
76  * Added a workaround to make mbgmon (BC) build under Windows.
77  * In mbg_get_serial_settings() return an error if the number of provided
78  * serial ports or supported string types exceeds the numbers supported
79  * by the driver.
80  * Moved mbg_get_serial_settings() and mbg_save_serial_settings()
81  * to an extra file. These functions expect parameters the sizes of
82  * which might change in future API versions, which would make
83  * functions exported by shared libraries incompatible across versions.
84  * Made functions mbg_get_gps_all_port_info() and
85  * mbg_get_gps_all_str_type_info() non-static so they are now exported
86  * by the shared libraries built from this module.
87  * Include cfg_hlp.h.
88  * Conditionally use older IOCTL request buffer structures.
89  * Moved some macros etc. to the .h file.
90  * Modified generic IOCTL handling such that for calls requiring variable sizes
91  * a fixed request block containing input and output buffer pointers and sizes is
92  * passed down to the kernel driver. This simplifies implementation under *BSD
93  * and also works for other target systems.
94  * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
95  * Added mbg_dev_has_pzf() function.
96  * Support PTP unicast configuration.
97  * Account for some IOCTL codes renamed to follow common naming conventions.
98  * Renamed mutex stuff to critical sections.
99  * Added API calls to support PTP unicast.
100  * Specify I/O range number when calling port I/O macros
101  * so they can be used for different ranges under BSD.
102  * Modifications to support FreeBSD.
103  * Moved definition of MBG_HW_NAME to the header file.
104  * Compute PC cycles frequency under Linux if cpu_tick is not set by the kernel.
105  * Fixed a bug that kept the function mbg_open_device_by_name in a loop under certain conditions.
106  * Made xhrt leap second check an inline function.
107  * Revision 1.35 2010/01/12 13:40:25 martin
108  * Fixed a typo in mbg_dev_has_raw_irig_data().
109  * Revision 1.34 2009/12/15 15:34:58Z daniel
110  * Support reading the raw IRIG data bits for firmware versions
111  * which support this feature.
112  * Revision 1.33 2009/09/29 15:08:40Z martin
113  * Support retrieving time discipline info.
114  * Revision 1.32 2009/08/17 13:46:29 martin
115  * Moved specific definition of symbol _HAVE_IOCTL_WITH_SIZE
116  * to mbgioctl.h and renamed it to _MBG_SUPP_VAR_ACC_SIZE.
117  * Revision 1.31 2009/08/12 14:28:26 daniel
118  * Included PTP functions in build.
119  * Revision 1.30 2009/06/19 12:19:41Z martin
120  * Support reading raw IRIG time.
121  * Revision 1.29 2009/06/08 18:23:22 daniel
122  * Added PTP configuration functions and PTP state functions, but
123  * they are still excluded from build.
124  * Added calls to support simple LAN interface configuration.
125  * Revision 1.28 2009/03/19 15:30:04 martin
126  * Added support for configurable time scales.
127  * Support reading/writing GPS UTC parameters.
128  * Support reading IRIG control function bits.
129  * Support reading MM timestamps without cycles.
130  * Fixed endianess correction in mbg_get_gps_pos().
131  * Endianess correction for ASIC version and ASIC features
132  * is now done by the kernel driver.
133  * Use generic cycles types and functions in mbg_get_default_cycles_frequency().
134  * mbg_tgt.h is now included in mbgdevio.h.
135  * Account for renamed IOCTL codes.
136  * Revision 1.27 2008/12/17 10:37:37 martin
137  * Fixed a bug in mbg_open_device_by_name() with sel. mode MBG_MATCH_ANY.
138  * Support variable read buffer sizes under Linux, so
139  * mbg_get_all_port_info() and mbg_get_all_str_type_info()
140  * can now be used under Linux.
141  * Support PC cycles under Linux via inline rdtsc call.
142  * Use predefined constants to convert fractions.
143  * New API calls mbg_get_fast_hr_timestamp_cycles(), and
144  * mbg_get_fast_hr_timestamp_comp() which take memory mapped HR time stamps
145  * in kernel space, and mbg_dev_has_fast_hr_timestamp() to check whether
146  * this is supported by a device.
147  * Removed mm_*() functions since these are obsolete now.
148  * Support extrapolated HR time (xhrt) for Windows and Linux
149  * by providing a function mbg_xhrt_poll_thread_create() which
150  * starts a poll thread for a specific device which to read
151  * HR time plus associated cycles in regular intervals.
152  * Added functions mbg_get_process_affinity(), mbg_set_process_affinity(),
153  * and mbg_set_current_process_affinity_to_cpu(), and mbg_create_thread()
154  * and mbg_set_thread_affinity() to control the extrapolation feature.
155  * Use new preprocessor symbol MBGDEVIO_HAVE_THREAD_AFFINITY.
156  * Added new functions mbg_get_xhrt_time_as_pcps_hr_time() and
157  * mbg_get_xhrt_time_as_filetime() (Windows only) to retrieve
158  * fast extrapolated timestamps.
159  * Added function mbg_get_xhrt_cycles_frequency() to retrieve the
160  * cycles counter frequency computed by the polling thread.
161  * Added function mbg_get_default_cycles_frequency_from_dev(),
162  * and mbg_get_default_cycles_frequency() (Windows only).
163  * Moved mbg_open_device..() functions upwards.
164  * Made device_info_list common.
165  * New functions mbg_dev_is_msf(), mbg_dev_is_wwvb(), mbg_dev_is_lwr(),
166  * mbg_dev_has_asic_version(), mbg_dev_has_asic_features(),
167  * and mbg_get_irq_stat_info().
168  * Exclude 2 more functions from build if symbol MBGDEVIO_SIMPLE is not 0.
169  * Account for MBG_VIRT_ADDR having beenrenamed to MBG_MEM_ADDR.
170  * Account Linux for device names renamed from /dev/mbgclk to /dev/mbgclock.
171  * Support bigendian target platforms.
172  * Revision 1.26 2008/02/26 16:54:21 martin
173  * New/changed functions for memory mapped access which are
174  * currently excluded from build.
175  * Changed separator for device names from ' ' to '_'.
176  * Added new type MBG_HW_NAME.
177  * Comment cleanup for doxygen.
178  * Revision 1.25 2008/02/04 13:42:45Z martin
179  * Account for preprocessor symbol MBG_TGT_SUPP_MMAP.
180  * Revision 1.24 2008/01/31 08:31:40Z martin
181  * Picked up changes from 1.19.1.2:
182  * Under DOS detect and disable any TSR while searching for devices.
183  * Exclude some complex configuration API calls from build
184  * If MBGDEVIO_SIMPLE is defined != 0.
185  * Revision 1.23 2008/01/30 10:32:35Z daniel
186  * Renamed mapped memory funtions.
187  * Revision 1.22 2008/01/25 15:27:42Z daniel
188  * Fixed a bug in mbg_get_hr_time_comp() where an overflow
189  * of the fractions was handled with wrong sign.
190  * Revision 1.21 2008/01/17 15:49:59Z daniel
191  * Added functions mbg_find_devices_with_hw_id() and
192  * mbg_free_devics_list() to work with Linux Win32 OSs.
193  * Added Doxygen compliant comments for API functions.
194  * Support for mapped memory I/O under linux and windows.
195  * Added functions mbg_get_mapped_memory_info(),
196  * mbg_unmap_mapped_memory() and
197  * mbg_get_hr_timestamp_memory_mapped().
198  * Account for PCI_ASIC_FEATURES.
199  * Cleanup for PCI ASIC version.
200  * Revision 1.20 2007/09/27 07:31:12 daniel
201  * Moved declaration of portable inline specifier to mbg_tgt.h.
202  * Support hotplugging of devices as used with USB by Daniel's new
203  * functions mbg_find_devices_with_names(), mbg_free_device_name_list(),
204  * mbg_open_device_by_hw_id(), and mbg_open_device_by_name().
205  * In mbg_get_serial_settings() account for devices which have no
206  * serial port at all.
207  * Register event source if Windows DLL is loaded.
208  * Revision 1.19 2007/05/21 15:00:00Z martin
209  * Unified naming convention for symbols related to ref_offs.
210  * Revision 1.18 2007/03/02 10:17:41Z martin
211  * Use generic port I/O macros.
212  * Changes due to modified/renamed macros.
213  * Changes due to renamed library symbols.
214  * Preliminary support for *BSD.
215  * Revision 1.17 2006/05/02 13:15:37 martin
216  * Added mbg_set_gps_port_settings(), mbg_get_gps_all_pout_info(),
217  * mbg_set_gps_pout_settings_idx(), mbg_set_gps_pout_settings().
218  * Revision 1.16 2005/06/02 11:53:12Z martin
219  * Implemented existing mbg_generic_..() functions.
220  * Added new functions mbg_generic_io() and mbg_dev_has_generic_io().
221  * Added new function mbg_get_synth_state().
222  * Partially use inline function.
223  * Changed order of some functions.
224  * More simplifications using macros.
225  * Unified macros for Win32 and Linux.
226  * Fixed warning under Win32 using type cast.
227  * Revision 1.15 2005/01/31 16:44:21Z martin
228  * Added function mbg_get_hr_time_comp() which returns HR time stamp
229  * which has latency compensated.
230  * Revision 1.14 2005/01/14 10:22:23Z martin
231  * Added functions which query device features.
232  * Revision 1.13 2004/12/09 11:23:59Z martin
233  * Support configuration of on-board frequency synthesizer.
234  * Revision 1.12 2004/11/09 14:11:07Z martin
235  * Modifications were required in order to be able to configure IRIG
236  * settings of cards which provide both IRIG input and output.
237  * Renamed functions mbg_get_irig_info() and mbg_set_irig_settings()
238  * to mbg_get_irig_rx_info() and mbg_set_irig_rx_settings()
239  * New functions mbg_get_irig_tx_info() and mbg_set_irig_tx_settings().
240  * All API functions now use well defined parameter types instead of
241  * generic types. Some new types have been defined therefore.
242  * Added a workaround for GPS169PCI cards with early firmware versions
243  * which used the same codes to configure the IRIG output as the TCR
244  * cards use to configure the IRIG input. Those codes are now
245  * exclusively used to configure the IRIG input. The workaround
246  * has been included in order to let GPS169PCI cards work properly
247  * after a driver update, without requiring a firmware update.
248  * The macro _pcps_ddev_requires_irig_workaround() is used to check
249  * if the workaround is required.
250  * Renamed function mbg_get_gps_stat() to mbg_get_gps_bvar_stat().
251  * Revision 1.11 2004/08/17 11:13:45Z martin
252  * Account for renamed symbols.
253  * Revision 1.10 2004/04/14 09:39:17Z martin
254  * Allow [g|s]et_irig_info() also for new devices with IRIG output.
255  * Use MBGDEVIO_COMPAT_VERSION to check version.
256  * Revision 1.9 2003/12/22 15:30:52Z martin
257  * Added functions mbg_get_asic_version(), mbg_get_time_cycles(),
258  * and mbg_get_hr_time_cycles().
259  * Support higher baud rates for TCR510PCI and PCI510.
260  * Support PCPS_HR_TIME for TCR510PCI.
261  * API calls return ioctl results instead of success/-1.
262  * Moved some Win32 specific code to mbgsvctl DLL.
263  * Log Win32 ioctl errors to event log for debugging.
264  * Revision 1.8 2003/06/19 08:42:33Z martin
265  * Renamed function mbg_clr_cap_buff() to mbg_clr_ucap_buff().
266  * New functions mbg_get_ucap_entries() and mbg_get_ucap_event().
267  * New function mbg_get_hr_ucap().
268  * New functions mbgdevio_get_version() and mbgdevio_check_version().
269  * New functions for generic read/write access.
270  * New functions mbg_get_pcps_tzdl() and mbg_set_pcps_tzdl().
271  * Fixed a bug passing the wrong command code to a
272  * direct access target in mbg_get_sync_time().
273  * Return driver info for direct access targets.
274  * Include pcpsdrvr.h and pcps_dos.h, if applicable.
275  * For direct access targets, check if a function is supported
276  * before accessing the hardware.
277  * Use const parameter pointers if applicable.
278  * Changes due to renamed symbols/macros.
279  * Source code cleanup.
280  * Revision 1.7 2003/05/16 08:52:46 MARTIN
281  * Swap doubles inside API functions.
282  * Enhanced support for direct access targets.
283  * Removed obsolete code.
284  * Revision 1.6 2003/04/25 10:14:16 martin
285  * Renamed macros.
286  * Extended macro calls for direct access targets.
287  * Updated macros for Linux.
288  * Revision 1.5 2003/04/15 19:35:25Z martin
289  * New functions mbg_setup_receiver_info(),
290  * mbg_get_serial_settings(), mbg_save_serial_settings().
291  * Revision 1.4 2003/04/09 16:07:16Z martin
292  * New API functions mostly complete.
293  * Use renamed IOCTL codes from mbgioctl.h.
294  * Added DllEntry function for Win32.
295  * Made MBG_Device_count and MBG_Device_Path local.
296  * Revision 1.3 2003/01/24 13:44:40Z martin
297  * Fixed get_ref_time_from_driver_at_sec_change() to be used
298  * with old kernel drivers.
299  * Revision 1.2 2002/09/06 11:04:01Z martin
300  * Some old API functions have been replaced by new ones
301  * for a common PnP/non-PnP API.
302  * New API function which clears capture buffer.
303  * New function get_ref_time_from_driver_at_sec_change().
304  * Revision 1.1 2002/02/19 13:48:20Z MARTIN
305  * Initial revision
306  *
307  **************************************************************************/
308 
309 #define _MBGDEVIO
310  #include <mbgdevio.h>
311 #undef _MBGDEVIO
312 
313 #include <mbgutil.h>
314 #include <gpsutils.h>
315 #include <mbgerror.h>
316 #include <cfg_hlp.h>
317 #include <str_util.h>
318 
319 #if defined( MBG_TGT_DOS_PM )
320  #include <mbg_dpmi.h>
321 #endif
322 
323 
324 #if !MBG_TGT_USE_IOCTL
325 
326  #include <pcpsdrvr.h>
327  #include <pci_asic.h>
328 
329  static PCPS_DRVR_INFO drvr_info = { MBGDEVIO_VERSION, 0, "MBGDEVIO direct" };
330 
331 #endif
332 
333 
334 // target specific code for different environments
335 
336 #if defined( MBG_TGT_WIN32 )
337 
338  #include <mbgsvctl.h>
339  #include <mbgnames.h>
340  #include <pci_asic.h>
341  #include <mbgutil.h>
342  #include <timecnv.h>
343  #include <pcpsutil.h>
344 
345  #include <tchar.h>
346  #include <stdio.h>
347 
348 #elif defined( MBG_TGT_POSIX ) && !defined( MBG_TGT_QNX_NTO )
349 
350  #include <unistd.h>
351  #include <stdlib.h>
352  #include <string.h>
353 
354  #if defined( DEBUG )
355  #include <stdio.h> // printf() debug output
356  #endif
357 
358 #else // other target OSs which access the hardware directly
359 
360  #if defined( MBG_TGT_QNX_NTO )
361  #include <stdio.h>
362  #include <sys/neutrino.h>
363  #endif
364 
365  #if MBG_USE_DOS_TSR
366  #include <pcps_dos.h>
367  #else
368  #define pcps_read_safe _pcps_read
369  #define pcps_write_safe pcps_write
370  #define pcps_read_gps_safe pcps_read_gps
371  #define pcps_write_gps_safe pcps_write_gps
372 
373  #define _pcps_write_byte_safe _pcps_write_byte
374  #define _pcps_read_var_safe _pcps_read_var
375  #define _pcps_write_var_safe _pcps_write_var
376  #define _pcps_read_gps_var_safe _pcps_read_gps_var
377  #define _pcps_write_gps_var_safe _pcps_write_gps_var
378  #endif
379 
380 #endif // end of target specific code
381 
382 
383 #if !defined( _MBG_SUPP_VAR_ACC_SIZE )
384  // If this symbol has not yet been defined then mbgioctl.h has probably
385  // not yet been included. On target systems where the hardware is accessed
386  // directly without a kernel driver variable buffer sizes are supported,
387  // so we set the default to 1.
388  #define _MBG_SUPP_VAR_ACC_SIZE 1
389 #endif
390 
391 
392 #if !defined( _mbgdevio_chk_cond )
393  // If the macro has not been defined previously then
394  // it may not be required for the target environment and
395  // is defined as empty string.
396  #define _mbgdevio_chk_cond( _cond ) _nop_macro_fnc()
397 #endif
398 
399 
400 
401 #define _mbgdevio_read_chk( _dh, _cmd, _ioctl, _p, _sz, _cond ) \
402 do \
403 { \
404  _mbgdevio_chk_cond( _cond ); \
405  rc = _do_mbgdevio_read( _dh, _cmd, _ioctl, _p, _sz ); \
406 } while ( 0 )
407 
408 #define _mbgdevio_read_var_chk( _dh, _cmd, _ioctl, _p, _cond ) \
409 do \
410 { \
411  _mbgdevio_chk_cond( _cond ); \
412  rc = _mbgdevio_read_var( _dh, _cmd, _ioctl, _p ); \
413 } while ( 0 )
414 
415 #define _mbgdevio_write_var_chk( _dh, _cmd, _ioctl, _p, _cond ) \
416 do \
417 { \
418  _mbgdevio_chk_cond( _cond ); \
419  rc = _mbgdevio_write_var( _dh, _cmd, _ioctl, _p ); \
420 } while ( 0 )
421 
422 #define _mbgdevio_write_cmd_chk( _dh, _cmd, _ioctl, _cond ) \
423 do \
424 { \
425  _mbgdevio_chk_cond( _cond ); \
426  rc = _mbgdevio_write_cmd( _dh, _cmd, _ioctl ); \
427 } while ( 0 )
428 
429 #define _mbgdevio_read_gps_chk( _dh, _cmd, _ioctl, _p, _sz, _cond ) \
430 do \
431 { \
432  _mbgdevio_chk_cond( _cond ); \
433  rc = _do_mbgdevio_read_gps( _dh, _cmd, _ioctl, _p, _sz ); \
434 } while ( 0 )
435 
436 #define _mbgdevio_read_gps_var_chk( _dh, _cmd, _ioctl, _p, _cond ) \
437 do \
438 { \
439  _mbgdevio_chk_cond( _cond ); \
440  rc = _mbgdevio_read_gps_var( _dh, _cmd, _ioctl, _p ); \
441 } while ( 0 )
442 
443 #define _mbgdevio_write_gps_var_chk( _dh, _cmd, _ioctl, _p, _cond ) \
444 do \
445 { \
446  _mbgdevio_chk_cond( _cond ); \
447  rc = _mbgdevio_write_gps_var( _dh, _cmd, _ioctl, _p ); \
448 } while ( 0 )
449 
450 
451 
452 static /*HDR*/
469 int do_chk_dev_feat( MBG_DEV_HANDLE dh, uint32_t feat_type, uint32_t feat_num )
470 {
471  #if defined( _MBGIOCTL_H )
472  {
473  // This target uses a kernel driver, so we send an IOCTL
474  // to the kernel driver to retrieve the information.
475  MBGDEVIO_RET_VAL rc;
476  IOCTL_DEV_FEAT_REQ req;
477  req.feat_type = feat_type;
478  req.feat_num = feat_num;
479  rc = _do_mbg_ioctl( dh, IOCTL_CHK_DEV_FEAT,
480  &req, sizeof( req ), 0 );
481 #if 0 && DEBUG
482  {
483  int rc2 = _mbgdevio_cnv_ret_val( rc );
484  printf( "feat ioctl %lu:%lu ret: %i --> %i\n",
485  (ulong) feat_type, (ulong) feat_num, rc, rc2 );
486  return rc2;
487  }
488 #else
489  return _mbgdevio_cnv_ret_val( rc );
490 #endif
491  }
492  #else
493  // This target doesn't use a kernel driver, so we directly call
494  // the function that would be called by the kernel driver.
495  return pcps_chk_dev_feat( dh, feat_type, feat_num );
496  #endif
497 
498 } // do_chk_dev_feat
499 
500 
501 
524 {
525  // Call the current feature check function.
526  int rc = fnc( dh );
527  int is_success = mbg_rc_is_success( rc );
528 
529  if ( is_success // definitely supported
530  || ( rc == MBG_ERR_NOT_SUPP_BY_DEV ) ) // definitely NOT supported
531  {
532  // We could definitely determine if the requested feature
533  // is supported or not, so we accordingly update the integer
534  // variable the address of which has been passed by the caller,
535  // and return MBG_SUCCESS since the information could be
536  // retrieved successfully.
537  *p = is_success;
538  return MBG_SUCCESS;
539  }
540 
541  // If execution goes here then there was some error trying
542  // to determine the requested information, e.g. an IOCTL error
543  // when accessing the kernel driver, so we return the associated
544  // error code.
545  return rc;
546 
547 } // do_chk_dev_feat_deprecated
548 
549 
550 
551 #if defined( _MBGIOCTL_H )
552 
553 static /*HDR*/
570 int do_query_cond( MBG_DEV_HANDLE dh, unsigned int ioctl_code )
571 {
572  MBGDEVIO_RET_VAL rc;
573  int flag = 0;
574  rc = _mbgdevio_read_var( dh, -1, ioctl_code, &flag );
575 
576  if ( mbg_rc_is_success( rc ) ) // no IOCTL error
577  if ( flag == 0 ) // if returned value is 0
578  rc = MBG_ERR_NOT_SUPP_BY_DEV; // not supp.
579 
580  // success or IOCTL error
581  return _mbgdevio_cnv_ret_val( rc );
582 
583 } // do_query_cond
584 
585 #define _do_query_cond( _dh, _cond, _ioctl ) \
586  do_query_cond( _dh, _ioctl )
587 
588 #else
589 
590 #define _do_query_cond( _dh, _cond, _ioctl ) \
591  _cond( _dh ) ? MBG_SUCCESS : MBG_ERR_NOT_SUPP_BY_DEV
592 
593 #endif
594 
595 
597 
598 
599 
600 /*HDR*/
616 {
617  return MBGDEVIO_VERSION;
618 
619 } // mbgdevio_get_version
620 
621 
622 
623 /*HDR*/
642 {
643  if ( header_version >= MBGDEVIO_COMPAT_VERSION )
644  return MBG_SUCCESS;
645 
647 
648 } // mbgdevio_check_version
649 
650 
651 
652 /*HDR*/
675 {
677 
678 } // mbg_chk_dev_has_receiver_info
679 
681 
682 
683 
684 /*HDR*/
703 {
705 
706 } // mbg_chk_dev_has_gps_data
707 
709 
710 
711 
712 /*HDR*/
730 {
732 
733 } // mbg_chk_dev_has_generic_io
734 
736 
737 
738 
739 /*HDR*/
758 {
759  // TODO return do_chk_dev_feat( dh, DEV_FEAT_TYPE_PCPS, ... );
761 
762 } // mbg_chk_dev_has_asic_version
763 
765 
766 
767 
768 /*HDR*/
787 {
788  // TODO return do_chk_dev_feat( dh, DEV_FEAT_TYPE_PCPS, ... );
790 
791 } // mbg_chk_dev_has_asic_features
792 
794 
795 
796 
797 /*HDR*/
820 {
822 
823 } // mbg_chk_dev_has_xmr
824 
826 
827 
828 
829 static /*HDR*/
844 int chk_bus_flags( MBG_DEV_HANDLE dh, int bus_flag_mask )
845 {
846  PCPS_DEV dev_info;
847 
848  int rc = mbg_get_device_info( dh, &dev_info );
849 
850  if ( mbg_rc_is_error( rc ) )
851  return rc;
852 
853  return ( dev_info.type.bus_flags & bus_flag_mask ) ? MBG_SUCCESS : MBG_ERR_NOT_SUPP_BY_DEV;
854 
855 } // chk_bus_flags
856 
857 
858 
859 /*HDR*/
871 {
872  return chk_bus_flags( dh, PCPS_BUS_ISA );
873 
874 } // mbg_chk_dev_is_isa
875 
877 
878 
879 
880 /*HDR*/
892 {
893  return chk_bus_flags( dh, PCPS_BUS_MCA );
894 
895 } // mbg_chk_dev_is_mca
896 
898 
899 
900 
901 /*HDR*/
913 {
914  return chk_bus_flags( dh, PCPS_BUS_PCI );
915 
916 } // mbg_chk_dev_is_pci
917 
919 
920 
921 
922 /*HDR*/
934 {
935  PCPS_DEV dev_info;
936 
937  int rc = mbg_get_device_info( dh, &dev_info );
938 
939  if ( mbg_rc_is_error( rc ) )
940  return rc;
941 
942  // TODO Move this to the kernel driver
943  if ( ( dev_info.type.bus_flags == PCPS_BUS_PCI_MBGPEX ) ||
944  ( dev_info.type.bus_flags == PCPS_BUS_PCI_PEX8311 ) )
945  return MBG_SUCCESS;
946 
948 
949 } // mbg_chk_dev_is_pci_express
950 
952 
953 
954 
955 /*HDR*/
967 {
968  return chk_bus_flags( dh, PCPS_BUS_USB );
969 
970 } // mbg_chk_dev_is_usb
971 
973 
974 
975 
976 /*HDR*/
997 {
999 
1000 } // mbg_chk_dev_is_gnss
1001 
1003 
1004 
1005 
1006 /*HDR*/
1024 {
1026 
1027 } // mbg_chk_dev_is_gps
1028 
1030 
1031 
1032 
1033 /*HDR*/
1054 {
1056 
1057 } // mbg_chk_dev_is_dcf
1058 
1060 
1061 
1062 
1063 /*HDR*/
1087 {
1089 
1090 } // mbg_chk_dev_has_pzf
1091 
1093 
1094 
1095 
1096 /*HDR*/
1112 {
1114 
1115 } // mbg_chk_dev_is_msf
1116 
1118 
1119 
1120 
1121 /*HDR*/
1137 {
1139 
1140 } // _pcps_ddev_is_wwvb
1141 
1143 
1144 
1145 
1146 /*HDR*/
1159 {
1161 
1162 } // _pcps_ddev_is_jjy
1163 
1165 
1166 
1167 
1168 /*HDR*/
1189 {
1190  int rc = mbg_chk_dev_is_dcf( dh );
1191 
1192  if ( mbg_rc_is_success( rc ) )
1193  goto out;
1194 
1195  rc = mbg_chk_dev_is_msf( dh );
1196 
1197  if ( mbg_rc_is_success( rc ) )
1198  goto out;
1199 
1200  rc = mbg_chk_dev_is_wwvb( dh );
1201 
1202  if ( mbg_rc_is_success( rc ) )
1203  goto out;
1204 
1205  rc = mbg_chk_dev_is_jjy( dh );
1206 
1207  if ( mbg_rc_is_success( rc ) )
1208  goto out;
1209 
1210 out:
1211  return rc;
1212 
1213 } // mbg_chk_dev_is_lwr
1214 
1216 
1217 
1218 
1219 /*HDR*/
1238 {
1240 
1241 } // mbg_chk_dev_is_tcr
1242 
1244 
1245 
1246 
1247 /*HDR*/
1266 {
1268 
1269 } // mbg_chk_dev_has_lan_intf
1270 
1272 
1273 
1274 
1275 /*HDR*/
1295 {
1297 
1298 } // mbg_chk_dev_has_ptp
1299 
1301 
1302 
1303 
1304 /*HDR*/
1328 {
1330 
1331 } // mbg_chk_dev_has_ptp_unicast
1332 
1334 
1335 
1336 
1337 /*HDR*/
1355 {
1357 
1358 } // mbg_chk_dev_has_hr_time
1359 
1361 
1362 
1363 
1364 /*HDR*/
1382 {
1384 
1385 } // mbg_chk_dev_has_fast_hr_timestamp
1386 
1388 
1389 
1390 
1391 /*HDR*/
1411 {
1413 
1414 } // mbg_chk_dev_has_time_scale
1415 
1417 
1418 
1419 
1420 /*HDR*/
1421 /* (Intentionally excluded from Doxygen)
1422  * @brief Check if a device supports setting an event time
1423  *
1424  * This feature is only supported by some special custom firmware
1425  * to preset a %UTC time at which the clock is to generate an output signal.
1426  *
1427  * @note This function should be preferred over ::mbg_dev_has_event_time,
1428  * which has been deprecated.
1429  *
1430  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
1431  *
1432  * @return ::MBG_SUCCESS if the requested feature is supported, ::MBG_ERR_NOT_SUPP_BY_DEV
1433  * if not supported, or one of the other @ref MBG_ERROR_CODES
1434  *
1435  * @ingroup mbgdevio_chk_supp_fncs
1436  * @see ::mbg_set_event_time
1437  */
1439 {
1441 
1442 } // mbg_chk_dev_has_event_time
1443 
1445 
1446 
1447 
1448 /*HDR*/
1471 {
1473 
1474 } // mbg_chk_dev_has_ucap
1475 
1477 
1478 
1479 
1480 /*HDR*/
1500 {
1502 
1503 } // mbg_chk_dev_can_clr_ucap_buff
1504 
1506 
1507 
1508 
1509 /*HDR*/
1527 {
1529 
1530 } // mbg_chk_dev_has_tzdl
1531 
1533 
1534 
1535 
1536 /*HDR*/
1554 {
1556 
1557 } // mbg_chk_dev_has_pcps_tzdl
1558 
1560 
1561 
1562 
1563 /*HDR*/
1581 {
1583 
1584 } // mbg_chk_dev_has_tzcode
1585 
1587 
1588 
1589 
1590 /*HDR*/
1608 {
1610 
1611 } // mbg_chk_dev_has_tz
1612 
1614 
1615 
1616 
1617 /*HDR*/
1634 {
1636 
1637 } // mbg_chk_dev_has_irig
1638 
1640 
1641 
1642 
1643 /*HDR*/
1663 {
1665 
1666 } // mbg_chk_dev_has_irig_tx
1667 
1669 
1670 
1671 
1672 /*HDR*/
1688 {
1690 
1691 } // mbg_chk_dev_has_irig_ctrl_bits
1692 
1694 
1695 
1696 
1697 /*HDR*/
1714 {
1716 
1717 } // mbg_chk_dev_has_raw_irig_data
1718 
1720 
1721 
1722 
1723 /*HDR*/
1739 {
1741 
1742 } // mbg_chk_dev_has_irig_time
1743 
1745 
1746 
1747 
1748 /*HDR*/
1766 {
1768 
1769 } // mbg_chk_dev_has_signal
1770 
1772 
1773 
1774 
1775 /*HDR*/
1792 {
1794 
1795 } // mbg_chk_dev_has_mod
1796 
1798 
1799 
1800 
1801 /*HDR*/
1802 /* (Intentionally excluded from Doxygen)
1803  * @brief Check if a device supports higher baud rates than usual
1804  *
1805  * Check if a device provides a serial output that supports
1806  * higher baud rates than older cards, i.e. ::DEFAULT_BAUD_RATES_DCF_HS
1807  * rather than ::DEFAULT_BAUD_RATES_DCF.
1808  *
1809  * The call ::mbg_get_serial_settings takes care of this, so applications
1810  * which use that call as suggested don't need to use this call directly.
1811  *
1812  * @note This function should be preferred over ::mbg_dev_has_serial_hs,
1813  * which has been deprecated.
1814  *
1815  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
1816  *
1817  * @return ::MBG_SUCCESS if the requested feature is supported, ::MBG_ERR_NOT_SUPP_BY_DEV
1818  * if not supported, or one of the other @ref MBG_ERROR_CODES
1819  *
1820  * @ingroup mbgdevio_chk_supp_fncs
1821  * @see ::mbg_get_serial_settings
1822  */
1824 {
1826 
1827 } // mbg_chk_dev_has_serial_hs
1828 
1830 
1831 
1832 
1833 /*HDR*/
1850 {
1852 
1853 } // mbg_chk_dev_has_synth
1854 
1856 
1857 
1858 
1859 /*HDR*/
1878 {
1880 
1881 } // mbg_chk_dev_has_gpio
1882 
1884 
1885 
1886 
1887 /*HDR*/
1904 {
1906 
1907 } // mbg_chk_dev_has_cab_len
1908 
1910 
1911 
1912 
1913 /*HDR*/
1933 {
1934  return mbg_chk_dev_is_tcr( dh ); // All TCRs have this
1935 
1936 } // mbg_chk_dev_has_ref_offs
1937 
1939 
1940 
1941 
1942 /*HDR*/
1962 {
1963  return mbg_chk_dev_is_tcr( dh ); // All TCRs have this
1964 
1965 } // mbg_chk_dev_has_opt_flags
1966 
1968 
1969 
1970 
1971 /*HDR*/
2000 {
2002 
2003 } // mbg_chk_dev_has_utc_parm
2004 
2006 
2007 
2008 
2009 /*HDR*/
2031 {
2032  return mbg_chk_dev_has_pzf( dh ); // All DCF77 PZF receivers have this
2033 
2034 } // mbg_chk_dev_has_corr_info
2035 
2037 
2038 
2039 
2040 /*HDR*/
2061 {
2062  return mbg_chk_dev_has_pzf( dh ); // All DCF77 PZF receivers have this
2063 
2064 } // mbg_chk_dev_has_tr_distance
2065 
2067 
2068 
2069 
2070 /*HDR*/
2086 {
2087  return mbg_chk_dev_is_tcr( dh ); // All TCRs have this
2088 
2089 } // mbg_chk_dev_has_debug_status
2090 
2092 
2093 
2094 
2095 /*HDR*/
2114 {
2116 
2117 } // mbg_chk_dev_has_evt_log
2118 
2120 
2121 
2122 
2123 /*HDR*/
2135 {
2137 
2138 } // mbg_chk_dev_has_dac_ctrl
2139 
2141 
2142 
2143 
2144 /*HDR*/
2159 _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 )
2160 {
2162 
2163 } // mbg_dev_has_receiver_info
2164 
2165 
2166 
2167 /*HDR*/
2182 _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 )
2183 {
2185 
2186 } // mbg_dev_has_gps_data
2187 
2188 
2189 
2190 /*HDR*/
2205 _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 )
2206 {
2208 
2209 } // mbg_dev_has_generic_io
2210 
2211 
2212 
2213 /*HDR*/
2228 _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 )
2229 {
2231 
2232 } // mbg_dev_has_asic_version
2233 
2234 
2235 
2236 /*HDR*/
2252 _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 )
2253 {
2255 
2256 } // mbg_dev_has_asic_features
2257 
2258 
2259 
2260 /*HDR*/
2276 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_xmr" ) _MBG_API mbg_dev_has_xmr( MBG_DEV_HANDLE dh, int *p )
2277 {
2279 
2280 } // mbg_dev_has_xmr
2281 
2282 
2283 
2284 /*HDR*/
2299 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_gnss" ) _MBG_API mbg_dev_is_gnss( MBG_DEV_HANDLE dh, int *p )
2300 {
2302 
2303 } // mbg_dev_is_gnss
2304 
2305 
2306 
2307 /*HDR*/
2322 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_gps" ) _MBG_API mbg_dev_is_gps( MBG_DEV_HANDLE dh, int *p )
2323 {
2325 
2326 } // mbg_dev_is_gps
2327 
2328 
2329 
2330 /*HDR*/
2345 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_dcf" ) _MBG_API mbg_dev_is_dcf( MBG_DEV_HANDLE dh, int *p )
2346 {
2348 
2349 } // mbg_dev_is_dcf
2350 
2351 
2352 
2353 /*HDR*/
2368 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_pzf" ) _MBG_API mbg_dev_has_pzf( MBG_DEV_HANDLE dh, int *p )
2369 {
2371 
2372 } // mbg_dev_has_pzf
2373 
2374 
2375 
2376 /*HDR*/
2391 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_msf" ) _MBG_API mbg_dev_is_msf( MBG_DEV_HANDLE dh, int *p )
2392 {
2394 
2395 } // mbg_dev_is_msf
2396 
2397 
2398 
2399 /*HDR*/
2414 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_wwvb" ) _MBG_API mbg_dev_is_wwvb( MBG_DEV_HANDLE dh, int *p )
2415 {
2417 
2418 } // mbg_dev_is_wwvb
2419 
2420 
2421 
2422 /*HDR*/
2437 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_lwr" ) _MBG_API mbg_dev_is_lwr( MBG_DEV_HANDLE dh, int *p )
2438 {
2440 
2441 } // mbg_dev_is_lwr
2442 
2443 
2444 
2445 /*HDR*/
2460 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_is_tcr" ) _MBG_API mbg_dev_is_irig_rx( MBG_DEV_HANDLE dh, int *p )
2461 {
2463 
2464 } // mbg_dev_is_irig_rx
2465 
2466 
2467 
2468 /*HDR*/
2483 _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 )
2484 {
2486 
2487 } // mbg_dev_has_lan_intf
2488 
2489 
2490 
2491 /*HDR*/
2506 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ptp" ) _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p )
2507 {
2509 
2510 } // mbg_dev_has_ptp
2511 
2512 
2513 
2514 /*HDR*/
2529 _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 )
2530 {
2532 
2533 } // mbg_dev_has_ptp_unicast
2534 
2535 
2536 
2537 /*HDR*/
2552 _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 )
2553 {
2555 
2556 } // mbg_dev_has_hr_time
2557 
2558 
2559 
2560 /*HDR*/
2575 _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 )
2576 {
2578 
2579 } // mbg_dev_has_fast_hr_timestamp
2580 
2581 
2582 
2583 /*HDR*/
2598 _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 )
2599 {
2601 
2602 } // mbg_dev_has_time_scale
2603 
2604 
2605 
2606 /*HDR*/
2623 _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 )
2624 {
2626 
2627 } // mbg_dev_has_event_time
2628 
2629 
2630 
2631 /*HDR*/
2646 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_ucap" ) _MBG_API mbg_dev_has_ucap( MBG_DEV_HANDLE dh, int *p )
2647 {
2649 
2650 } // mbg_dev_has_ucap
2651 
2652 
2653 
2654 /*HDR*/
2668 _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 )
2669 {
2671 
2672 } // mbg_dev_can_clr_ucap_buff
2673 
2674 
2675 
2676 /*HDR*/
2691 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tzdl" ) _MBG_API mbg_dev_has_tzdl( MBG_DEV_HANDLE dh, int *p )
2692 {
2694 
2695 } // mbg_dev_has_tzdl
2696 
2697 
2698 
2699 /*HDR*/
2714 _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 )
2715 {
2717 
2718 } // mbg_dev_has_pcps_tzdl
2719 
2720 
2721 
2722 /*HDR*/
2737 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tzcode" ) _MBG_API mbg_dev_has_tzcode( MBG_DEV_HANDLE dh, int *p )
2738 {
2740 
2741 } // mbg_dev_has_tzcode
2742 
2743 
2744 
2745 /*HDR*/
2760 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_tz" ) _MBG_API mbg_dev_has_tz( MBG_DEV_HANDLE dh, int *p )
2761 {
2763 
2764 } // mbg_dev_has_tz
2765 
2766 
2767 
2768 /*HDR*/
2783 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_irig" ) _MBG_API mbg_dev_has_irig( MBG_DEV_HANDLE dh, int *p )
2784 {
2786 
2787 } // mbg_dev_has_irig
2788 
2789 
2790 
2791 /*HDR*/
2806 _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 )
2807 {
2809 
2810 } // mbg_dev_has_irig_tx
2811 
2812 
2813 
2814 /*HDR*/
2829 _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 )
2830 {
2832 
2833 } // mbg_dev_has_irig_ctrl_bits
2834 
2835 
2836 
2837 /*HDR*/
2851 _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 )
2852 {
2854 
2855 } // mbg_dev_has_raw_irig_data
2856 
2857 
2858 
2859 /*HDR*/
2874 _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 )
2875 {
2877 
2878 } // mbg_dev_has_irig_time
2879 
2880 
2881 
2882 /*HDR*/
2897 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_signal" ) _MBG_API mbg_dev_has_signal( MBG_DEV_HANDLE dh, int *p )
2898 {
2900 
2901 } // mbg_dev_has_signal
2902 
2903 
2904 
2905 /*HDR*/
2920 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_mod" ) _MBG_API mbg_dev_has_mod( MBG_DEV_HANDLE dh, int *p )
2921 {
2923 
2924 } // mbg_dev_has_mod
2925 
2926 
2927 
2928 /*HDR*/
2929 /* (Intentionally excluded from Doxygen)
2930  * @brief Check if a device supports higher baud rates than usual
2931  *
2932  * Check if a device provides a serial output that supports
2933  * higher baud rates than older cards, i.e. ::DEFAULT_BAUD_RATES_DCF_HS
2934  * rather than ::DEFAULT_BAUD_RATES_DCF.
2935  *
2936  * @deprecated This function is deprecated, use ::mbg_chk_dev_has_serial_hs preferably.
2937  *
2938  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
2939  * @param[out] p Pointer to an int which is updated if the API call succeeds.
2940  * The flag is set != 0 if the requested feature is supported, else 0.
2941  *
2942  * @return ::MBG_SUCCESS on success, if *p has been updated, else one of the @ref MBG_ERROR_CODES
2943  *
2944  * @ingroup mbgdevio_chk_supp_fncs_deprecated
2945  * @see ::mbg_chk_dev_has_serial_hs
2946  */
2947 _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 )
2948 {
2950 
2951 } // mbg_dev_has_serial_hs
2952 
2953 
2954 
2955 /*HDR*/
2970 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_synth" ) _MBG_API mbg_dev_has_synth( MBG_DEV_HANDLE dh, int *p )
2971 {
2973 
2974 } // mbg_dev_has_synth
2975 
2976 
2977 
2978 /*HDR*/
2993 _MBG_API_ATTR int _DEPRECATED_BY( "mbg_chk_dev_has_gpio" ) _MBG_API mbg_dev_has_gpio( MBG_DEV_HANDLE dh, int *p )
2994 {
2996 
2997 } // mbg_dev_has_gpio
2998 
2999 
3000 
3001 /*HDR*/
3016 _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 )
3017 {
3019 
3020 } // mbg_dev_has_cab_len
3021 
3022 
3023 
3024 /*HDR*/
3039 _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 )
3040 {
3042 
3043 } // mbg_dev_has_ref_offs
3044 
3045 
3046 
3047 /*HDR*/
3062 _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 )
3063 {
3065 
3066 } // mbg_dev_has_opt_flags
3067 
3068 
3069 
3070 /*HDR*/
3085 _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 )
3086 {
3088 
3089 } // mbg_dev_has_utc_parm
3090 
3091 
3092 
3093 /*HDR*/
3108 _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 )
3109 {
3111 
3112 } // mbg_dev_has_corr_info
3113 
3114 
3115 
3116 /*HDR*/
3131 _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 )
3132 {
3134 
3135 } // mbg_dev_has_tr_distance
3136 
3137 
3138 
3139 /*HDR*/
3154 _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 )
3155 {
3157 
3158 } // mbg_dev_has_debug_status
3159 
3160 
3161 
3162 /*HDR*/
3177 _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 )
3178 {
3180 
3181 } // mbg_dev_has_evt_log
3182 
3183 
3184 
3185 static /*HDR*/
3198  const MBG_PC_CYCLES *p_cyc_ts,
3199  const MBG_PC_CYCLES *p_cyc_ontime,
3200  const MBG_PC_CYCLES_FREQUENCY *p_cyc_freq,
3201  int32_t *hns_latency )
3202 {
3203  #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_POSIX )
3204 
3205  int64_t cyc_latency;
3206  int64_t frac_latency;
3207  int64_t comp_frac; //uint??
3208 
3209  // Compute latency in cycles counter units
3210  cyc_latency = mbg_delta_pc_cycles( p_cyc_ts, p_cyc_ontime );
3211 
3212  #if DEBUG && defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
3213  printf( "comp_lat: %08llX.%08llX %llX - %llX = %lli",
3214  (unsigned long long) ts->sec,
3215  (unsigned long long) ts->frac,
3216  (unsigned long long) *p_cyc_ts,
3217  (unsigned long long) *p_cyc_ontime,
3218  (unsigned long long) cyc_latency
3219  );
3220  #endif
3221 
3222  // Account for cycles counter overflow. If the CPU's TSC is used
3223  // this is supposed to happen once every 2^^63 units of the
3224  // cycles counter frequency, i.e. about every 97 years on a system
3225  // with 3 GHz clock.
3226  if ( cyc_latency < 0 )
3227  {
3228  cyc_latency += ( (uint64_t) -1 ) >> 1;
3229 
3230  #if DEBUG && defined( MBG_TGT_LINUX )
3231  printf( "->%lli (%llX)",
3232  (unsigned long long) cyc_latency,
3233  (unsigned long long) ( ( (uint64_t) -1 ) >> 1 )
3234  );
3235  #endif
3236  }
3237 
3238  // Convert latency to binary fractions of seconds,
3239  // i.e. units of 2^^-32.
3240  frac_latency = (*p_cyc_freq) ? ( cyc_latency * ( ( (int64_t) 1 ) << 32 ) / *p_cyc_freq ) : 0;
3241 
3242  // Compute the compensated fractional part of the HR time stamp
3243  // and account for borrows from the sec field.
3244  comp_frac = ts->frac - frac_latency;
3245  ts->frac = (uint32_t) comp_frac; // yields 32 LSBs
3246  ts->sec += (uint32_t) ( comp_frac >> 32 ); // yields 32 MSBs
3247 
3248  #if DEBUG && defined( MBG_TGT_LINUX )
3249  printf( " frac_lat: %llX comp_frac: %08llX.%08llX",
3250  (unsigned long long) frac_latency,
3251  (unsigned long long) ts->sec,
3252  (unsigned long long) ts->frac
3253  );
3254  #endif
3255 
3256  if ( hns_latency && *p_cyc_freq )
3257  {
3258  int64_t tmp_hns_latency;
3259 
3260  // convert to hectonanoseconds
3261  tmp_hns_latency = cyc_latency * 10000000 / *p_cyc_freq;
3262 
3263  // check for range overflow
3264  #define MAX_HNS_LATENCY 0x7FFFFFFF // int32_t
3265  #define MIN_HNS_LATENCY ( -MAX_HNS_LATENCY - 1 )
3266 
3267  if ( tmp_hns_latency > MAX_HNS_LATENCY )
3268  tmp_hns_latency = MAX_HNS_LATENCY;
3269  else
3270  if ( tmp_hns_latency < MIN_HNS_LATENCY )
3271  tmp_hns_latency = MIN_HNS_LATENCY;
3272 
3273  *hns_latency = (int32_t) tmp_hns_latency;
3274  }
3275 
3276  #if DEBUG && defined( MBG_TGT_LINUX )
3277  printf( "\n" );
3278  #endif
3279 
3280  return MBG_SUCCESS;
3281 
3282  #else
3283 
3284  // This is currently not supported by the target environment.
3285  return MBG_ERR_NOT_SUPP_ON_OS;
3286 
3287  #endif
3288 
3289 } // mbg_comp_hr_latency
3290 
3291 
3292 
3293 /*HDR*/
3319 _MBG_API_ATTR int _MBG_API mbg_dev_fn_from_dev_idx( char *s, int max_len, int dev_idx )
3320 {
3321  int n = 0;
3322 
3323  #if MBG_TGT_HAS_DEV_FN_BASE
3324  n = snprintf_safe( s, max_len, mbg_dev_fn_fmt, dev_idx );
3325  #else
3326  n = snprintf_safe( s, max_len, "Device #%i", dev_idx );
3327  #endif
3328 
3329  return n;
3330 
3331 } // mbg_dev_fn_from_dev_idx
3332 
3333 
3334 
3335 /*HDR*/
3353 {
3354  if ( dev_idx < 0 )
3355  goto fail;
3356 
3357  #if defined( MBG_TGT_WIN32 )
3358  {
3359  const char *device_path = mbg_svc_get_device_path( dev_idx );
3360 
3361  return mbg_open_device_by_dev_fn( device_path );
3362  }
3363  #elif MBG_TGT_HAS_DEV_FN
3364  {
3365  MBG_DEV_FN dev_fn;
3366 
3367  mbg_dev_fn_from_dev_idx( dev_fn, sizeof( dev_fn ), dev_idx );
3368 
3369  return mbg_open_device_by_dev_fn( dev_fn );
3370  }
3371  #else
3372 
3373  #if defined( _PCPSDRVR_H )
3374  if ( dev_idx < n_ddevs )
3375  return &pcps_ddev[dev_idx];
3376  #endif
3377 
3378  // intentionally fall-through to "fail"
3379  #endif
3380 
3381 fail:
3382  errno = ENODEV; // No such device
3383  return MBG_INVALID_DEV_HANDLE;
3384 
3385 } // mbg_open_device
3386 
3387 
3388 
3389 /*HDR*/
3411 {
3412 #if defined( MBG_TGT_WIN32 )
3413 
3414  if ( dev_fn == NULL )
3415  {
3416  SetLastError( ERROR_INVALID_PARAMETER ); // TODO Is this error code appropriate?
3417  return MBG_INVALID_DEV_HANDLE;
3418  }
3419 
3420  return CreateFileA(
3421  dev_fn, // file name
3422  GENERIC_READ | GENERIC_WRITE, // access mode
3423  0, // share mode
3424  NULL, // security descriptor
3425  OPEN_EXISTING, // how to create
3426  // If we don't use FILE_FLAG_OVERLAPPED here then
3427  // the Windows kernel serializes IOCTL calls (IRPs)
3428  // from several applications or threads. However,
3429  // serialization is anyway done by a device mutex
3430  // the kernel driver anyway, if required, so the
3431  // Windows kernel doesn't have to care.
3432  FILE_FLAG_OVERLAPPED, // file attributes
3433  NULL // handle to template file
3434  );
3435 
3436 #elif defined( MBG_TGT_POSIX ) && !defined( MBG_TGT_QNX_NTO )
3437 
3438  if ( dev_fn == NULL )
3439  {
3440  errno = EFAULT; // Bad address, invalid pointer
3441  return MBG_INVALID_DEV_HANDLE;
3442  }
3443 
3444  return open( dev_fn, O_RDWR );
3445 
3446 #else
3447 
3448  errno = ( dev_fn == NULL ) ? EFAULT : ENODEV;
3449  return MBG_INVALID_DEV_HANDLE;
3450 
3451 #endif
3452 
3453 } // mbg_open_device_by_dev_fn
3454 
3455 
3456 
3457 
3458 /*HDR*/
3482 _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 )
3483 {
3484  return mbg_open_device_by_dev_fn( dev_fn );
3485 
3486 } // mbg_open_device_by_hw_id
3487 
3488 
3489 
3490 /*HDR*/
3504 {
3505  #if defined( _PCPSDRVR_H )
3506 
3507  #if defined( MBG_TGT_QNX_NTO )
3508  // Since this program accessed the hardware directly
3509  // I/O privileges have to be assigned to the thread.
3510  if ( ThreadCtl( _NTO_TCTL_IO, NULL ) == -1 )
3511  {
3512  fprintf( stderr, "** ThreadCtl() failed to request I/O privileges: %s\n\n", strerror( errno ) );
3513  exit( 1 );
3514  }
3515  #endif
3516 
3517  #if defined( MBG_TGT_DOS ) && MBG_USE_DOS_TSR
3518  {
3519  short prv_busy;
3520 
3521  pcps_detect_any_tsr();
3522  prv_busy = pcps_tsr_set_busy_flag( 1 );
3524  pcps_tsr_set_busy_flag( prv_busy );
3525  }
3526  #else
3528  #endif
3529 
3530  return n_ddevs;
3531 
3532  #elif defined( MBG_TGT_WIN32 )
3533 
3534  return mbg_svc_find_devices();
3535 
3536  #elif defined( MBG_TGT_POSIX )
3537 
3538  MBG_DEV_HANDLE dh;
3539  int i = 0;
3540  int n = 0;
3541 
3542  while ( i < N_SUPP_DEV_BUS )
3543  {
3544  dh = mbg_open_device( i );
3545 
3546  if ( dh != MBG_INVALID_DEV_HANDLE )
3547  {
3548  mbg_close_device( &dh );
3549  n++;
3550  }
3551 
3552  i++;
3553  }
3554 
3555  return n;
3556 
3557  #endif
3558 
3559 } // mbg_find_devices
3560 
3561 
3562 
3563 #if MBG_TGT_HAS_DEV_FN
3564 
3575 static /*HDR*/
3577 {
3578  #if defined( MBG_TGT_WIN32 )
3579  mbg_svc_free_device_list( list ); // TODO
3580  #else
3581  while ( list )
3582  {
3583  MBG_DEV_FN_LIST_ENTRY *next;
3584 
3585  if ( list->dev_fn_ptr )
3586  {
3587  free( list->dev_fn_ptr );
3588  list->dev_fn_ptr = NULL;
3589  }
3590 
3591  next = list->next;
3592  free( list );
3593  list = next;
3594  }
3595  #endif
3596 
3597 } // free_dev_fn_list
3598 
3599 #endif // MBG_TGT_HAS_DEV_FN
3600 
3601 
3602 
3603 #if MBG_TGT_HAS_DEV_FN
3604 
3605 static /*HDR*/
3621 {
3622  // The way to retrieve a list of devices currently present
3623  // in the system depends on the operating system.
3624 
3625  #if defined( MBG_TGT_WIN32 )
3626 
3627  return mbg_svc_find_devices_with_hw_id( p_list, max_devs );
3628 
3629  #elif defined( MBG_TGT_POSIX )
3630 
3631  MBG_DEV_FN_LIST_ENTRY *list_head = NULL;
3632  MBG_DEV_FN_LIST_ENTRY *pos = NULL;
3633  int n_dev_fn = 0;
3634  int i;
3635 
3636  for ( i = 0; i < max_devs; i++ )
3637  {
3638  MBG_DEV_FN dev_fn;
3639  MBG_DEV_HANDLE dh;
3640 
3641  mbg_dev_fn_from_dev_idx( dev_fn, sizeof( dev_fn ), i );
3642  dh = mbg_open_device_by_dev_fn( dev_fn );
3643 
3644  if ( dh != MBG_INVALID_DEV_HANDLE )
3645  {
3646  size_t sz = strlen( dev_fn ) + 1; // including terminating 0
3647 
3648  if ( list_head == NULL ) // first turn
3649  {
3650  list_head = (MBG_DEV_FN_LIST_ENTRY *) calloc( 1, sizeof( *list_head ) );
3651  pos = list_head;
3652  }
3653  else
3654  {
3655  pos->next = (MBG_DEV_FN_LIST_ENTRY *) calloc( 1, sizeof( *pos ) );
3656  pos = pos->next;
3657  }
3658 
3659  if ( pos == NULL )
3660  goto out_free;
3661 
3662  pos->dev_fn_ptr = (char *) calloc( 1, sz );
3663 
3664  if ( pos->dev_fn_ptr == NULL )
3665  goto out_free;
3666 
3667  strncpy_safe( pos->dev_fn_ptr, dev_fn, sz );
3668  n_dev_fn++;
3669 
3670  mbg_close_device( &dh );
3671  }
3672  }
3673 
3674  if ( n_dev_fn )
3675  goto out;
3676 
3677 
3678 out_free:
3679  free_dev_fn_list( list_head );
3680  list_head = NULL;
3681  n_dev_fn = 0;
3682 
3683 out:
3684  *p_list = list_head; // Return the list
3685  return n_dev_fn;
3686 
3687  #else
3688 
3689  *p_list = NULL;
3690  return 0;
3691 
3692  #endif
3693 
3694 } // setup_dev_fn_list
3695 
3696 #endif // MBG_TGT_HAS_DEV_FN
3697 
3698 
3699 
3700 #if MBG_TGT_HAS_DEV_FN
3701 
3702 static /*HDR*/
3711 int get_dev_info_for_dev_fn( PCPS_DEV *p, const char *dev_fn )
3712 {
3713  MBG_DEV_HANDLE dh;
3714  int rc;
3715 
3716  memset( p, 0, sizeof( *p ) );
3717 
3718  // Try to retrieve device information.
3719  dh = mbg_open_device_by_dev_fn( dev_fn );
3720 
3721  if ( dh == MBG_INVALID_DEV_HANDLE )
3722  return mbg_get_last_error( NULL );
3723 
3724  rc = mbg_get_device_info( dh, p );
3725 
3726  mbg_close_device( &dh );
3727 
3728  return rc;
3729 
3730 } // get_dev_info_for_dev_fn
3731 
3732 #endif // MBG_TGT_HAS_DEV_FN
3733 
3734 
3735 
3736 #if MBG_TGT_HAS_DEV_FN
3737 
3738 static /*HDR*/
3759 int snprint_dev_name( char *s, size_t max_len, const PCPS_DEV *p_dev )
3760 {
3761  size_t n = snprintf_safe( s, max_len, MBG_DEV_NAME_FMT,
3762  _pcps_type_name( p_dev ), _pcps_sernum( p_dev ) );
3763  return _int_from_size_t( n );
3764 
3765 } // snprint_dev_name
3766 
3767 #endif // MBG_TGT_HAS_DEV_FN
3768 
3769 
3770 
3771 static /*HDR*/
3787 int lookup_dev_idx( const PCPS_DEV *dev_array, int n_dev,
3788  const char *type_name, const char *sernum )
3789 {
3790  int i;
3791 
3792  for ( i = 0; i < n_dev; i++ )
3793  {
3794  const PCPS_DEV *p_dev = &dev_array[i];
3795 
3796  if ( type_name && strcmp( _pcps_type_name( p_dev ), type_name ) )
3797  continue; // Type name given, but doesn't match.
3798 
3799  if ( sernum && strcmp( _pcps_sernum( p_dev ), sernum ) )
3800  continue; // Serial number given, but doesn't match.
3801 
3802  return i; // Matching device found.
3803  }
3804 
3805  return -1; // No matching device found.
3806 
3807 } // lookup_dev_idx
3808 
3809 
3810 
3811 static /*HDR*/
3832 int lookup_dev_idx_ex( const PCPS_DEV *dev_array, int n_dev,
3833  const char *type_name, const char *sernum,
3834  int selection_mode )
3835 {
3836  int dev_idx = -1;
3837 
3838  if ( n_dev == 0 ) // no devices available
3839  goto out;
3840 
3841  dev_idx = lookup_dev_idx( dev_array, n_dev, type_name, sernum );
3842 
3843  if ( dev_idx >= 0 )
3844  goto out;
3845 
3846 
3847  // The requested combination of a clock model name and
3848  // serial number was not found. If an exact match was
3849  // requested then we're done anyway.
3850  if ( selection_mode == MBG_MATCH_EXACTLY )
3851  goto out;
3852 
3853 
3854  // Look for device with matching name only, ignoring
3855  // the serial number.
3856  dev_idx = lookup_dev_idx( dev_array, n_dev, type_name, NULL );
3857 
3858  if ( dev_idx >= 0 )
3859  goto out;
3860 
3861 
3862  // As a last resort select the first device that
3863  // has been found, if the selection mode allows.
3864  if ( selection_mode == MBG_MATCH_ANY )
3865  dev_idx = 0;
3866 
3867 out:
3868  return dev_idx;
3869 
3870 } // lookup_dev_idx_ex
3871 
3872 
3873 
3874 /*HDR*/
3898  int max_devices )
3899 {
3900 #if MBG_TGT_HAS_DEV_FN
3901 
3902  MBG_DEV_FN_LIST_ENTRY *dev_fn_list_head = NULL;
3903  MBG_DEV_FN_LIST_ENTRY *dev_fn_pos = NULL;
3904 
3905  MBG_DEV_NAME_LIST_ENTRY *list_head = NULL;
3906  MBG_DEV_NAME_LIST_ENTRY *pos = NULL;
3907 
3908  int n_dev_fn = 0;
3909  int n_dev_name = 0;
3910 
3911  // First set up a list of device names, the format of which
3912  // depends on the OS.
3913  n_dev_fn = setup_dev_fn_list( &dev_fn_list_head, max_devices );
3914 
3915  // Now iterate through the device *file name* list
3916  // and set up a *device name* list.
3917  for ( dev_fn_pos = dev_fn_list_head; dev_fn_pos; dev_fn_pos = dev_fn_pos->next )
3918  {
3919  PCPS_DEV dev;
3920  int rc;
3921 
3922  if ( list_head == NULL ) // first turn
3923  {
3924  list_head = (MBG_DEV_NAME_LIST_ENTRY *) calloc( 1, sizeof( *list_head ) );
3925  pos = list_head;
3926  }
3927  else
3928  {
3929  pos->next = (MBG_DEV_NAME_LIST_ENTRY *) calloc( 1, sizeof( *pos ) );
3930  pos = pos->next;
3931  }
3932 
3933  if ( pos == NULL ) // failed to allocate memory
3934  {
3935  mbg_free_device_name_list( list_head ); // free this list
3936  list_head = NULL;
3937  n_dev_name = 0;
3938  break;
3939  }
3940 
3941  // Get device details for the device.
3942  rc = get_dev_info_for_dev_fn( &dev, dev_fn_pos->dev_fn_ptr );
3943 
3944  if ( mbg_rc_is_success( rc ) )
3945  snprint_dev_name( pos->dev_name, sizeof( pos->dev_name ),
3946  &dev );
3947 
3948  if ( ++n_dev_name > n_dev_fn ) // This should never happen
3949  break;
3950  }
3951 
3952  // Free the device name list which we don't need anymore
3953  free_dev_fn_list( dev_fn_list_head );
3954 
3955  *p_list = list_head; // Return the list
3956 
3957  return n_dev_name;
3958 
3959 #else
3960 
3961  *p_list = NULL;
3962  return 0;
3963 
3964 #endif
3965 
3966 } // mbg_find_devices_with_names
3967 
3968 
3969 
3970 /*HDR*/
3982 {
3983  while ( list )
3984  {
3985  MBG_DEV_NAME_LIST_ENTRY *next = list->next;
3986 
3987  free( list );
3988  list = next;
3989  }
3990 
3991 } // mbg_free_device_name_list
3992 
3993 
3994 
3995 /*HDR*/
4017  char *type_name, size_t type_name_size,
4018  char *sernum, size_t sernum_size )
4019 {
4020  size_t dev_name_len = 0;
4021  size_t i = 0;
4022  char c;
4023 
4024  type_name[0] = 0;
4025  sernum[0] = 0;
4026 
4027  if ( dev_name )
4028  dev_name_len = strlen( dev_name );
4029 
4030  if ( dev_name_len )
4031  {
4032  // clock model name
4033  const char *cp = dev_name;
4034  i = 0;
4035 
4036  for (;;)
4037  {
4038  c = *cp;
4039 
4040  if ( c == 0 ) // end of string
4041  break;
4042 
4043  if ( c == '_' ) // separator before S/N, see MBG_DEV_NAME_FMT
4044  break;
4045 
4046  if ( i == ( type_name_size - 1 ) )
4047  break;
4048 
4049  type_name[i] = ( c >= 'a' && c <= 'z' ) ? ( c - 0x20 ) : c;
4050 
4051  i++;
4052  cp++;
4053  }
4054 
4055  type_name[i] = 0; // terminate string
4056 
4057  if ( *cp == '_' )
4058  {
4059  // Serial number
4060  cp++;
4061  i = 0;
4062 
4063  for (;;)
4064  {
4065  c = *cp;
4066 
4067  if ( c == 0 ) // end of string
4068  break;
4069 
4070  if ( i == ( sernum_size - 1 ) )
4071  break;
4072 
4073  if ( ( c < '0' || c > '9' ) && ( c != '?' ) ) // not a digit
4074  break;
4075 
4076  sernum[i] = c;
4077 
4078  i++;
4079  cp++;
4080  }
4081 
4082  sernum[i] = 0; // terminate string
4083  }
4084  }
4085 
4086 } // mbg_split_dev_name
4087 
4088 
4089 
4090 /*HDR*/
4113 {
4114  PCPS_DEV dev_array[N_SUPP_DEV_BUS] = { { { 0 } } };
4115  PCPS_CLOCK_NAME type_name;
4116  PCPS_SN_STR sernum;
4117  size_t i = 0;
4118  int dev_idx = -1;
4119 
4120  mbg_split_dev_name( srch_name, type_name, sizeof( type_name ),
4121  sernum, sizeof( sernum ) );
4122 
4123  #if MBG_TGT_HAS_DEV_FN
4124  {
4125  MBG_DEV_FN dev_fn_array[N_SUPP_DEV_BUS] = { { 0 } };
4126  MBG_DEV_FN_LIST_ENTRY *list_head = NULL;
4127 
4128  // Set up a temporary list with file names of devices
4129  // that are currently present in the system.
4130  int n_devices = setup_dev_fn_list( &list_head, N_SUPP_DEV_BUS );
4131 
4132  if ( n_devices )
4133  {
4134  MBG_DEV_FN_LIST_ENTRY *pos;
4135 
4136  for ( i = 0, pos = list_head; pos && pos->dev_fn_ptr; pos = pos->next )
4137  {
4138  int rc = get_dev_info_for_dev_fn( &dev_array[i], pos->dev_fn_ptr );
4139 
4140  if ( mbg_rc_is_success( rc ) )
4141  {
4142  // Save the associated device file name.
4143  sn_cpy_str_safe( dev_fn_array[i], sizeof( dev_fn_array[i] ), pos->dev_fn_ptr );
4144  i++;
4145  }
4146  }
4147 
4148  dev_idx = lookup_dev_idx_ex( dev_array, _int_from_size_t( i ), type_name,
4149  sernum, selection_mode );
4150  }
4151 
4152  free_dev_fn_list( list_head );
4153 
4154  // We even try to open the device if no match was found.
4155  // This causes an "invalid device handle" value to be
4156  // returned, and sets an appropriate "last error" code.
4157  return mbg_open_device_by_dev_fn( ( dev_idx >= 0 ) ? dev_fn_array[dev_idx] : "" );
4158  }
4159  #else
4160  #if defined( _PCPSDRVR_H )
4161  mbg_find_devices();
4162 
4163  for ( i = 0; i < n_ddevs; i++ )
4164  dev_array[i] = pcps_ddev[i].dev;
4165 
4166  dev_idx = lookup_dev_idx_ex( dev_array, _int_from_size_t( i ), type_name,
4167  sernum, selection_mode );
4168 
4169  if ( dev_idx >= 0 )
4170  return mbg_open_device( dev_idx );
4171  #endif
4172 
4173  errno = ENODEV;
4174  return MBG_INVALID_DEV_HANDLE;
4175 
4176  #endif
4177 
4178 } // mbg_open_device_by_name
4179 
4180 
4181 
4182 /*HDR*/
4191 {
4192  if ( *dev_handle != MBG_INVALID_DEV_HANDLE && *dev_handle != 0 ) //##++++ dev_handle NULL/0 ???
4193  {
4194  #if defined( MBG_TGT_WIN32 )
4195  CloseHandle( *dev_handle );
4196  #elif defined( MBG_TGT_POSIX ) && !defined( MBG_TGT_QNX_NTO )
4197  close( *dev_handle );
4198  #endif
4199  }
4200 
4201  *dev_handle = MBG_INVALID_DEV_HANDLE;
4202 
4203 } // mbg_close_device
4204 
4205 
4206 
4207 /*HDR*/
4217 {
4218  #if defined( _MBGIOCTL_H )
4219  MBGDEVIO_RET_VAL rc;
4220  rc = _mbgdevio_read_var( dh, -1, IOCTL_GET_PCPS_DRVR_INFO, p );
4221  return _mbgdevio_cnv_ret_val( rc );
4222  #else
4223  (void) dh; // avoid warning "never used"
4224  drvr_info.n_devs = n_ddevs;
4225  *p = drvr_info;
4226  return MBG_SUCCESS;
4227  #endif
4228 
4229 } // mbg_get_drvr_info
4230 
4231 
4232 
4233 /*HDR*/
4243 {
4244  #if defined( _MBGIOCTL_H )
4245  MBGDEVIO_RET_VAL rc;
4246  rc = _mbgdevio_read_var( dh, -1, IOCTL_GET_PCPS_DEV, p );
4247  // Endianess is converted inside the kernel driver, if necessary.
4248  return _mbgdevio_cnv_ret_val( rc );
4249  #else
4250  *p = dh->dev;
4251  return MBG_SUCCESS;
4252  #endif
4253 
4254 } // mbg_get_device_info
4255 
4256 
4257 
4258 /*HDR*/
4274 {
4275  #if defined( _MBGIOCTL_H )
4276  MBGDEVIO_RET_VAL rc;
4278  // No endianess conversion required.
4279  return _mbgdevio_cnv_ret_val( rc );
4280  #else
4281  *p = _pcps_ddev_read_status_port( dh );
4282  // No endianess conversion required.
4283  return MBG_SUCCESS;
4284  #endif
4285 
4286 } // mbg_get_status_port
4287 
4288 
4289 
4290 /*HDR*/
4291 /* (Intentionally excluded from Doxygen)
4292  * Generic read function which writes a command code to a device
4293  * and reads a number of replied data to a generic buffer.
4294  *
4295  * <b>Warning</b>: This is for debugging purposes only!
4296  * The specialized API calls should be used preferably.
4297  * Not all devices support each of the ::PC_GPS_COMMANDS.
4298  *
4299  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
4300  * @param[in] cmd Can be any @ref PCPS_CMD_CODES "command code" supported by the device
4301  * @param[out] p Pointer to a buffer to be filled up
4302  * @param[in] size Size of the output buffer
4303  *
4304  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4305  *
4306  * @see ::mbg_generic_write
4307  * @see ::mbg_generic_read_gps
4308  * @see ::mbg_generic_write_gps
4309  * @see ::mbg_generic_io
4310  */
4312  void *p, int size )
4313 {
4314  MBGDEVIO_RET_VAL rc;
4315  rc = _mbgdevio_gen_read( dh, cmd, p, size );
4316  // No type information available, so endianess has to be
4317  // converted by the caller, if required.
4318  return _mbgdevio_cnv_ret_val( rc );
4319 
4320 } // mbg_generic_read
4321 
4322 
4323 
4324 /*HDR*/
4325 /* (Intentionally excluded from Doxygen)
4326  * Generic read function which writes a GPS command code to a device
4327  * and reads a number of data bytes back into a generic buffer.
4328  * The function ::mbg_chk_dev_has_gps_data can be used to check
4329  * whether this call is supported by a device.
4330  *
4331  * <b>Warning</b>: This is for debugging purposes only!
4332  * The specialized API calls should be used preferably.
4333  * Not all devices support each of the ::PC_GPS_COMMANDS.
4334  *
4335  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
4336  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
4337  * @param[out] p Pointer to a buffer to be filled up
4338  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
4339  *
4340  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4341  *
4342  * @see ::mbg_chk_dev_has_gps_data
4343  * @see ::mbg_generic_write_gps
4344  * @see ::mbg_generic_read
4345  * @see ::mbg_generic_write
4346  * @see ::mbg_generic_io
4347  */
4349  void *p, int size )
4350 {
4351  MBGDEVIO_RET_VAL rc;
4352  rc = _mbgdevio_gen_read_gps( dh, cmd, p, size );
4353  // No type information available, so endianess has to be
4354  // converted by the caller, if required.
4355  return _mbgdevio_cnv_ret_val( rc );
4356 
4357 } // mbg_generic_read_gps
4358 
4359 
4360 
4361 /*HDR*/
4362 /* (Intentionally excluded from Doxygen)
4363  * Generic write function which writes a command code plus an
4364  * associated number of data bytes to a device.
4365  *
4366  * <b>Warning</b>: This is for debugging purposes only!
4367  * The specialized API calls should be used preferably.
4368  * Not all devices support each of the ::PC_GPS_COMMANDS.
4369  *
4370  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
4371  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
4372  * @param[in] p Pointer to a buffer of data to be written
4373  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
4374  *
4375  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4376  *
4377  * @see ::mbg_generic_read
4378  * @see ::mbg_generic_read_gps
4379  * @see ::mbg_generic_write_gps
4380  * @see ::mbg_generic_io
4381  */
4383  const void *p, int size )
4384 {
4385  MBGDEVIO_RET_VAL rc;
4386  // No type information available, so endianess has to be
4387  // converted by the caller, if required.
4388  rc = _mbgdevio_gen_write( dh, cmd, p, size );
4389  return _mbgdevio_cnv_ret_val( rc );
4390 
4391 } // mbg_generic_write
4392 
4393 
4394 
4395 /*HDR*/
4396 /* (Intentionally excluded from Doxygen)
4397  * Generic write function which writes a GPS command code plus an
4398  * associated number of data bytes to a device.
4399  * The function ::mbg_chk_dev_has_gps_data can be used to check
4400  * whether this call is supported by a device.
4401  *
4402  * <b>Warning</b>: This is for debugging purposes only!
4403  * The specialized API calls should be used preferably.
4404  * Not all devices support each of the ::PC_GPS_COMMANDS.
4405  *
4406  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
4407  * @param[in] cmd One of the ::PCPS_CMD_CODES supported by the device.
4408  * @param[in] p Pointer to a buffer of data to be written
4409  * @param[in] size Size of the buffer, has to match the expected data size associated with cmd
4410  *
4411  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4412  *
4413  * @see ::mbg_chk_dev_has_gps_data
4414  * @see ::mbg_generic_read_gps
4415  * @see ::mbg_generic_read
4416  * @see ::mbg_generic_write
4417  * @see ::mbg_generic_io
4418  */
4420  const void *p, int size )
4421 {
4422  MBGDEVIO_RET_VAL rc;
4423  // No type information available, so endianess has to be
4424  // converted by the caller, if required.
4425  rc = _mbgdevio_gen_write_gps( dh, cmd, p, size );
4426  return _mbgdevio_cnv_ret_val( rc );
4427 
4428 } // mbg_generic_write_gps
4429 
4430 
4431 
4432 /*HDR*/
4433 /* (Intentionally excluded from Doxygen)
4434  * Write and/or read generic data to/from a device.
4435  * The function ::mbg_chk_dev_has_generic_io checks
4436  * whether this call is supported by a device.
4437  *
4438  * <b>Warning</b>: This call is for debugging purposes and internal use only!
4439  *
4440  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4441  *
4442  * @see ::mbg_chk_dev_has_generic_io
4443  * @see ::mbg_generic_read
4444  * @see ::mbg_generic_write
4445  * @see ::mbg_generic_read_gps
4446  * @see ::mbg_generic_write_gps
4447  */
4449  const void *in_p, int in_sz,
4450  void *out_p, int out_sz )
4451 {
4452  MBGDEVIO_RET_VAL rc;
4453 
4454  #if !defined( _MBGIOCTL_H )
4455  // The hardware is accessed directly, so we must check
4456  // here if this call is supported.
4458  #endif
4459 
4460  // No type information available, so endianess must be
4461  // converted by the caller, if required.
4462  rc = _mbgdevio_gen_io( dh, type, in_p, in_sz, out_p, out_sz );
4463  return _mbgdevio_cnv_ret_val( rc );
4464 
4465 } // mbg_generic_io
4466 
4467 
4468 
4469 /*HDR*/
4492 {
4493  MBGDEVIO_RET_VAL rc;
4495  // No endianess conversion required.
4496  return _mbgdevio_cnv_ret_val( rc );
4497 
4498 } // mbg_get_time
4499 
4500 
4501 
4502 /*HDR*/
4519 {
4520  MBGDEVIO_RET_VAL rc;
4521  // No endianess conversion required.
4523  _pcps_ddev_can_set_time( dh ) );
4524  return _mbgdevio_cnv_ret_val( rc );
4525 
4526 } // mbg_set_time
4527 
4528 
4529 
4530 /*HDR*/
4556 {
4557  MBGDEVIO_RET_VAL rc;
4559  p, _pcps_ddev_has_sync_time( dh ) );
4560  // No endianess conversion required.
4561  return _mbgdevio_cnv_ret_val( rc );
4562 
4563 } // mbg_get_sync_time
4564 
4565 
4566 
4567 /*HDR*/
4587 {
4588  #if defined( MBG_TGT_WIN32 )
4589  MBGDEVIO_RET_VAL rc;
4591  // No endianess conversion required.
4592  return _mbgdevio_cnv_ret_val( rc );
4593  #else
4594  (void) dh; // avoid warning "never used"
4595  (void) p; // avoid warning "never used"
4596  return MBG_ERR_NOT_SUPP_ON_OS;
4597  #endif
4598 
4599 } // mbg_get_time_sec_change
4600 
4601 
4602 
4603 /*HDR*/
4626 {
4627  MBGDEVIO_RET_VAL rc;
4629  p, _pcps_ddev_has_hr_time( dh ) );
4631  return _mbgdevio_cnv_ret_val( rc );
4632 
4633 } // mbg_get_hr_time
4634 
4635 
4636 
4637 /*HDR*/
4638 /* (Intentionally excluded from Doxygen )
4639  * Write a high resolution time stamp ::PCPS_TIME_STAMP to a device
4640  * to configure a %UTC time when the clock shall generate an event.
4641  * The API call ::mbg_chk_dev_has_event_time checks whether
4642  * this call is supported by a device.
4643  *
4644  * <b>Note:</b> This is only supported by some special firmware.
4645  *
4646  * @param[in] dh Valid ::MBG_DEV_HANDLE handle to a Meinberg device.
4647  * @param[in] p Pointer to a ::PCPS_TIME_STAMP structure to be written.
4648  *
4649  * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES
4650  *
4651  * @see ::mbg_chk_dev_has_event_time
4652  */
4654 {
4655  MBGDEVIO_RET_VAL rc;
4656  #if defined( MBG_ARCH_BIG_ENDIAN )
4657  PCPS_TIME_STAMP tmp = *p;
4658  _mbg_swab_pcps_time_stamp( &tmp );
4659  p = &tmp;
4660  #endif
4662  p, _pcps_ddev_has_event_time( dh ) );
4663  return _mbgdevio_cnv_ret_val( rc );
4664 
4665 } // mbg_set_event_time
4666 
4667 
4668 
4669 /*HDR*/
4688 {
4689  MBGDEVIO_RET_VAL rc;
4691  // No endianess conversion required.
4692  return _mbgdevio_cnv_ret_val( rc );
4693 
4694 } // mbg_get_serial
4695 
4696 
4697 
4698 /*HDR*/
4717 {
4718  MBGDEVIO_RET_VAL rc;
4719  // No endianess conversion required.
4721  return _mbgdevio_cnv_ret_val( rc );
4722 
4723 } // mbg_set_serial
4724 
4725 
4726 
4727 /*HDR*/
4752 {
4753  MBGDEVIO_RET_VAL rc;
4755  p, _pcps_ddev_has_tzcode( dh ) );
4756  // No endianess conversion required.
4757  return _mbgdevio_cnv_ret_val( rc );
4758 
4759 } // mbg_get_tzcode
4760 
4761 
4762 
4763 /*HDR*/
4788 {
4789  MBGDEVIO_RET_VAL rc;
4790  // No endianess conversion required.
4792  p, _pcps_ddev_has_tzcode( dh ) );
4793  return _mbgdevio_cnv_ret_val( rc );
4794 
4795 } // mbg_set_tzcode
4796 
4797 
4798 
4799 /*HDR*/
4824 {
4825  MBGDEVIO_RET_VAL rc;
4827  p, _pcps_ddev_has_pcps_tzdl( dh ) );
4828  _mbg_swab_pcps_tzdl( p );
4829  return _mbgdevio_cnv_ret_val( rc );
4830 
4831 } // mbg_get_pcps_tzdl
4832 
4833 
4834 
4835 /*HDR*/
4859 {
4860  MBGDEVIO_RET_VAL rc;
4861  #if defined( MBG_ARCH_BIG_ENDIAN )
4862  PCPS_TZDL tmp = *p;
4863  _mbg_swab_pcps_tzdl( &tmp );
4864  p = &tmp;
4865  #endif
4867  p, _pcps_ddev_has_pcps_tzdl( dh ) );
4868  return _mbgdevio_cnv_ret_val( rc );
4869 
4870 } // mbg_set_pcps_tzdl
4871 
4872 
4873 
4874 /*HDR*/
4894 {
4895  MBGDEVIO_RET_VAL rc;
4897  p, _pcps_ddev_has_ref_offs( dh ) );
4899  return _mbgdevio_cnv_ret_val( rc );
4900 
4901 } // mbg_get_ref_offs
4902 
4903 
4904 
4905 /*HDR*/
4925 {
4926  MBGDEVIO_RET_VAL rc;
4927  #if defined( MBG_ARCH_BIG_ENDIAN )
4928  MBG_REF_OFFS tmp = *p;
4929  _mbg_swab_mbg_ref_offs( &tmp );
4930  p = &tmp;
4931  #endif
4933  p, _pcps_ddev_has_ref_offs( dh ) );
4934  return _mbgdevio_cnv_ret_val( rc );
4935 
4936 } // mbg_set_ref_offs
4937 
4938 
4939 
4940 /*HDR*/
4959 {
4960  MBGDEVIO_RET_VAL rc;
4962  p, _pcps_ddev_has_opt_flags( dh ) );
4964  return _mbgdevio_cnv_ret_val( rc );
4965 
4966 } // mbg_get_opt_info
4967 
4968 
4969 
4970 /*HDR*/
4989 {
4990  MBGDEVIO_RET_VAL rc;
4991  #if defined( MBG_ARCH_BIG_ENDIAN )
4992  MBG_OPT_SETTINGS tmp = *p;
4994  p = &tmp;
4995  #endif
4998  _pcps_ddev_has_opt_flags( dh ) );
4999  return _mbgdevio_cnv_ret_val( rc );
5000 
5001 } // mbg_set_opt_settings
5002 
5003 
5004 
5005 /*HDR*/
5029 {
5030  MBGDEVIO_RET_VAL rc;
5032  p, _pcps_ddev_is_irig_rx( dh ) );
5033  _mbg_swab_irig_info( p );
5034  return _mbgdevio_cnv_ret_val( rc );
5035 
5036 } // mbg_get_irig_rx_info
5037 
5038 
5039 
5040 /*HDR*/
5066 {
5067  MBGDEVIO_RET_VAL rc;
5068  #if defined( MBG_ARCH_BIG_ENDIAN )
5069  IRIG_SETTINGS tmp = *p;
5070  _mbg_swab_irig_settings( &tmp );
5071  p = &tmp;
5072  #endif
5075  _pcps_ddev_is_irig_rx( dh ) );
5076  return _mbgdevio_cnv_ret_val( rc );
5077 
5078 } // mbg_set_irig_rx_settings
5079 
5080 
5081 
5082 /*HDR*/
5100  const PCPS_DEV *pdev,
5101  IRIG_INFO *p_irig_info,
5102  MBG_REF_OFFS *p_ref_offs,
5103  MBG_OPT_INFO *p_opt_info )
5104 {
5105  int rc;
5106 
5107  if ( !_pcps_is_irig_rx( pdev ) )
5108  return MBG_ERR_NOT_SUPP_BY_DEV;
5109 
5110  rc = mbg_get_irig_rx_info( dh, p_irig_info );
5111 
5112  if ( mbg_rc_is_success( rc ) && _pcps_has_ref_offs( pdev ) )
5113  rc = mbg_get_ref_offs( dh, p_ref_offs );
5114 
5115  if ( mbg_rc_is_success( rc ) && _pcps_has_opt_flags( pdev ) )
5116  rc = mbg_get_opt_info( dh, p_opt_info );
5117 
5118  return rc;
5119 
5120 } // mbg_get_all_irig_rx_info
5121 
5122 
5123 
5124 /*HDR*/
5147  const PCPS_DEV *pdev,
5148  const IRIG_SETTINGS *p_irig_settings,
5149  const MBG_REF_OFFS *p_ref_offs,
5150  const MBG_OPT_SETTINGS *p_opt_settings )
5151 {
5152  int rc;
5153 
5154  if ( !_pcps_is_irig_rx( pdev ) )
5155  return MBG_ERR_NOT_SUPP_BY_DEV;
5156 
5157  rc = mbg_set_irig_rx_settings( dh, p_irig_settings );
5158 
5159  if ( mbg_rc_is_success( rc ) && _pcps_has_ref_offs( pdev ) )
5160  rc = mbg_set_ref_offs( dh, p_ref_offs );
5161 
5162  if ( mbg_rc_is_success( rc ) && _pcps_has_opt_flags( pdev ) )
5163  rc = mbg_set_opt_settings( dh, p_opt_settings );
5164 
5165  return rc;
5166 
5167 } // mbg_save_all_irig_rx_settings
5168 
5169 
5170 
5171 /*HDR*/
5203  MBG_IRIG_CTRL_BITS *p )
5204 {
5205  MBGDEVIO_RET_VAL rc;
5208  return _mbgdevio_cnv_ret_val( rc );
5209 
5210 } // mbg_get_irig_ctrl_bits
5211 
5212 
5213 
5214 /*HDR*/
5234  MBG_RAW_IRIG_DATA *p )
5235 {
5236  MBGDEVIO_RET_VAL rc;
5238  // No endianess conversion required.
5239  return _mbgdevio_cnv_ret_val( rc );
5240 
5241 } // mbg_get_raw_irig_data
5242 
5243 
5244 
5245 /*HDR*/
5269  MBG_RAW_IRIG_DATA *p )
5270 {
5271  PCPS_TIME t;
5272  MBGDEVIO_RET_VAL rc;
5273 
5274  rc = mbg_get_time_sec_change( dh, &t );
5275 
5276  if ( mbg_rc_is_success( rc ) )
5277  rc = mbg_get_raw_irig_data( dh, p );
5278 
5279  return _mbgdevio_cnv_ret_val( rc );
5280 
5281 } // mbg_get_raw_irig_data_on_sec_change
5282 
5283 
5284 
5285 /*HDR*/
5305  PCPS_IRIG_TIME *p )
5306 {
5307  MBGDEVIO_RET_VAL rc;
5310  return _mbgdevio_cnv_ret_val( rc );
5311 
5312 } // mbg_get_irig_time
5313 
5314 
5315 
5316 /*HDR*/
5332 {
5333  MBGDEVIO_RET_VAL rc;
5336  return _mbgdevio_cnv_ret_val( rc );
5337 
5338 } // mbg_clr_ucap_buff
5339 
5340 
5341 
5342 /*HDR*/
5363 {
5364  MBGDEVIO_RET_VAL rc;
5367  _pcps_ddev_has_ucap( dh ) );
5369  return _mbgdevio_cnv_ret_val( rc );
5370 
5371 } // mbg_get_ucap_entries
5372 
5373 
5374 
5375 /*HDR*/
5402 {
5403  MBGDEVIO_RET_VAL rc;
5406  _pcps_ddev_has_ucap( dh ) );
5408  return _mbgdevio_cnv_ret_val( rc );
5409 
5410 } // mbg_get_ucap_event
5411 
5412 
5413 
5414 /*HDR*/
5440 {
5441  MBGDEVIO_RET_VAL rc;
5443  _mbg_swab_tzdl( p );
5444  return _mbgdevio_cnv_ret_val( rc );
5445 
5446 } // mbg_get_gps_tzdl
5447 
5448 
5449 
5450 /*HDR*/
5476 {
5477  MBGDEVIO_RET_VAL rc;
5478  #if defined( MBG_ARCH_BIG_ENDIAN )
5479  TZDL tmp = *p;
5480  _mbg_swab_tzdl( &tmp );
5481  p = &tmp;
5482  #endif
5484  return _mbgdevio_cnv_ret_val( rc );
5485 
5486 } // mbg_set_gps_tzdl
5487 
5488 
5489 
5490 /*HDR*/
5514 {
5515  MBGDEVIO_RET_VAL rc;
5517  _mbg_swab_sw_rev( p );
5518  return _mbgdevio_cnv_ret_val( rc );
5519 
5520 } // mbg_get_gps_sw_rev
5521 
5522 
5523 
5524 /*HDR*/
5552 {
5553  MBGDEVIO_RET_VAL rc;
5555  _mbg_swab_bvar_stat( p );
5556  return _mbgdevio_cnv_ret_val( rc );
5557 
5558 } // mbg_get_gps_stat
5559 
5560 
5561 
5562 /*HDR*/
5581 {
5582  MBGDEVIO_RET_VAL rc;
5584  _mbg_swab_ttm( p );
5585  return _mbgdevio_cnv_ret_val( rc );
5586 
5587 } // mbg_get_gps_time
5588 
5589 
5590 
5591 /*HDR*/
5609 {
5610  MBGDEVIO_RET_VAL rc;
5611  #if defined( MBG_ARCH_BIG_ENDIAN )
5612  TTM tmp = *p;
5613  _mbg_swab_ttm( &tmp );
5614  p = &tmp;
5615  #endif
5617  return _mbgdevio_cnv_ret_val( rc );
5618 
5619 } // mbg_set_gps_time
5620 
5621 
5622 
5623 /*HDR*/
5645 {
5646  MBGDEVIO_RET_VAL rc;
5648  _mbg_swab_port_parm( p );
5649  return _mbgdevio_cnv_ret_val( rc );
5650 
5651 } // mbg_get_gps_port_parm
5652 
5653 
5654 
5655 /*HDR*/
5677 {
5678  MBGDEVIO_RET_VAL rc;
5679  #if defined( MBG_ARCH_BIG_ENDIAN )
5680  PORT_PARM tmp = *p;
5681  _mbg_swab_port_parm( &tmp );
5682  p = &tmp;
5683  #endif
5685  return _mbgdevio_cnv_ret_val( rc );
5686 
5687 } // mbg_set_gps_port_parm
5688 
5689 
5690 
5691 /*HDR*/
5710 {
5711  MBGDEVIO_RET_VAL rc;
5713  _mbg_swab_ant_info( p );
5714  return _mbgdevio_cnv_ret_val( rc );
5715 
5716 } // mbg_get_gps_ant_info
5717 
5718 
5719 
5720 /*HDR*/
5742 {
5743  MBGDEVIO_RET_VAL rc;
5745  _mbg_swab_ttm( p );
5746  return _mbgdevio_cnv_ret_val( rc );
5747 
5748 } // mbg_get_gps_ucap
5749 
5750 
5751 
5752 /*HDR*/
5777 {
5778  MBGDEVIO_RET_VAL rc;
5782  return _mbgdevio_cnv_ret_val( rc );
5783 
5784 } // mbg_get_gps_enable_flags
5785 
5786 
5787 
5788 /*HDR*/
5813  const ENABLE_FLAGS *p )
5814 {
5815  MBGDEVIO_RET_VAL rc;
5816  #if defined( MBG_ARCH_BIG_ENDIAN )
5817  ENABLE_FLAGS tmp = *p;
5818  _mbg_swab_enable_flags( &tmp );
5819  p = &tmp;
5820  #endif
5823  return _mbgdevio_cnv_ret_val( rc );
5824 
5825 } // mbg_set_gps_enable_flags
5826 
5827 
5828 
5829 /*HDR*/
5847 {
5848  MBGDEVIO_RET_VAL rc;
5850  _mbg_swab_stat_info( p );
5851  return _mbgdevio_cnv_ret_val( rc );
5852 
5853 } // mbg_get_gps_stat_info
5854 
5855 
5856 
5857 /*HDR*/
5872 {
5873  MBGDEVIO_RET_VAL rc;
5874  #if defined( MBG_ARCH_BIG_ENDIAN )
5875  GPS_CMD tmp = *p;
5876  _mbg_swab_gps_cmd( &tmp );
5877  p = &tmp;
5878  #endif
5880  return _mbgdevio_cnv_ret_val( rc );
5881 
5882 } // mbg_set_gps_cmd
5883 
5884 
5885 /*HDR*/
5906 {
5907  MBGDEVIO_RET_VAL rc;
5909  swap_pos_doubles( p );
5910  _mbg_swab_pos( p );
5911  return _mbgdevio_cnv_ret_val( rc );
5912 
5913 } // mbg_get_gps_pos
5914 
5915 
5916 
5917 /*HDR*/
5936 {
5937  MBGDEVIO_RET_VAL rc;
5938  XYZ xyz;
5939  int i;
5940 
5941  for ( i = 0; i < N_XYZ; i++ )
5942  {
5943  xyz[i] = p[i];
5944  swap_double( &xyz[i] );
5945  _mbg_swab_double( &xyz[i] );
5946  }
5947 
5948  // _mbgdevio_write_gps_var() would fail here since
5949  // XYZ is an array, not a structure.
5951  xyz, sizeof( XYZ ) );
5952  return _mbgdevio_cnv_ret_val( rc );
5953 
5954 } // mbg_set_gps_pos_xyz
5955 
5956 
5957 
5958 /*HDR*/
5977 {
5978  MBGDEVIO_RET_VAL rc;
5979  LLA lla;
5980  int i;
5981 
5982  for ( i = 0; i < N_LLA; i++ )
5983  {
5984  lla[i] = p[i];
5985  swap_double( &lla[i] );
5986  _mbg_swab_double( &lla[i] );
5987  }
5988 
5989  // _mbgdevio_write_gps_var() would fail here since
5990  // LLA is an array, not a structure.
5991  rc = _mbgdevio_write_gps( dh, PC_GPS_POS_LLA, IOCTL_SET_GPS_POS_LLA, lla, sizeof( LLA ) );
5992 
5993  return _mbgdevio_cnv_ret_val( rc );
5994 
5995 } // mbg_set_gps_pos_lla
5996 
5997 
5998 
5999 /*HDR*/
6019 {
6020  MBGDEVIO_RET_VAL rc;
6023  _pcps_ddev_has_cab_len( dh ) );
6025  return _mbgdevio_cnv_ret_val( rc );
6026 
6027 } // mbg_get_gps_ant_cable_len
6028 
6029 
6030 
6031 /*HDR*/
6055  const ANT_CABLE_LEN *p )
6056 {
6057  MBGDEVIO_RET_VAL rc;
6058  #if defined( MBG_ARCH_BIG_ENDIAN )
6059  ANT_CABLE_LEN tmp = *p;
6060  _mbg_swab_ant_cable_len( &tmp );
6061  p = &tmp;
6062  #endif
6065  _pcps_ddev_has_cab_len( dh ) );
6066  return _mbgdevio_cnv_ret_val( rc );
6067 
6068 } // mbg_set_gps_ant_cable_len
6069 
6070 
6071 
6072 /*HDR*/
6092 {
6093  MBGDEVIO_RET_VAL rc;
6097 
6099  return _mbgdevio_cnv_ret_val( rc );
6100 
6101 } // mbg_get_gps_receiver_info
6102 
6103 
6104 
6105 /*HDR*/
6126  STR_TYPE_INFO_IDX stii[],
6127  const RECEIVER_INFO *p_ri )
6128 {
6129  MBGDEVIO_RET_VAL rc;
6130 
6131  #if _MBG_SUPP_VAR_ACC_SIZE
6134  p_ri->n_str_type * sizeof( stii[0] ),
6136  #else
6137  // We check the model_code to see whether the receiver info
6138  // has been read from a device which really supports it, or
6139  // a dummy structure has been setup.
6140  if ( p_ri && ( p_ri->model_code != GPS_MODEL_UNKNOWN ) )
6142  p_ri->n_str_type * sizeof( stii[0] ) );
6143  else
6144  return MBG_ERR_NOT_SUPP_BY_DEV;
6145  #endif
6146 
6147  #if defined( MBG_ARCH_BIG_ENDIAN )
6148  if ( mbg_rc_is_success( rc ) )
6149  {
6150  int i;
6151  for ( i = 0; i < p_ri->n_str_type; i++ )
6152  {
6153  STR_TYPE_INFO_IDX *p = &stii[i];
6155  }
6156  }
6157  #endif
6158 
6159  return _mbgdevio_cnv_ret_val( rc );
6160 
6161 } // mbg_get_gps_all_str_type_info
6162 
6163 
6164 
6165 /*HDR*/
6186  PORT_INFO_IDX pii[],
6187  const RECEIVER_INFO *p_ri )
6188 {
6189  MBGDEVIO_RET_VAL rc;
6190 
6191  #if _MBG_SUPP_VAR_ACC_SIZE
6194  p_ri->n_com_ports * sizeof( pii[0] ),
6196  #else
6197  // We check the model_code to see whether the receiver info
6198  // has been read from a device which really supports it, or
6199  // a dummy structure has been set up.
6200  if ( p_ri && ( p_ri->model_code != GPS_MODEL_UNKNOWN ) )
6202  p_ri->n_com_ports * sizeof( pii[0] ) );
6203  else
6204  return MBG_ERR_NOT_SUPP_BY_DEV;
6205  #endif
6206 
6207  #if defined( MBG_ARCH_BIG_ENDIAN )
6208  if ( mbg_rc_is_success( rc ) )
6209  {
6210  int i;
6211  for ( i = 0; i < p_ri->n_com_ports; i++ )
6212  {
6213  PORT_INFO_IDX *p = &pii[i];
6215  }
6216  }
6217  #endif
6218 
6219  return _mbgdevio_cnv_ret_val( rc );
6220 
6221 } // mbg_get_gps_all_port_info
6222 
6223 
6224 
6225 /*HDR*/
6249  const PORT_SETTINGS_IDX *p )
6250 {
6251  MBGDEVIO_RET_VAL rc;
6252  #if defined( MBG_ARCH_BIG_ENDIAN )
6253  PORT_SETTINGS_IDX tmp = *p;
6255  p = &tmp;
6256  #endif
6260  return _mbgdevio_cnv_ret_val( rc );
6261 
6262 } // mbg_set_gps_port_settings_idx
6263 
6264 
6265 
6266 /*HDR*/
6291  const PORT_SETTINGS *p, int idx )
6292 {
6293  PORT_SETTINGS_IDX psi = { 0 };
6294 
6295  psi.idx = idx;
6296  psi.port_settings = *p;
6298 
6299  return mbg_set_gps_port_settings_idx( dh, &psi );
6300 
6301 } // mbg_set_gps_port_settings
6302 
6303 
6304 
6305 /*HDR*/
6330  const PCPS_DEV *p_dev,
6331  RECEIVER_INFO *p )
6332 {
6333  PCPS_DEV dev = { { 0 } };
6334  int rc;
6335 
6336  if ( p_dev == NULL )
6337  {
6338  rc = mbg_get_device_info( dh, &dev );
6339 
6340  if ( mbg_rc_is_error( rc ) )
6341  return rc;
6342 
6343  p_dev = &dev;
6344  }
6345 
6346  // If the clock supports the receiver_info structure then
6347  // read it from the clock, otherwise set up some default
6348  // values depending on the clock type.
6349  if ( _pcps_has_receiver_info( p_dev ) )
6350  {
6351  rc = mbg_get_gps_receiver_info( dh, p );
6352 
6353  if ( mbg_rc_is_error( rc ) )
6354  return rc;
6355 
6356  goto check;
6357  }
6358 
6359  if ( _pcps_is_gps( p_dev ) )
6361  else
6363 
6364 check:
6365  return chk_dev_receiver_info( p );
6366 
6367 } // mbg_setup_receiver_info
6368 
6369 
6370 
6371 /*HDR*/
6386 {
6387  #if defined( _MBGIOCTL_H )
6388  MBGDEVIO_RET_VAL rc;
6390  return _mbgdevio_cnv_ret_val( rc );
6391  #else
6392  if ( !_pcps_ddev_has_asic_version( dh ) )
6393  return MBG_ERR_NOT_SUPP_BY_DEV;
6394 
6395  // TODO Should we care about memory mapped vs. port I/O access ?
6396  *p = _mbg_inp32_to_cpu( dh, 0, _pcps_ddev_io_base_mapped( dh, 0 )
6397  + offsetof( PCI_ASIC, raw_version ) );
6398 
6399  return MBG_SUCCESS;
6400  #endif
6401 
6402 } // mbg_get_asic_version
6403 
6404 
6405 
6406 /*HDR*/
6421  PCI_ASIC_FEATURES *p )
6422 {
6423 
6424  #if defined( _MBGIOCTL_H )
6425  MBGDEVIO_RET_VAL rc;
6427  return _mbgdevio_cnv_ret_val( rc );
6428  #else
6429  if ( !_pcps_ddev_has_asic_features( dh ) )
6430  {
6431  *p = 0;
6432  return MBG_ERR_NOT_SUPP_BY_DEV;
6433  }
6434 
6435  // TODO Should we care about memory mapped vs. port I/O access ?
6436  *p = _mbg_inp32_to_cpu( dh, 0, _pcps_ddev_io_base_mapped( dh, 0 )
6437  + offsetof( PCI_ASIC, features ) );
6438 
6439  return MBG_SUCCESS;
6440  #endif
6441 
6442 } // mbg_get_asic_features
6443 
6444 
6445 
6446 /*HDR*/
6467 {
6468  MBGDEVIO_RET_VAL rc;
6471  _pcps_ddev_has_time_scale( dh ) );
6473  return _mbgdevio_cnv_ret_val( rc );
6474 
6475 } // mbg_get_time_scale_info
6476 
6477 
6478 
6479 /*HDR*/
6503 {
6504  MBGDEVIO_RET_VAL rc;
6505  #if defined( MBG_ARCH_BIG_ENDIAN )
6506  MBG_TIME_SCALE_SETTINGS tmp = *p;
6508  p = &tmp;
6509  #endif
6512  _pcps_ddev_has_time_scale( dh ) );
6513  return _mbgdevio_cnv_ret_val( rc );
6514 
6515 } // mbg_set_time_scale_settings
6516 
6517 
6518 
6519 /*HDR*/
6537 {
6538  MBGDEVIO_RET_VAL rc;
6541  _pcps_ddev_has_utc_parm( dh ) );
6542  _mbg_swab_utc_parm( p );
6543  swap_double( &p->A0 );
6544  swap_double( &p->A1 );
6545  return _mbgdevio_cnv_ret_val( rc );
6546 
6547 } // mbg_get_utc_parm
6548 
6549 
6550 
6551 /*HDR*/
6574 {
6575  MBGDEVIO_RET_VAL rc;
6576 
6577  // the original parameters need to be modified anyway, so always use a copy
6578  UTC tmp = *p;
6579 
6580  #if defined( MBG_ARCH_BIG_ENDIAN )
6581  _mbg_swab_utc_parm( &tmp );
6582  #endif
6583 
6584  swap_double( &tmp.A0 );
6585  swap_double( &tmp.A1 );
6586 
6588  IOCTL_SET_GPS_UTC_PARM, &tmp,
6589  _pcps_ddev_has_utc_parm( dh ) );
6590  return _mbgdevio_cnv_ret_val( rc );
6591 
6592 } // mbg_set_utc_parm
6593 
6594 
6595 
6596 /*HDR*/
6630 {
6631  MBGDEVIO_RET_VAL rc;
6633  // No endianess conversion required.
6634  #if !defined( _MBGIOCTL_H )
6635  // only if not using IOCTLs
6636  // for PCPS_TIME, read stamp AFTER the call
6637  p->cycles = 0; //##++
6638  #endif
6639  return _mbgdevio_cnv_ret_val( rc );
6640 
6641 } // mbg_get_time_cycles
6642 
6643 
6644 
6645 /*HDR*/
6683  PCPS_HR_TIME_CYCLES *p )
6684 {
6685  MBGDEVIO_RET_VAL rc;
6686  #if !defined( _MBGIOCTL_H )
6687  // only if not using IOCTLs
6688  // for PCPS_HR_TIME, read stamp BEFORE the call
6689  p->cycles = 0; //##++
6690  #endif
6693  p, _pcps_ddev_has_hr_time( dh ) );
6695  return _mbgdevio_cnv_ret_val( rc );
6696 
6697 } // mbg_get_hr_time_cycles
6698 
6699 
6700 
6701 /*HDR*/
6740  int32_t *hns_latency )
6741 {
6742  PCPS_HR_TIME_CYCLES htc;
6743  MBG_PC_CYCLES cyc_now;
6744  int rc;
6745 
6746  // First get current time stamp counter value, then read
6747  // a high resolution time stamp from the board, plus the
6748  // associated time stamp counter value.
6749  mbg_get_pc_cycles( &cyc_now );
6750 
6751  rc = mbg_get_hr_time_cycles( dh, &htc );
6752 
6753  if ( mbg_rc_is_success( rc ) )
6754  {
6756  rc = mbg_comp_hr_latency( &htc.t.tstamp, &htc.cycles, &cyc_now, &pc_cycles_frequency, hns_latency );
6757  *p = htc.t;
6758  }
6759 
6760  return rc;
6761 
6762 } // mbg_get_hr_time_comp
6763 
6764 
6765 
6766 /*HDR*/
6788 {
6789  MBGDEVIO_RET_VAL rc;
6790 
6791  #if !defined( _MBGIOCTL_H )
6792  // This is a workaround for GPS169PCIs with early
6793  // firmware versions. See RCS log for details.
6794  uint8_t pcps_cmd = PCPS_GET_IRIG_TX_INFO;
6795 
6797  pcps_cmd = PCPS_GET_IRIG_RX_INFO;
6798 
6799  #define _PCPS_CMD pcps_cmd
6800  #else
6801  #define _PCPS_CMD PCPS_GET_IRIG_TX_INFO
6802  #endif
6803 
6805  p, _pcps_ddev_has_irig_tx( dh ) );
6806  #undef _PCPS_CMD
6807 
6808  _mbg_swab_irig_info( p );
6809  return _mbgdevio_cnv_ret_val( rc );
6810 
6811 } // mbg_get_irig_tx_info
6812 
6813 
6814 
6815 /*HDR*/
6834 {
6835  MBGDEVIO_RET_VAL rc;
6836  #if !defined( _MBGIOCTL_H )
6837  uint8_t pcps_cmd;
6838  #endif
6839 
6840  #if defined( MBG_ARCH_BIG_ENDIAN )
6841  IRIG_SETTINGS tmp = *p;
6842  _mbg_swab_irig_settings( &tmp );
6843  p = &tmp;
6844  #endif
6845 
6846  #if !defined( _MBGIOCTL_H )
6847  // This is a workaround for GPS169PCIs with early
6848  // firmware versions. See RCS log for details.
6849  pcps_cmd = PCPS_SET_IRIG_TX_SETTINGS;
6850 
6852  pcps_cmd = PCPS_SET_IRIG_RX_SETTINGS;
6853 
6854  #define _PCPS_CMD pcps_cmd
6855  #else
6856  #define _PCPS_CMD PCPS_SET_IRIG_TX_SETTINGS
6857  #endif
6858 
6860  p, _pcps_ddev_has_irig_tx( dh ) );
6861  #undef _PCPS_CMD
6862 
6863  return _mbgdevio_cnv_ret_val( rc );
6864 
6865 } // mbg_set_irig_tx_settings
6866 
6867 
6868 
6869 /*HDR*/
6890 {
6891  MBGDEVIO_RET_VAL rc;
6893  p, _pcps_ddev_has_synth( dh ) );
6894  _mbg_swab_synth( p );
6895  return _mbgdevio_cnv_ret_val( rc );
6896 
6897 } // mbg_get_synth
6898 
6899 
6900 
6901 /*HDR*/
6922 {
6923  MBGDEVIO_RET_VAL rc;
6924  #if defined( MBG_ARCH_BIG_ENDIAN )
6925  SYNTH tmp = *p;
6926  _mbg_swab_synth( &tmp );
6927  p = &tmp;
6928  #endif
6930  p, _pcps_ddev_has_synth( dh ) );
6931  return _mbgdevio_cnv_ret_val( rc );
6932 
6933 } // mbg_set_synth
6934 
6935 
6936 
6937 /*HDR*/
6955 {
6956  MBGDEVIO_RET_VAL rc;
6958  p, _pcps_ddev_has_synth( dh ) );
6959  _mbg_swab_synth_state( p );
6960  return _mbgdevio_cnv_ret_val( rc );
6961 
6962 } // mbg_get_synth_state
6963 
6964 
6965 
6966 /*HDR*/
6983 {
6984  #if defined( _MBGIOCTL_H )
6985  MBGDEVIO_RET_VAL rc;
6987  // native endianess, no need to swap bytes
6988  return _mbgdevio_cnv_ret_val( rc );
6989  #else
6990  // This is currently not supported by the target environment.
6991  return MBG_ERR_NOT_SUPP_ON_OS;
6992  #endif
6993 
6994 } // mbg_get_fast_hr_timestamp_cycles
6995 
6996 
6997 
6998 /*HDR*/
7018  PCPS_TIME_STAMP *p,
7019  int32_t *hns_latency )
7020 {
7022  MBG_PC_CYCLES cyc_now;
7023  int rc;
7024 
7025  // First get current time stamp counter value, then read
7026  // a high resolution time stamp from the board, plus the
7027  // associated time stamp counter value.
7028  mbg_get_pc_cycles( &cyc_now );
7029 
7030  rc = mbg_get_fast_hr_timestamp_cycles( dh, &tc );
7031 
7032  if ( mbg_rc_is_success( rc ) )
7033  {
7035  rc = mbg_comp_hr_latency( &tc.tstamp, &tc.cycles, &cyc_now, &pc_cycles_frequency, hns_latency );
7036  *p = tc.tstamp;
7037  }
7038 
7039  return rc;
7040 
7041 } // mbg_get_fast_hr_timestamp_comp
7042 
7043 
7044 
7045 /*HDR*/
7067  PCPS_TIME_STAMP *p )
7068 {
7069  #if defined( _MBGIOCTL_H )
7070  MBGDEVIO_RET_VAL rc;
7072  // native endianess, no need to swap bytes
7073  return _mbgdevio_cnv_ret_val( rc );
7074  #else
7075  // This is currently not supported by the target environment.
7076  return MBG_ERR_NOT_SUPP_ON_OS;
7077  #endif
7078 
7079 } // mbg_get_fast_hr_timestamp
7080 
7081 
7082 
7083 /*HDR*/
7110  POUT_INFO_IDX pii[],
7111  const RECEIVER_INFO *p_ri )
7112 {
7113  MBGDEVIO_RET_VAL rc;
7114 
7115  #if _MBG_SUPP_VAR_ACC_SIZE
7118  p_ri->n_prg_out * sizeof( pii[0] ),
7120  #else
7121  // We check the model_code to see whether the receiver info
7122  // has been read from a device which really supports it, or
7123  // a dummy structure has been setup.
7124  if ( p_ri && ( p_ri->model_code != GPS_MODEL_UNKNOWN ) )
7126  p_ri->n_prg_out * sizeof( pii[0] ) );
7127  else
7128  return MBG_ERR_NOT_SUPP_BY_DEV;
7129  #endif
7130 
7131  #if defined( MBG_ARCH_BIG_ENDIAN )
7132  if ( mbg_rc_is_success( rc ) )
7133  {
7134  int i;
7135  for ( i = 0; i < p_ri->n_prg_out; i++ )
7136  {
7137  POUT_INFO_IDX *p = &pii[i];
7139  }
7140  }
7141  #endif
7142 
7143  return _mbgdevio_cnv_ret_val( rc );
7144 
7145 } // mbg_get_gps_all_pout_info
7146 
7147 
7148 
7149 /*HDR*/
7170  const POUT_SETTINGS_IDX *p )
7171 {
7172  MBGDEVIO_RET_VAL rc;
7173  #if defined( MBG_ARCH_BIG_ENDIAN )
7174  POUT_SETTINGS_IDX tmp = *p;
7176  p = &tmp;
7177  #endif
7181  return _mbgdevio_cnv_ret_val( rc );
7182 
7183 } // mbg_set_gps_pout_settings_idx
7184 
7185 
7186 
7187 /*HDR*/
7210  const POUT_SETTINGS *p, int idx )
7211 {
7212  POUT_SETTINGS_IDX psi = { 0 };
7213 
7214  psi.idx = idx;
7215  psi.pout_settings = *p;
7216 
7217  return mbg_set_gps_pout_settings_idx( dh, &psi );
7218 
7219 } // mbg_set_gps_pout_settings
7220 
7221 
7222 
7223 /*HDR*/
7239 {
7240  #if defined( _MBGIOCTL_H )
7241  MBGDEVIO_RET_VAL rc;
7242  rc = _mbgdevio_read_var( dh, -1, IOCTL_GET_IRQ_STAT_INFO, p );
7243  // native endianess, no need to swap bytes
7244  return _mbgdevio_cnv_ret_val( rc );
7245  #else
7246  *p = dh->irq_stat_info;
7247  return MBG_SUCCESS;
7248  #endif
7249 
7250 } // mbg_get_irq_stat_info
7251 
7252 
7253 
7254 /*HDR*/
7272 {
7273  MBGDEVIO_RET_VAL rc;
7276  _pcps_ddev_has_lan_intf( dh ) );
7277  _mbg_swab_lan_if_info( p );
7278  return _mbgdevio_cnv_ret_val( rc );
7279 
7280 } // mbg_get_lan_if_info
7281 
7282 
7283 
7284 /*HDR*/
7302 {
7303  MBGDEVIO_RET_VAL rc;
7306  _pcps_ddev_has_lan_intf( dh ) );
7308  return _mbgdevio_cnv_ret_val( rc );
7309 
7310 } // mbg_get_ip4_state
7311 
7312 
7313 
7314 /*HDR*/
7332 {
7333  MBGDEVIO_RET_VAL rc;
7336  _pcps_ddev_has_lan_intf( dh ) );
7338  return _mbgdevio_cnv_ret_val( rc );
7339 
7340 } // mbg_get_ip4_settings
7341 
7342 
7343 
7344 /*HDR*/
7361  const IP4_SETTINGS *p )
7362 {
7363  MBGDEVIO_RET_VAL rc;
7364  #if defined( MBG_ARCH_BIG_ENDIAN )
7365  IP4_SETTINGS tmp = *p;
7366  _mbg_swab_ip4_settings( &tmp );
7367  p = &tmp;
7368  #endif
7371  _pcps_ddev_has_lan_intf( dh ) );
7372  return _mbgdevio_cnv_ret_val( rc );
7373 
7374 } // mbg_set_ip4_settings
7375 
7376 
7377 
7378 /*HDR*/
7397 {
7398  MBGDEVIO_RET_VAL rc;
7401  _pcps_ddev_has_ptp( dh ) );
7402  _mbg_swab_ptp_state( p );
7403  return _mbgdevio_cnv_ret_val( rc );
7404 
7405 } // mbg_get_ptp_state
7406 
7407 
7408 
7409 /*HDR*/
7428 {
7429  MBGDEVIO_RET_VAL rc;
7432  _pcps_ddev_has_ptp( dh ) );
7434  return _mbgdevio_cnv_ret_val( rc );
7435 
7436 } // mbg_get_ptp_cfg_info
7437 
7438 
7439 
7440 /*HDR*/
7459  const PTP_CFG_SETTINGS *p )
7460 {
7461  MBGDEVIO_RET_VAL rc;
7462  #if defined( MBG_ARCH_BIG_ENDIAN )
7463  PTP_CFG_SETTINGS tmp = *p;
7465  p = &tmp;
7466  #endif
7469  _pcps_ddev_has_ptp( dh ) );
7470  return _mbgdevio_cnv_ret_val( rc );
7471 
7472 } // mbg_set_ptp_cfg_settings
7473 
7474 
7475 
7476 /*HDR*/
7495 {
7496  MBGDEVIO_RET_VAL rc;
7500 
7502  return _mbgdevio_cnv_ret_val( rc );
7503 
7504 } // mbg_get_ptp_uc_master_cfg_limits
7505 
7506 
7507 
7508 /*HDR*/
7528  PTP_UC_MASTER_INFO_IDX pii[],
7529  const PTP_UC_MASTER_CFG_LIMITS *p_umsl )
7530 {
7531  MBGDEVIO_RET_VAL rc;
7532 
7533  #if _MBG_SUPP_VAR_ACC_SIZE
7536  p_umsl->n_supp_master * sizeof( pii[0] ),
7538  #else
7539  if ( p_umsl && p_umsl->n_supp_master )
7541  p_umsl->n_supp_master * sizeof( pii[0] ) );
7542  else
7543  return MBG_ERR_NOT_SUPP_BY_DEV;
7544  #endif
7545 
7546  #if defined( MBG_ARCH_BIG_ENDIAN )
7547  if ( mbg_rc_is_success( rc ) )
7548  {
7549  int i;
7550  for ( i = 0; i < p_umsl->n_supp_master; i++ )
7551  {
7552  PTP_UC_MASTER_INFO_IDX *p = &pii[i];
7554  }
7555  }
7556  #endif
7557 
7558  return _mbgdevio_cnv_ret_val( rc );
7559 
7560 } // mbg_get_all_ptp_uc_master_info
7561 
7562 
7563 
7564 /*HDR*/
7583  const PTP_UC_MASTER_SETTINGS_IDX *p )
7584 {
7585  MBGDEVIO_RET_VAL rc;
7586  #if defined( MBG_ARCH_BIG_ENDIAN )
7587  PTP_UC_MASTER_SETTINGS_IDX tmp = *p;
7589  p = &tmp;
7590  #endif
7594  return _mbgdevio_cnv_ret_val( rc );
7595 
7596 } // mbg_set_ptp_uc_master_settings_idx
7597 
7598 
7599 
7600 /*HDR*/
7627 {
7628  #if defined( _MBGIOCTL_H )
7629  MBGDEVIO_RET_VAL rc;
7631  _pcps_ddev_has_hr_time( dh ) );
7633  return _mbgdevio_cnv_ret_val( rc );
7634  #else
7635  return MBG_ERR_NOT_SUPP_ON_OS;
7636  #endif
7637 
7638 } // mbg_get_time_info_hrt
7639 
7640 
7641 
7642 /*HDR*/
7660 {
7661  #if defined( _MBGIOCTL_H )
7662  MBGDEVIO_RET_VAL rc;
7666  return _mbgdevio_cnv_ret_val( rc );
7667  #else
7668  return MBG_ERR_NOT_SUPP_ON_OS;
7669  #endif
7670 
7671 } // mbg_get_time_info_tstamp
7672 
7673 
7674 
7675 /*HDR*/
7691 {
7692  MBGDEVIO_RET_VAL rc;
7695  _pcps_ddev_has_corr_info( dh ) );
7696  _mbg_swab_corr_info( p );
7697  return _mbgdevio_cnv_ret_val( rc );
7698 
7699 } // mbg_get_corr_info
7700 
7701 
7702 
7703 /*HDR*/
7723 {
7724  MBGDEVIO_RET_VAL rc;
7728  _mbg_swab_tr_distance( p );
7729  return _mbgdevio_cnv_ret_val( rc );
7730 
7731 } // mbg_get_tr_distance
7732 
7733 
7734 
7735 /*HDR*/
7755 {
7756  MBGDEVIO_RET_VAL rc;
7757  #if defined( MBG_ARCH_BIG_ENDIAN )
7758  TR_DISTANCE tmp = *p;
7759  _mbg_swab_tr_distance( &tmp );
7760  p = &tmp;
7761  #endif
7763  p, _pcps_ddev_has_tr_distance( dh ) );
7764  return _mbgdevio_cnv_ret_val( rc );
7765 
7766 } // mbg_set_tr_distance
7767 
7768 
7769 
7770 /*HDR*/
7791 {
7792  MBGDEVIO_RET_VAL rc;
7797  return _mbgdevio_cnv_ret_val( rc );
7798 
7799 } // mbg_get_debug_status
7800 
7801 
7802 
7803 /*HDR*/
7820 {
7821  MBGDEVIO_RET_VAL rc;
7823  _pcps_ddev_has_evt_log( dh ) );
7824  return _mbgdevio_cnv_ret_val( rc );
7825 
7826 } // mbg_clr_evt_log
7827 
7828 
7829 
7830 /*HDR*/
7852 {
7853  MBGDEVIO_RET_VAL rc;
7856  _pcps_ddev_has_evt_log( dh ) );
7858  return _mbgdevio_cnv_ret_val( rc );
7859 
7860 } // mbg_get_num_evt_log_entries
7861 
7862 
7863 
7864 /*HDR*/
7887 {
7888  MBGDEVIO_RET_VAL rc;
7891  _pcps_ddev_has_evt_log( dh ) );
7893  return _mbgdevio_cnv_ret_val( rc );
7894 
7895 } // mbg_get_first_evt_log_entry
7896 
7897 
7898 
7899 /*HDR*/
7923 {
7924  MBGDEVIO_RET_VAL rc;
7927  _pcps_ddev_has_evt_log( dh ) );
7929  return _mbgdevio_cnv_ret_val( rc );
7930 
7931 } // mbg_get_next_evt_log_entry
7932 
7933 
7934 
7935 /*HDR*/
7957 {
7958  MBGDEVIO_RET_VAL rc;
7961  _pcps_ddev_is_gnss( dh ) );
7963  return _mbgdevio_cnv_ret_val( rc );
7964 
7965 } // mbg_get_gps_gnss_mode_info
7966 
7967 
7968 
7969 /*HDR*/
7994  const MBG_GNSS_MODE_SETTINGS *p_ms )
7995 {
7996  MBGDEVIO_RET_VAL rc;
7997  #if defined( MBG_ARCH_BIG_ENDIAN )
7998  MBG_GNSS_MODE_SETTINGS tmp = *p_ms;
8000  p_ms = &tmp;
8001  #endif
8004  _pcps_ddev_is_gnss( dh ) );
8005  return _mbgdevio_cnv_ret_val( rc );
8006 
8007 } // mbg_set_gps_gnss_mode_settings
8008 
8009 
8010 
8011 /*HDR*/
8029  GNSS_SAT_INFO_IDX gsii[],
8030  const MBG_GNSS_MODE_INFO *p_mi )
8031 {
8032  MBGDEVIO_RET_VAL rc;
8033 
8034  int n_supp = num_bits_set( p_mi->supp_gnss_types );
8035 
8036  #if _MBG_SUPP_VAR_ACC_SIZE
8039  n_supp * sizeof( gsii[0] ),
8040  _pcps_ddev_is_gnss( dh ) );
8041  #else
8043  n_supp * sizeof( gsii[0] ) );
8044  #endif
8045 
8046  #if defined( MBG_ARCH_BIG_ENDIAN )
8047  if ( mbg_rc_is_success( rc ) )
8048  {
8049  int i;
8050  for ( i = 0; i < n_supp; i++ )
8051  {
8052  GNSS_SAT_INFO_IDX *p = &gsii[i];
8054  }
8055  }
8056  #endif
8057 
8058  return _mbgdevio_cnv_ret_val( rc );
8059 
8060 } // mbg_get_gps_all_gnss_sat_info
8061 
8062 
8063 
8064 /*HDR*/
8083 {
8084  MBGDEVIO_RET_VAL rc;
8087  _pcps_ddev_has_gpio( dh ) );
8089 
8090  return _mbgdevio_cnv_ret_val( rc );
8091 
8092 } // mbg_get_gpio_cfg_limits
8093 
8094 
8095 
8096 /*HDR*/
8116  MBG_GPIO_INFO_IDX gii[],
8117  const MBG_GPIO_CFG_LIMITS *p_gcl )
8118 {
8119  MBGDEVIO_RET_VAL rc;
8120 
8121  uint32_t n_supp = p_gcl->num_io;
8122 
8123  #if _MBG_SUPP_VAR_ACC_SIZE
8126  n_supp * sizeof( gii[0] ),
8127  _pcps_ddev_has_gpio( dh ) );
8128  #else
8130  n_supp * sizeof( gii[0] ) );
8131  #endif
8132 
8133  #if defined( MBG_ARCH_BIG_ENDIAN )
8134  if ( mbg_rc_is_success( rc ) )
8135  {
8136  int i;
8137  for ( i = 0; i < n_supp; i++ )
8138  {
8139  MBG_GPIO_INFO_IDX *p = &gii[i];
8141  }
8142  }
8143  #endif
8144 
8145  return _mbgdevio_cnv_ret_val( rc );
8146 
8147 } // mbg_get_gps_all_gpio_info
8148 
8149 
8150 
8151 /*HDR*/
8173  const MBG_GPIO_SETTINGS_IDX *p )
8174 {
8175  MBGDEVIO_RET_VAL rc;
8176  #if defined( MBG_ARCH_BIG_ENDIAN )
8177  MBG_GPIO_SETTINGS_IDX tmp = *p;
8179  p = &tmp;
8180  #endif
8183  _pcps_ddev_has_gpio( dh ) );
8184  return _mbgdevio_cnv_ret_val( rc );
8185 
8186 } // mbg_set_gps_gpio_settings_idx
8187 
8188 
8189 
8190 /*HDR*/
8206  MBG_GPIO_STATUS_IDX gsi[],
8207  const MBG_GPIO_CFG_LIMITS *p_gcl )
8208 {
8209  MBGDEVIO_RET_VAL rc;
8210 
8211  uint32_t n_supp;
8212 
8213  if ( !( p_gcl->flags & MBG_GPIO_CFG_LIMIT_FLAG_MASK_STATUS_SUPP ) )
8214  return MBG_ERR_NOT_SUPP_BY_DEV;
8215 
8216  n_supp = p_gcl->num_io;
8217 
8218  #if _MBG_SUPP_VAR_ACC_SIZE
8221  n_supp * sizeof( gsi[0] ),
8222  _pcps_ddev_has_gpio( dh ) );
8223  #else
8225  n_supp * sizeof( gsi[0] ) );
8226  #endif
8227 
8228  #if defined( MBG_ARCH_BIG_ENDIAN )
8229  if ( mbg_rc_is_success( rc ) )
8230  {
8231  int i;
8232  for ( i = 0; i < n_supp; i++ )
8233  {
8234  MBG_GPIO_STATUS_IDX *p = &gsi[i];
8236  }
8237  }
8238  #endif
8239 
8240  return _mbgdevio_cnv_ret_val( rc );
8241 
8242 } // mbg_get_gps_all_gpio_status
8243 
8244 
8245 
8246 /*HDR*/
8262 {
8263  MBGDEVIO_RET_VAL rc;
8266  _pcps_ddev_has_xmr( dh ) );
8268  return _mbgdevio_cnv_ret_val( rc );
8269 
8270 } // mbg_get_xmr_instances
8271 
8272 
8273 
8274 /*HDR*/
8291  XMULTI_REF_STATUS_IDX xmrsi[],
8292  const XMULTI_REF_INSTANCES *p_xmri )
8293 {
8294  MBGDEVIO_RET_VAL rc;
8295 
8296  int n_supp = p_xmri->n_xmr_settings;
8297 
8298  #if _MBG_SUPP_VAR_ACC_SIZE
8300  IOCTL_GET_ALL_XMR_STATUS, xmrsi,
8301  n_supp * sizeof( xmrsi[0] ),
8302  _pcps_ddev_has_xmr( dh ) );
8303  #else
8305  n_supp * sizeof( xmrsi[0] ) );
8306  #endif
8307 
8308  #if defined( MBG_ARCH_BIG_ENDIAN )
8309  if ( mbg_rc_is_success( rc ) )
8310  {
8311  int i;
8312  for ( i = 0; i < n_supp; i++ )
8313  {
8314  XMULTI_REF_STATUS_IDX *p = &xmrsi[i];
8316  }
8317  }
8318  #endif
8319 
8320  return _mbgdevio_cnv_ret_val( rc );
8321 
8322 } // mbg_get_gps_all_xmr_status
8323 
8324 
8325 
8326 /*HDR*/
8343  XMULTI_REF_INFO_IDX xmrii[],
8344  const XMULTI_REF_INSTANCES *p_xmri )
8345 {
8346  MBGDEVIO_RET_VAL rc;
8347 
8348  int n_supp = p_xmri->n_xmr_settings;
8349 
8350  #if _MBG_SUPP_VAR_ACC_SIZE
8352  IOCTL_GET_ALL_XMR_INFO, xmrii,
8353  n_supp * sizeof( xmrii[0] ),
8354  _pcps_ddev_has_xmr( dh ) );
8355  #else
8357  n_supp * sizeof( xmrii[0] ) );
8358  #endif
8359 
8360  #if defined( MBG_ARCH_BIG_ENDIAN )
8361  if ( mbg_rc_is_success( rc ) )
8362  {
8363  int i;
8364  for ( i = 0; i < n_supp; i++ )
8365  {
8366  XMULTI_REF_INFO_IDX *p = &xmrii[i];
8368  }
8369  }
8370  #endif
8371 
8372  return _mbgdevio_cnv_ret_val( rc );
8373 
8374 } // mbg_get_gps_all_xmr_info
8375 
8376 
8377 
8378 /*HDR*/
8400  const XMULTI_REF_SETTINGS_IDX *p )
8401 {
8402  MBGDEVIO_RET_VAL rc;
8403  #if defined( MBG_ARCH_BIG_ENDIAN )
8404  XMULTI_REF_SETTINGS_IDX tmp = *p;
8406  p = &tmp;
8407  #endif
8410  _pcps_ddev_has_xmr( dh ) );
8411  return _mbgdevio_cnv_ret_val( rc );
8412 
8413 } // mbg_set_gps_xmr_settings_idx
8414 
8415 
8416 
8417 /*HDR*/
8437  const XMULTI_REF_INSTANCES *p_xmri )
8438 {
8439  MBGDEVIO_RET_VAL rc;
8440 
8441  if ( !( p_xmri->flags & XMRIF_MSK_HOLDOVER_STATUS_SUPP ) )
8442  return MBG_ERR_NOT_SUPP_BY_DEV;
8443 
8446  _pcps_ddev_has_xmr( dh ) );
8448 
8449  return _mbgdevio_cnv_ret_val( rc );
8450 
8451 } // mbg_get_xmr_holdover_status
8452 
8453 
8454 
8455 /*HDR*/
8471 {
8472  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8473 
8474  if ( sched_getaffinity( pid, sizeof( *p ), p ) == 0 ) // success
8475  return MBG_SUCCESS;
8476 
8477  return mbg_get_last_error( NULL );
8478 
8479  #elif defined( MBG_TGT_WIN32 )
8480 
8481  MBG_CPU_SET system_affinity_mask = 0;
8482 
8483  if ( GetProcessAffinityMask( pid, p, &system_affinity_mask ) )
8484  return MBG_SUCCESS;
8485 
8486  return mbg_get_last_error( NULL );
8487 
8488  #else
8489 
8490  return MBG_ERR_NOT_SUPP_ON_OS;
8491 
8492  #endif
8493 
8494 } // mbg_get_process_affinity
8495 
8496 
8497 
8498 /*HDR*/
8514 {
8515  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8516 
8517  if ( sched_setaffinity( pid, sizeof( *p ), p ) == 0 )
8518  return MBG_SUCCESS;
8519 
8520  return mbg_get_last_error( NULL );
8521 
8522  #elif defined( MBG_TGT_WIN32 )
8523 
8524  if ( SetProcessAffinityMask( pid, *p ) )
8525  return MBG_SUCCESS;
8526 
8527  return mbg_get_last_error( NULL );
8528 
8529  #else
8530 
8531  return MBG_ERR_NOT_SUPP_ON_OS;
8532 
8533  #endif
8534 
8535 } // mbg_set_process_affinity
8536 
8537 
8538 
8539 /*HDR*/
8553 {
8554  MBG_CPU_SET cpu_set;
8555 
8556  _mbg_cpu_clear( &cpu_set );
8557  _mbg_cpu_set( cpu_num, &cpu_set );
8558 
8559  return mbg_set_process_affinity( _mbg_get_current_process(), &cpu_set );
8560 
8561 } // mbg_set_current_process_affinity_to_cpu
8562 
8563 
8564 
8565 #if MBGDEVIO_USE_THREAD_API
8566 
8567 /*HDR*/
8584  MBG_THREAD_FNC fnc, void *arg )
8585 {
8586  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8587 
8588  if ( pthread_create( &p_ti->thread_id, NULL, fnc, arg ) == 0 )
8589  return MBG_SUCCESS;
8590 
8591  return mbg_get_last_error( NULL );
8592 
8593  #elif defined( MBG_TGT_WIN32 )
8594 
8595  HANDLE h;
8596  DWORD thread_id = 0;
8597 
8598  p_ti->exit_request = CreateEvent( NULL, FALSE, FALSE, NULL );
8599 
8600  if ( p_ti->exit_request == NULL )
8601  goto fail;
8602 
8603  h = CreateThread( NULL, 0, fnc, arg, 0, &thread_id );
8604 
8605  if ( h == NULL )
8606  {
8607  CloseHandle( p_ti->exit_request );
8608  goto fail;
8609  }
8610 
8611  p_ti->thread_id = h;
8612 
8613  return MBG_SUCCESS;
8614 
8615 fail:
8616  return mbg_get_last_error( NULL );
8617 
8618  #else
8619 
8620  return MBG_ERR_NOT_SUPP_ON_OS;
8621 
8622  #endif
8623 
8624 } // mbg_thread_create
8625 
8626 
8627 
8628 /*HDR*/
8645 {
8646  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8647 
8648  pthread_cancel( p_ti->thread_id );
8649 
8650  if ( pthread_join( p_ti->thread_id, NULL ) == 0 )
8651  return MBG_SUCCESS;
8652 
8653  return mbg_get_last_error( NULL );
8654 
8655  #elif defined( MBG_TGT_WIN32 )
8656 
8657  if ( SetEvent( p_ti->exit_request ) &&
8658  WaitForSingleObject( p_ti->thread_id, 10000L ) == 0 )
8659  {
8660  CloseHandle( p_ti->exit_request );
8661  p_ti->exit_request = NULL;
8662 
8663  CloseHandle( p_ti->thread_id );
8664  p_ti->thread_id = NULL;
8665 
8666  return MBG_SUCCESS;
8667  }
8668 
8669  return mbg_get_last_error( NULL );
8670 
8671  #else
8672 
8673  return MBG_ERR_NOT_SUPP_ON_OS;
8674 
8675  #endif
8676 
8677 } // mbg_thread_stop
8678 
8679 
8680 
8681 /*HDR*/
8702 {
8703  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8704 
8705  if ( usleep( sleep_ms * 1000 ) == 0 )
8706  return MBG_SUCCESS;
8707 
8708  return mbg_get_last_error( NULL );
8709 
8710  #elif defined( MBG_TGT_WIN32 )
8711 
8712  DWORD dw = WaitForSingleObject( p_ti->exit_request, sleep_ms );
8713 
8714  switch ( dw )
8715  {
8716  case WAIT_OBJECT_0: // has been interrupted to terminate
8717  return MBG_ERR_INTR;
8718 
8719  case WAIT_TIMEOUT: // sleep interval expired without interruption
8720  return MBG_SUCCESS;
8721  }
8722 
8723  return mbg_get_last_error( NULL );
8724 
8725  #else
8726 
8727  return MBG_ERR_NOT_SUPP_ON_OS;
8728 
8729  #endif
8730 
8731 } // mbg_thread_sleep_interruptible
8732 
8733 
8734 
8735 #if MBGDEVIO_HAVE_THREAD_AFFINITY
8736 
8737 /*HDR*/
8756 {
8757  #if defined( MBG_TGT_LINUX ) // TODO Eventually generally for POSIX?
8758 
8759  if ( pthread_setaffinity_np( tid, sizeof( *p ), p ) == 0 )
8760  return MBG_SUCCESS;
8761 
8762  return mbg_get_last_error( NULL );
8763 
8764  #elif defined( MBG_TGT_WIN32 )
8765 
8766  MBG_CPU_SET prv_thread_affinity = SetThreadAffinityMask( p_ti->thread_id, *p );
8767 
8768  if ( prv_thread_affinity )
8769  return MBG_SUCCESS;
8770 
8771  return mbg_get_last_error( NULL );
8772 
8773  #else
8774 
8775  return MBG_ERR_NOT_SUPP_ON_OS;
8776 
8777  #endif
8778 
8779 } // mbg_thread_set_affinity
8780 
8781 #endif
8782 
8783 
8784 
8785 static /*HDR*/
8813 MBG_THREAD_FNC_RET_VAL MBG_THREAD_FNC_ATTR mbg_xhrt_poll_thread_fnc( void *p_void )
8814 {
8815  MBG_XHRT_VARS prv_xhrt_vars;
8816 
8817  MBG_POLL_THREAD_INFO *p_pti = (MBG_POLL_THREAD_INFO *) p_void;
8818  MBG_XHRT_INFO *p = &p_pti->xhrt_info;
8819 
8820  memset( &prv_xhrt_vars, 0, sizeof( prv_xhrt_vars ) );
8821 
8822  for (;;)
8823  {
8824  MBG_XHRT_VARS xhrt_vars;
8825  MBG_PC_CYCLES_FREQUENCY freq = 0;
8826  int sleep_ms;
8827 
8828  int rc = mbg_get_hr_time_cycles( p->dh, &xhrt_vars.htc );
8829 
8830  if ( mbg_rc_is_success( rc ) )
8831  {
8832  xhrt_vars.pcps_hr_tstamp64 = pcps_time_stamp_to_uint64( &xhrt_vars.htc.t.tstamp );
8833 
8834  if ( prv_xhrt_vars.pcps_hr_tstamp64 && ( ( xhrt_vars.htc.t.status & PCPS_LS_ENB ) == 0 ) )
8835  freq = ( mbg_delta_pc_cycles( &xhrt_vars.htc.cycles, &prv_xhrt_vars.htc.cycles ) * MBG_FRAC32_UNITS_PER_SEC )
8836  / ( xhrt_vars.pcps_hr_tstamp64 - prv_xhrt_vars.pcps_hr_tstamp64 );
8837  }
8838 
8839 
8841 
8842  if ( mbg_rc_is_success( rc ) )
8843  {
8844  p->vars = xhrt_vars;
8845  p->prv_vars = prv_xhrt_vars;
8846 
8847  if ( freq )
8848  p->freq_hz = freq;
8849  }
8850 
8851  p->ioctl_status = rc;
8852 
8853  sleep_ms = p->sleep_ms;
8854 
8856 
8857 
8858  if ( mbg_rc_is_success( rc ) )
8859  prv_xhrt_vars = xhrt_vars;
8860 
8861  if ( mbg_rc_is_error( mbg_thread_sleep_interruptible( &p_pti->ti, sleep_ms ) ) )
8862  break;
8863  }
8864 
8865  _mbg_thread_exit( MBG_SUCCESS ); // TODO or an optional error code?
8866 
8867 } // mbg_xhrt_poll_thread_fnc
8868 
8869 MBG_THREAD_FNC mbg_xhrt_poll_thread_fnc;
8870 
8871 
8872 
8873 /*HDR*/
8898  MBG_PC_CYCLES_FREQUENCY freq_hz, int sleep_ms )
8899 {
8900  int rc = mbg_chk_dev_has_hr_time( dh );
8901 
8902  if ( mbg_rc_is_error( rc ) )
8903  return rc;
8904 
8905  memset( p_pti, 0, sizeof( *p_pti ) );
8906 
8907  p_pti->xhrt_info.dh = dh;
8908  p_pti->xhrt_info.freq_hz = freq_hz;
8909  p_pti->xhrt_info.sleep_ms = sleep_ms ? sleep_ms : 1000; // sleep 1 second by default
8910  _mbg_crit_sect_init( &p_pti->xhrt_info.crit_sect, "MBGDEVIO_xhrt_info" );
8911 
8912  rc = mbg_thread_create( &p_pti->ti, mbg_xhrt_poll_thread_fnc, p_pti );
8913 
8914  return rc;
8915 
8916 } // mbg_xhrt_poll_thread_create
8917 
8918 
8919 
8920 /*HDR*/
8936 {
8937  int rc = mbg_thread_stop( &p_pti->ti );
8938 
8939  if ( mbg_rc_is_success( rc ) )
8941 
8942  return rc;
8943 
8944 } // mbg_xhrt_poll_thread_stop
8945 
8946 
8947 
8948 static __mbg_inline /*HDR*/
8974 int mbg_get_xhrt_data( MBG_XHRT_INFO *p, uint64_t *p_tstamp, MBG_XHRT_VARS *p_vars )
8975 {
8976  MBG_XHRT_VARS xhrt_vars;
8977  MBG_PC_CYCLES cyc_now;
8978  uint64_t t_now = 0;
8979  MBG_PC_CYCLES_FREQUENCY freq_hz;
8980  int ioctl_status;
8981 
8982  mbg_get_pc_cycles( &cyc_now );
8983 
8985  xhrt_vars = p->vars;
8986  freq_hz = p->freq_hz;
8987  ioctl_status = p->ioctl_status;
8989 
8990  if ( freq_hz && xhrt_vars.pcps_hr_tstamp64 )
8991  {
8992  t_now = xhrt_vars.pcps_hr_tstamp64 +
8993  ( mbg_delta_pc_cycles( &cyc_now, &xhrt_vars.htc.cycles ) * MBG_FRAC32_UNITS_PER_SEC ) / freq_hz;
8994  mbg_chk_tstamp64_leap_sec( &t_now, &xhrt_vars.htc.t.status );
8995  }
8996 
8997  if ( p_tstamp )
8998  *p_tstamp = t_now;
8999 
9000  if ( p_vars )
9001  *p_vars = xhrt_vars;
9002 
9003  return ioctl_status;
9004 
9005 } // mbg_get_xhrt_data
9006 
9007 
9008 
9009 /*HDR*/
9034 {
9035  uint64_t tstamp64;
9036  MBG_XHRT_VARS xhrt_vars;
9037 
9038  int rc = mbg_get_xhrt_data( p, &tstamp64, &xhrt_vars );
9039 
9040  // Even if an IOCTL error has occurred recently in the polling thread
9041  // the interpolation may still work correctly. So we just continue
9042  // normally but pass the return code on to the calling function.
9043 
9044  uint64_to_pcps_time_stamp( &p_hrt->tstamp, tstamp64 );
9045 
9046  // Update status (valid only for the previous second!)
9047  p_hrt->signal = xhrt_vars.htc.t.signal;
9048  p_hrt->status = xhrt_vars.htc.t.status;
9049  p_hrt->utc_offs = xhrt_vars.htc.t.utc_offs;
9050 
9051  return rc;
9052 
9053 } // mbg_get_xhrt_time_as_pcps_hr_time
9054 
9055 
9056 
9057 #if defined( MBG_TGT_WIN32 )
9058 
9059 /*HDR*/
9085 {
9086  uint64_t tstamp64;
9087 
9088  int rc = mbg_get_xhrt_data( p, &tstamp64, NULL );
9089 
9090  // Even if an IOCTL error has occurred recently in the polling thread
9091  // the interpolation may still work correctly. So we just continue
9092  // normally but pass the return code on to the calling function.
9093 
9094  mbg_pcps_tstamp64_to_filetime( p_ft, &tstamp64 );
9095 
9096  return rc;
9097 
9098 } // mbg_get_xhrt_time_as_filetime
9099 
9100 #endif
9101 
9102 
9103 
9104 /*HDR*/
9128 {
9129  MBG_PC_CYCLES_FREQUENCY freq_hz;
9130  int ioctl_status;
9131 
9133  freq_hz = p->freq_hz;
9134  ioctl_status = p->ioctl_status;
9136 
9137  if ( p_freq_hz )
9138  *p_freq_hz = freq_hz;
9139 
9140  return ioctl_status;
9141 
9142 } // mbg_get_xhrt_cycles_frequency
9143 
9144 #endif // defined MBGDEVIO_USE_THREAD_API
9145 
9146 
9147 
9148 /*HDR*/
9162 {
9163  #if defined( _MBGIOCTL_H )
9164  MBGDEVIO_RET_VAL rc;
9166  // native endianess, no need to swap bytes
9167  if ( mbg_rc_is_error( rc ) )
9168  *p = 0;
9169 
9170  #if defined( MBG_TGT_LINUX )
9171  if ( *p == 0 )
9172  {
9173  rc = mbg_chk_dev_has_hr_time( dh );
9174 
9175  if ( mbg_rc_is_success( rc ) )
9176  {
9177  PCPS_HR_TIME_CYCLES htc1;
9178  PCPS_HR_TIME_CYCLES htc2;
9179  double delta_cycles;
9180  double delta_t;
9181 
9182  rc = mbg_get_hr_time_cycles( dh, &htc1 );
9183 
9184  if ( mbg_rc_is_error( rc ) )
9185  goto done;
9186 
9187  sleep( 1 );
9188 
9189  rc = mbg_get_hr_time_cycles( dh, &htc2 );
9190 
9191  if ( mbg_rc_is_error( rc ) )
9192  goto done;
9193 
9194  // compute cycles frequency from delta htc
9195  delta_cycles = mbg_delta_pc_cycles( &htc2.cycles, &htc1.cycles );
9196  delta_t = pcps_time_stamp_to_uint64( &htc2.t.tstamp ) - pcps_time_stamp_to_uint64( &htc1.t.tstamp );
9197  *p = ( delta_cycles * MBG_FRAC32_UNITS_PER_SEC ) / delta_t;
9198  }
9199  }
9200 done:
9201  #endif
9202 
9203  return _mbgdevio_cnv_ret_val( rc );
9204 
9205  #else
9206 
9207  *p = 0;
9208 
9209  return MBG_ERR_NOT_SUPP_ON_OS;
9210 
9211  #endif
9212 
9213 } // mbg_get_default_cycles_frequency_from_dev
9214 
9215 
9216 
9217 /*HDR*/
9230 {
9231  #if defined MBG_TGT_WIN32
9232 
9234 
9235  mbg_get_pc_cycles_frequency( &pc_cycles_frequency );
9236 
9237  return pc_cycles_frequency;
9238 
9239  #else
9240 
9241  return 0;
9242 
9243  #endif
9244 
9245 } // mbg_get_default_cycles_frequency
9246 
9247 
9248 
9249 #if defined( MBG_TGT_WIN32 )
9250 
9251 #if defined( _USRDLL )
9252 
9253 BOOL APIENTRY DllMain( HANDLE hModule,
9254  DWORD ul_reason_for_call,
9255  LPVOID lpReserved )
9256 {
9257  if ( ul_reason_for_call == DLL_PROCESS_ATTACH )
9258  mbg_svc_register_event_source( MBG_APP_EVTLOG_NAME_MBGDEVIO_DLL );
9259 
9260  return TRUE;
9261 }
9262 
9263 #endif // defined( _USRDLL )
9264 
9265 #endif // defined( MBG_TGT_WIN32 )
9266 
_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)
Read the status of all XMR sources.
Definition: mbgdevio.c:8290
A generic thread info structure.
Definition: mbgdevio.h:513
_MBG_API_ATTR int _MBG_API mbg_set_utc_parm(MBG_DEV_HANDLE dh, const UTC *p)
Write a UTC parameter structure to a device.
Definition: mbgdevio.c:6573
_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)
Read a STR_TYPE_INFO_IDX array of supported string types.
Definition: mbgdevio.c:6125
A structure to used to read the status of the PTP protocol stack.
Definition: gpsdefs.h:13184
_MBG_API_ATTR int _MBG_API mbg_get_gps_pos(MBG_DEV_HANDLE dh, POS *p)
Read the current geographic position from a GPS device.
Definition: mbgdevio.c:5905
uint16_t TR_DISTANCE
Receiver distance from transmitter [km].
Definition: pcpsdefs.h:1553
_MBG_API_ATTR int _MBG_API 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 IOCTL_GET_PCPS_TZCODE
Definition: mbgioctl.h:537
#define IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES
Definition: mbgioctl.h:656
_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
#define IOCTL_GET_SYNTH
Definition: mbgioctl.h:604
Configuration settings for a specific PTP unicast master.
Definition: gpsdefs.h:14329
#define IOCTL_DEV_HAS_PCI_ASIC_VERSION
Definition: mbgioctl.h:646
(r/w) UTC, UTC corr. param., only if PCPS_HAS_UTC_PARM
Definition: pcpsdefs.h:1688
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
uint32_t num_io
number of supported GPIO ports
Definition: gpsdefs.h:7610
_MBG_API_ATTR int _MBG_API mbg_find_devices(void)
Get the number of devices installed on the computer.
Definition: mbgdevio.c:3503
#define _mbg_crit_sect_leave
Definition: mbgmutex.h:238
#define _mbg_swab_mbg_gpio_status_idx(_p)
Definition: gpsdefs.h:9324
_MBG_API_ATTR int _MBG_API 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
Configuration settings of a specific serial port.
Definition: gpsdefs.h:3594
uint8_t n_str_type
max num of string types supported by any port
Definition: gpsdefs.h:888
#define IOCTL_GET_GPS_ALL_PORT_INFO
Definition: mbgioctl.h:592
double A1
+- Clock Correction Coefficient 1 [sec/sec]
Definition: gpsdefs.h:18571
_MBG_API_ATTR int _MBG_API 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_API_ATTR int _MBG_API 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
High resolution device time, system time, and associated cycles counts.
Definition: pcpsdev.h:1418
(-/w) POUT_SETTINGS_IDX, settings for one programmable output
Definition: pcpsdefs.h:1657
#define PCPS_GET_SERIAL
(r-) Read serial settings as PCPS_SERIAL, deprecated by PC_GPS_ALL_PORT_INFO
Definition: pcpsdefs.h:728
_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)
Write all IRIG input configuration settings to a device.
Definition: mbgdevio.c:5146
#define IOCTL_SET_GPS_POS_LLA
Definition: mbgioctl.h:585
_MBG_API_ATTR int _MBG_API 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_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
#define IOCTL_GET_MBG_OPT_INFO
Definition: mbgioctl.h:546
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_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)
Read a GNSS_SAT_INFO_IDX array of satellite status information.
Definition: mbgdevio.c:8028
_MBG_API_ATTR int _MBG_API 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_is_msf
Check if a device is a MSF receiver.
Definition: mbgdevio.c:1117
#define _mbgdevio_write_gps(_dh, _cmd, _ioctl, _p, _sz)
Definition: mbgdevio.h:5650
(r/w) TTM, current time, deprecated by PCPS_GIVE_HR_TIME
Definition: pcpsdefs.h:1638
_MBG_API_ATTR int _MBG_API 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
MBG_CHK_SUPP_FNC mbg_chk_dev_has_event_time
Definition: mbgdevio.c:1444
_MBG_API_ATTR int _MBG_API 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_thread_create(MBG_THREAD_INFO *p_ti, MBG_THREAD_FNC fnc, void *arg)
Create a new execution thread for the current process.
(r/w) ENABLE_FLAGS, when to enable serial, pulses, and synth, only if GPS_MODEL_HAS_ENABLE_FLAGS ...
Definition: pcpsdefs.h:1645
uint64_t pcps_hr_tstamp64
Time stamp read from a device.
Definition: mbgdevio.h:544
static char * dev_name
Definition: mbgctrl.c:131
_MBG_API_ATTR int _MBG_API 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
#define _PCPS_CMD
#define _pcps_ddev_has_asic_features(_p)
Definition: pcpsdrvr.h:1290
_MBG_API_ATTR int _MBG_API 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
Settings of an IPv4-only network interface.
Definition: gpsdefs.h:11239
char * strncpy_safe(char *dst, const char *src, size_t max_len)
A portable, safe implementation of strncpy()
Definition: str_util.c:247
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
#define GPS_HAS_GPIO
see GPS_FEAT_GPIO
Definition: gpsdefs.h:2296
uint16_t n_supp_master
number of unicast masters which can be specified
Definition: gpsdefs.h:14233
(r/-) PTP_UC_MASTER_CFG_LIMITS, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1665
#define IOCTL_SET_GPS_POS_XYZ
Definition: mbgioctl.h:584
MBG_THREAD_INFO ti
Definition: mbgdevio.h:586
#define IOCTL_SET_GPS_UTC_PARM
Definition: mbgioctl.h:665
PCPS_HR_TIME t
Definition: pcpsdev.h:1395
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
#define MBG_ERR_INTR
interrupted function call
Definition: mbgerror.h:335
POUT_SETTINGS pout_settings
Definition: gpsdefs.h:6252
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tzdl
Check if a device supports timezone configuration using the TZDL structure.
Definition: mbgdevio.c:1532
_MBG_API_ATTR int _MBG_API 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
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
#define IOCTL_GET_GPS_POS
Definition: mbgioctl.h:583
#define _mbg_swab_mbg_gpio_cfg_limits(_p)
Definition: gpsdefs.h:7616
#define _pcps_ddev_has_sync_time(_p)
Definition: pcpsdrvr.h:1222
_MBG_API_ATTR int _MBG_API mbg_get_lan_if_info(MBG_DEV_HANDLE dh, LAN_IF_INFO *p)
Read LAN interface information from a device.
Definition: mbgdevio.c:7271
Time scale configuration settings plus capabilities.
Definition: gpsdefs.h:5519
_MBG_API_ATTR int _MBG_API mbg_generic_read_gps(MBG_DEV_HANDLE dh, int cmd, void *p, int size)
Definition: mbgdevio.c:4348
PCPS_IRQ_STAT_INFO irq_stat_info
Definition: pcpsdrvr.h:820
#define PCPS_CLR_UCAP_BUFF
(-w) No param., clear on-board capture FIFO, only if _pcps_has_ucap
Definition: pcpsdefs.h:768
MBG_XHRT_VARS prv_vars
Definition: mbgdevio.h:563
PCPS_BUS_FLAGS bus_flags
see PCPS_BUS_FLAG_MASKS
Definition: pcpsdev.h:518
feat_num field contains one of the GPS_FEATURE_BITS
Definition: pcpsdev.h:1316
#define IOCTL_SET_PCPS_TIME
Definition: mbgioctl.h:523
#define IOCTL_GET_PCPS_UCAP_EVENT
Definition: mbgioctl.h:554
#define _mbg_cpu_clear(_ps)
Definition: mbgdevio.h:476
#define IOCTL_SET_GPS_ENABLE_FLAGS
Definition: mbgioctl.h:575
#define _pcps_ddev_has_cab_len(_p)
Definition: pcpsdrvr.h:1227
_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
uint16_t idx
port index, 0..RECEIVER_INFO::n_com_ports-1
Definition: gpsdefs.h:3596
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_GET_PCPS_DEV
Definition: mbgioctl.h:511
Status information on a ref time source at a specific priority level.
Definition: gpsdefs.h:6885
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API 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
#define PCPS_GIVE_SYNC_TIME
(r-) Read last sync time as PCPS_TIME, only if _pcps_has_sync_time
Definition: pcpsdefs.h:714
_MBG_API_ATTR int _MBG_API 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
(-/w) MBG_GPIO_SETTINGS_IDX, settings for a specific port, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1671
#define IOCTL_GET_IRIG_CTRL_BITS
Definition: mbgioctl.h:668
(r/-) XMR_HOLDOVER_STATUS, only if XMRIF_MSK_HOLDOVER_STATUS_SUPP
Definition: pcpsdefs.h:1678
#define _mbg_swab_mbg_opt_info(_p)
Definition: gpsdefs.h:5349
_MBG_API_ATTR int _MBG_API mbg_get_irig_rx_info(MBG_DEV_HANDLE dh, IRIG_INFO *p)
Read the current IRIG input settings plus capabilities.
Definition: mbgdevio.c:5028
PCPS_DEV_TYPE type
Definition: pcpsdev.h:1045
#define _mbg_swab_mbg_gnss_mode_settings(_p)
Definition: gpsdefs.h:10685
#define IOCTL_GET_PCPS_IRIG_RX_INFO
Definition: mbgioctl.h:549
A structure used to control a poll thread function.
Definition: mbgdevio.h:583
#define IOCTL_SET_GPS_CMD
Definition: mbgioctl.h:579
#define _mbg_swab_xmulti_ref_instances(_p)
Definition: gpsdefs.h:7064
#define IOCTL_GET_FAST_HR_TIMESTAMP
Definition: mbgioctl.h:657
#define _mbg_swab_gnss_sat_info_idx(_p)
Definition: gpsdefs.h:10786
use the next device available on the system
Definition: mbgdevio.h:600
#define _mbg_swab_pcps_hr_time_cycles(_p)
Definition: pcpsdev.h:1399
#define _pcps_ddev_io_base_mapped(_p, _n)
Definition: pcpsdrvr.h:1177
Current IRIG settings and supported codes.
Definition: gpsdefs.h:5054
#define IOCTL_GET_CYCLES_FREQUENCY
Definition: mbgioctl.h:653
Configuration settings of a serial port.
Definition: gpsdefs.h:3507
#define _pcps_sernum(_d)
Definition: pcpsdev.h:1120
_MBG_API_ATTR int _MBG_API mbg_get_tr_distance(MBG_DEV_HANDLE dh, TR_DISTANCE *p)
Read configurable "distance from transmitter" parameter from a device.
Definition: mbgdevio.c:7722
static __mbg_inline void mbg_get_pc_cycles(MBG_PC_CYCLES *p)
Definition: mbgpccyc.h:178
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1394
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 MBG_DEV_NAME_FMT
A string format specifier for MBG_DEV_NAME.
Definition: pcpsdev.h:1534
#define _mbg_swab_xmulti_ref_status_idx(_p)
Definition: gpsdefs.h:6892
_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
MBG_CHK_SUPP_FNC _pcps_ddev_is_wwvb
Definition: mbgdevio.c:1142
Supports DAC control via PCI or USB bus API.
Definition: gpsdefs.h:2366
static __mbg_inline int num_bits_set(long val)
Count the number of bits which are not 0.
Definition: cfg_hlp.h:1024
_MBG_API_ATTR int _MBG_API mbg_generic_write(MBG_DEV_HANDLE dh, int cmd, const void *p, int size)
Definition: mbgdevio.c:4382
#define IOCTL_GET_XMR_HOLDOVER_STATUS
Definition: mbgioctl.h:727
#define MAX_HNS_LATENCY
_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)
Read all IRIG input configuration information from a device.
Definition: mbgdevio.c:5099
#define MBGDEVIO_RET_VAL
Definition: mbgdevio.h:364
#define _pcps_ddev_requires_irig_workaround(_d)
Definition: pcpsdrvr.h:1463
An event log entry.
Definition: gpsdefs.h:9564
_MBG_API_ATTR int _MBG_API 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_API_ATTR int _MBG_API mbg_get_utc_parm(MBG_DEV_HANDLE dh, UTC *p)
Read a UTC parameter structure from a device.
Definition: mbgdevio.c:6536
_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
#define MBGDEVIO_COMPAT_VERSION
Definition: mbgdevio.h:229
#define _mbgdevio_gen_io(_dh, _type, _in_p, _in_sz, _out_p, _out_sz)
Definition: mbgdevio.h:5678
_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 _pcps_ddev_has_debug_status(_p)
Definition: pcpsdrvr.h:1317
#define MBG_THREAD_FNC_RET_VAL
Definition: mbgdevio.h:501
#define IOCTL_GET_GPS_TZDL
Definition: mbgioctl.h:557
uint8_t PCPS_STATUS_PORT
Type of the status register port.
Definition: pcpsdefs.h:431
#define _int_from_size_t(_n)
Definition: words.h:662
_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_clr_ucap_buff(MBG_DEV_HANDLE dh)
Clear a device&#39;s on-board time capture FIFO buffer.
Definition: mbgdevio.c:5331
_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
#define _mbgdevio_read_gps_chk(_dh, _cmd, _ioctl, _p, _sz, _cond)
Definition: mbgdevio.c:429
#define IOCTL_SET_PCPS_IRIG_RX_SETTINGS
Definition: mbgioctl.h:550
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
#define _pcps_is_gps(_d)
Definition: pcpsdev.h:1074
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig
Check if a device provides either an IRIG input or output.
Definition: mbgdevio.c:1639
feat_num field contains one of the PCPS_FEATURE_BITS
Definition: pcpsdev.h:1315
_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
_MBG_API_ATTR int _MBG_API 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
#define _mbg_crit_sect_enter
Definition: mbgmutex.h:237
Current settings and general capabilities of a specific unicast master.
Definition: gpsdefs.h:14382
int sn_cpy_str_safe(char *dst, size_t max_len, const char *src)
A function to copy a string safely, returning the number of characters copied.
Definition: str_util.c:276
_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
uint32_t flags
see XMR_INST_FLAG_BIT_MASKS
Definition: gpsdefs.h:7056
_MBG_API_ATTR int _MBG_API 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_asic_features
Check if a device supports the mbg_get_asic_features call.
Definition: mbgdevio.c:793
#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
(-/w) PORT_SETTINGS_IDX, settings for specified serial port, only if RECEIVER_INFO::n_com_ports > 0 ...
Definition: pcpsdefs.h:1655
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
#define PCPS_GET_SYNTH_STATE
(r-) Read SYNTH_STATE, only if _pcps_has_synth
Definition: pcpsdefs.h:756
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
#define IOCTL_GET_GPS_STAT_INFO
Definition: mbgioctl.h:577
#define PCPS_SET_SERIAL
(-w) Write serial settings as PCPS_SERIAL, deprecated by PC_GPS_PORT_SETTINGS_IDX, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:729
#define IOCTL_GET_ALL_XMR_INFO
Definition: mbgioctl.h:724
_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)
Get all GPIO settings and capabilities.
Definition: mbgdevio.c:8115
#define _mbg_swab_ant_info(_p)
Definition: gpsdefs.h:3109
#define IOCTL_SET_GPS_PORT_PARM
Definition: mbgioctl.h:568
_MBG_API_ATTR int _MBG_API mbg_get_ip4_settings(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 settings from a device.
Definition: mbgdevio.c:7331
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
#define _mbgdevio_read_var_chk(_dh, _cmd, _ioctl, _p, _cond)
Definition: mbgdevio.c:408
#define _ri_addr(_p)
Definition: pcpsdev.h:1138
_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
#define _pcps_ddev_has_generic_io(_p)
Definition: pcpsdrvr.h:1278
#define PCPS_SET_IRIG_RX_SETTINGS
(-w) Write IRIG_SETTINGS, only if _pcps_is_irig_rx, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:744
#define _pcps_ddev_has_pcps_tzdl(_p)
Definition: pcpsdrvr.h:1229
MBG_CHK_SUPP_FNC mbg_chk_dev_is_pci
Check if the device is connected via the PCI bus.
Definition: mbgdevio.c:918
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
(r/-) n * MBG_GPIO_INFO_IDX, all GPIO info, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1669
General GPIO config info to be read from a device.
Definition: gpsdefs.h:7608
#define IOCTL_GET_PCPS_STATUS_PORT
Definition: mbgioctl.h:512
uint8_t n_com_ports
number of on-board serial ports
Definition: gpsdefs.h:887
Time read from a device plus associated system cycles count.
Definition: pcpsdev.h:1354
#define _mbg_swab_corr_info(_p)
Definition: pcpsdefs.h:1571
_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
#define _pcps_ddev_is_irig_rx(_p)
Definition: pcpsdrvr.h:1142
_NO_MBG_API_ATTR int _MBG_API chk_dev_receiver_info(const RECEIVER_INFO *p)
Definition: cfg_hlp.c:733
_MBG_API_ATTR int _MBG_API 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
#define _mbg_swab_mbg_time_scale_settings(_p)
Definition: gpsdefs.h:5512
#define _mbgdevio_write_gps_var(_dh, _cmd, _ioctl, _p)
Definition: mbgdevio.h:5668
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_SET_REF_OFFS
Definition: mbgioctl.h:544
_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
#define IOCTL_SET_IP4_SETTINGS
Definition: mbgioctl.h:674
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR MBG_PC_CYCLES_FREQUENCY _MBG_API mbg_get_default_cycles_frequency(void)
Retrieve the system&#39;s default cycles counter frequency.
Definition: mbgdevio.c:9229
(-/w) XYZ, current position in ECEF coordinates, only if GPS_MODEL_HAS_POS_XYZ
Definition: pcpsdefs.h:1639
#define IOCTL_GET_GPS_ANT_CABLE_LEN
Definition: mbgioctl.h:587
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API mbgdevio_check_version(int header_version)
Check if the DLL/shared library is compatible with a given version.
Definition: mbgdevio.c:641
High resolution time stamp plus associated system cycles count.
Definition: pcpsdev.h:1369
(r/w) TZDL, time zone / daylight saving, only if GPS_MODEL_HAS_TZDL
Definition: pcpsdefs.h:1635
#define IOCTL_SET_GNSS_MODE_SETTINGS
Definition: mbgioctl.h:714
#define _mbgdevio_gen_read_gps(_dh, _cmd, _p, _sz)
Definition: mbgdevio.h:5681
(r/w) ANT_CABLE_LEN, length of antenna cable, only if GPS_MODEL_HAS_ANT_CABLE_LEN ...
Definition: pcpsdefs.h:1650
#define IOCTL_CLR_EVT_LOG
Definition: mbgioctl.h:707
Status of the time capture FIFO buffer.
Definition: pcpsdefs.h:1529
_MBG_API_ATTR int _MBG_API 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
static int chk_bus_flags(MBG_DEV_HANDLE dh, int bus_flag_mask)
Check if device is a specific bus type.
Definition: mbgdevio.c:844
#define _mbg_swab_irig_ctrl_bits(_p)
Definition: gpsdefs.h:5394
Configuration settings for a single programmable pulse output.
Definition: gpsdefs.h:5692
_MBG_API_ATTR int _MBG_API 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
#define _mbg_swab_mbg_time_info_tstamp(_p)
Definition: pcpsdev.h:1452
(r/-) BVAR_STAT, status of buffered variables, only if GPS_MODEL_HAS_BVAR_STAT
Definition: pcpsdefs.h:1637
#define IOCTL_DEV_HAS_TZ
Definition: mbgioctl.h:617
#define _mbg_swab_bvar_stat(_p)
Definition: gpsdefs.h:772
_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
(-/w) LLA, current position in geographic coordinates, only if GPS_MODEL_HAS_POS_LLA ...
Definition: pcpsdefs.h:1640
see XMRIF_BIT_HOLDOVER_STATUS_SUPP
Definition: gpsdefs.h:7106
Time scale configuration settings.
Definition: gpsdefs.h:5505
#define _mbg_swab_mbg_evt_log_entry(_p)
Definition: gpsdefs.h:9572
#define IOCTL_CHK_DEV_FEAT
Definition: mbgioctl.h:730
_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)
Split an MBG_DEV_NAME into the &#39;type name&#39; and &#39;serial number&#39; components.
Definition: mbgdevio.c:4016
#define _pcps_has_receiver_info(_d)
Definition: pcpsdev.h:1160
#define GPS_HAS_PTP_UNICAST
see GPS_FEAT_PTP_UNICAST
Definition: gpsdefs.h:2295
_MBG_API_ATTR int _MBG_API mbg_get_synth(MBG_DEV_HANDLE dh, SYNTH *p)
Read the current frequency synthesizer settings from a device.
Definition: mbgdevio.c:6889
_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
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
Definition: pcpsdev.h:1372
_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 PCPS_SET_TZCODE
(-w) Write PCPS_TZCODE, only if _pcps_has_tzcode, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:732
#define _MBG_API_ATTR
Definition: mbg_tgt.h:1024
#define _mbg_swab_ptp_uc_master_info_idx(_p)
Definition: gpsdefs.h:14389
#define IOCTL_GET_DEBUG_STATUS
Definition: mbgioctl.h:704
#define _pcps_ddev_has_ref_offs(_p)
Definition: pcpsdrvr.h:1263
#define PCPS_NUM_EVT_LOG_ENTRIES
(r-) Read MBG_NUM_EVT_LOG_ENTRIES, only if _pcps_has_evt_log
Definition: pcpsdefs.h:777
#define IOCTL_GET_PTP_CFG_INFO
Definition: mbgioctl.h:679
int32_t utc_offs
UTC offs [sec] (loc_time = tstamp + utc_offs)
Definition: pcpsdefs.h:1088
static int lookup_dev_idx_ex(const PCPS_DEV *dev_array, int n_dev, const char *type_name, const char *sernum, int selection_mode)
Lookup a specific device in an array, depending on a match code.
Definition: mbgdevio.c:3832
Specification of a local time zone.
Definition: pcpsdefs.h:1504
uint16_t n_xmr_settings
number of XMULTI_REF_INFO_IDX or XMULTI_REF_STATUS_IDX which can be retrieved
Definition: gpsdefs.h:7057
_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
_MBG_API_ATTR int _MBG_API 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
double A0
+- Clock Correction Coefficient 0 [sec]
Definition: gpsdefs.h:18570
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
(r/-) IP4_SETTINGS, LAN interface state, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1660
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
#define PCPS_GIVE_UCAP_ENTRIES
(r-) Read PCPS_UCAP_ENTRIES, only if _pcps_has_ucap
Definition: pcpsdefs.h:769
#define IOCTL_GET_ALL_GNSS_SAT_INFO
Definition: mbgioctl.h:715
#define IOCTL_GET_PCPS_TIME_SEC_CHANGE
Definition: mbgioctl.h:527
_MBG_API_ATTR int _MBG_API 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
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1356
uint16_t n_devs
the number of devices handled by the driver
Definition: pcpsdev.h:1333
uint16_t model_code
identifier for receiver model, see GPS_MODEL_CODES
Definition: gpsdefs.h:875
PCPS_TIME_STATUS_X status
status bits, see PCPS_TIME_STATUS_FLAGS
Definition: pcpsdefs.h:1089
#define PCPS_FIRST_EVT_LOG_ENTRY
(r-) Read first (oldest) MBG_EVT_LOG_ENTRY, only if _pcps_has_evt_log
Definition: pcpsdefs.h:778
#define IOCTL_GET_GPS_ENABLE_FLAGS
Definition: mbgioctl.h:574
#define _pcps_ddev_has_ptp_unicast(_p)
Definition: pcpsdrvr.h:1302
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
#define IOCTL_SET_PCPS_SERIAL
Definition: mbgioctl.h:535
#define IOCTL_GET_IRIG_TIME
Definition: mbgioctl.h:683
_MBG_API_ATTR int _MBG_API 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
Information on a specific supported string format.
Definition: gpsdefs.h:3733
#define _mbg_swab_xmr_holdover_status(_p)
Definition: gpsdefs.h:7170
#define _mbg_swab_pcps_hr_time(_p)
Definition: pcpsdefs.h:1094
_MBG_API_ATTR int _MBG_API mbg_dev_has_serial_hs(MBG_DEV_HANDLE dh, int *p)
Definition: mbgdevio.c:2947
#define MBG_ERR_LIB_NOT_COMPATIBLE
Installed shared library version not compatible with version used at build time.
Definition: mbgerror.h:290
#define IOCTL_GET_TIME_INFO_TSTAMP
Definition: mbgioctl.h:686
Reference source configuration for a specific priority level.
Definition: gpsdefs.h:6749
(-/w) GPS_CMD, send one of the PC_GPS_COMMANDS
Definition: pcpsdefs.h:1647
_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
_MBG_API_ATTR int _MBG_API mbg_set_process_affinity(MBG_PROCESS_ID pid, MBG_CPU_SET *p)
Set the CPU affinity of a process.
Definition: mbgdevio.c:8513
#define MIN_HNS_LATENCY
#define _mbgdevio_gen_read(_dh, _cmd, _p, _sz)
Definition: mbgdevio.h:5672
#define IOCTL_GET_GPS_ANT_INFO
Definition: mbgioctl.h:570
Register layout of a PCI ASIC.
Definition: pci_asic.h:198
#define _setup_default_receiver_info_dcf(_p, _pdev)
Initialize a RECEIVER_INFO structure for legacy DCF77 receivers.
Definition: gpsdefs.h:1971
#define _mbg_swab_pout_settings_idx_on_set(_p)
Definition: gpsdefs.h:6256
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
int n_ddevs
MBG_CHK_SUPP_FNC mbg_chk_dev_has_tr_distance
Check if a device supports configurable distance from transmitter.
Definition: mbgdevio.c:2066
IRIG or similar time code, see http://www.meinberg.de/english/info/irig.htm.
Definition: pcpsdefs.h:296
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
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
#define IOCTL_SET_PTP_CFG_SETTINGS
Definition: mbgioctl.h:680
_MBG_API_ATTR int _MBG_API 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
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 int _MBG_API mbg_get_tzcode(MBG_DEV_HANDLE dh, PCPS_TZCODE *p)
Read time zone/daylight saving configuration code from a device.
Definition: mbgdevio.c:4751
_MBG_API_ATTR int _MBG_API 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
#define _pcps_has_ref_offs(_d)
Definition: pcpsdev.h:1196
#define _pcps_ddev_has_corr_info(_p)
Definition: pcpsdrvr.h:1308
#define IOCTL_GET_REF_OFFS
Definition: mbgioctl.h:543
_MBG_API_ATTR int _MBG_API mbg_get_device_info(MBG_DEV_HANDLE dh, PCPS_DEV *p)
Read detailed device information.
Definition: mbgdevio.c:4242
_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
#define _mbg_swab_mbg_gpio_info_idx(_p, _recv)
Definition: gpsdefs.h:9280
_MBG_API_ATTR int _MBG_API mbg_get_process_affinity(MBG_PROCESS_ID pid, MBG_CPU_SET *p)
Read the CPU affinity of a process.
Definition: mbgdevio.c:8470
#define IOCTL_PCPS_CLR_UCAP_BUFF
Definition: mbgioctl.h:552
#define IOCTL_GET_CORR_INFO
Definition: mbgioctl.h:699
double XYZ[N_XYZ]
A position in cartesian coordinates.
Definition: gpsdefs.h:2742
#define IOCTL_GET_PCPS_UCAP_ENTRIES
Definition: mbgioctl.h:553
#define _mbg_swab_lan_if_info(_p)
Definition: gpsdefs.h:11287
_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
(r/w) MBG_GNSS_MODE_INFO / MBG_GNSS_MODE_SETTINGS, only if PCPS_IS_GNSS
Definition: pcpsdefs.h:1672
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
_MBG_API_ATTR int _MBG_API 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
#define _mbg_swab_ttm(_p)
Definition: gpsdefs.h:2721
int do_chk_dev_feat_deprecated(MBG_DEV_HANDLE dh, MBG_CHK_SUPP_FNC *fnc, int *p)
A generic function to implement Deprecated mbgdevio functions to check if a particular feature is sup...
Definition: mbgdevio.c:523
High resolution device time stamp, system time, and associated cycles counts.
Definition: pcpsdev.h:1445
#define _mbgdevio_write_var(_dh, _cmd, _ioctl, _p)
Definition: mbgdevio.h:5659
#define IOCTL_GET_PCI_ASIC_VERSION
Definition: mbgioctl.h:596
A structure used to transmit information on date and time.
Definition: gpsdefs.h:2713
#define GPS_HAS_XMULTI_REF
see GPS_FEAT_XMULTI_REF
Definition: gpsdefs.h:2286
_MBG_API_ATTR int _MBG_API 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
(-/w) XMULTI_REF_SETTINGS_IDX, idx 0..XMULTI_REF_INSTANCES::n_xmr_settings-1, only if GPS_HAS_XMULTI_...
Definition: pcpsdefs.h:1675
#define IOCTL_SET_GPS_TZDL
Definition: mbgioctl.h:558
#define PCPS_BUS_ISA
IBM compatible PC/AT ISA bus.
Definition: pcpsdev.h:413
#define PCPS_SET_TR_DISTANCE
(-w) Write TR_DISTANCE, only if _pcps_has_tr_distance
Definition: pcpsdefs.h:774
#define _mbg_crit_sect_init
Definition: mbgmutex.h:233
_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_API_ATTR int _MBG_API 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
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
_MBG_API_ATTR int _MBG_API 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
#define _pcps_ddev_has_hr_time(_p)
Definition: pcpsdrvr.h:1225
MBG_CHK_SUPP_FNC mbg_chk_dev_has_ref_offs
Check if a device provides a configurable ref time offset.
Definition: mbgdevio.c:1938
(r/-) n * MBG_GPIO_STATUS_IDX, where n == MBG_GPIO_CFG_LIMITS::num_io, only if MBG_GPIO_CFG_LIMIT_FLA...
Definition: pcpsdefs.h:1680
#define PCPS_GIVE_UCAP_EVENT
(r-) Return oldest event as PCPS_HR_TIME, only if _pcps_has_ucap
Definition: pcpsdefs.h:770
GNSS mode settings.
Definition: gpsdefs.h:10677
(r/-) XMULTI_REF_INSTANCES, only if GPS_HAS_XMULTI_REF and GPS_HAS_XMRS_MULT_INSTC ...
Definition: pcpsdefs.h:1674
#define PCPS_GIVE_TIME
Command codes used to communicate with bus level devices.
Definition: pcpsdefs.h:712
char PCPS_CLOCK_NAME[10]
Definition: pcpsdev.h:498
MBG_CHK_SUPP_FNC mbg_chk_dev_has_lan_intf
Check if a device supports simple LAN interface API calls.
Definition: mbgdevio.c:1271
#define _mbg_swab_synth(_p)
Definition: gpsdefs.h:2864
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
#define PCPS_GET_TR_DISTANCE
(r-) Read TR_DISTANCE, only if _pcps_has_tr_distance
Definition: pcpsdefs.h:773
_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
(r/w) PTP_CFG_SETTINGS / PTP_CFG_INFO, only if PCPS_HAS_PTP
Definition: pcpsdefs.h:1664
#define _pcps_has_opt_flags(_d)
Definition: pcpsdev.h:1202
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
#define IOCTL_GET_PCPS_SYNC_TIME
Definition: mbgioctl.h:525
_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
#define IOCTL_DEV_HAS_SIGNAL
Definition: mbgioctl.h:624
uint32_t PCI_ASIC_FEATURES
A data type to hold the PCI ASIC feature flags mask.
Definition: pci_asic.h:162
_MBG_API_ATTR int _MBG_API mbg_set_gps_pos_xyz(MBG_DEV_HANDLE dh, const XYZ p)
Set the GPS receiver position using XYZ coordinates.
Definition: mbgdevio.c:5935
char PCPS_SN_STR[(16+1)]
A buffer for a serial number string, including terminating 0.
Definition: pcpsdefs.h:925
_MBG_API_ATTR int _MBG_API 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
MBG_CHK_SUPP_FNC mbg_chk_dev_has_gps_data
Check if a device supports large configuration data structures.
Definition: mbgdevio.c:708
#define IOCTL_DEV_HAS_IRIG
Definition: mbgioctl.h:626
#define IOCTL_GET_GPIO_CFG_LIMITS
Definition: mbgioctl.h:718
#define _mbgdevio_write_gps_var_chk(_dh, _cmd, _ioctl, _p, _cond)
Definition: mbgdevio.c:443
_MBG_API_ATTR int _MBG_API 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
#define _pcps_ddev_has_xmr(_p)
Definition: pcpsdrvr.h:1338
int MBG_CHK_SUPP_FNC(MBG_DEV_HANDLE dh)
The type of functions to check if a feature is supported.
Definition: mbgdevio.h:845
#define _mbg_swab_stat_info(_p)
Definition: gpsdefs.h:10601
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
Definition: pcpsdefs.h:1087
#define _pcps_ddev_can_clr_ucap_buff(_p)
Definition: pcpsdrvr.h:1235
#define IOCTL_DEV_HAS_MOD
Definition: mbgioctl.h:625
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_GET_GPS_BVAR_STAT
Definition: mbgioctl.h:562
_MBG_API_ATTR int _MBG_API 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
#define _mbgdevio_gen_write_gps(_dh, _cmd, _p, _sz)
Definition: mbgdevio.h:5684
_MBG_API_ATTR int _MBG_API mbg_get_ptp_state(MBG_DEV_HANDLE dh, PTP_STATE *p)
Read PTP/IEEE1588 status from a device.
Definition: mbgdevio.c:7396
Configuration settings for a specific programmable pulse output.
Definition: gpsdefs.h:6249
#define _mbg_swab_double(_p)
Definition: mbg_arch.h:177
(r/w) IP4_SETTINGS, LAN interface configuration, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1662
#define MBG_CPU_SET
Definition: mbgdevio.h:468
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
#define _mbg_swab_ip4_settings(_p)
Definition: gpsdefs.h:11250
uint32_t flags
see MBG_GPIO_CFG_LIMIT_FLAG_MASKS
Definition: gpsdefs.h:7612
int16_t MBG_REF_OFFS
A data type used to configure the ref offset.
Definition: gpsdefs.h:5297
Request buffer used to query a device feature.
Definition: mbgioctl.h:473
#define _mbg_swab_mbg_gnss_mode_info(_p)
Definition: gpsdefs.h:10703
#define IOCTL_GET_SYNTH_STATE
Definition: mbgioctl.h:635
#define PCPS_SET_SYNTH
(-w) Write SYNTH, only if _pcps_has_synth, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:750
_MBG_API_ATTR int _MBG_API 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
#define _mbg_swab_mbg_opt_settings(_p)
Definition: gpsdefs.h:5329
_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
#define _mbgdevio_write_var_chk(_dh, _cmd, _ioctl, _p, _cond)
Definition: mbgdevio.c:415
#define IOCTL_SET_GPS_POUT_SETTINGS_IDX
Definition: mbgioctl.h:638
#define _pcps_ddev_is_gnss(_p)
Definition: pcpsdrvr.h:1147
#define _pcps_ddev_has_gpio(_p)
Definition: pcpsdrvr.h:1335
#define _mbg_swab_mbg_num_evt_log_entries(_p)
Definition: gpsdefs.h:9547
unsigned char uint8_t
Definition: words.h:210
__int64 int64_t
Definition: words.h:249
#define _mbg_swab_pcps_irig_time(_p)
Definition: pcpsdefs.h:1223
_MBG_API_ATTR int _MBG_API 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_thread_stop(MBG_THREAD_INFO *p_ti)
Stop a thread which has been created by mbg_thread_create.
#define IOCTL_GET_ALL_PTP_UC_MASTER_INFO
Definition: mbgioctl.h:693
#define _mbg_swab_ptp_state(_p)
Definition: gpsdefs.h:13219
#define IOCTL_GET_GNSS_MODE_INFO
Definition: mbgioctl.h:713
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
(r/-) PTP_STATE, only if PCPS_HAS_PTP
Definition: pcpsdefs.h:1663
_MBG_API_ATTR int _MBG_API 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
_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)
Read the status of all GPIO signal ports.
Definition: mbgdevio.c:8205
#define _pcps_ddev_has_serial_hs(_p)
Definition: pcpsdrvr.h:1241
_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
static int lookup_dev_idx(const PCPS_DEV *dev_array, int n_dev, const char *type_name, const char *sernum)
Lookup a specific device in an array of PCPS_DEV structures.
Definition: mbgdevio.c:3787
_MBG_API_ATTR int _MBG_API mbg_set_event_time(MBG_DEV_HANDLE dh, const PCPS_TIME_STAMP *p)
Definition: mbgdevio.c:4653
(r/-) n * PORT_INFO_IDX, settings and capabilities of all serial ports, only if RECEIVER_INFO::n_com_...
Definition: pcpsdefs.h:1654
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
(r/-) POS, position XYZ, LLA, and DMS combined, only if GPS_MODEL_HAS_POS
Definition: pcpsdefs.h:1649
#define PCPS_BUS_PCI_MBGPEX
Definition: pcpsdev.h:434
#define FILETIME
Definition: mbgdevio.h:456
_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)
Read current configuraton and features provided by the programmable pulse outputs.
Definition: mbgdevio.c:7109
(r/-) n * GNSS_SAT_INFO_IDX, satellite info, only if PCPS_IS_GNSS
Definition: pcpsdefs.h:1673
DCF77 long wave signal (Germany), see http://www.meinberg.de/english/info/dcf77.htm.
Definition: pcpsdefs.h:294
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
#define _mbg_swab_mbg_gpio_settings_idx(_p, _recv)
Definition: gpsdefs.h:9191
_MBG_API_ATTR int _MBG_API 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
#define _pcps_ddev_has_ucap(_p)
Definition: pcpsdrvr.h:1236
(r/-) MBG_GPIO_CFG_LIMITS, only if GPS_HAS_GPIO
Definition: pcpsdefs.h:1668
#define IOCTL_GET_GPS_TIME
Definition: mbgioctl.h:564
#define _mbg_swab_irig_info(_p)
Definition: gpsdefs.h:5061
#define _mbg_swab_pcps_time_stamp(_p)
Definition: pcpsdefs.h:979
#define _mbg_swab_port_parm(_p)
Definition: gpsdefs.h:3936
MBG_CHK_SUPP_FNC mbg_chk_dev_has_serial_hs
Definition: mbgdevio.c:1829
_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
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_SET_GPIO_SETTINGS_IDX
Definition: mbgioctl.h:720
#define _mbg_swab_gps_cmd(_p)
Definition: gpsdefs.h:721
JJY long wave signal (Japan)
Definition: pcpsdefs.h:301
#define PCPS_SET_OPT_SETTINGS
(-w) Write MBG_OPT_SETTINGS, only if _pcps_has_opt_flags, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:741
#define IOCTL_GET_PCI_ASIC_FEATURES
Definition: mbgioctl.h:643
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
#define _mbgdevio_chk_cond(_cond)
Definition: mbgdevio.c:396
#define _mbgdevio_read_var(_dh, _cmd, _ioctl, _p)
Definition: mbgdevio.h:5656
PCPS_DDEV pcps_ddev[16]
#define MBGDEVIO_VERSION
Definition: mbgdevio.h:227
Raw IRIG time.
Definition: pcpsdefs.h:1207
#define PCPS_GET_REF_OFFS
(r-) Read MBG_REF_OFFS, only if _pcps_has_ref_offs
Definition: pcpsdefs.h:737
_MBG_API_ATTR int _MBG_API 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
int pcps_chk_dev_feat(PCPS_DDEV *p_ddev, uint feat_type, uint feat_num)
Check if a specific feature of a specific feature type is supported.
Definition: pcpsdrvr.c:5112
#define IOCTL_GET_PCPS_IRIG_TX_INFO
Definition: mbgioctl.h:601
#define PCPS_GIVE_IRIG_TIME
(r-) Read raw IRIG time as PCPS_IRIG_TIME, only if _pcps_has_irig_time
Definition: pcpsdefs.h:716
#define PCPS_SET_TIME
(-w) Set on-board time, see PCPS_STIME. Returns MBG_ERR_STIME on error.
Definition: pcpsdefs.h:718
(r/-) RECEIVER_INFO, rcvr model info, only if PCPS_HAS_RECEIVER_INFO
Definition: pcpsdefs.h:1651
#define _pcps_ddev_has_irig(_p)
Definition: pcpsdrvr.h:1251
_MBG_API_ATTR int _MBG_API mbg_set_synth(MBG_DEV_HANDLE dh, const SYNTH *p)
Write frequency synthesizer configuration settings to a device.
Definition: mbgdevio.c:6921
Time zone / daylight saving parameters.
Definition: gpsdefs.h:2940
#define _mbg_swab_str_type_info_idx(_p)
Definition: gpsdefs.h:3740
PORT_SETTINGS port_settings
Definition: gpsdefs.h:3597
#define _mbgdevio_read_gps_var(_dh, _cmd, _ioctl, _p)
Definition: mbgdevio.h:5665
#define MBG_FRAC32_UNITS_PER_SEC
Constant used to convert e.g. PCPS_TIME_STAMP::frac values.
Definition: mbgtime.h:400
(r/-) LAN_IF_INFO, LAN interface info, only if PCPS_HAS_LAN_INTF
Definition: pcpsdefs.h:1659
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
Definition: mbgerror.h:259
#define _mbg_swab_enable_flags(_p)
Definition: gpsdefs.h:3151
#define _mbg_swab_mbg_time_info_hrt(_p)
Definition: pcpsdev.h:1425
#define _mbg_swab_xmulti_ref_info_idx(_p)
Definition: gpsdefs.h:6846
_MBG_API_ATTR int _MBG_API 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
int ioctl_status
Definition: mbgdevio.h:565
#define PCPS_GET_IRIG_RX_INFO
(r-) Read IRIG_INFO, only if _pcps_is_irig_rx
Definition: pcpsdefs.h:743
_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)
Definition: mbgdevio.c:4448
#define _mbg_swab_pout_info_idx_on_get(_p)
Definition: gpsdefs.h:6358
_MBG_API_ATTR int _MBG_API mbg_get_gps_tzdl(MBG_DEV_HANDLE dh, TZDL *p)
Read the card&#39;s time zone/daylight saving parameters.
Definition: mbgdevio.c:5439
_MBG_API_ATTR int _MBG_API 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
uint32_t PCPS_IRQ_STAT_INFO
Definition: pcpsdev.h:1468
#define IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX
Definition: mbgioctl.h:694
Synthesizer configuration parameters.
Definition: gpsdefs.h:2856
#define _pcps_ddev_has_signal(_p)
Definition: pcpsdrvr.h:1245
MBG_CHK_SUPP_FNC mbg_chk_dev_has_irig_tx
Check if a device provides a configurable IRIG output.
Definition: mbgdevio.c:1668
#define _mbg_cpu_set(_i, _ps)
Definition: mbgdevio.h:480
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
#define _mbgdevio_gen_write(_dh, _cmd, _p, _sz)
Definition: mbgdevio.h:5675
MBG_CHK_SUPP_FNC mbg_chk_dev_has_mod
Check if a device provides a modulation signal.
Definition: mbgdevio.c:1797
static int max_devs
_MBG_API_ATTR void _MBG_API 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
#define _pcps_ddev_has_fast_hr_timestamp(_p)
Definition: pcpsdrvr.h:1293
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.
(r/w) MBG_TIME_SCALE_SETTINGS / MBG_TIME_SCALE_INFO, only if PCPS_HAS_TIME_SCALE
Definition: pcpsdefs.h:1658
#define PCPS_GET_IRIG_TX_INFO
(r-) Read IRIG_INFO, only if _pcps_has_irig_tx
Definition: pcpsdefs.h:746
_MBG_API_ATTR int _MBG_API mbg_clr_evt_log(MBG_DEV_HANDLE dh)
Clear the device&#39;s on-board event log.
Definition: mbgdevio.c:7819
#define PCPS_BUS_MCA
IBM PS/2 micro channel.
Definition: pcpsdev.h:414
_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
_MBG_API_ATTR int _MBG_API 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
static MBG_PC_CYCLES_FREQUENCY pc_cycles_frequency
Definition: mbgdevio.c:596
_MBG_API_ATTR int _MBG_API mbg_get_gpio_cfg_limits(MBG_DEV_HANDLE dh, MBG_GPIO_CFG_LIMITS *p)
Read common GPIO configuration limits.
Definition: mbgdevio.c:8082
A geographic position represented in different formats.
Definition: mbggeo.h:113
#define PCPS_BUS_USB
USB.
Definition: pcpsdev.h:416
_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
MSF long wave signal (UK)
Definition: pcpsdefs.h:297
_MBG_API_ATTR void _MBG_API 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
void MBG_THREAD_FNC(void *)
A generic type of a thread function.
Definition: mbgdevio.h:527
#define _pcps_ddev_has_synth(_p)
Definition: pcpsdrvr.h:1275
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
#define _mbg_swab_ant_cable_len(_p)
Definition: gpsdefs.h:11014
_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
#define _pcps_ddev_has_tzcode(_p)
Definition: pcpsdrvr.h:1230
#define IOCTL_GET_ALL_GPIO_INFO
Definition: mbgioctl.h:719
MBG_CHK_SUPP_FNC mbg_chk_dev_has_xmr
Check if a device provides eXtended Multi Ref (XMR) inputs.
Definition: mbgdevio.c:825
MBG_PC_CYCLES cycles
Definition: pcpsdev.h:1371
_MBG_API_ATTR int _MBG_API 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
MBG_CHK_SUPP_FNC mbg_chk_dev_is_usb
Check if the device is connected via the USB bus.
Definition: mbgdevio.c:972
#define IOCTL_SET_GPS_ANT_CABLE_LEN
Definition: mbgioctl.h:588
#define _mbg_swab_port_settings_idx(_p)
Definition: gpsdefs.h:3601
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
(r/-) n * PTP_UC_MASTER_INFO_IDX, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1666
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
#define IOCTL_GET_IP4_STATE
Definition: mbgioctl.h:672
int pcps_isa_ports[16+1]
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API mbg_set_ip4_settings(MBG_DEV_HANDLE dh, const IP4_SETTINGS *p)
Write LAN IPv4 settings to a device.
Definition: mbgdevio.c:7360
#define _pcps_ddev_has_tz(_p)
Definition: pcpsdrvr.h:1231
GPS satellite system, see http://www.meinberg.de/english/info/gps.htm.
Definition: pcpsdefs.h:295
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
static __mbg_inline MBG_PC_CYCLES mbg_delta_pc_cycles(const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2)
Definition: mbgpccyc.h:296
_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
#define _mbg_inp32_to_cpu(_dev, _rsrc_idx, _port_addr)
Definition: mbggenio.h:614
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
#define _mbg_swab_tr_distance(_p)
Definition: pcpsdefs.h:1555
#define IOCTL_GET_PCPS_HR_TIME
Definition: mbgioctl.h:529
#define PCPS_GET_OPT_INFO
(r-) Read MBG_OPT_INFO, only if _pcps_has_opt_flags
Definition: pcpsdefs.h:740
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
#define _mbg_swab_irig_settings(_p)
Definition: gpsdefs.h:5006
#define IOCTL_GET_XMR_INSTANCES
Definition: mbgioctl.h:723
#define _mbg_swab_ptp_cfg_settings(_p)
Definition: gpsdefs.h:13311
MBG_CHK_SUPP_FNC mbg_chk_dev_is_lwr
Check if a device is any long wave signal receiver.
Definition: mbgdevio.c:1215
static __mbg_inline uint8_t _pcps_ddev_read_status_port(const PCPS_DDEV *pddev)
Definition: pcpsdrvr.h:1430
_MBG_API_ATTR int _MBG_API mbg_set_gps_pos_lla(MBG_DEV_HANDLE dh, const LLA p)
Set the GPS receiver position using LLA coordinates.
Definition: mbgdevio.c:5976
#define IOCTL_SET_TR_DISTANCE
Definition: mbgioctl.h:701
#define IOCTL_SET_SYNTH
Definition: mbgioctl.h:605
#define IOCTL_SET_GPS_TIME_SCALE_SETTINGS
Definition: mbgioctl.h:661
#define PCPS_BUS_PCI
PCI.
Definition: pcpsdev.h:415
#define _setup_default_receiver_info_gps(_p)
Initialize a RECEIVER_INFO structure for legacy GPS receivers.
Definition: gpsdefs.h:1996
_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 _mbg_swab_ptp_uc_master_cfg_limits(_p)
Definition: gpsdefs.h:14246
static int mbg_comp_hr_latency(PCPS_TIME_STAMP *ts, const MBG_PC_CYCLES *p_cyc_ts, const MBG_PC_CYCLES *p_cyc_ontime, const MBG_PC_CYCLES_FREQUENCY *p_cyc_freq, int32_t *hns_latency)
Update a PCPS_TIME_STAMP to compensate the latency of an API call.
Definition: mbgdevio.c:3197
_MBG_API_ATTR int _MBG_API mbg_get_debug_status(MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p)
Read a debug status word from a device.
Definition: mbgdevio.c:7790
#define _mbgdevio_cnv_ret_val(_v)
Definition: mbgdevio.h:369
High resolution time including status and local time offset.
Definition: pcpsdefs.h:1085
#define PCPS_GET_RAW_IRIG_DATA
(r-) Read MBG_RAW_IRIG_DATA, only if _pcps_has_raw_irig_data
Definition: pcpsdefs.h:758
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.
#define _pcps_ddev_can_set_time(_p)
Definition: pcpsdrvr.h:1220
_MBG_API_ATTR int _MBG_API mbg_generic_write_gps(MBG_DEV_HANDLE dh, int cmd, const void *p, int size)
Definition: mbgdevio.c:4419
(r/w) PORT_PARM, param. of the serial ports, deprecated by PC_GPS_ALL_PORT_INFO
Definition: pcpsdefs.h:1641
#define _pcps_ddev_has_asic_version(_p)
Definition: pcpsdrvr.h:1287
#define MBG_INVALID_DEV_HANDLE
Definition: mbgdevio.h:358
Satellite receiver status information.
Definition: gpsdefs.h:10591
#define IOCTL_SET_PCPS_TZCODE
Definition: mbgioctl.h:538
void swap_double(double *p)
Swap the bytes of a single variable of type "double".
Definition: gpsutils.c:101
#define _mbg_swab_tzdl(_p)
Definition: gpsdefs.h:2950
_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
#define PCPS_GET_SYNTH
(r-) Read SYNTH, only if _pcps_has_synth
Definition: pcpsdefs.h:749
#define IOCTL_GET_GPS_ALL_POUT_INFO
Definition: mbgioctl.h:637
Software revision information.
Definition: gpsdefs.h:732
static int setup_dev_fn_list(MBG_DEV_FN_LIST_ENTRY **p_list, int max_devs)
Allocate and fill a list of device file names.
Definition: mbgdevio.c:3620
_MBG_API_ATTR int _MBG_API mbgdevio_get_version(void)
Get the version number of the precompiled DLL/shared object library.
Definition: mbgdevio.c:615
#define IOCTL_GET_GPS_RECEIVER_INFO
Definition: mbgioctl.h:590
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
#define PCPS_SET_PCPS_TZDL
(-w) Write PCPS_TZDL, only if _pcps_has_pcps_tzdl, returns MBG_ERR_CFG on error
Definition: pcpsdefs.h:735
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 PCPS_GET_PCPS_TZDL
(r-) Read PCPS_TZDL, only if _pcps_has_pcps_tzdl
Definition: pcpsdefs.h:734
#define _pcps_ddev_has_tr_distance(_p)
Definition: pcpsdrvr.h:1311
(r/-) GPS_STAT_INFO, satellite info, mode of operation, and DAC info, only if GPS_MODEL_HAS_STAT_INFO...
Definition: pcpsdefs.h:1646
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API 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
PCPS_SIG_VAL signal
signal strength, see PCPS_SIG_VAL_DEFS, or capture input channel number
Definition: pcpsdefs.h:1090
#define _mbg_get_current_process()
Definition: mbgdevio.h:416
#define IOCTL_GET_PCPS_TIME
Definition: mbgioctl.h:522
Local calendar date and time, plus sync status.
Definition: pcpsdefs.h:1128
_MBG_API_ATTR int _MBG_API 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
_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
#define IOCTL_GET_IRQ_STAT_INFO
Definition: mbgioctl.h:652
_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
#define IOCTL_GET_IP4_SETTINGS
Definition: mbgioctl.h:673
#define _pcps_has_ri_ptp_unicast(_p_ri)
Definition: pcpsdev.h:1230
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_SET_GPS_TIME
Definition: mbgioctl.h:565
feat_num field contains one of the MBG_XFEATURE_BITS
Definition: pcpsdev.h:1317
#define IOCTL_SET_XMR_SETTINGS_IDX
Definition: mbgioctl.h:725
#define PCPS_CLR_EVT_LOG
(-w) Write clear on-board event log, only if _pcps_has_evt_log
Definition: pcpsdefs.h:776
void _MBG_INIT_CODE_ATTR pcps_detect_devices(int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS])
Detect all bus-level devices in a non-PnP system.
Definition: pcpsdrvr.c:6683
see MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP
Definition: gpsdefs.h:7648
uint16_t idx
0..RECEIVER_INFO::n_prg_out-1
Definition: gpsdefs.h:6251
A high resolution time stamp.
Definition: pcpsdefs.h:972
#define _mbg_swab_synth_state(_p)
Definition: gpsdefs.h:2897
#define IOCTL_GET_GPS_UTC_PARM
Definition: mbgioctl.h:664
double LLA[N_LLA]
A geographic position based on latitude, longitude, and altitude.
Definition: gpsdefs.h:2764
#define _pcps_ddev_has_opt_flags(_p)
Definition: pcpsdrvr.h:1266
(r/-) n * XMULTI_REF_INFO_IDX, where n == XMULTI_REF_INSTANCES::n_xmr_settings, only if GPS_HAS_XMULT...
Definition: pcpsdefs.h:1676
(-/w) PTP_UC_MASTER_SETTINGS_IDX, only if PTP_CFG_MSK_SUPPORT_PTP_UNICAST
Definition: pcpsdefs.h:1667
#define _mbg_swab_utc_parm(_p)
Definition: gpsdefs.h:18580
WWVB long wave signal (U.S.)
Definition: pcpsdefs.h:300
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_GET_PCPS_TZDL
Definition: mbgioctl.h:540
Configuration settings of an IRIG input or output.
Definition: gpsdefs.h:4999
#define _pcps_ddev_has_mod(_p)
Definition: pcpsdrvr.h:1248
char * dev_fn_ptr
Definition: mbgdevio.h:630
#define _pcps_type_name(_d)
Definition: pcpsdev.h:1068
#define PCPS_GET_TZCODE
(r-) Read PCPS_TZCODE, only if _pcps_has_tzcode
Definition: pcpsdefs.h:731
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
Definition: str_util.c:156
#define _MBG_API
Definition: mbg_tgt.h:1020
uint8_t n_prg_out
number of programmable pulse outputs
Definition: gpsdefs.h:889
MBG_DEV_FN_LIST_ENTRY * next
Definition: mbgdevio.h:632
#define IOCTL_GET_TIME_INFO_HRT
Definition: mbgioctl.h:685
#define _pcps_ddev_has_utc_parm(_p)
Definition: pcpsdrvr.h:1284
_MBG_API_ATTR int _MBG_API 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
#define MBG_ERR_NOT_SUPP_BY_DEV
Command or feature not supported by device.
Definition: mbgerror.h:286
#define IOCTL_GET_ALL_GPIO_STATUS
Definition: mbgioctl.h:729
#define _mbg_crit_sect_destroy
Definition: mbgmutex.h:235
#define PCPS_NEXT_EVT_LOG_ENTRY
(r-) Read next MBG_EVT_LOG_ENTRY, only if _pcps_has_evt_log
Definition: pcpsdefs.h:779
#define PCPS_GIVE_HR_TIME
(r-) Read high res. time as PCPS_HR_TIME, only if _pcps_has_hr_time
Definition: pcpsdefs.h:715
_MBG_API_ATTR int _MBG_API mbg_get_pcps_tzdl(MBG_DEV_HANDLE dh, PCPS_TZDL *p)
Read time zone/daylight saving parameters from a device.
Definition: mbgdevio.c:4823
#define _pcps_ddev_has_event_time(_p)
Definition: pcpsdrvr.h:1233
#define IOCTL_SET_GPS_PORT_SETTINGS_IDX
Definition: mbgioctl.h:594
#define MBG_PROCESS_ID
Definition: mbgdevio.h:415
_MBG_API_ATTR int _MBG_API 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_get_xhrt_time_as_filetime(MBG_XHRT_INFO *p, int *p_ft)
Retrieve an extrapolated time stamp in FILETIME format.
#define IOCTL_GET_GPS_PORT_PARM
Definition: mbgioctl.h:567
_MBG_API_ATTR int _MBG_API 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
MBG_CHK_SUPP_FNC _pcps_ddev_is_jjy
Definition: mbgdevio.c:1164
feat_num field contains one of the PCPS_REF_TYPES
Definition: pcpsdev.h:1314
#define _mbg_swab_xmulti_ref_settings_idx(_p)
Definition: gpsdefs.h:6756
(r/w) n * XMULTI_REF_STATUS_IDX, where n == XMULTI_REF_INSTANCES::n_xmr_settings, one structure on wr...
Definition: pcpsdefs.h:1677
MBG_CHK_SUPP_FNC mbg_chk_dev_has_dac_ctrl
Check if a device supports bus level DAC control commands.
Definition: mbgdevio.c:2140
#define _mbg_swab_mbg_ref_offs(_p)
Definition: gpsdefs.h:5299
#define _pcps_ddev_has_lan_intf(_p)
Definition: pcpsdrvr.h:1296
uint32_t MBG_IRIG_CTRL_BITS
Bit coded return type for PCPS_GET_IRIG_CTRL_BITS.
Definition: gpsdefs.h:5392
_MBG_API_ATTR int _MBG_API 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
(r/-) SW_REV, software revision, deprecated by PC_GPS_RECEIVER_INFO
Definition: pcpsdefs.h:1636
#define mbg_rc_is_error(_rc)
Definition: mbgerror.h:617
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
_MBG_API_ATTR int _MBG_API 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
#define _mbgdevio_read_gps_var_chk(_dh, _cmd, _ioctl, _p, _cond)
Definition: mbgdevio.c:436
#define _mbg_swab_sw_rev(_p)
Definition: gpsdefs.h:740
_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
_MBG_API_ATTR int _MBG_API 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 IOCTL_GET_NUM_EVT_LOG_ENTRIES
Definition: mbgioctl.h:708
void swap_pos_doubles(POS *p)
Swap the "double" fields in a POS structure.
Definition: gpsutils.c:265
#define _mbg_swab_pcps_tzdl(_p)
Definition: pcpsdefs.h:1513
#define _mbg_swab_pcps_ucap_entries(_p)
Definition: pcpsdefs.h:1536
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
static int do_chk_dev_feat(MBG_DEV_HANDLE dh, uint32_t feat_type, uint32_t feat_num)
A generic function to implement mbgdevio functions used to check if a particular feature is supported...
Definition: mbgdevio.c:469
_MBG_API_ATTR int _MBG_API mbg_get_xmr_instances(MBG_DEV_HANDLE dh, XMULTI_REF_INSTANCES *p)
Read XMULTI_REF_INSTANCES.
Definition: mbgdevio.c:8261
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_GET_ALL_XMR_STATUS
Definition: mbgioctl.h:726
static int snprint_dev_name(char *s, size_t max_len, const PCPS_DEV *p_dev)
Create a string with a unique device name.
Definition: mbgdevio.c:3759
#define _pcps_is_irig_rx(_d)
Definition: pcpsdev.h:1078
#define IOCTL_SET_PCPS_IRIG_TX_SETTINGS
Definition: mbgioctl.h:602
Antenna status and error at reconnect information.
Definition: gpsdefs.h:3100
#define IOCTL_GET_FIRST_EVT_LOG_ENTRY
Definition: mbgioctl.h:709
#define IOCTL_GET_TR_DISTANCE
Definition: mbgioctl.h:700
_MBG_API_ATTR int _MBG_API mbg_set_gps_time(MBG_DEV_HANDLE dh, const TTM *p)
Set the time on a GPS receiver device.
Definition: mbgdevio.c:5608
unsigned __int64 uint64_t
Definition: words.h:250
MBG_PC_CYCLES_FREQUENCY freq_hz
Definition: mbgdevio.h:564
#define _mbg_swab_ptp_cfg_info(_p)
Definition: gpsdefs.h:13364
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
#define _mbg_swab_mbg_time_scale_info(_p)
Definition: gpsdefs.h:5527
PCPS_DEV dev
Device info data that can be passed to user space.
Definition: pcpsdrvr.h:779
static int get_dev_info_for_dev_fn(PCPS_DEV *p, const char *dev_fn)
Open a device, retrieve the PCPS_DEV info, then close it.
Definition: mbgdevio.c:3711
#define IOCTL_GET_PCPS_DRVR_INFO
Definition: mbgioctl.h:510
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.
#define IOCTL_DEV_HAS_EVENT_TIME
Definition: mbgioctl.h:618
_MBG_API_ATTR int _MBG_API mbg_get_ip4_state(MBG_DEV_HANDLE dh, IP4_SETTINGS *p)
Read LAN IPv4 state from a device.
Definition: mbgdevio.c:7301
#define _mbgdevio_write_cmd_chk(_dh, _cmd, _ioctl, _cond)
Definition: mbgdevio.c:422
(r/-) TTM, user capture events, deprecated by PCPS_GIVE_UCAP_EVENT
Definition: pcpsdefs.h:1644
_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
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API 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
int64_t MBG_PC_CYCLES
Generic types to hold PC cycle counter values.
Definition: mbgpccyc.h:97
#define IOCTL_GET_GPS_TIME_SCALE_INFO
Definition: mbgioctl.h:660
_MBG_API_ATTR int _MBG_API 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
_MBG_API_ATTR int _MBG_API mbg_generic_read(MBG_DEV_HANDLE dh, int cmd, void *p, int size)
Definition: mbgdevio.c:4311
#define PCPS_GET_DEBUG_STATUS
(r-) Read MBG_DEBUG_STATUS, only if _pcps_has_debug_status
Definition: pcpsdefs.h:761
#define MBG_ERR_NOT_SUPP_ON_OS
Function is not supported on this operating system.
Definition: mbgerror.h:289
#define IOCTL_SET_MBG_OPT_SETTINGS
Definition: mbgioctl.h:547
#define _pcps_ddev_has_time_scale(_p)
Definition: pcpsdrvr.h:1281
_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
#define _mbg_swab_receiver_info(_p)
Definition: gpsdefs.h:894
#define IOCTL_GET_GPS_ALL_STR_TYPE_INFO
Definition: mbgioctl.h:591
MBG_DEV_HANDLE dh
Definition: mbgdevio.h:568
(r/-) ANT_INFO, time diff at sync. after antenna had been disconn., only if GPS_MODEL_HAS_ANT_INFO ...
Definition: pcpsdefs.h:1642
#define _mbg_swab_ptp_uc_master_settings_idx(_p)
Definition: gpsdefs.h:14336
_MBG_API_ATTR int _MBG_API 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 long ulong
Definition: words.h:292
#define PCPS_GET_CORR_INFO
(r-) Read CORR_INFO structure, only if _pcps_has_pzf
Definition: pcpsdefs.h:772
#define IOCTL_GET_LAN_IF_INFO
Definition: mbgioctl.h:671
char dev_name[40]
Readable device name (Should be MBG_DEV_NAME, which is smaller, though)
Definition: mbgdevio.h:662
#define PCPS_SET_IRIG_TX_SETTINGS
(-w) Write IRIG_SETTINGS, only if _pcps_has_irig_tx, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:747
#define PCPS_SET_EVENT_TIME
(-w) Write event time as PCPS_TIME_STAMP, only if _pcps_has_event_time
Definition: pcpsdefs.h:720
#define PCPS_BUS_PCI_PEX8311
Definition: pcpsdev.h:433
#define IOCTL_GET_PCPS_TIME_CYCLES
Definition: mbgioctl.h:598
A structure used to identify a device type and supported features.
Definition: gpsdefs.h:873
static PCPS_DRVR_INFO drvr_info
Definition: mbgdevio.c:329
PCPS_HR_TIME_CYCLES htc
Cycles count associated with the time stamp.
Definition: mbgdevio.h:543
(r/-) n * POUT_INFO_IDX, all programmable output info
Definition: pcpsdefs.h:1656
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
#define N_SUPP_DEV_BUS
Definition: cfg_hlp.h:114
MBG_CHK_SUPP_FNC mbg_chk_dev_has_pzf
Check if a device supports demodulation of the DCF77 PZF code.
Definition: mbgdevio.c:1092
#define PCPS_GET_IRIG_CTRL_BITS
(r-) Read MBG_IRIG_CTRL_BITS, only if _pcps_has_irig_ctrl_bits
Definition: pcpsdefs.h:757
_MBG_API_ATTR int _MBG_API 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
#define _pcps_ddev_has_ptp(_p)
Definition: pcpsdrvr.h:1299
_MBG_API_ATTR int _MBG_API 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
#define IOCTL_GET_GPS_SW_REV
Definition: mbgioctl.h:560
_MBG_API_ATTR int _MBG_API 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
MBG_CHK_SUPP_FNC mbg_chk_dev_has_evt_log
Check if a device provides an on-board event log.
Definition: mbgdevio.c:2119
_MBG_API_ATTR int _MBG_API mbg_get_gps_sw_rev(MBG_DEV_HANDLE dh, SW_REV *p)
Retrieve the software revision of a GPS receiver.
Definition: mbgdevio.c:5513
#define IOCTL_SET_PCPS_TZDL
Definition: mbgioctl.h:541
#define _pcps_ddev_has_receiver_info(_p)
Definition: pcpsdrvr.h:1234
#define IOCTL_GET_RAW_IRIG_DATA
Definition: mbgioctl.h:689
int mbg_get_last_error(const char *info)
Get and translate last error after non-socket function call.
Definition: mbgerror.c:993
uint32_t MBG_DEBUG_STATUS
A data type used to read the board&#39;s debug status.
Definition: gpsdefs.h:5204
#define _mbg_swab_debug_status(_p)
Definition: gpsdefs.h:5206
#define PCPS_SET_REF_OFFS
(-w) Write MBG_REF_OFFS, only if _pcps_has_ref_offs, returns MBG_ERR_CFG on error ...
Definition: pcpsdefs.h:738
#define _do_query_cond(_dh, _cond, _ioctl)
Definition: mbgdevio.c:590
uint32_t feat_num
Number and range depending on IOCTL_DEV_FEAT_REQ::feat_type value.
Definition: mbgioctl.h:476
#define _pcps_ddev_has_irig_tx(_p)
Definition: pcpsdrvr.h:1237
_MBG_API_ATTR int _MBG_API 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
static __mbg_inline void mbg_get_pc_cycles_frequency(MBG_PC_CYCLES_FREQUENCY *p)
Definition: mbgpccyc.h:250
#define _mbg_swab_pos(_p)
Definition: mbggeo.h:123
_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
#define IOCTL_DEV_HAS_PCI_ASIC_FEATURES
Definition: mbgioctl.h:645
#define _pcps_ddev_has_evt_log(_p)
Definition: pcpsdrvr.h:1314
#define IOCTL_GET_GPS_UCAP
Definition: mbgioctl.h:572
#define IOCTL_PTP_UC_MASTER_CFG_LIMITS
Definition: mbgioctl.h:692
#define IOCTL_GET_PCPS_SERIAL
Definition: mbgioctl.h:534
_MBG_API_ATTR int _MBG_API mbg_get_corr_info(MBG_DEV_HANDLE dh, CORR_INFO *p)
Read PZF correlation info from a device.
Definition: mbgdevio.c:7690
#define IOCTL_GET_NEXT_EVT_LOG_ENTRY
Definition: mbgioctl.h:710
Device info structure.
Definition: pcpsdev.h:1043
_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
_MBG_API_ATTR int _MBG_API 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
uint32_t feat_type
See DEV_FEAT_TYPES.
Definition: mbgioctl.h:475
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
#define IOCTL_GET_PTP_STATE
Definition: mbgioctl.h:678
#define _mbg_swab_port_info_idx(_p)
Definition: gpsdefs.h:3684
static __mbg_inline void mbg_init_pc_cycles_frequency(MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p)
Definition: mbgdevio.h:5769
(r/-) n * STR_TYPE_INFO_IDX, names and capabilities of all supp. string types, only if RECEIVER_INFO:...
Definition: pcpsdefs.h:1653
uint32_t supp_gnss_types
Bit masks of supported GNSS types, see MBG_GNSS_TYPE_MASKS.
Definition: gpsdefs.h:10697
#define _mbg_thread_exit(_v)
Definition: mbgdevio.h:505
#define IOCTL_GET_PCPS_HR_TIME_CYCLES
Definition: mbgioctl.h:599
#define IOCTL_SET_PCPS_EVENT_TIME
Definition: mbgioctl.h:532
static void free_dev_fn_list(MBG_DEV_FN_LIST_ENTRY *list)
Free a list of device names that has been allocated before.
Definition: mbgdevio.c:3576
_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)
Read all XMR settings and capabilities.
Definition: mbgdevio.c:8342
#define IOCTL_DEV_HAS_SERIAL_HS
Definition: mbgioctl.h:623