summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2012-08-09 12:00:00 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2012-08-09 12:00:00 +0200
commit49a1a7ac911259fc1e2817b6631d5dbc5ce1713c (patch)
treee74f8a4db98449b194232a630947504548a36dcb
parent384267346c5824f02bac7265e45f8937c9a7b48b (diff)
downloadmbgsdk-win-49a1a7ac911259fc1e2817b6631d5dbc5ce1713c.tar.gz
mbgsdk-win-49a1a7ac911259fc1e2817b6631d5dbc5ce1713c.zip
Update mbglib files for the C demo projects
Files provided by mbgsdk-win-c-patch-dkwin-3069912-2012-08-09.zip
-rw-r--r--c/mbglib/include/deviohlp.h181
-rw-r--r--c/mbglib/include/eventlog.h87
-rw-r--r--c/mbglib/include/extiohlp.h116
-rw-r--r--c/mbglib/include/gpsdefs.h3323
-rw-r--r--c/mbglib/include/gpsserio.h982
-rw-r--r--c/mbglib/include/gpsutils.h24
-rw-r--r--c/mbglib/include/mbg_arch.h28
-rw-r--r--c/mbglib/include/mbg_tgt.h121
-rw-r--r--c/mbglib/include/mbg_w32.h309
-rw-r--r--c/mbglib/include/mbgdevio.h2254
-rw-r--r--c/mbglib/include/mbgerror.h12
-rw-r--r--c/mbglib/include/mbgextio.h265
-rw-r--r--c/mbglib/include/mbggeo.h16
-rw-r--r--c/mbglib/include/mbgioctl.h954
-rw-r--r--c/mbglib/include/mbgmutex.h259
-rw-r--r--c/mbglib/include/mbgpccyc.h305
-rw-r--r--c/mbglib/include/mbgserio.h192
-rw-r--r--c/mbglib/include/mbgsvcio.h69
-rw-r--r--c/mbglib/include/mbgsvctl.h263
-rw-r--r--c/mbglib/include/mbgtime.h87
-rw-r--r--c/mbglib/include/mbgutil.h18
-rw-r--r--c/mbglib/include/messages.h1151
-rw-r--r--c/mbglib/include/pci_asic.h101
-rw-r--r--c/mbglib/include/pcpsdefs.h490
-rw-r--r--c/mbglib/include/pcpsdev.h1067
-rw-r--r--c/mbglib/include/rs232.h135
-rw-r--r--c/mbglib/include/shmem.h253
-rw-r--r--c/mbglib/include/timecnv.h362
-rw-r--r--c/mbglib/include/usbdefs.h44
-rw-r--r--c/mbglib/include/use_pack.h18
-rw-r--r--c/mbglib/include/words.h114
-rw-r--r--c/mbglib/lib/bc/mbgdevio.libbin26112 -> 29696 bytes
-rw-r--r--c/mbglib/lib/bc/mbgsvcio.libbin1024 -> 2560 bytes
-rw-r--r--c/mbglib/lib/bc/mbgutil.libbin6144 -> 6144 bytes
-rw-r--r--c/mbglib/lib/msc/mbgdevio.libbin197556 -> 223752 bytes
-rw-r--r--c/mbglib/lib/msc/mbgsvcio.libbin4248 -> 7148 bytes
-rw-r--r--c/mbglib/lib/msc/mbgsvctl.libbin0 -> 57888 bytes
-rw-r--r--c/mbglib/lib/msc/mbgutil.libbin45034 -> 45706 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgdevio.libbin33774 -> 39182 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgsvcio.libbin2754 -> 4164 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgutil.libbin8630 -> 8630 bytes
41 files changed, 11839 insertions, 1761 deletions
diff --git a/c/mbglib/include/deviohlp.h b/c/mbglib/include/deviohlp.h
new file mode 100644
index 0000000..79c9b4d
--- /dev/null
+++ b/c/mbglib/include/deviohlp.h
@@ -0,0 +1,181 @@
+
+/**************************************************************************
+ *
+ * $Id: deviohlp.h 1.1.1.10 2012/07/18 11:00:46Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for deviohlp.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: deviohlp.h $
+ * Revision 1.1.1.10 2012/07/18 11:00:46Z martin
+ * Revision 1.1.1.9 2012/07/12 09:07:36Z martin
+ * Revision 1.1.1.8 2012/07/12 08:38:51Z martin
+ * Account for renamed structure.
+ * Revision 1.1.1.7 2012/07/10 09:53:57 martin
+ * Revision 1.1.1.6 2012/04/11 15:45:10Z martin
+ * Updated doxygen comments.
+ * Revision 1.1.1.5 2011/09/21 16:00:22 martin
+ * Revision 1.1.1.4 2011/09/21 14:44:50 martin
+ * Updated function prototypes.
+ * Revision 1.1.1.3 2011/09/20 15:36:03 marvin
+ * new functions:
+ * mbg_get_serial_settings
+ * mbg_set_serial_settings
+ * include mbgextio.h
+ * Revision 1.1.1.2 2011/08/05 10:30:28 martin
+ * Revision 1.1.1.1 2011/08/05 09:55:58 martin
+ * Revision 1.1 2011/08/03 15:36:44Z martin
+ * Initial revision with functions moved here from mbgdevio.
+ *
+ **************************************************************************/
+
+#ifndef _DEVIOHLP_H
+#define _DEVIOHLP_H
+
+
+/* Other headers to be included */
+
+#include <mbgdevio.h>
+#include <cfg_hlp.h>
+
+
+#ifdef _DEVIOHLP
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct
+{
+ PTP_CFG_INFO ptp_cfg_info;
+ PTP_UC_MASTER_CFG_LIMITS ptp_uc_master_cfg_limits;
+ ALL_PTP_UC_MASTER_INFO_IDX all_ptp_uc_master_info_idx;
+
+} ALL_PTP_CFG_INFO;
+
+
+
+/* function prototypes: */
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ /**
+ Read all serial port settings and supported configuration parameters.
+
+ The functions mbg_get_device_info() and mbg_setup_receiver_info()
+ must have been called before, and the returned ::PCPS_DEV and
+ ::RECEIVER_INFO structures must be passed to this function.
+
+ The complementary function mbg_save_serial_settings() should be used
+ to write the modified serial port configuration back to the board.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *pdev Pointer to a ::PCPS_DEV structure.
+ @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure to be filled up.
+ @param *p_ri Pointer to a ::RECEIVER_INFO structure.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_device_info()
+ @see mbg_setup_receiver_info()
+ @see mbg_save_serial_settings()
+*/
+ int mbg_get_serial_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, RECEIVER_PORT_CFG *pcfg, const RECEIVER_INFO *p_ri ) ;
+
+ /**
+ Write the configuration settings for a single serial port to the board.
+
+ Modifications to the serial port configuration should be made only
+ after mbg_get_serial_settings() had been called to read all serial port
+ settings and supported configuration parameters.
+ This function has finally to be called once for every serial port
+ the configuration of which has been modified.
+
+ As also required by mbg_get_serial_settings(), the functions
+ mbg_get_device_info() and mbg_setup_receiver_info() must have been
+ called before, and the returned ::PCPS_DEV and ::RECEIVER_INFO structures
+ must be passed to this function.
+
+ @param dh Valid handle to a Meinberg device
+ @param *pdev Pointer to a ::PCPS_DEV structure
+ @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure
+ @param port_num Index of the ::serial port to be saved
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_serial_settings()
+ @see mbg_get_device_info()
+ @see mbg_setup_receiver_info()
+*/
+ int mbg_save_serial_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, RECEIVER_PORT_CFG *pcfg, int port_num ) ;
+
+ /**
+ Read all PTP settings and supported configuration parameters.
+
+ The complementary function mbg_save_all_ptp_cfg_info() should
+ be used to write the modified configuration back to the device.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p Pointer to a ::ALL_PTP_CFG_INFO structure.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_save_all_ptp_cfg_info()
+ @see mbg_get_ptp_cfg_info()
+ @see mbg_get_ptp_uc_master_cfg_limits()
+ @see mbg_get_all_ptp_uc_master_info()
+ @see mbg_dev_has_ptp()
+ @see mbg_dev_has_ptp_unicast()
+*/
+ int mbg_get_all_ptp_cfg_info( MBG_DEV_HANDLE dh, ALL_PTP_CFG_INFO *p ) ;
+
+ /**
+ Write all PTP settings and supported configuration parameters
+ to a device.
+
+ The complementary function mbg_get_all_ptp_cfg_info() should
+ have been used to read the original PTP settings and supported
+ configuration parameters.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p Pointer to a ::ALL_PTP_CFG_INFO structure.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_all_ptp_cfg_info()
+ @see mbg_set_ptp_cfg_settings()
+ @see mbg_set_ptp_uc_master_settings_idx()
+ @see mbg_dev_has_ptp()
+ @see mbg_dev_has_ptp_unicast()
+*/
+ int mbg_save_all_ptp_cfg_info( MBG_DEV_HANDLE dh, const ALL_PTP_CFG_INFO *p ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _DEVIOHLP_H */
diff --git a/c/mbglib/include/eventlog.h b/c/mbglib/include/eventlog.h
new file mode 100644
index 0000000..910be4c
--- /dev/null
+++ b/c/mbglib/include/eventlog.h
@@ -0,0 +1,87 @@
+
+/**************************************************************************
+ *
+ * $Id: eventlog.h 1.3 2007/09/26 14:56:03Z martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for eventlog.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: eventlog.h $
+ * Revision 1.3 2007/09/26 14:56:03Z martin
+ * Updated function prototypes.
+ * Revision 1.2 2004/04/14 08:36:54Z martin
+ * Pack structures 1 byte aligned.
+ * Revision 1.1 2002/11/28 09:18:36Z Martin
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _EVENTLOG_H
+#define _EVENTLOG_H
+
+
+/* Other headers to be included */
+
+#include <windows.h>
+#include <use_pack.h>
+
+
+#ifdef _EVENTLOG
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK ) // set byte alignment
+ #pragma pack( 1 )
+#endif
+
+
+extern const char *eventlog_name; // must be provided by the application
+
+
+#if defined( DEBUG ) || defined ( _DEBUG )
+ #define reportDebugEvent( _p1, _p2 ) \
+ reportAnEvent( _p1, _p2 )
+#else
+ #define reportDebugEvent( _p1, _p2 );
+#endif
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ void reportAnEvent( DWORD dwIdEvent, const char *message ) ;
+ void reportAnEventEx( DWORD dwIdEvent, const char *insert1, const char* insert2, int err_code ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USE_PACK ) // set default alignment
+ #pragma pack()
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _EVENTLOG_H */
diff --git a/c/mbglib/include/extiohlp.h b/c/mbglib/include/extiohlp.h
new file mode 100644
index 0000000..ee744bc
--- /dev/null
+++ b/c/mbglib/include/extiohlp.h
@@ -0,0 +1,116 @@
+
+/**************************************************************************
+ *
+ * $Id: extiohlp.h 1.2.1.1 2012/03/13 16:27:20Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for extiohlp.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: extiohlp.h $
+ * Revision 1.2.1.1 2012/03/13 16:27:20Z martin
+ * Revision 1.2 2012/03/09 08:35:51Z martin
+ * Updated function prototypes.
+ * Revision 1.1 2011/09/21 15:59:59 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _EXTIOHLP_H
+#define _EXTIOHLP_H
+
+
+/* Other headers to be included */
+
+#include <mbgextio.h>
+
+#include <cfg_hlp.h>
+
+
+#ifdef _EXTIOHLP
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+
+
+/* function prototypes: */
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ /**
+ Read all serial port settings and supported configuration parameters.
+ from a non bus level device
+
+ The function mbgextio_get_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO must be passed to this function.
+
+ The complementary function mbgextio_save_serial_settings() should
+ be used to write the modified configuration back to the device.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure to be filled up.
+ @param *p_ri Pointer to a ::RECEIVER_INFO structure.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbgextio_save_serial_settings()
+ @see mbgextio_get_receiver_info()
+*/
+ int mbgextio_get_serial_settings( MBG_MSG_CTL *pmctl, RECEIVER_PORT_CFG *pcfg, const RECEIVER_INFO *p_ri ) ;
+
+ /**
+ Write the configuration settings for a single serial port via serial connection to the board.
+
+ Modifications to the serial port configuration should be made only
+ after mbgextio_get_serial_settings() had been called to read all serial port
+ settings and supported configuration parameters.
+ This function has finally to be called once for every serial port
+ the configuration of which has been modified.
+
+ As also required by mbgextio_get_serial_settings(), the function
+ mbgextio_get_receiver_info() must have been
+ called before, and the returned ::RECEIVER_INFO structure
+ must be passed to this function.
+
+ @param dh Valid handle to a Meinberg device via serial connection
+ @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure
+ @param port_idx Index of the ::serial port to be saved
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbgextio_get_serial_settings()
+ @see mbgextio_get_receiver_info()
+*/
+ int mbgextio_save_serial_settings( MBG_MSG_CTL *dh, const RECEIVER_PORT_CFG *pcfg, int port_idx ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _EXTIOHLP_H */
diff --git a/c/mbglib/include/gpsdefs.h b/c/mbglib/include/gpsdefs.h
index 232f30b..c65a251 100644
--- a/c/mbglib/include/gpsdefs.h
+++ b/c/mbglib/include/gpsdefs.h
@@ -1,19 +1,152 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.79 2009/08/12 14:12:38Z daniel REL_M $
+ * $Id: gpsdefs.h 1.105.1.5.1.6 2012/08/03 11:33:33Z Gregoire TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
* General definitions to be used with Meinberg clocks.
* These definitions have initially be used with GPS devices only.
- * However, more and more Meinberg non-GPS devices also use some of
+ * However, more and more Meinberg non-GPS devices also use some of
* these definitions.
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
- * Revision 1.79 2009/08/12 14:12:38Z daniel
+ * Revision 1.105.1.5.1.6 2012/08/03 11:33:33Z Gregoire
+ * short strings for GPIO types added (DEFAULT_GPIO_TYPES_SHORT_STRS)
+ * Revision 1.105.1.5.1.5 2012/07/23 14:53:05Z andre
+ * bugfix in XMULTI Ref Names
+ * Revision 1.105.1.5.1.4 2012/07/20 10:12:04Z martin
+ * Revision 1.105.1.5.1.3 2012/07/20 09:36:46 martin
+ * Revision 1.105.1.5.1.2 2012/07/19 14:03:27 martin
+ * More changes, not yet finished.
+ * Revision 1.105.1.5.1.1 2012/07/19 12:57:57 martin
+ * Started to modify GPIO structures.
+ * Revision 1.105.1.5 2012/07/19 10:29:48 martin
+ * Revision 1.105.1.4 2012/07/10 12:43:20 werner
+ * GRC defines added
+ * Revision 1.105.1.3 2012/06/28 08:20:02Z marvin
+ * Added default baud rate and framing for binary protocol.
+ * Revision 1.105.1.2 2012/06/22 14:48:27Z martin
+ * Revision 1.105.1.1 2012/06/21 08:44:25 martin
+ * Revision 1.105 2012/06/01 16:31:16 martin
+ * Some TIME_SLOT definitions added by marvin.
+ * Moved some PTP configuration defaults and limits to ptpdflts.h.
+ * Revision 1.104 2012/04/11 16:02:55Z martin
+ * Fixed some doxygen comments.
+ * Revision 1.103 2012/04/02 11:08:57Z martin
+ * Extended description of GPS UTC/leap second data.
+ * Revision 1.102 2012/03/16 11:43:31 martin
+ * Fixed a potential compiler warning.
+ * Revision 1.101 2012/03/06 16:56:01Z martin
+ * Added support for PTP multicast auto role.
+ * Merged Daniel's definitions for PTP profile support.
+ * Support time slot mode for programmable pulse outputs.
+ * Support LNO180.
+ * Moved definition of MBG_MAC_ADDR here.
+ * Use MBG_MAC_ADDR in definition of LAN_IF_INFO.
+ * Revision 1.100 2012/01/17 13:33:55 martin
+ * Added new IRIG RX delay compensation code groups for G0xx and G1xx codes.
+ * As a consequence the value of N_IRIG_RX_COMP has changed.
+ * Added definition of IRIG_RX_COMP_MAX.
+ * Updated IRIG code classification macros.
+ * Removed obsolete/unused definition of CAL_REC_INFO.
+ * Added some comments.
+ * Revision 1.99 2011/12/09 09:22:03 martin
+ * Fixed a typo.
+ * Revision 1.98 2011/11/25 14:58:34 martin
+ * Renamed some evt_log definitions.
+ * Revision 1.97 2011/11/25 10:11:17 martin
+ * Initializers for XMRS status bit strings added by gregoire.
+ * New feature GPS_FEAT_EVT_LOG.
+ * Added definitions used with event logs.
+ * Moved cal_reg and gen_io stuff here.
+ * Added macro _mbg_swab_debug_status().
+ * Updated some comments.
+ * Revision 1.96 2011/10/11 13:40:46Z andre
+ * changed reserved field into slot_id in XMULTI_REF_INSTANCES
+ * Revision 1.95.1.1 2011/10/07 09:31:58Z andre
+ * Revision 1.95 2011/10/04 09:35:41Z martin
+ * Added support for ESI180.
+ * Changed RECEIVER_INFO::flags bit GPS_10MHZ_DISBD to a RECEIVER_INFO::features bit.
+ * Support MULTI_REF_INTERNAL, MULTI_REF_LWR and MULTI_REF_PZF.
+ * Added MBG_GPIO_BITS structure and associated definitions.
+ * Revision 1.94 2011/08/25 07:42:43Z martin
+ * Fixed a bug in macro _mbg_swab_pout_settings() where the 16 bit timeout
+ * field was swapped using a macro for 32 bit types.
+ * Use shorter names for some PTP unicast master default values.
+ * Revision 1.93 2011/08/10 08:19:38Z martin
+ * New PORT_INFO and PORT_SETTINGS flag PORT_FLAG_PORT_INVISIBLE.
+ * Revision 1.92 2011/07/29 09:49:35 martin
+ * Support PZF180PEX, MGR180, MSF600, WWVB600, JJY600,
+ * GPS180HS, and GPS180AMC.
+ * Added receiver info features GPS_FEAT_PTP_UNICAST
+ * and GPS_FEAT_XMRS_MULT_INSTC.
+ * Added receiver info flag bit GPS_10MHZ_DISBD.
+ * Added initializers for PTP timescale names.
+ * New PTP_STATE flags bit PTP_FLAG_MSK_IS_UNICAST.
+ * Made unused PTP_STATE fields num_clients and num_masters reserved.
+ * Account for different PTP roles.
+ * Added / renamed some definitions for PTP.
+ * Modified default string for PTP layer 2 protocol.
+ * Support PTP unicast configuration.
+ * Support GPIO configuration.
+ * Introduced XMULTI_REF_INSTANCES.
+ * Moved flags XMRS_..._IS_EXTERNAL and XMRS_..._INSTC_EXCEEDED
+ * to definitions for XMULTI_REF_STATUS::status.
+ * Some comments added, updated, and converted to doxygen style.
+ * Cleaned up handling of pragma pack().
+ * Removed trailing whitespace and hard tabs.
+ * Revision 1.91 2011/01/31 11:23:56Z martin
+ * Added model type name definitions for GPS180PEX and TCR180PEX.
+ * Introduced synthesizer mode for programmable outputs.
+ * Added IRIG-RX code TXC-101 DTR-6.
+ * Fixed missing comma bugs in DEFAULT_GPS_MODEL_NAMES.
+ * Fixed missing comma bugs in some IRIG string initializers.
+ * Fixed AFNOR notation.
+ * Modified some comments for doxygen.
+ * Revision 1.90 2010/10/15 11:47:53 martin
+ * Added definitions POUT_TIMEBASE_UTC and POUT_SUPP_DCF77_UTC.
+ * Added receiver info feature GPS_FEAT_RAW_IRIG_TIME.
+ * Support IRIG format C37.118.
+ * Added initializers for short IRIG code names.
+ * Cleaned up IRIG definitions and comments.
+ * Revision 1.89 2010/09/06 07:40:02Z martin
+ * Picked up Daniel's definitions for multi GNSS support.
+ * Moved MBG_IRIG_CTRL_BITS, MBG_RAW_IRIG_DATA and related definitions
+ * from pcpsdefs.h here.
+ * Added macros _pcps_tfom_from_irig_ctrl_bits()
+ * and _pcps_tfom_from_raw_irig_data().
+ * Added RI_FEATURES type.
+ * Revision 1.88 2010/04/21 13:47:54 daniel
+ * Added support for new model GLN170.
+ * Revision 1.87 2010/03/10 11:29:37Z martin
+ * Added definitions for GPS180.
+ * Added multiref source 1 PPS plus associated string.
+ * Revision 1.86 2010/02/17 14:16:42 martin
+ * Added definitions for PZF600 and TCR600.
+ * Revision 1.85 2010/02/15 11:34:36 martin
+ * Changed definition of PTP_TABLE::name to const char *.
+ * Added definitions to support new model JJY511.
+ * Revision 1.84 2010/02/01 13:20:50 martin
+ * Support programmable outputs being disabled when sync. is lost.
+ * Revision 1.83 2010/01/28 09:15:50 martin
+ * Added new POUT mode DCF77_M59 and associated definitions.
+ * Revision 1.82 2010/01/07 09:04:55 martin
+ * Added XMR status bit XMRS_BIT_NOT_PHASE_LOCKED.
+ * Revision 1.81 2009/11/09 09:08:24 martin
+ * New TM_GPS status bit TM_INVT.
+ * Added definitions to support VLAN.
+ * Changed DEFAULT_PTP_DELAY_MECH_MASK to include also
+ * PTP_DELAY_MECH_MSK_P2P.
+ * There is now only one type of TCXO supported which matches the former
+ * TCXO HQ, so the default name for TCXO HQ has been changed to TCXO.
+ * TCXO LQ and MQ names are still supported for backward compatibility.
+ * Revision 1.80 2009/09/28 14:55:53 martin
+ * Support IRIG formats G002/G142 and G006/G146.
+ * Modified IRIG format description strings.
+ * Revision 1.79 2009/08/12 14:12:38 daniel
* Added definitions to support new model MGR170.
* Added definitions and commands to support configuration
* of navigation engine (currently supported by u-blox
@@ -25,7 +158,7 @@
* Added macro _nano_time_negative().
* Revision 1.77 2009/06/08 19:22:32Z daniel
* Added feature GPS_HAS_PTP.
- * Added preliminary structures and definitions for PTP
+ * Added preliminary structures and definitions for PTP
* configuration and state.
* Added IP4_ADDR type.
* Added Bitmask IP4_MSK_DHCP.
@@ -38,7 +171,7 @@
* Revision 1.75 2009/03/19 14:06:39Z martin
* Modified string initializer for unknown oscillator type.
* Revision 1.74 2009/03/18 13:45:53 daniel
- * Added missing commas in
+ * Added missing commas in
* MBG_DEBUG_STATUS_STRS initializer.
* Adjusted some comments for doxygen parser.
* Revision 1.73 2009/03/10 16:55:33Z martin
@@ -114,7 +247,7 @@
* Revision 1.52 2006/12/12 15:47:18 martin
* Added MBG_DEBUG_STATUS type and associated definitions.
* Added definition GPS_HAS_REF_OFFS.
- * Moved PCPS_REF_OFFS and associated definitions from pcpsdefs.h here
+ * Moved PCPS_REF_OFFS and associated definitions from pcpsdefs.h here
* and renamed them to MBG_REF_OFFS, etc.
* Revision 1.51 2006/10/23 15:31:27 martin
* Added definitions for GPS170.
@@ -186,7 +319,7 @@
* Added definitions OSC_DAC_RANGE, OSC_DAC_BIAS.
* Revision 1.27 2004/03/08 14:06:45Z martin
* New model code and name for GPS169PCI.
- * Existing feature GPS_FEAT_IRIG has been
+ * Existing feature GPS_FEAT_IRIG has been
* renamed to GPS_FEAT_IRIG_TX.
* Added feature GPS_FEAT_IRIG_RX.
* Added IPv4 LAN interface feature flags.
@@ -225,7 +358,7 @@
* Added initializer for oscillator names.
* Added initializer for oscillator list ordered by quality.
* Revision 1.13 2002/05/08 08:16:03 MARTIN
- * Added GPS_OSC_CFG_SUPP for RECEIVER_INFO.flags.
+ * Added GPS_OSC_CFG_SUPP for RECEIVER_INFO::flags.
* Fixed some comments.
* Revision 1.12 2002/03/14 13:45:56 MARTIN
* Changed type CSUM from short to ushort.
@@ -271,7 +404,7 @@
#include <config.h>
#endif
-// CLOCK_MEINBERG is defined in NTP's config.h if configured
+// CLOCK_MEINBERG is defined in NTP's config.h if configured
// to support Meinberg clocks.
#if !defined( CLOCK_MEINBERG )
// avoid having to use these headers in non-Meinberg projects
@@ -280,12 +413,13 @@
#endif
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
-#endif
+/* Start of header body */
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
-/* Start of header body */
/* "magic" number */
#define MEINBERG_MAGIC 0x6AAC
@@ -331,23 +465,29 @@ typedef uint16_t IOD; /* Issue-Of-Data code */
#endif
-/**
- The type which is used to pass a cmd code via serial port, or bus.
- The cmd codes are defined in gpsserio.h and pcpsdefs.h.
-*/
+/**
+ * @brief The type of a GPS command code
+ *
+ * These command codes can be passed via
+ * @ref group_gps_cmds_serial "serial port" (see @file gpsserio.h), or
+ * @ref group_gps_cmds_bus "system bus" (see @file pcpsdefs.h).
+ */
typedef uint16_t GPS_CMD;
#define _mbg_swab_gps_cmd( _p ) _mbg_swab16( _p )
-/**
- A struct used to hold the software revision information
- */
+/**
+ * @brief Software revision information
+ *
+ * Contains a software revision code, plus an optional
+ * identifier for a customized version.
+ */
typedef struct
{
- uint16_t code; /**< e.g. 0x0120 means rev. 1.20 */
- char name[GPS_ID_STR_SIZE]; /**< used to identify customized versions */
- uint8_t reserved; /**< yield even structure size */
+ uint16_t code; /**< Version number, e.g. 0x0120 means v1.20 */
+ char name[GPS_ID_STR_SIZE]; /**< Optional string identifying a customized version */
+ uint8_t reserved; /**< Reserved field to yield even structure size */
} SW_REV;
#define _mbg_swab_sw_rev( _p ) \
@@ -357,14 +497,31 @@ typedef struct
-typedef uint16_t BVAR_STAT; /**< holds status of battery buffered vars */
+/**
+ * @defgroup group_bvar_stat BVAR_STAT status of buffered GPS data
+ *
+ * Status word, associated bit numbers and bit masks indicating
+ * whether certain data from the GPS satellites are
+ * available and valid.
+ *
+ * These bits defined are set in ::BVAR_STAT if the corresponding
+ * parameters are NOT valid and complete.
+ *
+ * @{ */
+
+/**
+ * @brief Status flags of battery buffered data received
+ * from GPS satellites.
+ *
+ * All '0' means OK, single bits set to '1' indicate
+ * the associated type of GPS data is not available.
+ */
+typedef uint16_t BVAR_STAT;
#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) )
-/**
- The bits defined below are set in BVAR_STAT if the corresponding
- parameters are NOT valid and complete:
-*/
+
+/** @brief Enumeration of bits used with BVAR_STAT */
enum
{
BVAR_BIT_CFGH_INVALID,
@@ -372,22 +529,25 @@ enum
BVAR_BIT_UTC_INVALID,
BVAR_BIT_IONO_INVALID,
BVAR_BIT_RCVR_POS_INVALID,
- N_BVAR_BIT // number of defined bits
+ N_BVAR_BIT /**< @brief number of defined ::BVAR_STAT bits */
};
-#define BVAR_CFGH_INVALID ( 1UL << BVAR_BIT_CFGH_INVALID )
-#define BVAR_ALM_NOT_COMPLETE ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE )
-#define BVAR_UTC_INVALID ( 1UL << BVAR_BIT_UTC_INVALID )
-#define BVAR_IONO_INVALID ( 1UL << BVAR_BIT_IONO_INVALID )
-#define BVAR_RCVR_POS_INVALID ( 1UL << BVAR_BIT_RCVR_POS_INVALID )
+#define BVAR_CFGH_INVALID ( 1UL << BVAR_BIT_CFGH_INVALID ) /**< @brief Configuration and health data (::CFGH) not valid */
+#define BVAR_ALM_NOT_COMPLETE ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ) /**< @brief Almanach data (::ALM) not complete */
+#define BVAR_UTC_INVALID ( 1UL << BVAR_BIT_UTC_INVALID ) /**< @brief UTC data not valid */
+#define BVAR_IONO_INVALID ( 1UL << BVAR_BIT_IONO_INVALID ) /**< @brief Ionospheric correction data (::IONO) not valid */
+#define BVAR_RCVR_POS_INVALID ( 1UL << BVAR_BIT_RCVR_POS_INVALID ) /**< @brief Receiver position (::POS) not valid */
-/**< bit mask for all defined bits */
-#define BVAR_MASK ( ( 1UL << N_BVAR_BIT ) - 1 )
+#define BVAR_MASK ( ( 1UL << N_BVAR_BIT ) - 1 ) /**< @brief Bit mask for all defined bits */
+/** @} group_bvar_stat */
-/* a struct used to hold a fixed frequency value */
-/* frequ[kHz] = khz_val * 10^range */
+
+/**
+ A structure used to hold a fixed frequency value.
+ frequ[kHz] = khz_val * 10^range
+*/
typedef struct
{
@@ -402,6 +562,8 @@ typedef struct
}
+typedef uint32_t RI_FEATURES; // type of RECEIVER_INFO::features field
+
/*
* The following code defines features and properties
@@ -423,7 +585,7 @@ typedef struct
char epld_name[GPS_EPLD_STR_SIZE]; /**< ASCIIZ, file name of EPLD image */
uint8_t n_channels; /**< number of sats to be tracked simultaneously */
uint32_t ticks_per_sec; /**< resolution of fractions of seconds */
- uint32_t features; /**< optional features, see below */
+ RI_FEATURES features; /**< optional features, see below */
FIXED_FREQ_INFO fixed_freq; /**< optional non-standard fixed frequency */
uint8_t osc_type; /**< type of installed oscillator, see below */
uint8_t osc_flags; /**< oscillator flags, see below */
@@ -477,10 +639,28 @@ enum
GPS_MODEL_TCR170PEX,
GPS_MODEL_WWVB511,
GPS_MODEL_MGR170,
+ GPS_MODEL_JJY511,
+ GPS_MODEL_PZF600,
+ GPS_MODEL_TCR600,
+ GPS_MODEL_GPS180,
+ GPS_MODEL_GLN170,
+ GPS_MODEL_GPS180PEX,
+ GPS_MODEL_TCR180PEX,
+ GPS_MODEL_PZF180PEX,
+ GPS_MODEL_MGR180,
+ GPS_MODEL_MSF600,
+ GPS_MODEL_WWVB600,
+ GPS_MODEL_JJY600,
+ GPS_MODEL_GPS180HS,
+ GPS_MODEL_GPS180AMC,
+ GPS_MODEL_ESI180,
+ GPS_MODEL_CPE180,
+ GPS_MODEL_LNO180,
+ GPS_MODEL_GRC180,
N_GPS_MODEL
- /* If new model codes are added then care must be taken
- * to update the associated string initializers below
- * accordingly, and to check whether the classification macros
+ /* If new model codes are added then care must be taken
+ * to update the associated string initializers below
+ * accordingly, and to check whether the classification macros
* also cover the new model names. */
};
@@ -518,7 +698,24 @@ enum
#define GPS_MODEL_NAME_TCR170PEX "TCR170PEX"
#define GPS_MODEL_NAME_WWVB511 "WWVB511"
#define GPS_MODEL_NAME_MGR170 "MGR170"
-
+#define GPS_MODEL_NAME_JJY511 "JJY511"
+#define GPS_MODEL_NAME_PZF600 "PZF600"
+#define GPS_MODEL_NAME_TCR600 "TCR600"
+#define GPS_MODEL_NAME_GPS180 "GPS180"
+#define GPS_MODEL_NAME_GLN170 "GLN170"
+#define GPS_MODEL_NAME_GPS180PEX "GPS180PEX"
+#define GPS_MODEL_NAME_TCR180PEX "TCR180PEX"
+#define GPS_MODEL_NAME_PZF180PEX "PZF180PEX"
+#define GPS_MODEL_NAME_MGR180 "MGR180"
+#define GPS_MODEL_NAME_MSF600 "MSF600"
+#define GPS_MODEL_NAME_WWVB600 "WWVB600"
+#define GPS_MODEL_NAME_JJY600 "JJY600"
+#define GPS_MODEL_NAME_GPS180HS "GPS180HS"
+#define GPS_MODEL_NAME_GPS180AMC "GPS180AMC"
+#define GPS_MODEL_NAME_ESI180 "ESI180"
+#define GPS_MODEL_NAME_CPE180 "CPE180"
+#define GPS_MODEL_NAME_LNO180 "LNO180"
+#define GPS_MODEL_NAME_GRC180 "GRC180"
/*
* The definition below can be used to initialize
@@ -554,13 +751,31 @@ enum
GPS_MODEL_NAME_GEN170, \
GPS_MODEL_NAME_TCR170PEX, \
GPS_MODEL_NAME_WWVB511, \
- GPS_MODEL_NAME_MGR170 \
+ GPS_MODEL_NAME_MGR170, \
+ GPS_MODEL_NAME_JJY511, \
+ GPS_MODEL_NAME_PZF600, \
+ GPS_MODEL_NAME_TCR600, \
+ GPS_MODEL_NAME_GPS180, \
+ GPS_MODEL_NAME_GLN170, \
+ GPS_MODEL_NAME_GPS180PEX, \
+ GPS_MODEL_NAME_TCR180PEX, \
+ GPS_MODEL_NAME_PZF180PEX, \
+ GPS_MODEL_NAME_MGR180, \
+ GPS_MODEL_NAME_MSF600, \
+ GPS_MODEL_NAME_WWVB600, \
+ GPS_MODEL_NAME_JJY600, \
+ GPS_MODEL_NAME_GPS180HS, \
+ GPS_MODEL_NAME_GPS180AMC, \
+ GPS_MODEL_NAME_ESI180, \
+ GPS_MODEL_NAME_CPE180, \
+ GPS_MODEL_NAME_LNO180, \
+ GPS_MODEL_NAME_GRC180 \
}
/*
* The macros below can be used to classify a receiver,
- * e.g. depending on the time source and/or depending on
+ * e.g. depending on the time source and/or depending on
* whether it's a plug-in card or an external device.
*/
@@ -611,12 +826,16 @@ enum
#define _mbg_rcvr_is_msf( _p_ri ) \
( strstr( (_p_ri)->model_name, "MSF" ) )
+#define _mbg_rcvr_is_jjy( _p_ri ) \
+ ( strstr( (_p_ri)->model_name, "JJY" ) )
+
#define _mbg_rcvr_is_msf_plug_in( _p_ri ) \
( _mbg_rcvr_is_msf( _p_ri ) && \
_mbg_rcvr_is_plug_in( _p_ri ) )
#define _mbg_rcvr_is_glonass( _p_ri ) \
- ( strstr( (_p_ri)->model_name, "GRC" ) )
+ ( strstr( (_p_ri)->model_name, "GRC" ) || \
+ ( strstr( (_p_ri)->model_name, "GLN" ) )
#define _mbg_rcvr_is_glonass_plug_in( _p_ri ) \
( _mbg_rcvr_is_glonass( _p_ri ) && \
@@ -661,7 +880,7 @@ enum
{ \
"[unknown]", \
"TCXO LQ", \
- "TCXO HQ", \
+ "TCXO", \
"OCXO LQ", \
"OCXO MQ", \
"OCXO HQ", \
@@ -707,25 +926,34 @@ enum
*/
enum
{
- GPS_FEAT_PPS, /**< has pulse per second output */
- GPS_FEAT_PPM, /**< has pulse per minute output */
- GPS_FEAT_SYNTH, /**< has programmable synthesizer output */
- GPS_FEAT_DCFMARKS, /**< has DCF77 compatible time mark output */
- GPS_FEAT_IRIG_TX, /**< has on-board IRIG output */
- GPS_FEAT_IRIG_RX, /**< has on-board IRIG input */
- GPS_FEAT_LAN_IP4, /**< has LAN IPv4 interface */
- GPS_FEAT_MULTI_REF, /**< has multiple input sources with priorities */
- GPS_FEAT_RCV_TIMEOUT, /**< timeout after GPS reception has stopped */
- GPS_FEAT_IGNORE_LOCK, /**< supports "ignore lock", alternatively */
- /**< MBG_OPT_BIT_EMU_SYNC may be supported */
- GPS_FEAT_5_MHZ, /**< output 5 MHz rather than 100 kHz */
- GPS_FEAT_XMULTI_REF, /**< has extended multiple input source configuration */
- GPS_FEAT_OPT_SETTINGS, /**< supports MBG_OPT_SETTINGS */
- GPS_FEAT_TIME_SCALE, /**< supports configurable time scale (UTC, TAI, GPS, ...) */
- GPS_FEAT_IRIG_CTRL_BITS, /**< supports IRIG control bits */
- GPS_FEAT_PTP, /**< has PTP support */
+ GPS_FEAT_PPS, /**< has pulse per second output */
+ GPS_FEAT_PPM, /**< has pulse per minute output */
+ GPS_FEAT_SYNTH, /**< has programmable synthesizer output */
+ GPS_FEAT_DCFMARKS, /**< has DCF77 compatible time mark output */
+ GPS_FEAT_IRIG_TX, /**< has on-board IRIG output */
+ GPS_FEAT_IRIG_RX, /**< has on-board IRIG input */
+ GPS_FEAT_LAN_IP4, /**< has LAN IPv4 interface */
+ GPS_FEAT_MULTI_REF, /**< has multiple input sources with priorities */
+
+ GPS_FEAT_RCV_TIMEOUT, /**< timeout after GPS reception has stopped */
+ GPS_FEAT_IGNORE_LOCK, /**< supports "ignore lock", MBG_OPT_BIT_EMU_SYNC can be set alternatively */
+ GPS_FEAT_5_MHZ, /**< output 5 MHz rather than 100 kHz */
+ GPS_FEAT_XMULTI_REF, /**< has extended multiple input source configuration */
+ GPS_FEAT_OPT_SETTINGS, /**< supports MBG_OPT_SETTINGS */
+ GPS_FEAT_TIME_SCALE, /**< supports configurable time scale (UTC, TAI, GPS, ...) */
+ GPS_FEAT_IRIG_CTRL_BITS, /**< supports IRIG control bits */
+ GPS_FEAT_PTP, /**< has PTP support */
+
GPS_FEAT_NAV_ENGINE_SETTINGS, /**< supports navigation engine configuration */
- N_GPS_FEATURE /**< the number of valid features */
+ GPS_FEAT_RAW_IRIG_DATA, /**< supports reading raw IRIG input data */
+ GPS_FEAT_RAW_IRIG_TIME, /**< supports reading decoded IRIG time */
+ GPS_FEAT_PTP_UNICAST, /**< has PTP Unicast support */
+ GPS_FEAT_GPIO, /**< has general purpose in/outputs */
+ GPS_FEAT_XMRS_MULT_INSTC, /**< multiple XMRS instances of the same ref type supported, @see XMRSF_BIT_MULT_INSTC_SUPP */
+ GPS_FEAT_10MHZ_DISBD, /**< 10 MHz output is always disabled */
+ GPS_FEAT_EVT_LOG, /**< Event logging supported */
+
+ N_GPS_FEATURE /**< the number of valid features */
};
@@ -743,11 +971,18 @@ enum
"Ignore Lock", \
"5 MHz Output", \
"Ext. Multiple Ref. Src. Cfg.", \
- "Supp. Optional Settings", \
+ "Optional Settings", \
"Configurable Time Scale", \
- "Irig Control Bits", \
+ "IRIG Control Bits", \
"PTP/IEEE1588", \
- "Supp. Nav. Engine Settings" \
+ "Nav. Engine Settings", \
+ "Raw IRIG Data", \
+ "Raw IRIG Time", \
+ "PTP/IEEE1588 Unicast", \
+ "General Purpose I/O", \
+ "Multiple XMRS Instances", \
+ "10 MHz Output Disabled", \
+ "Event Logging" \
}
@@ -755,25 +990,32 @@ enum
* Bit masks used with RECEIVER_INFO.features
* (others are reserved):
*/
-#define GPS_HAS_PPS ( 1UL << GPS_FEAT_PPS )
-#define GPS_HAS_PPM ( 1UL << GPS_FEAT_PPM )
-#define GPS_HAS_SYNTH ( 1UL << GPS_FEAT_SYNTH )
-#define GPS_HAS_DCFMARKS ( 1UL << GPS_FEAT_DCFMARKS )
-#define GPS_HAS_IRIG_TX ( 1UL << GPS_FEAT_IRIG_TX )
-#define GPS_HAS_IRIG_RX ( 1UL << GPS_FEAT_IRIG_RX )
-#define GPS_HAS_LAN_IP4 ( 1UL << GPS_FEAT_LAN_IP4 )
-#define GPS_HAS_MULTI_REF ( 1UL << GPS_FEAT_MULTI_REF )
-#define GPS_HAS_RCV_TIMEOUT ( 1UL << GPS_FEAT_RCV_TIMEOUT )
-#define GPS_HAS_IGNORE_LOCK ( 1UL << GPS_FEAT_IGNORE_LOCK )
-#define GPS_HAS_5_MHZ ( 1UL << GPS_FEAT_5_MHZ )
-#define GPS_HAS_XMULTI_REF ( 1UL << GPS_FEAT_XMULTI_REF )
-#define GPS_HAS_OPT_SETTINGS ( 1UL << GPS_FEAT_OPT_SETTINGS )
-#define GPS_HAS_TIME_SCALE ( 1UL << GPS_FEAT_TIME_SCALE )
-#define GPS_HAS_IRIG_CTRL_BITS ( 1UL << GPS_FEAT_IRIG_CTRL_BITS )
-#define GPS_HAS_PTP ( 1UL << GPS_FEAT_PTP )
+#define GPS_HAS_PPS ( 1UL << GPS_FEAT_PPS )
+#define GPS_HAS_PPM ( 1UL << GPS_FEAT_PPM )
+#define GPS_HAS_SYNTH ( 1UL << GPS_FEAT_SYNTH )
+#define GPS_HAS_DCFMARKS ( 1UL << GPS_FEAT_DCFMARKS )
+#define GPS_HAS_IRIG_TX ( 1UL << GPS_FEAT_IRIG_TX )
+#define GPS_HAS_IRIG_RX ( 1UL << GPS_FEAT_IRIG_RX )
+#define GPS_HAS_LAN_IP4 ( 1UL << GPS_FEAT_LAN_IP4 )
+#define GPS_HAS_MULTI_REF ( 1UL << GPS_FEAT_MULTI_REF )
+#define GPS_HAS_RCV_TIMEOUT ( 1UL << GPS_FEAT_RCV_TIMEOUT )
+#define GPS_HAS_IGNORE_LOCK ( 1UL << GPS_FEAT_IGNORE_LOCK )
+#define GPS_HAS_5_MHZ ( 1UL << GPS_FEAT_5_MHZ )
+#define GPS_HAS_XMULTI_REF ( 1UL << GPS_FEAT_XMULTI_REF )
+#define GPS_HAS_OPT_SETTINGS ( 1UL << GPS_FEAT_OPT_SETTINGS )
+#define GPS_HAS_TIME_SCALE ( 1UL << GPS_FEAT_TIME_SCALE )
+#define GPS_HAS_IRIG_CTRL_BITS ( 1UL << GPS_FEAT_IRIG_CTRL_BITS )
+#define GPS_HAS_PTP ( 1UL << GPS_FEAT_PTP )
#define GPS_HAS_NAV_ENGINE_SETTINGS ( 1UL << GPS_FEAT_NAV_ENGINE_SETTINGS )
+#define GPS_HAS_RAW_IRIG_DATA ( 1UL << GPS_FEAT_RAW_IRIG_DATA )
+#define GPS_HAS_RAW_IRIG_TIME ( 1UL << GPS_FEAT_RAW_IRIG_TIME )
+#define GPS_HAS_PTP_UNICAST ( 1UL << GPS_FEAT_PTP_UNICAST )
+#define GPS_HAS_GPIO ( 1UL << GPS_FEAT_GPIO )
+#define GPS_HAS_XMRS_MULT_INSTC ( 1UL << GPS_FEAT_XMRS_MULT_INSTC )
+#define GPS_HAS_10MHZ_DISBD ( 1UL << GPS_FEAT_10MHZ_DISBD )
+#define GPS_HAS_EVT_LOG ( 1UL << GPS_FEAT_EVT_LOG )
-#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
+#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
/*
@@ -790,13 +1032,14 @@ enum
/*
- * Codes to be used with RECEIVER_INFO.flags:
+ * Codes to be used with RECEIVER_INFO::flags:
*/
#define GPS_OSC_CFG_SUPP 0x0001 // GPS_OSC_CFG supported
#define GPS_IRIG_FO_IN 0x0002 // IRIG input via fiber optics
#define GPS_HAS_FPGA 0x0004 // device provides on-board FPGA
+
/*
* If the GPS_HAS_FPGA flag is set in RECEIVER_INFO::flags then the card
* provides an FPGA and the following information about the FPGA is available:
@@ -846,7 +1089,7 @@ typedef struct
-/**
+/**
Date and time referred to the linear time scale defined by GPS.
GPS time is defined by the number of weeks since midnight from
January 5, 1980 to January 6, 1980 plus the number of seconds of
@@ -869,26 +1112,27 @@ typedef struct
}
-/* Local date and time computed from GPS time. The current number */
-/* of leap seconds have to be added to get UTC from GPS time. */
-/* Additional corrections could have been made according to the */
-/* time zone/daylight saving parameters (TZDL, see below) defined */
-/* by the user. The status field can be checked to see which corrections */
-/* have been applied. */
-
+/**
+ Local date and time computed from GPS time. The current number
+ of leap seconds have to be added to get UTC from GPS time.
+ Additional corrections could have been made according to the
+ time zone/daylight saving parameters (TZDL, see below) defined
+ by the user. The status field can be checked to see which corrections
+ have been applied.
+*/
typedef struct
{
- int16_t year; /* 0..9999 */
- int8_t month; /* 1..12 */
- int8_t mday; /* 1..31 */
- int16_t yday; /* 1..366 */
- int8_t wday; /* 0..6 == Sun..Sat */
- int8_t hour; /* 0..23 */
- int8_t min; /* 0..59 */
- int8_t sec; /* 0..59 */
- int32_t frac; /* fractions of a second; scale: 1/GPS_TICKS_PER_SEC*/
- int32_t offs_from_utc; /* local time's offset from UTC */
- uint16_t status; /* flags */
+ int16_t year; /**< year number, 0..9999 */
+ int8_t month; /**< month, 1..12 */
+ int8_t mday; /**< day of month, 1..31 */
+ int16_t yday; /**< day of year, 1..366 */
+ int8_t wday; /**< day of week, 0..6 == Sun..Sat */
+ int8_t hour; /**< hours, 0..23 */
+ int8_t min; /**< minutes, 0..59 */
+ int8_t sec; /**< seconds, 0..59 */
+ int32_t frac; /**< fractions of a second; scale: 1/GPS_TICKS_PER_SEC */
+ int32_t offs_from_utc; /**< local time's offset from UTC */
+ uint16_t status; /**< status flags */
} TM_GPS;
#define _mbg_swab_tm_gps( _p ) \
@@ -912,9 +1156,9 @@ enum
TM_BIT_LS_ANN, /* leap second will be inserted */
TM_BIT_LS_ENB, /* current second is leap second */
TM_BIT_LS_ANN_NEG, /* set in addition to TM_LS_ANN if leap sec negative */
- /* Bit 7 is reserved and not used, yet. */
+ TM_BIT_INVT, /* invalid time, e.g. if RTC battery empty */
- TM_BIT_EXT_SYNC = 8, /* sync'd externally */
+ TM_BIT_EXT_SYNC, /* sync'd externally */
TM_BIT_HOLDOVER, /* holdover mode after previous sync. */
TM_BIT_ANT_SHORT, /* antenna cable short circuited */
TM_BIT_NO_WARM, /* OCXO has not warmed up */
@@ -927,7 +1171,7 @@ enum
// Type of an extended TM status which is mainly used by the firmware.
typedef uint32_t TM_STATUS_EXT; // extended status, mainly used by the firmware
-// The lower 16 bits of the TM_STATUS_X type correspond to those defined above,
+// The lower 16 bits of the TM_STATUS_X type correspond to those defined above,
// and the upper bits are defined below:
enum
{
@@ -946,6 +1190,7 @@ enum
#define TM_LS_ANN ( 1UL << TM_BIT_LS_ANN )
#define TM_LS_ENB ( 1UL << TM_BIT_LS_ENB )
#define TM_LS_ANN_NEG ( 1UL << TM_BIT_LS_ANN_NEG )
+#define TM_INVT ( 1UL << TM_BIT_INVT )
#define TM_EXT_SYNC ( 1UL << TM_BIT_EXT_SYNC )
#define TM_HOLDOVER ( 1UL << TM_BIT_HOLDOVER )
@@ -963,7 +1208,7 @@ enum
#define TM_MSK_TIME_VALID ( TM_UTC | TM_SCALE_GPS | TM_SCALE_TAI )
/**
- This structure is used to transmit information on date and time
+ * @brief A structure used to transmit information on date and time
*/
typedef struct
{
@@ -1009,7 +1254,7 @@ typedef struct
/* sequence and number of components of a cartesian position */
enum { XP, YP, ZP, N_XYZ };
- /** a type of array holding a cartesian position */
+ /** @brief An array holding a cartesian position */
typedef double XYZ[N_XYZ]; /**< values are in [m] */
#define _XYZ_DEFINED
@@ -1022,7 +1267,7 @@ typedef struct
/* sequence and number of components of a geographic position */
enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
- /** a type of array holding a geographic position */
+ /** @brief An array holding a geographic position */
typedef double LLA[N_LLA]; /**< lon, lat in [rad], alt in [m] */
#define _LLA_DEFINED
@@ -1032,33 +1277,33 @@ typedef struct
/**
- @defgroup group_synth Synthesizer parameters
+ @defgroup group_synth Synthesizer parameters
- Synthesizer frequency is expressed as a
- four digit decimal number (freq) to be multiplied by 0.1 Hz and an
- base 10 exponent (range). If the effective frequency is less than
- 10 kHz its phase is synchronized corresponding to the variable phase.
- Phase may be in a range from -360 deg to +360 deg with a resolution
- of 0.1 deg, so the resulting numbers to be stored are in a range of
- -3600 to +3600.
+ Synthesizer frequency is expressed as a
+ four digit decimal number (freq) to be multiplied by 0.1 Hz and an
+ base 10 exponent (range). If the effective frequency is less than
+ 10 kHz its phase is synchronized corresponding to the variable phase.
+ Phase may be in a range from -360 deg to +360 deg with a resolution
+ of 0.1 deg, so the resulting numbers to be stored are in a range of
+ -3600 to +3600.
Example:<br>
- Assume the value of freq is 2345 (decimal) and the value of phase is 900.
- If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
- If range == 1 the synthesizer will generate a 2345 Hz output frequency
- and so on.
+ Assume the value of freq is 2345 (decimal) and the value of phase is 900.
+ If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
+ If range == 1 the synthesizer will generate a 2345 Hz output frequency
+ and so on.
Limitations:<br>
- If freq == 0 the synthesizer is disabled. If range == 0 the least
- significant digit of freq is limited to 0, 3, 5 or 6. The resulting
- frequency is shown in the examples below:
- - freq == 1230 --> 123.0 Hz
- - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
- - freq == 1235 --> 123.5 Hz
- - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
-
- If range == MAX_RANGE the value of freq must not exceed 1000, so the
- output frequency is limited to 10 MHz.
+ If freq == 0 the synthesizer is disabled. If range == 0 the least
+ significant digit of freq is limited to 0, 3, 5 or 6. The resulting
+ frequency is shown in the examples below:
+ - freq == 1230 --> 123.0 Hz
+ - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
+ - freq == 1235 --> 123.5 Hz
+ - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
+
+ If range == MAX_RANGE the value of freq must not exceed 1000, so the
+ output frequency is limited to 10 MHz.
@{
*/
@@ -1075,24 +1320,22 @@ typedef struct
#define MAX_SYNTH_FREQ_EDIT 9999 /**< max sequence of digits when editing */
-/** The maximum frequency that can be configured for the synthesizer */
+/** @brief The maximum frequency that can be configured for the synthesizer */
#define MAX_SYNTH_FREQ_VAL 10000000UL /**< 10 MHz */
/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */
-/**
- The synthesizer phase will only be synchronized if the frequency
- is below this limit: */
+/** @brief The synthesizer's phase is only be synchronized if the frequency is below this limit */
#define SYNTH_PHASE_SYNC_LIMIT 10000UL /**< 10 kHz */
-/**
- the position of the decimal point if the frequency is
- printed as 4 digit value */
+/**
+ the position of the decimal point if the frequency is
+ printed as 4 digit value */
#define _synth_dp_pos_from_range( _r ) \
( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 )
-/**
- An initializer for commonly displayed synthesizer frequency units
- (N_SYNTH_RANGE strings) */
+/**
+ An initializer for commonly displayed synthesizer frequency units
+ (N_SYNTH_RANGE strings) */
#define DEFAULT_FREQ_RANGES \
{ \
"Hz", \
@@ -1120,7 +1363,7 @@ typedef struct
}
-/**
+/**
The definitions below can be used to query the
current synthesizer state.
*/
@@ -1144,20 +1387,20 @@ typedef struct
#define SYNTH_FLAG_PHASE_IGNORED 0x01
-/** @} */ // endgroup
+/** @} group_synth */
/**
@defgroup group_tzdl Time zone/daylight saving parameters
Example: <br>
- For automatic daylight saving enable/disable in Central Europe,
+ For automatic daylight saving enable/disable in Central Europe,
the variables are to be set as shown below: <br>
- - offs = 3600L one hour from UTC
- - offs_dl = 3600L one additional hour if daylight saving enabled
- - tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG )
- - tm_off = first Sunday from October 25, 03:00:00h ( year |= DL_AUTO_FLAG )
- - name[0] == "CET " name if daylight saving not enabled
- - name[1] == "CEST " name if daylight saving is enabled
+ - offs = 3600L one hour from UTC
+ - offs_dl = 3600L one additional hour if daylight saving enabled
+ - tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG )
+ - tm_off = first Sunday from October 25, 03:00:00h ( year |= DL_AUTO_FLAG )
+ - name[0] == "CET " name if daylight saving not enabled
+ - name[1] == "CEST " name if daylight saving is enabled
@{
*/
@@ -1183,8 +1426,8 @@ typedef struct
/**
- If the year in tzdl.tm_on and tzdl.tm_off is or'ed with that constant,
- the receiver automatically generates daylight saving year by year.
+ If the year in tzdl.tm_on and tzdl.tm_off is or'ed with that constant,
+ the receiver automatically generates daylight saving year by year.
*/
#define DL_AUTO_FLAG 0x8000
@@ -1197,8 +1440,8 @@ typedef struct
#define DEFAULt_TZDL_OFFS_DL 3600L /**< usually DST is +1 hour */
-/**
- The symbol below can be used to initialize both the tm_on
+/**
+ The symbol below can be used to initialize both the tm_on
and tm_off fields for time zones which do not switch to DST:
*/
#define DEFAULT_TZDL_TM_ON_OFF_NO_DST \
@@ -1221,7 +1464,7 @@ typedef struct
}
-/**
+/**
The symbols below specify beginning and end of DST for
Central Europe, as constituted by the European Parliament:
*/
@@ -1238,8 +1481,8 @@ typedef struct
#define TZ_INFO_CET_CEST_EN "CET/CEST (Central Europe)"
#define TZ_INFO_CET_CEST_DE "MEZ/MESZ (Mitteleuropa)"
-#define DEFAULT_TZDL_NAMES_CET_CEST_EN { "CET ", "CEST " }
-#define DEFAULT_TZDL_NAMES_CET_CEST_DE { "MEZ ", "MESZ " }
+#define DEFAULT_TZDL_NAMES_CET_CEST_EN { "CET ", "CEST " }
+#define DEFAULT_TZDL_NAMES_CET_CEST_DE { "MEZ ", "MESZ " }
#define DEFAULT_TZDL_OFFS_CET 3600L
@@ -1277,8 +1520,8 @@ typedef struct
#define TZ_INFO_EET_EEST_EN "EET/EEST (East Europe)"
#define TZ_INFO_EET_EEST_DE "OEZ/OEST (Osteuropa)"
-#define DEFAULT_TZDL_NAMES_EET_EEST_EN { "EET ", "EEST " }
-#define DEFAULT_TZDL_NAMES_EET_EEST_DE { "OEZ ", "OESZ " }
+#define DEFAULT_TZDL_NAMES_EET_EEST_EN { "EET ", "EEST " }
+#define DEFAULT_TZDL_NAMES_EET_EEST_DE { "OEZ ", "OESZ " }
#define DEFAULT_TZDL_OFFS_EET 7200L
@@ -1300,10 +1543,10 @@ typedef struct
DEFAULT_TZDL_NAMES_EET_EEST_DE /* name[] */ \
}
-/** @} */ // endgroup
+/** @} group_tzdl */
/**
- * The structure below reflects the status of the antenna,
+ * The structure below reflects the status of the antenna,
* the times of last disconnect/reconnect, and the board's
* clock offset after the disconnection interval.
*/
@@ -1324,8 +1567,8 @@ typedef struct
}
-/**
- The status field may be set to one of the values below:
+/**
+ The status field may be set to one of the values below:
*/
enum
{
@@ -1343,8 +1586,8 @@ enum
#define EF_FREQ_ALL 0x07 /**< all fixed freq. outputs on */
#define EF_SYNTH 0x01 /**< synth. on */
-/**
- The structure holds some flags which let
+/**
+ The structure holds some flags which let
the corresponding outputs be disabled after power-up until
the receiver has synchronized (flag == 0x00, the default) or force
the outputs to be enabled immediately after power-up. The fixed
@@ -1454,7 +1697,7 @@ enum
/*
* The bit masks below can be used to determine which baud rates
* are supported by a serial port. This may vary between
- * different ports of the same radio clock since different
+ * different ports of the same device since different
* types of UART are used which must not necessarily support
* each baud rate:
*/
@@ -1507,7 +1750,7 @@ enum
/*
* The bit masks below can be used to determine which framings
* are supported by a serial port. This may vary between
- * different ports of the same radio clock since different
+ * different ports of the same device since different
* types of UART are used which must not necessarily support
* each framing type:
*/
@@ -1522,6 +1765,12 @@ enum
#define MBG_PORT_HAS_8O1 ( 1UL << MBG_FRAMING_8O1 )
+// Default port settings to be used
+// with the binary protocol
+#define MBG_DEFAULT_BAUDRATE 19200L
+#define MBG_DEFAULT_FRAMING "8N1"
+
+
/*
* By default, the baud rates and framings below
@@ -1598,7 +1847,7 @@ typedef struct
/*
* The definitions below can be used to mark specific fields of a
- * PORT_SETTINGS structure, e.g. when editing build a mask indicating
+ * PORT_SETTINGS structure, e.g. when editing build a mask indicating
* which of the fields have changed or which are not valid.
*/
enum
@@ -1686,6 +1935,19 @@ typedef struct
}
+/**
+ * @brief Flags used with PORT_SETTINGS::flags and PORT_INFO::flags
+ */
+enum
+{
+ PORT_FLAG_BIT_PORT_INVISIBLE, /**< this port is used internally and should not be displayed by config apps */
+ N_PORT_FLAGS /**< the number of defined bits */
+};
+
+#define PORT_FLAG_PORT_INVISIBLE ( 1UL << PORT_FLAG_BIT_PORT_INVISIBLE )
+
+
+
/*
* The structure below adds an index number to the structure
* above to allow addressing of several instances:
@@ -1874,46 +2136,74 @@ enum
/**
- @defgroup group_icode Irig Codes
+ @defgroup group_icode IRIG codes
The following definitions are used to configure an optional
- on-board IRIG input or output.
+ on-board IRIG input or output. Which frame types are supported
+ by a device depends on the device type, and may eventually
+ depend on the device's firmware version.
- A GPS device can generate an IRIG output signal if the bit
- #GPS_HAS_IRIG_TX is set in the RECEIVER_INFO.features field.
- If a device has an optional IRIG input then the bit
- #GPS_HAS_IRIG_RX is set.
+ All IRIG frames transport the day-of-year number plus the time-of-day,
+ and include a control field segment which can transport user defined
+ information.
+ Some newer IRIG frames are compatible with older frame types but support
+ well defined extensions like the year number, local time offset, DST status,
+ etc., in the control fields:
- Supported IRIG signal code types:
- - \b A002: 1000 bps, DC shift, time-of-year
- - \b A003: 1000 bps, DC shift, time-of-year, SBS
+ - \b A002: 1000 bps, DCLS, time-of-year
+ - \b A003: 1000 bps, DCLS, time-of-year, SBS
- \b A132: 1000 bps, 10 kHz carrier, time-of-year
- \b A133: 1000 bps, 10 kHz carrier, time-of-year, SBS
- - \b B002: 100 bps, DC shift, time-of-year
- - \b B003: 100 bps, DC shift, time-of-year, SBS
+ - \b B002: 100 bps, DCLS, time-of-year
+ - \b B003: 100 bps, DCLS, time-of-year, SBS
- \b B122: 100 bps, 1 kHz carrier, time-of-year
- \b B123: 100 bps, 1 kHz carrier, time-of-year, SBS
+ - \b B006: 100 bps, DCLS, complete date
+ - \b B007: 100 bps, DCLS, complete date, SBS
+ - \b B126: 100 bps, 1 kHz carrier, complete date
+ - \b B127: 100 bps, 1 kHz carrier, complete date, SBS
+ - \b B220/1344: 100 bps, DCLS, manchester encoded, IEEE1344 extensions
+ - \b B222: 100 bps, DCLS, manchester encoded, time-of-year
+ - \b B223: 100 bps, DCLS, manchester encoded, time-of-year, SBS
+ - \b G002: 10 kbps, DCLS, time-of-year
+ - \b G142: 10 kbps, 100 kHz carrier, time-of-year
+ - \b G006: 10 kbps, DCLS, complete date
+ - \b G146: 10 kbps, 100 kHz carrier, complete date
- \b AFNOR: 100 bps, 1 kHz carrier, SBS, complete date
- - <b> AFNOR DC:</b> 100 bps, DC shift, SBS, complete date
+ - <b> AFNOR DC:</b> 100 bps, DCLS, SBS, complete date
- \b IEEE1344: 100 bps, 1 kHz carrier, time-of-year, SBS, IEEE1344 extensions (B120)
- - <b> IEEE1344 DC:</b> 100 bps, DC shift, time-of-year, SBS, IEEE1344 extensions (B000)
- - \b B220/1344: 100 bps, DC shift, manchester encoded, IEEE1344 extensions
- - \b B222: 100 bps, DC shift, manchester encoded, time-of-year
- - \b B223: 100 bps, DC shift, manchester encoded, time-of-year, SBS
-
+ - <b> IEEE1344 DC:</b> 100 bps, DCLS, time-of-year, SBS, IEEE1344 extensions (B000)
+ - \b C37.118: like IEEE1344, but UTC offset with reversed sign
+ - \b C37.118 DC: like IEEE1344 DC, but UTC offset with reversed sign
+
- time-of-year: day-of-year, hours, minutes, seconds
+ - complete date: time-of-year plus year number
- SBS: straight binary seconds, second-of-day
- - IEEE1344 extensions: time zone info
- - AFNOR: french standard AFNOR NFS-87500
-
+
+ AFNOR codes are based on the french standard AFNOR NF S87-500
+
+ IEEE1344 codes are defined in IEEE standard 1344-1995. The code frame is compatible
+ with B002/B122 but provides some well defined extensions in the control field which
+ include a quality indicator (time figure of merit, TFOM), year number, DST and leap
+ second status, and local time offset from UTC.
+
+ C37.118 codes are defined in IEEE standard C37.118-2005 which includes a revised version
+ of the IEEE 1344 standard from 1995. These codes provide the same extensions as IEEE 1344
+ but unfortunately define the UTC offset with reversed sign.
+
+ @note There are 3rd party IRIG devices out there which apply the UTC offset as specified
+ in C37.118, but claim to be compatible with IEEE 1344. So if local time is transmitted
+ by the IRIG signal then care must be taken that the UTC offset is evaluated by the IRIG
+ receiver in the same way as computed by the IRIG generator. Otherwise the UTC
+ time computed by the receiver may be <b>wrong</b>.
@{
*/
/**
- * Definitions used with IRIG transmitters which generate
- * the same IRIG code both with and without carrier signal
- * at the same time. */
+ * Definitions used with IRIG transmitters which usually output both
+ * the unmodulated and the modulated IRIG signals at the same time: */
enum
{
ICODE_TX_B002_B122,
@@ -1922,11 +2212,14 @@ enum
ICODE_TX_A003_A133,
ICODE_TX_AFNOR,
ICODE_TX_IEEE1344,
- ICODE_TX_B220_1344,
- ICODE_TX_B222,
- ICODE_TX_B223,
+ ICODE_TX_B2201344, // DCLS only
+ ICODE_TX_B222, // DCLS only
+ ICODE_TX_B223, // DCLS only
ICODE_TX_B006_B126,
ICODE_TX_B007_B127,
+ ICODE_TX_G002_G142,
+ ICODE_TX_G006_G146,
+ ICODE_TX_C37118,
N_ICODE_TX /**< number of code types */
};
@@ -1940,31 +2233,60 @@ enum
"B003+B123", \
"A002+A132", \
"A003+A133", \
- "AFNOR NFS-87500", \
+ "AFNOR NF S87-500", \
"IEEE1344", \
- "B220/1344+IEEE1344", \
- "B222+B122", \
- "B223+B123", \
+ "B220(1344) DCLS", \
+ "B222 DCLS", \
+ "B223 DCLS", \
"B006+B126", \
- "B007+B127" \
+ "B007+B127", \
+ "G002+G142", \
+ "G006+G146", \
+ "C37.118" \
+}
+
+/**
+ * Initializers for short name strings which must not
+ * be longer than 10 printable characters.
+ */
+#define DEFAULT_ICODE_TX_NAMES_SHORT \
+{ \
+ "B002+B122", \
+ "B003+B123", \
+ "A002+A132", \
+ "A003+A133", \
+ "AFNOR NF-S", \
+ "IEEE1344", \
+ "B220/1344", \
+ "B222 DC", \
+ "B223 DC", \
+ "B006+B126", \
+ "B007+B127", \
+ "G002+G142", \
+ "G006+G146", \
+ "C37.118" \
}
+
/**
* Initializers for English format description strings.
*/
-#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG \
-{ \
- "100 bps, DC or 1 kHz carrier", \
- "100 bps, DC or 1 kHz carrier, SBS", \
- "1000 bps, DC or 10 kHz carrier", \
- "1000 bps, DC or 10 kHz carrier, SBS", \
- "100 bps, DC or 1 kHz carrier, SBS, complete date", \
- "100 bps, DC or 1 kHz carrier, SBS, time zone info", \
- "100 bps, DC manchester enc. or 1kHz carrier, SBS, time zone info", \
- "100 bps, DC manchester enc. or 1kHz carrier, time-of-year", \
- "100 bps, DC manchester enc. or 1kHz carrier, time-of-year, SBS", \
- "100 bps, DC or 1 kHz carrier, complete date", \
- "100 bps, DC or 1 kHz carrier, complete date, SBS" \
+#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG \
+{ \
+ "100 bps, DCLS or 1 kHz carrier", \
+ "100 bps, DCLS or 1 kHz carrier, SBS", \
+ "1000 bps, DCLS or 10 kHz carrier", \
+ "1000 bps, DCLS or 10 kHz carrier, SBS", \
+ "100 bps, DCLS or 1 kHz carrier, SBS, complete date", \
+ "100 bps, DCLS or 1 kHz carrier, SBS, complete date, time zone info", \
+ "100 bps, Manchester enc., DCLS only, SBS, complete date, time zone info", \
+ "100 bps, Manchester enc., DCLS only", \
+ "100 bps, Manchester enc., DCLS only, SBS", \
+ "100 bps, DCLS or 1 kHz carrier, complete date", \
+ "100 bps, DCLS or 1 kHz carrier, complete date, SBS", \
+ "10 kbps, DCLS or 100 kHz carrier", \
+ "10 kbps, DCLS or 100 kHz carrier, complete date", \
+ "like IEEE1344, but UTC offset with reversed sign" \
}
/*
@@ -1978,19 +2300,22 @@ enum
#define MSK_ICODE_TX_A003_A133 ( 1UL << ICODE_TX_A003_A133 )
#define MSK_ICODE_TX_AFNOR ( 1UL << ICODE_TX_AFNOR )
#define MSK_ICODE_TX_IEEE1344 ( 1UL << ICODE_TX_IEEE1344 )
-#define MSK_ICODE_TX_B220_1344 ( 1UL << ICODE_TX_B220_1344 )
+#define MSK_ICODE_TX_B2201344 ( 1UL << ICODE_TX_B2201344 )
#define MSK_ICODE_TX_B222 ( 1UL << ICODE_TX_B222 )
#define MSK_ICODE_TX_B223 ( 1UL << ICODE_TX_B223 )
#define MSK_ICODE_TX_B006_B126 ( 1UL << ICODE_TX_B006_B126 )
#define MSK_ICODE_TX_B007_B127 ( 1UL << ICODE_TX_B007_B127 )
+#define MSK_ICODE_TX_G002_G142 ( 1UL << ICODE_TX_G002_G142 )
+#define MSK_ICODE_TX_G006_G146 ( 1UL << ICODE_TX_G006_G146 )
+#define MSK_ICODE_TX_C37118 ( 1UL << ICODE_TX_C37118 )
/**
* A mask of IRIG formats with manchester encoded DC output:
*/
#define MSK_ICODE_TX_DC_MANCH \
( \
- MSK_ICODE_TX_B220_1344 | \
- MSK_ICODE_TX_B222 | \
+ MSK_ICODE_TX_B2201344 | \
+ MSK_ICODE_TX_B222 | \
MSK_ICODE_TX_B223 \
)
@@ -2003,11 +2328,12 @@ enum
MSK_ICODE_TX_B003_B123 | \
MSK_ICODE_TX_AFNOR | \
MSK_ICODE_TX_IEEE1344 | \
- MSK_ICODE_TX_B220_1344 | \
+ MSK_ICODE_TX_B2201344 | \
MSK_ICODE_TX_B222 | \
MSK_ICODE_TX_B223 | \
MSK_ICODE_TX_B006_B126 | \
- MSK_ICODE_TX_B007_B127 \
+ MSK_ICODE_TX_B007_B127 | \
+ MSK_ICODE_TX_C37118 \
)
/**
@@ -2020,6 +2346,15 @@ enum
)
/**
+ * A mask of IRIG formats with 100 kHz carrier:
+ */
+#define MSK_ICODE_TX_100KHZ \
+( \
+ MSK_ICODE_TX_G002_G142 | \
+ MSK_ICODE_TX_G006_G146 \
+)
+
+/**
* A mask of IRIG formats with 100 bps data rate:
*/
#define MSK_ICODE_TX_100BPS \
@@ -2029,7 +2364,8 @@ enum
MSK_ICODE_TX_AFNOR | \
MSK_ICODE_TX_IEEE1344 | \
MSK_ICODE_TX_B006_B126 | \
- MSK_ICODE_TX_B007_B127 \
+ MSK_ICODE_TX_B007_B127 | \
+ MSK_ICODE_TX_C37118 \
)
/**
@@ -2042,11 +2378,21 @@ enum
)
/**
+ * A mask of IRIG formats with 10 kbps data rate:
+ */
+#define MSK_ICODE_TX_10000BPS \
+( \
+ MSK_ICODE_TX_G002_G142 | \
+ MSK_ICODE_TX_G006_G146 \
+)
+
+/**
* A mask of IRIG formats which support TFOM:
*/
#define MSK_ICODE_TX_HAS_TFOM \
( \
- MSK_ICODE_TX_IEEE1344 \
+ MSK_ICODE_TX_IEEE1344 | \
+ MSK_ICODE_TX_C37118 \
)
/**
@@ -2054,7 +2400,8 @@ enum
*/
#define MSK_ICODE_TX_HAS_TZI \
( \
- MSK_ICODE_TX_IEEE1344 \
+ MSK_ICODE_TX_IEEE1344 | \
+ MSK_ICODE_TX_C37118 \
)
/**
@@ -2076,21 +2423,27 @@ enum
/**
* Definitions used with IRIG receivers which decode
- * two similar IRIG codes
+ * two similar IRIG codes (with or without SBS)
* at the same time.
*/
enum
{
- ICODE_RX_B122_B123,
- ICODE_RX_A132_A133,
- ICODE_RX_B002_B003,
- ICODE_RX_A002_A003,
- ICODE_RX_AFNOR,
- ICODE_RX_AFNOR_DC,
- ICODE_RX_IEEE1344,
- ICODE_RX_IEEE1344_DC,
- ICODE_RX_B126_B127,
- ICODE_RX_B006_B007,
+ ICODE_RX_B122_B123, // modulated
+ ICODE_RX_A132_A133, // modulated
+ ICODE_RX_B002_B003, // DCLS
+ ICODE_RX_A002_A003, // DCLS
+ ICODE_RX_AFNOR, // modulated
+ ICODE_RX_AFNOR_DC, // DCLS
+ ICODE_RX_IEEE1344, // modulated
+ ICODE_RX_IEEE1344_DC, // DCLS
+ ICODE_RX_B126_B127, // modulated
+ ICODE_RX_B006_B007, // DCLS
+ ICODE_RX_G142_G146, // modulated
+ ICODE_RX_G002_G006, // DCLS
+ ICODE_RX_C37118, // modulated
+ ICODE_RX_C37118_DC, // DCLS
+ ICODE_RX_TXC_101, // modulated
+ ICODE_RX_TXC_101_DC, // DCLS
N_ICODE_RX /* the number of valid signal code types */
};
@@ -2101,16 +2454,47 @@ enum
{ \
"B122/B123", \
"A132/A133", \
- "B002/B003 (DC)", \
- "A002/A003 (DC)", \
- "AFNOR NFS-87500", \
- "AFNOR NFS-87500 (DC)", \
+ "B002/B003 (DCLS)", \
+ "A002/A003 (DCLS)", \
+ "AFNOR NF S87-500", \
+ "AFNOR NF S87-500 (DCLS)", \
"IEEE1344", \
- "IEEE1344 (DC)", \
+ "IEEE1344 (DCLS)", \
"B126/B127", \
- "B006/B007 (DC)" \
+ "B006/B007 (DCLS)", \
+ "G142/G146", \
+ "G002/G006 (DCLS)", \
+ "C37.118", \
+ "C37.118 (DCLS)", \
+ "TXC-101 DTR-6", \
+ "TXC-101 DTR-6 (DCLS)" \
+}
+
+/**
+ * Initializers for short name strings which must not
+ * be longer than 11 printable characters.
+ */
+#define DEFAULT_ICODE_RX_NAMES_SHORT \
+{ \
+ "B122/B123", \
+ "A132/A133", \
+ "B002/B003", \
+ "A002/A003", \
+ "AFNOR NF-S", \
+ "AFNOR DC", \
+ "IEEE1344", \
+ "IEEE1344 DC", \
+ "B126/B127", \
+ "B006/B007", \
+ "G142/G146", \
+ "G002/G006", \
+ "C37.118", \
+ "C37.118 DC", \
+ "TXC-101", \
+ "TXC-101 DC" \
}
+
/**
* Initializers for English format description strings.
*/
@@ -2118,14 +2502,20 @@ enum
{ \
"100 bps, 1 kHz carrier, SBS optionally", \
"1000 bps, 10 kHz carrier, SBS optionally", \
- "100 bps, DC shift, SBS optionally", \
- "1000 bps, DC shift, SBS optionally", \
+ "100 bps, DCLS, SBS optionally", \
+ "1000 bps, DCLS, SBS optionally", \
"100 bps, 1 kHz carrier, SBS, complete date", \
- "100 bps, DC shift, SBS, complete date", \
+ "100 bps, DCLS, SBS, complete date", \
"100 bps, 1 kHz carrier, SBS, time zone info", \
- "100 bps, DC shift, SBS, time zone info", \
+ "100 bps, DCLS, SBS, time zone info", \
"100 bps, 1 kHz carrier, complete date, SBS optionally", \
- "100 bps, DC shift, complete date, SBS optionally" \
+ "100 bps, DCLS, complete date, SBS optionally", \
+ "10 kbps, 100 kHz carrier, complete date optionally", \
+ "10 kbps, DCLS, complete date optionally", \
+ "like IEEE1344, but UTC offset with reversed sign", \
+ "like IEEE1344 DC, but UTC offset with reversed sign", \
+ "code from TV time sync device TXC-101 DTR-6", \
+ "DC code from TV time sync device TXC-101 DTR-6" \
}
/*
@@ -2141,17 +2531,26 @@ enum
#define MSK_ICODE_RX_IEEE1344_DC ( 1UL << ICODE_RX_IEEE1344_DC )
#define MSK_ICODE_RX_B126_B127 ( 1UL << ICODE_RX_B126_B127 )
#define MSK_ICODE_RX_B006_B007 ( 1UL << ICODE_RX_B006_B007 )
+#define MSK_ICODE_RX_G142_G146 ( 1UL << ICODE_RX_G142_G146 )
+#define MSK_ICODE_RX_G002_G006 ( 1UL << ICODE_RX_G002_G006 )
+#define MSK_ICODE_RX_C37118 ( 1UL << ICODE_RX_C37118 )
+#define MSK_ICODE_RX_C37118_DC ( 1UL << ICODE_RX_C37118_DC )
+#define MSK_ICODE_RX_TXC_101 ( 1UL << ICODE_RX_TXC_101 )
+#define MSK_ICODE_RX_TXC_101_DC ( 1UL << ICODE_RX_TXC_101_DC )
/**
- * A mask of IRIG formats which have DC shift:
+ * A mask of IRIG DCLS formats:
*/
-#define MSK_ICODE_RX_DC \
-( \
- MSK_ICODE_RX_B002_B003 | \
- MSK_ICODE_RX_A002_A003 | \
- MSK_ICODE_RX_AFNOR_DC | \
- MSK_ICODE_RX_IEEE1344_DC | \
- MSK_ICODE_RX_B006_B007 \
+#define MSK_ICODE_RX_DC \
+( \
+ MSK_ICODE_RX_B002_B003 | \
+ MSK_ICODE_RX_A002_A003 | \
+ MSK_ICODE_RX_AFNOR_DC | \
+ MSK_ICODE_RX_IEEE1344_DC | \
+ MSK_ICODE_RX_B006_B007 | \
+ MSK_ICODE_RX_G002_G006 | \
+ MSK_ICODE_RX_C37118_DC | \
+ MSK_ICODE_RX_TXC_101_DC \
)
/**
@@ -2162,7 +2561,9 @@ enum
MSK_ICODE_RX_B122_B123 | \
MSK_ICODE_RX_AFNOR | \
MSK_ICODE_RX_IEEE1344 | \
- MSK_ICODE_RX_B126_B127 \
+ MSK_ICODE_RX_B126_B127 | \
+ MSK_ICODE_RX_C37118 | \
+ MSK_ICODE_RX_TXC_101 \
)
/**
@@ -2174,18 +2575,30 @@ enum
)
/**
+ * A mask of IRIG formats with 100 kHz carrier:
+ */
+#define MSK_ICODE_RX_100KHZ \
+( \
+ MSK_ICODE_RX_G142_G146 \
+)
+
+/**
* A mask of IRIG formats with 100 bps data rate:
*/
#define MSK_ICODE_RX_100BPS \
( \
- MSK_ICODE_RX_B122_B123 | \
- MSK_ICODE_RX_B002_B003 | \
- MSK_ICODE_RX_AFNOR | \
- MSK_ICODE_RX_AFNOR_DC | \
- MSK_ICODE_RX_IEEE1344 | \
- MSK_ICODE_RX_IEEE1344_DC | \
- MSK_ICODE_RX_B126_B127 | \
- MSK_ICODE_RX_B006_B007 \
+ MSK_ICODE_RX_B122_B123 | \
+ MSK_ICODE_RX_B002_B003 | \
+ MSK_ICODE_RX_AFNOR | \
+ MSK_ICODE_RX_AFNOR_DC | \
+ MSK_ICODE_RX_IEEE1344 | \
+ MSK_ICODE_RX_IEEE1344_DC | \
+ MSK_ICODE_RX_B126_B127 | \
+ MSK_ICODE_RX_B006_B007 | \
+ MSK_ICODE_RX_C37118 | \
+ MSK_ICODE_RX_C37118_DC | \
+ MSK_ICODE_RX_TXC_101 | \
+ MSK_ICODE_RX_TXC_101_DC \
)
/**
@@ -2198,21 +2611,34 @@ enum
)
/**
+ * A mask of IRIG formats with 10 kbps data rate:
+ */
+#define MSK_ICODE_RX_10000BPS \
+( \
+ MSK_ICODE_RX_G142_G146 | \
+ MSK_ICODE_RX_G002_G006 \
+)
+
+/**
* A mask of IRIG formats which support TFOM:
*/
#define MSK_ICODE_RX_HAS_TFOM \
( \
- MSK_ICODE_RX_IEEE1344 | \
- MSK_ICODE_RX_IEEE1344_DC \
+ MSK_ICODE_RX_IEEE1344 | \
+ MSK_ICODE_RX_IEEE1344_DC | \
+ MSK_ICODE_RX_C37118 | \
+ MSK_ICODE_RX_C37118_DC \
)
/**
* A mask of IRIG formats which support time zone information:
*/
-#define MSK_ICODE_RX_HAS_TZI \
-( \
- MSK_ICODE_RX_IEEE1344 | \
- MSK_ICODE_RX_IEEE1344_DC \
+#define MSK_ICODE_RX_HAS_TZI \
+( \
+ MSK_ICODE_RX_IEEE1344 | \
+ MSK_ICODE_RX_IEEE1344_DC | \
+ MSK_ICODE_RX_C37118 | \
+ MSK_ICODE_RX_C37118_DC \
)
/**
@@ -2230,7 +2656,10 @@ enum
MSK_ICODE_RX_AFNOR_DC \
)
#endif
-/** @} */
+
+/** @} group_icode */
+
+
/**
* The structure below is used to configure an optional
@@ -2250,21 +2679,29 @@ typedef struct
/**
- @defgroup group_irig_flags Bit Masks used with IRIG_SETTINGS.flags
-
- (others are reserved)
-* @{
+ * @defgroup group_irig_flags Bit Masks used with IRIG_SETTINGS::flags
+ *
+ * (others are reserved)
+ * @{
*/
#define IFLAGS_DISABLE_TFOM 0x0001 /**< RX ignore/TX don't gen TFOM */
#define IFLAGS_TX_GEN_LOCAL_TIME 0x0002 /**< gen local time, not UTC */
#define IFLAGS_MASK 0x0003 /**< flags above or'ed */
-/** @} */
+// Note: the presence or absence of the IFLAGS_DISABLE_TFOM flag for the IRIG RX
+// settings of some PCI cards may not be evaluated correctly by some firmware
+// versions for those cards, even if an IRIG code has been configured which supports
+// this flag. See the comments near the declaration of the _pcps_incoming_tfom_ignored()
+// macro in pcpsdev.h for details.
+
+/** @} group_irig_flags */
/**
- * The structure is used to query the IRIG configuration
- * plus the supported codes:
+ * @brief Current IRIG settings and supported codes
+ *
+ * Used to query the IRIG current IRIG settings
+ * plus a mask of supported codes.
*/
typedef struct
{
@@ -2279,10 +2716,127 @@ typedef struct
}
+/**
+ * @defgroup group_irig_comp IRIG input delay compensation
+ *
+ * These definitions are used with IRIG RX delay compensation
+ * which is supported by some IRIG receivers. Delay compensation
+ * depends on the basic frame type, so there are different records
+ * required for the different frame type groups.
+ * @{ */
+
+/**
+ * The number of coefficients of a compensation record
+ * for a single frame type group, and the structure
+ * which contains those coefficients.
+ */
+#define N_IRIG_RX_COMP_VAL 4
+
+/** @brief A structure which stores compensation values. */
+typedef struct
+{
+ /** Delay compensation values [100 ns units].
+ *
+ * Only the first value is actually used to compensate a delay,
+ * so the remaining values should be 0.
+ */
+ int16_t c[N_IRIG_RX_COMP_VAL];
+
+} IRIG_RX_COMP;
+
+#define _mbg_swab_irig_rx_comp( _p ) \
+{ \
+ int i; \
+ for ( i = 0; i < N_IRIG_RX_COMP_VAL; i++ ) \
+ _mbg_swab16( &(_p)->c[i] ); \
+}
+
+
+/** The absolute value of the maximum compensation value accepted by a device */
+#define IRIG_RX_COMP_MAX 999 // [100 ns units], i.e. valid range is +/-99.9 us
+
+
+
+/** @brief Structure used to retrieve the number of records for a given type */
+typedef struct
+{
+ uint16_t type; /**< record type */
+ uint16_t idx; /**< index if several records of same type are supported */
+} CAL_REC_HDR;
+
+#define _mbg_swab_cal_rec_hdr( _p ) \
+{ \
+ _mbg_swab16( &(_p)->type ); \
+ _mbg_swab16( &(_p)->idx ); \
+}
+
+
+/** @brief Types to be used with CAL_REC_HDR::type */
+enum
+{
+ CAL_REC_TYPE_UNDEF, /**< undefined */
+ CAL_REC_TYPE_IRIG_RX_COMP, /**< IRIG receiver delay compensation */
+ N_CAL_REC_TYPE /**< number of known types */
+};
+
+
+/**
+ * @brief Types to be used with CAL_REC_HDR::idx
+ *
+ * IRIG frame type groups to be distinguished for delay compensation.
+ */
+enum
+{
+ IRIG_RX_COMP_B1, /**< codes B1xx, AFNOR, IEEE1344 */
+ IRIG_RX_COMP_A1, /**< code A1xx */
+ IRIG_RX_COMP_B0, /**< codes B0xx, AFNOR DC, IEEE1344 DC */
+ IRIG_RX_COMP_A0, /**< code A0xx */
+ IRIG_RX_COMP_G1, /**< code G14x */
+ IRIG_RX_COMP_G0, /**< code G00x */
+ N_IRIG_RX_COMP /**< number of compensation values */
+};
+
+
+/** @brief Initializers for format name strings. */
+#define DEFAULT_IRIG_RX_COMP_NAMES \
+{ \
+ "B1xx/AFNOR/IEEE1344", \
+ "A1xx", \
+ "B0xx/AFNOR DC/IEEE1344 DC", \
+ "A0xx", \
+ "G14X", \
+ "G00X", \
+}
+
+
+
+/** @brief Structure used to transfer calibration records. */
+typedef struct
+{
+ CAL_REC_HDR hdr;
+ IRIG_RX_COMP comp_data; /**< IRIG receiver delay compensation */
+
+} CAL_REC_IRIG_RX_COMP;
+
+#define _mbg_swab_cal_rec_irig_rx_comp( _p ) \
+{ \
+ _mbg_swab_cal_rec_hdr( &(_p)->hdr ); \
+ _mbg_swab_irig_rx_comp( &(_p)->comp_data ); \
+}
+
+/** @} group_irig_comp */
+
+
+
// The type below is used to read the board's debug status
// which also include IRIG decoder status:
typedef uint32_t MBG_DEBUG_STATUS;
+#define _mbg_swab_debug_status( _p ) \
+ _mbg_swab32( _p )
+
+
+
// The debug status is bit coded as defined below:
enum
{
@@ -2395,19 +2949,63 @@ enum
#define MBG_OPT_FLAG_EMU_SYNC ( 1UL << MBG_OPT_BIT_EMU_SYNC )
-/**
- @defgroup group_scale Time Scale Configuration
- The structures and defines can be used to configure the GPS receiver's
- basic time scale. By default this is UTC which can optionally
- be converted to some local time. However, some applications
- prefer TAI or pure GPS time. This can be configured using the
- structures below if the GPS_HAS_TIME_SCALE flag is set in
+// bit coded return type for PCPS_GET_IRIG_CTRL_BITS
+typedef uint32_t MBG_IRIG_CTRL_BITS;
+
+#define _mbg_swab_irig_ctrl_bits( _p ) _mbg_swab32( _p )
+
+
+// The following macro extracts the 4 bit TFOM code from the
+// IRIG control bits read from a card. This only works if the received
+// IRIG code is a code which supports TFOM, this is currently
+// only IEEE1344.
+#define _pcps_tfom_from_irig_ctrl_bits( _p ) \
+ ( ( ( *(_p) ) >> 24 ) & 0x0F )
+
+
+
+#define RAW_IRIG_SIZE 16
+
+/**
+ The buffer below can be used to get the raw data bits
+ from the IRIG decoder. A maximum number of RAW_IRIG_SIZE
+ bytes can be filled. If less bytes are used then the rest
+ of the bytes are filled with zeros.
+
+ The first IRIG bit received from the transmitter is saved
+ in the MSB (bit 7) of data_bytes[0], etc.
+*/
+typedef struct
+{
+ uint8_t data_bytes[RAW_IRIG_SIZE];
+} MBG_RAW_IRIG_DATA;
+
+// The following macro extracts the 4 bit TFOM code from the raw
+// data bits read from a card. This only works if the received
+// IRIG code is a code which supports TFOM, this is currently
+// only IEEE1344.
+#define _pcps_tfom_from_raw_irig_data( _p ) \
+ ( ( ( (_p)->data_bytes[9] >> 2 ) & 0x08 ) \
+ | ( ( (_p)->data_bytes[9] >> 4 ) & 0x04 ) \
+ | ( ( (_p)->data_bytes[9] >> 6 ) & 0x02 ) \
+ | ( ( (_p)->data_bytes[8] & 0x01 ) ) )
+
+
+
+/**
+ @defgroup group_time_scale Time Scale Configuration
+
+ The structures and defines can be used to configure the GPS receiver's
+ basic time scale. By default this is UTC which can optionally
+ be converted to some local time. However, some applications
+ prefer TAI or pure GPS time. This can be configured using the
+ structures below if the GPS_HAS_TIME_SCALE flag is set in
RECEIVER_INFO::features.
@{
*/
-enum
+enum MBG_TIME_SCALES
{
MBG_TIME_SCALE_DEFAULT, /**< UTC or local time, t_gps - deltat_ls */
MBG_TIME_SCALE_GPS, /**< GPS time, monotonical */
@@ -2432,7 +3030,7 @@ enum
-/**
+/**
The fixed time offset between the GPS and TAI time scales, in seconds
*/
#define GPS_TAI_OFFSET 19 /**< [s], TAI = GPS + GPS_TAI_OFFSET */
@@ -2440,7 +3038,7 @@ enum
typedef struct
{
- uint8_t scale; /**< current time scale code from the enum above */
+ uint8_t scale; /**< current time scale code from enum MBG_TIME_SCALES */
uint8_t flags; /**< reserved, currently always 0 */
} MBG_TIME_SCALE_SETTINGS;
@@ -2462,7 +3060,7 @@ typedef struct
_mbg_swab32( &(_p)->supp_scales ); \
}
-/** @} */ // endgroup
+/** @} group_time_scale */
/*
@@ -2493,10 +3091,10 @@ typedef struct
*/
typedef struct
{
- uint8_t hour; /* 0..23 */
- uint8_t min; /* 0..59 */
- uint8_t sec; /* 0..59,60 */
- uint8_t sec100; /* reserved, currently always 0 */
+ uint8_t hour; /**< 0..23 */
+ uint8_t min; /**< 0..59 */
+ uint8_t sec; /**< 0..59,60 */
+ uint8_t sec100; /**< reserved, currently always 0 */
} MBG_TIME;
#define _mbg_swab_mbg_time( _p ) \
@@ -2554,21 +3152,76 @@ typedef struct
uint16_t pulse_len; /**< 10 msec units, or COM port number */
uint16_t timeout; /**< [min], for dcf_mode */
uint16_t flags; /**< see below */
- POUT_TIME tm[N_POUT_TIMES]; /**< switching times */
+ POUT_TIME tm[N_POUT_TIMES]; /**< switching times, or other data */
} POUT_SETTINGS;
-#define _mbg_swab_pout_settings( _p ) \
-{ \
- int i; \
- _mbg_swab16( &(_p)->mode ); \
- _mbg_swab16( &(_p)->pulse_len ); \
- _mbg_swab32( &(_p)->timeout ); \
- _mbg_swab16( &(_p)->flags ); \
- \
- for ( i = 0; i < N_POUT_TIMES; i++ ) \
- _mbg_swab_pout_time( &(_p)->tm[i] ); \
+// If the mode is set to POUT_TIME_SLOTS then POUT_SETTINGS::tm must be
+// interpretet as POUT_DATA, i.e. just an array of bytes. We can not change
+// the type of the tm field to a union for compatibility reasons ...
+typedef union
+{
+ uint8_t b[N_POUT_TIMES * sizeof( POUT_TIME )];
+} POUT_DATA;
+
+// In POUT_TIME_SLOTS mode the number of time slots per minute is stored
+// in the pulse_len field. Valid numbers all numbers n in the range 1..60
+// for which the remainder of 60 / n is 0.
+#define MIN_TIME_SLOTS_PER_MINUTE 1
+#define MAX_TIME_SLOTS_PER_MINUTE 60
+#define TIME_SLOT_REGISTER_IN_SEC 60
+
+#define TIME_SLOT_SWITCH_OFF_BUFFER_MIN 50
+#define TIME_SLOT_SWITCH_OFF_BUFFER_MAX 500
+#define TIME_SLOT_SWITCH_OFF_BUFFER_STD 500
+#define TIME_SLOT_SWITCH_OFF_BUFFER_STEP_SIZE 50
+
+#define _valid_time_slots_per_minute( _n ) \
+ ( ( (_n) >= MIN_TIME_SLOTS_PER_MINUTE ) && \
+ ( (_n) <= MAX_TIME_SLOTS_PER_MINUTE ) && \
+ ( ( 60 % (_n) ) == 0 ) \
+ )
+
+
+// When reading data from a device we first need to correct the endianess
+// of the mode first, and correct the endianess of the tm field only
+// if the tm field is not interpreted as POUT_DATA.
+#define _mbg_swab_pout_settings_on_get( _p ) \
+{ \
+ _mbg_swab16( &(_p)->mode ); \
+ _mbg_swab16( &(_p)->pulse_len ); \
+ _mbg_swab16( &(_p)->timeout ); \
+ _mbg_swab16( &(_p)->flags ); \
+ \
+ if ( (_p)->mode != POUT_TIME_SLOTS ) \
+ { \
+ int i; \
+ \
+ for ( i = 0; i < N_POUT_TIMES; i++ ) \
+ _mbg_swab_pout_time( &(_p)->tm[i] ); \
+ } \
}
+// When writing data to a device we first need to check the mode,
+// and correct the endianess of the tm field only if the tm field
+// is not interpreted as POUT_DATA. Finally we can also correct
+// the endianess of the mode field.
+#define _mbg_swab_pout_settings_on_set( _p ) \
+{ \
+ if ( (_p)->mode != POUT_TIME_SLOTS ) \
+ { \
+ int i; \
+ \
+ for ( i = 0; i < N_POUT_TIMES; i++ ) \
+ _mbg_swab_pout_time( &(_p)->tm[i] ); \
+ } \
+ \
+ _mbg_swab16( &(_p)->mode ); \
+ _mbg_swab16( &(_p)->pulse_len ); \
+ _mbg_swab16( &(_p)->timeout ); \
+ _mbg_swab16( &(_p)->flags ); \
+}
+
+
#define MAX_POUT_PULSE_LEN 1000 /**< 10 secs, in 10 msec units */
#define MAX_POUT_DCF_TIMOUT ( 48 * 60 ) /**< 48 hours, in minutes */
@@ -2595,6 +3248,9 @@ enum
POUT_TIMECODE, /**< IRIG/AFNOR DCLS output */
POUT_TIMESTR, /**< COM port number in pulse_len field */
POUT_10MHZ, /**< 10 MHz fixed frequency */
+ POUT_DCF77_M59, /**< DCF77-like signal with 500 ms pulse in 59th second */
+ POUT_SYNTH, /**< programmable synthesizer frequency */
+ POUT_TIME_SLOTS, /**< programmable time slots during each minute */
N_POUT_MODES
};
@@ -2617,6 +3273,9 @@ enum
#define ENG_POUT_NAME_TIMECODE "DCLS Time Code"
#define ENG_POUT_NAME_TIMESTR "COM Time String"
#define ENG_POUT_NAME_10MHZ "10 MHz Frequency"
+#define ENG_POUT_NAME_DCF77_M59 "DCF77-like M59"
+#define ENG_POUT_NAME_SYNTH "Synthesizer Frequency"
+#define ENG_POUT_NAME_TIME_SLOTS "Time Slots per Minute"
#define DEFAULT_ENG_POUT_NAMES \
{ \
@@ -2633,7 +3292,10 @@ enum
ENG_POUT_NAME_ALL_SYNC, \
ENG_POUT_NAME_TIMECODE, \
ENG_POUT_NAME_TIMESTR, \
- ENG_POUT_NAME_10MHZ \
+ ENG_POUT_NAME_10MHZ, \
+ ENG_POUT_NAME_DCF77_M59, \
+ ENG_POUT_NAME_SYNTH, \
+ ENG_POUT_NAME_TIME_SLOTS \
}
@@ -2651,6 +3313,9 @@ enum
#define ENG_POUT_HINT_TIMECODE "Duplicate IRIG time code signal"
#define ENG_POUT_HINT_TIMESTR "Duplicate serial time string of specified port"
#define ENG_POUT_HINT_10MHZ "10 MHz fixed output frequency"
+#define ENG_POUT_HINT_DCF77_M59 "DCF77 time marks with 500 ms pulse in 59th second"
+#define ENG_POUT_HINT_SYNTH "Frequency generated by programmable synthesizer"
+#define ENG_POUT_HINT_TIME_SLOTS "Output enabled during specified time slots per minute"
#define DEFAULT_ENG_POUT_HINTS \
{ \
@@ -2667,7 +3332,10 @@ enum
ENG_POUT_HINT_ALL_SYNC, \
ENG_POUT_HINT_TIMECODE, \
ENG_POUT_HINT_TIMESTR, \
- ENG_POUT_HINT_10MHZ \
+ ENG_POUT_HINT_10MHZ, \
+ ENG_POUT_HINT_DCF77_M59, \
+ ENG_POUT_HINT_SYNTH, \
+ ENG_POUT_HINT_TIME_SLOTS \
}
@@ -2690,12 +3358,17 @@ enum
#define MSK_POUT_TIMECODE ( 1UL << POUT_TIMECODE )
#define MSK_POUT_TIMESTR ( 1UL << POUT_TIMESTR )
#define MSK_POUT_10MHZ ( 1UL << POUT_10MHZ )
+#define MSK_POUT_DCF77_M59 ( 1UL << POUT_DCF77_M59 )
+#define MSK_POUT_SYNTH ( 1UL << POUT_SYNTH )
+#define MSK_POUT_TIME_SLOTS ( 1UL << POUT_TIME_SLOTS )
/*
- * The codes below are used with POUT_SETTINGS.flags:
+ * The codes below are used with POUT_SETTINGS::flags:
*/
-#define POUT_INVERTED 0x0001
+#define POUT_INVERTED 0x0001 // invert output level
+#define POUT_IF_SYNC_ONLY 0x0002 // disable in holdover mode
+#define POUT_TIMEBASE_UTC 0x0004 // use UTC, only applicable for DCF77 output
/**
@@ -2711,18 +3384,24 @@ typedef struct
POUT_SETTINGS pout_settings;
} POUT_SETTINGS_IDX;
-#define _mbg_swab_pout_settings_idx( _p ) \
-{ \
- _mbg_swab16( &(_p)->idx ); \
- _mbg_swab_pout_settings( &(_p)->pout_settings ); \
+#define _mbg_swab_pout_settings_idx_on_set( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_pout_settings_on_set( &(_p)->pout_settings ); \
+}
+
+#define _mbg_swab_pout_settings_idx_on_get( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_pout_settings_on_get( &(_p)->pout_settings ); \
}
/**
The structure below holds the current settings
- for a programmable pulse output, plus additional
- informaton on the output's capabilities.
- This can be read by setup programs to allow setup
+ for a programmable pulse output, plus additional
+ informaton on the output's capabilities.
+ This can be read by setup programs to allow setup
of supported features only.
*/
typedef struct
@@ -2732,21 +3411,29 @@ typedef struct
uint8_t timestr_ports; /**< bit mask of COM ports supported for POUT_TIMESTR */
uint8_t reserved_0; /**< reserved for future use, currently 0 */
uint16_t reserved_1; /**< reserved for future use, currently 0 */
- uint32_t flags; /**< reserved for future use, currently 0 */
+ uint32_t flags; /**< see below */
} POUT_INFO;
-#define _mbg_swab_pout_info( _p ) \
-{ \
- _mbg_swab_pout_settings( &(_p)->pout_settings ); \
- _mbg_swab32( &(_p)->supp_modes ); \
- _mbg_swab16( &(_p)->reserved_1 ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_pout_info_on_get( _p ) \
+{ \
+ _mbg_swab_pout_settings_on_get( &(_p)->pout_settings ); \
+ _mbg_swab32( &(_p)->supp_modes ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->flags ); \
}
/** The max number of COM ports that can be handled by POUT_INFO::timestr_ports */
#define MAX_POUT_TIMESTR_PORTS 8
+
+/*
+ * The codes below are used with POUT_INFO::flags:
+ */
+#define POUT_SUPP_IF_SYNC_ONLY 0x0001 // supports disabling outputs in holdover mode
+#define POUT_SUPP_DCF77_UTC 0x0002 // supports UTC output in DCF77 mode
+
+
/**
The structure below adds an index number to the structure
above to allow addressing of several instances:
@@ -2757,36 +3444,42 @@ typedef struct
POUT_INFO pout_info;
} POUT_INFO_IDX;
-#define _mbg_swab_pout_info_idx( _p ) \
-{ \
- _mbg_swab16( &(_p)->idx ); \
- _mbg_swab_pout_info( &(_p)->pout_info ); \
+#define _mbg_swab_pout_info_idx_on_get( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_pout_info_on_get( &(_p)->pout_info ); \
}
-/*
- * The codes below are used with devices which support multiple
+/*
+ * The codes below are used with devices which support multiple
* ref time sources at the same time. The priorities of the
* supported ref time sources is configurable.
*/
-/*
- * All possibly supported ref time sources
+/**
+ * @brief All possibly supported ref time sources
*/
-enum
+enum MULTI_REF_TYPES
{
- MULTI_REF_NONE = -1, // nothing, undefined
- MULTI_REF_GPS = 0, // standard GPS
- MULTI_REF_10MHZ, // 10 MHz input frequency
- MULTI_REF_PPS, // 1 PPS input signal
- MULTI_REF_10MHZ_PPS, // combined 10 MHz plus PPS
- MULTI_REF_IRIG, // IRIG input
- MULTI_REF_NTP, // Network Time Protocol (NTP)
- MULTI_REF_PTP, // Precision Time Protocol (PTP, IEEE1588)
- MULTI_REF_PTP_E1, // PTP over E1
- MULTI_REF_FREQ, // fixed frequency
- N_MULTI_REF // the number of defined sources
+ MULTI_REF_NONE = -1, /**< nothing, undefined */
+ MULTI_REF_GPS = 0, /**< standard GPS */
+ MULTI_REF_10MHZ, /**< 10 MHz input frequency */
+ MULTI_REF_PPS, /**< 1 PPS input signal */
+ MULTI_REF_10MHZ_PPS, /**< combined 10 MHz plus PPS */
+ MULTI_REF_IRIG, /**< IRIG input */
+ MULTI_REF_NTP, /**< Network Time Protocol (NTP) */
+ MULTI_REF_PTP, /**< Precision Time Protocol (PTP, IEEE1588) */
+ MULTI_REF_PTP_E1, /**< PTP over E1 */
+ MULTI_REF_FREQ, /**< fixed frequency */
+ MULTI_REF_PPS_STRING, /**< PPS in addition to string */
+ MULTI_REF_GPIO, /**< variable input signal via GPIO */
+ MULTI_REF_INTERNAL, /**< reserved, used internally by firmware only */
+ MULTI_REF_PZF, /**< DCF77 PZF providing much more accuracy than a standard LWR */
+ MULTI_REF_LWR, /**< long wave receiver. e.g. DCF77 AM, WWVB, MSF, JJY */
+ MULTI_REF_GRC, /**< Glonass / GPS receiver */
+ N_MULTI_REF /**< the number of defined sources, can not exceed bit number of uint32_t - 1 */
};
@@ -2803,12 +3496,18 @@ enum
"NTP", \
"PTP (IEEE1588)", \
"PTP over E1", \
- "Fixed Freq. in" \
+ "Fixed Freq. in", \
+ "PPS plus string", \
+ "Var. freq. via GPIO", \
+ "(reserved)", \
+ "DCF77 PZF Receiver", \
+ "Long Wave Receiver", \
+ "GLONASS/GPS Receiver" \
}
/*
- * Bit masks used to indicate supported reference sources
+ * Bit masks used to indicate supported reference sources
*/
#define HAS_MULTI_REF_GPS ( 1UL << MULTI_REF_GPS )
#define HAS_MULTI_REF_10MHZ ( 1UL << MULTI_REF_10MHZ )
@@ -2818,20 +3517,27 @@ enum
#define HAS_MULTI_REF_NTP ( 1UL << MULTI_REF_NTP )
#define HAS_MULTI_REF_PTP ( 1UL << MULTI_REF_PTP )
#define HAS_MULTI_REF_PTP_E1 ( 1UL << MULTI_REF_PTP_E1 )
+
#define HAS_MULTI_REF_FREQ ( 1UL << MULTI_REF_FREQ )
+#define HAS_MULTI_REF_PPS_STRING ( 1UL << MULTI_REF_PPS_STRING )
+#define HAS_MULTI_REF_GPIO ( 1UL << MULTI_REF_GPIO )
+#define HAS_MULTI_REF_INTERNAL ( 1UL << MULTI_REF_INTERNAL )
+#define HAS_MULTI_REF_PZF ( 1UL << MULTI_REF_PZF )
+#define HAS_MULTI_REF_LWR ( 1UL << MULTI_REF_LWR )
+#define HAS_MULTI_REF_GRC ( 1UL << MULTI_REF_GRC )
/*
- * There are 2 different ways to configure multi ref support
- * provided by some devices.
+ * There are 2 different ways to configure multi ref support
+ * provided by some devices.
*
* Newer devices which have the GPS_FEAT_XMULTI_REF flag set
* in RECEIVER_INFO::features support the newer XMULTI_REF_...
* structures which provide a more flexible interface.
*
- * Older devices which have the GPS_FEAT_MULTI_REF flag set
- * support these MULTI_REF_... structures below where
- * the number of supported input sources and priorities
+ * Older devices which have the GPS_FEAT_MULTI_REF flag set
+ * support these MULTI_REF_... structures below where
+ * the number of supported input sources and priorities
* is limited to N_MULTI_REF_PRIO.
*/
@@ -2839,12 +3545,12 @@ enum
/**
- The structure below is used to configure the priority of
+ The structure below is used to configure the priority of
the supported ref sources.
-
- The number stored in prio[0] of the array indicates the ref time
- source with highest priority. If that source fails, the device
- falls back to the source indicated by prio[1]. Each field of
+
+ The number stored in prio[0] of the array indicates the ref time
+ source with highest priority. If that source fails, the device
+ falls back to the source indicated by prio[1]. Each field of
the prio[] array must be set to one of the values 0..N_MULTI_REF-1,
or to -1 (0xFF) if the value is not assigned.
*/
@@ -2874,11 +3580,11 @@ typedef uint16_t MULTI_REF_STATUS; /* flag bits as defined below */
/*
- * The bits and associated bit masks below are used with the
- * MULTI_REF_STATUS type. Each bit is set if the associated
+ * The bits and associated bit masks below are used with the
+ * MULTI_REF_STATUS type. Each bit is set if the associated
* condition is true and is reset if the condition is not true:
*/
-enum
+enum
{
WRN_MODULE_MODE, /* selected input mode was invalid, set to default */
WRN_COLD_BOOT, /* GPS is in cold boot mode */
@@ -2904,41 +3610,55 @@ enum
-/*
+/**
+ * @defgroup group_xmr_cfg Extended multiref configuration stuff
+ *
* If the RECEIVER_INFO::features flag GPS_FEAT_XMULTI_REF is set
- * then the following XMULTI_REF_... data structures must be used
- * instead of the older MULTI_REF_... structures above.
+ * then the following XMULTI_REF_... data structures must be used
+ * instead of the older MULTI_REF_... structures.
*
* Those devices support a number of priority levels addressed by
- * the priority index, starting at 0 for highest priority. A single
- * reference time source from the set of supported sources can be
+ * the priority index, starting at 0 for highest priority. A single
+ * reference time source from the set of supported sources can be
* assigned to each priority level.
- *
- * The structures below are used to configure the individual
- * time source for each priority level, and retrieve the status
+ *
+ * These structures are used to configure the individual
+ * time source for each priority level, and retrieve the status
* of the time source at each priority level.
- */
+ *
+ * @{ */
+/**
+ * @brief Identifier for a reference source
+ */
typedef struct
{
- uint8_t type; /* 0..N_MULTI_REF-1 from the enum above */
- uint8_t instance; /* reserved, currently always 0 */
+ uint8_t type; /**< one of the enum MULTI_REF_TYPES */
+ uint8_t instance; /**< instance number, if multiple instances are supported, else 0 */
+
} XMULTI_REF_ID;
+
+
+/**
+ * @brief Reference source configuration settings
+ */
typedef struct
{
- XMULTI_REF_ID id; /* time source identifier */
- uint16_t flags; /* reserved, currently always 0 */
- NANO_TIME bias; /* time bias, e.g. path delay */
- NANO_TIME precision; /* precision of the time source */
- uint32_t fine_limit; /* smooth control if below this limit */
+ XMULTI_REF_ID id; /**< time source identifier */
+ uint16_t flags; /**< reserved, currently always 0 */
+ NANO_TIME bias; /**< time bias, e.g. path delay */
+ NANO_TIME precision; /**< precision of the time source */
+ uint32_t fine_limit; /**< smooth control if below this limit */
+
} XMULTI_REF_SETTINGS;
-/*
- * The structure below is used to retrieve or configure the time source
- * for a specific priority level.
- * After configuring, a structure with idx == 0xFFFF (-1) must be sent
+
+/**
+ * @brief Reference source configuration settings for a specific priority level
+ *
+ * @note After configuring, a structure with idx == 0xFFFF (-1) must be sent
* to let the changes become effective.
*/
typedef struct
@@ -2949,91 +3669,133 @@ typedef struct
} XMULTI_REF_SETTINGS_IDX;
-/*
- * The structure below contains the XMULTI_REF configuration
- * for a single priority level, plus information on supported
- * ref time sources, and the number of supported priority levels.
+
+/**
+ * @brief Reference source configuration settings and capabilities
*/
typedef struct
{
- XMULTI_REF_SETTINGS settings; /* current settings */
- uint32_t supp_ref; /* supp. HAS_MULTI_REF_... codes or'ed */
- uint8_t n_supp_ref; /* number of supported ref time sources */
- uint8_t n_prio; /* number of supported priority levels */
- uint16_t flags; /* reserved, currently 0, e.g. multiple instance support */
+ XMULTI_REF_SETTINGS settings; /**< current settings */
+ uint32_t supp_ref; /**< bit mask of or'ed HAS_MULTI_REF_... codes */
+ uint8_t n_supp_ref; /**< number of supported ref time sources */
+ uint8_t n_prio; /**< number of supported priority levels */
+ uint16_t flags; /**< currently always 0 */
} XMULTI_REF_INFO;
-/*
- * The structure below is used to retrieve the XMULTI_REF configuration
- * information for a specific priority level.
+
+/**
+ * @brief Reference source configuration settings and capabilities for a specific priority level
*/
typedef struct
{
- uint16_t idx; /* the priority level index, highest == 0 */
- XMULTI_REF_INFO info;
+ uint16_t idx; /**< the priority level index, highest == 0 */
+ XMULTI_REF_INFO info; /**< ref source cfg and capabilities */
} XMULTI_REF_INFO_IDX;
-/*
- * The structure below contains status information on a single
- * ref time source.
+
+/**
+ * @brief Status information on a single ref time source
*/
typedef struct
{
- XMULTI_REF_ID id; /* time source identifier */
- uint16_t status; /* flag bits as defined below */
- NANO_TIME offset; /* time offset from main time base */
- uint32_t reserved; /* reserved, currently always 0 */
-
+ XMULTI_REF_ID id; /**< time source identifier */
+ uint16_t status; /**< flag bits as defined below */
+ NANO_TIME offset; /**< time offset from main time base */
+ uint16_t flags; /**< see flags specified below */
+ uint8_t ssm; /**< synchronization status message ( if supported by src. )*/
+ uint8_t soc; /**< signal outage counter ( updt. on loss of signal ) */
} XMULTI_REF_STATUS;
-/*
- * The structure below is used to retrieve the the status information
- * of the time source at a specific priority level.
+
+/**
+ * @brief Bits and masks used with XMULTI_REF_STATUS::flags
+ *
+ * @note This API is only supported if bit GPS_HAS_XMRS_MULT_INSTC
+ * is set in RECEIVER_INFO::features.
+ */
+enum
+{
+ XMRSF_BIT_MULT_INSTC_SUPP, /**< multiple instances of the same ref type supported */
+ XMRSF_BIT_IS_EXTERNAL, /**< this ref source is on extension card */
+ N_XMRS_FLAGS
+};
+
+#define XMRSF_MSK_MULT_INSTC_SUPP ( 1UL << XMRSF_BIT_MULT_INSTC_SUPP )
+#define XMRSF_MSK_IS_EXTERNAL ( 1UL << XMRSF_BIT_IS_EXTERNAL )
+
+
+
+/**
+ * @brief Status information on a ref time source at a specific priority level
*/
typedef struct
{
- uint16_t idx; /* the priority level index, highest == 0 */
- XMULTI_REF_STATUS status;
+ uint16_t idx; /**< the priority level index, highest == 0 */
+ XMULTI_REF_STATUS status; /**< status information */
} XMULTI_REF_STATUS_IDX;
-/*
- * Bits used with XMULTI_REF_STATUS.
- */
-enum
-{
- XMRS_BIT_NOT_SUPP, /* ref type cfg'd for this level is not supported */
- XMRS_BIT_NO_CONN, /* input signal is disconnected */
- XMRS_BIT_NO_SIGNAL, /* no input signal */
- XMRS_BIT_IS_MASTER, /* reference is master source */
- XMRS_BIT_IS_LOCKED, /* locked to input signal */
- XMRS_BIT_IS_ACCURATE, /* oscillator control has reached full accuracy */
- XMRS_BIT_NOT_SETTLED, /* reference time signal not settled */
- N_XMRS_BITS
-};
-
-/* bit masks corresponding to the flag bits above */
+/**
+ * @brief Bits and bit masks used with XMULTI_REF_STATUS::status
+ *
+ * @note Flags XMRS_BIT_MULT_INSTC_SUPP and XMRS_BIT_NUM_SRC_EXC
+ * are set in the status flags for every priority if the associated
+ * condition is met.
+ */
+enum
+{
+ XMRS_BIT_NOT_SUPP, /**< ref type cfg'd for this level is not supported */
+ XMRS_BIT_NO_CONN, /**< input signal is disconnected */
+ XMRS_BIT_NO_SIGNAL, /**< no input signal */
+ XMRS_BIT_IS_MASTER, /**< reference is master source */
+ XMRS_BIT_IS_LOCKED, /**< locked to input signal */
+ XMRS_BIT_IS_ACCURATE, /**< oscillator control has reached full accuracy */
+ XMRS_BIT_NOT_SETTLED, /**< reference time signal not settled */
+ XMRS_BIT_NOT_PHASE_LOCKED, /**< oscillator not phase locked to PPS */
+ XMRS_BIT_NUM_SRC_EXC, /**< number of available sources exceeds what can be handled */
+ XMRS_BIT_IS_EXTERNAL, /**< this ref source is on extension card */
+ N_XMRS_BITS /**< number of know status bits */
+};
-#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP )
-#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN )
-#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL )
-#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER )
-#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED )
-#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE )
-#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED )
+#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP )
+#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN )
+#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL )
+#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER )
+#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED )
+#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE )
+#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED )
+#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED )
+#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC )
+#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL )
+/*
+ * Initializers for XMRS status bit strings.
+ */
+#define MBG_XMRS_STATUS_STRS \
+{ \
+ "Ref type not supported", \
+ "No connection", \
+ "No signal", \
+ "Is Master", \
+ "Is locked", \
+ "Is accuracte", \
+ "Not settled", \
+ "Phase not locked", \
+ "Number sources exceeds limit", \
+ "Is external" \
+}
/*
- * An initializer for a XMULTI_REF_STATUS variable
- * with status invalid / not used
+ * An initializer for a XMULTI_REF_STATUS variable
+ * with status invalid / not used
*/
#define XMULTI_REF_STATUS_INVALID \
{ \
@@ -3044,11 +3806,655 @@ enum
}
+/**
+ * @brief The number of supported instances of each ref source type
+ *
+ * @note This structure is only supported if bit GPS_HAS_XMRS_MULT_INSTC
+ * is set in RECEIVER_INFO::features.
+ */
+typedef struct
+{
+ uint32_t flags; /**< currently always 0 */
+ uint16_t n_xmr_settings; /**< number of configurable multi ref settings */
+ uint8_t slot_id; /**< current slot ID of board ( 0..15 ) */
+ uint8_t reserved; /**< reserved */
+ uint8_t n_inst[32]; /**< N_MULTI_REF entries used, but can not exceed bit number of uint32_t - 1 */
+} XMULTI_REF_INSTANCES;
+
+/** @} group_xmr_cfg */
+
+
+
+/**
+ * @defgroup group_gpio GPIO port configuration stuff
+ *
+ * @note This is only supported if the GPS_HAS_GPIO bit is set
+ * in the RECEIVER_INFO::features mask.
+ *
+ * @{ */
+
+
+/**
+ * @brief General GPIO config info to be read from a device
+ *
+ * Used to query from a device how many GPIO ports are supported
+ * by the device, then index 0..num_io-1 configuration or status
+ * records can be read from or written to the device.
+ */
+typedef struct
+{
+ uint32_t num_io; /**< number of supported GPIO ports */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_CFG_LIMITS;
+
+
+
+/**
+ * @brief Enumeration of GPIO types
+ *
+ * Usually a specific GPIO port can only be either an input
+ * or an output, and supports only a single signal type.
+ * This is due to hardware limitations, i.e. input or output
+ * circuitry required for the given signal
+ */
+enum MBG_GPIO_TYPES
+{
+ MBG_GPIO_TYPE_FREQ_IN, /**< variable frequency input */
+ MBG_GPIO_TYPE_FREQ_OUT, /**< variable frequency output */
+ MBG_GPIO_TYPE_FIXED_FREQ_OUT, /**< fixed frequency output */
+ MBG_GPIO_TYPE_BITS_IN, /**< framed data stream input */
+ MBG_GPIO_TYPE_BITS_OUT, /**< framed data stream output */
+ N_MBG_GPIO_TYPES /**< number of known types */
+};
+
+
+#define DEFAULT_GPIO_TYPES_SHORT_STRS \
+{ \
+ "Freq. In", \
+ "Freq. Out", \
+ "Fixed Freq Out", \
+ "BITS In", \
+ "BITS Out" \
+}
+
+
+
+/**
+ * @brief Enumeration of signal shapes
+ *
+ * Used to specify the signal shape of an input or output
+ * frequency signal.
+ */
+enum MBG_GPIO_SIGNAL_SHAPES
+{
+ MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED, /**< unknown or unspecified signal shape */
+ MBG_GPIO_SIGNAL_SHAPE_SINE, /**< sine wave */
+ MBG_GPIO_SIGNAL_SHAPE_SQUARE, /**< square wave */
+ N_MBG_GPIO_SIGNAL_SHAPES /**< number of known signal shapes */
+};
+
+/** Bit masks of signal shapes, corresponding to enum MBG_GPIO_SIGNAL_SHAPES */
+#define MBG_GPIO_SIGNAL_SHAPE_MSK_UNSPECIFIED ( 1UL << MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED )
+#define MBG_GPIO_SIGNAL_SHAPE_MSK_SINE ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SINE )
+#define MBG_GPIO_SIGNAL_SHAPE_MSK_SQUARE ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SQUARE )
+
+
+
+/**
+ * @brief A structure used to specify a variable frequency
+ *
+ * Used to specify a variable frequency for GPIO input or output
+ */
+typedef struct
+{
+ uint32_t hz; /**< integral number, Hz */
+ uint32_t frac; /**< fractional part, binary */
+
+} MBG_GPIO_FREQ;
+
+
+
+/**
+ * @brief Configuration of a GPIO variable frequency input
+ *
+ * @see MBG_GPIO_TYPE_FREQ_IN
+ */
+typedef struct
+{
+ MBG_GPIO_FREQ freq; /**< frequency */
+ uint32_t csc_limit; /**< max. cycle slip [1/1000 cycle units] */
+ uint32_t shape; /**< signal shape, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_IN_SETTINGS;
+
+
+/**
+ * @brief Supported options for a variable frequency GPIO input
+ *
+ * @see MBG_GPIO_TYPE_FREQ_IN
+ */
+typedef struct
+{
+ //##++++++++++++++++
+ uint32_t freq_min; /**< minimum output frequency [Hz] */
+ uint32_t freq_max; /**< maximum output frequency [Hz] */
+ uint32_t csc_limit_max; /**< max. milli_phase, unspecified if 0 */
+ uint32_t supp_shapes; /**< bit mask of supported signal shapes, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_IN_SUPP;
+
+
+
+/**
+ * @brief Configuration of a GPIO variable frequency output
+ *
+ * @see MBG_GPIO_TYPE_FREQ_OUT
+ */
+typedef struct
+{
+ MBG_GPIO_FREQ freq; /**< frequency */
+ int32_t milli_phase; /**< phase [1/1000 degree units] */
+ uint32_t shape; /**< signal shape, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_OUT_SETTINGS;
+
+
+
+/**
+ * @brief Supported options for a variable frequency GPIO output
+ *
+ * @see MBG_GPIO_TYPE_FREQ_OUT
+ */
+typedef struct
+{
+ uint32_t freq_min; /**< minimum output frequency [Hz] */
+ uint32_t freq_max; /**< maximum output frequency [Hz] */
+ uint32_t freq_resolution; /**< frequency resolution [Hz], unspecified if 0 */
+ uint32_t milli_phase_max; /**< max. abs. milli_phase */
+ uint32_t supp_shapes; /**< bit mask of supported signal shapes, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FREQ_OUT_SUPP;
+
+
+
+/**
+ * @brief Supported fixed frequencies
+ */
+enum MBG_GPIO_FIXED_FREQ
+{
+ MBG_GPIO_FIXED_FREQ_8kHz, /**< 8kHz */
+ MBG_GPIO_FIXED_FREQ_48kHz, /**< 48kHz */
+ MBG_GPIO_FIXED_FREQ_1MHz, /**< 1MHz */
+ MBG_GPIO_FIXED_FREQ_1544kHz, /**< 1.544MHz */
+ MBG_GPIO_FIXED_FREQ_2048kHz, /**< 2.048MHz */
+ MBG_GPIO_FIXED_FREQ_5MHz, /**< 5MHz */
+ MBG_GPIO_FIXED_FREQ_10MHz, /**< 10MHz */
+ MBG_GPIO_FIXED_FREQ_19440kHz, /**< 19.44MHz */
+ N_MBG_GPIO_FIXED_FREQ /**< number of known frequencies */
+};
+
+/** Bit masks of supported fixed frequencies */
+#define MSK_MBG_GPIO_FIXED_FREQ_8kHz ( 1UL << MBG_GPIO_FIXED_FREQ_8kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_48kHz ( 1UL << MBG_GPIO_FIXED_FREQ_48kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_1MHz ( 1UL << MBG_GPIO_FIXED_FREQ_1MHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_1544kHz ( 1UL << MBG_GPIO_FIXED_FREQ_1544kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_2048kHz ( 1UL << MBG_GPIO_FIXED_FREQ_2048kHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_5MHz ( 1UL << MBG_GPIO_FIXED_FREQ_5MHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_10MHz ( 1UL << MBG_GPIO_FIXED_FREQ_10MHz )
+#define MSK_MBG_GPIO_FIXED_FREQ_19440kHz ( 1UL << MBG_GPIO_FIXED_FREQ_19440kHz )
+
+/*
+ * Initializers for GPIO fixed frequency strings.
+ */
+#define MBG_GPIO_FIXED_FREQ_STRS \
+{ \
+ "8kHz", \
+ "48kHz", \
+ "1MHz", \
+ "1544kHz", \
+ "2048kHz", \
+ "5MHz", \
+ "10MHz", \
+ "19440kHz" \
+}
+
+
+/**
+ * @brief Configuration of a GPIO fixed frequency output
+ *
+ * @see MBG_GPIO_TYPE_FIXED_FREQ_OUT
+ */
+typedef struct
+{
+ uint32_t freq_idx; /**< fixed frequency index, @see enum MBG_GPIO_FIXED_FREQ */
+ uint32_t shape; /**< signal shape, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_FIXED_FREQ_OUT_SETTINGS;
+
+
+/**
+ * @brief Supported options for a fixed frequency output
+ *
+ * @see MBG_GPIO_TYPE_FIXED_FREQ_OUT
+ */
+typedef struct
+{
+ uint32_t supp_freq; /**< bit mask of supported fixed frequencies, @see enum MBG_GPIO_FIXED_FREQ */
+ uint32_t supp_shapes; /**< bit mask of supported signal shapes, @see enum MBG_GPIO_SIGNAL_SHAPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t supp_flags; /**< currently always 0 */
+
+} MBG_GPIO_FIXED_FREQ_OUT_SUPP;
+
+
+
+/**
+ * @brief Definitions for MBG_GPIO_BITS::format
+ */
+enum MBG_GPIO_BITS_FORMATS
+{
+ MBG_GPIO_BITS_E1_FRAMED, /**< 2.048MBit */
+ MBG_GPIO_BITS_T1_FRAMED, /**< 1.544MBit */
+ MBG_GPIO_BITS_E1_TIMING, /**< 2.048MHz */
+ MBG_GPIO_BITS_T1_TIMING, /**< 2.048MHz */
+ N_MBG_GPIO_BITS_FORMATS /**< number of formats */
+};
+
+#define MSK_MBG_GPIO_BITS_E1_FRAMED ( 1UL << MBG_GPIO_BITS_E1_FRAMED )
+#define MSK_MBG_GPIO_BITS_T1_FRAMED ( 1UL << MBG_GPIO_BITS_T1_FRAMED )
+#define MSK_MBG_GPIO_BITS_E1_TIMING ( 1UL << MBG_GPIO_BITS_E1_TIMING )
+#define MSK_MBG_GPIO_BITS_T1_TIMING ( 1UL << MBG_GPIO_BITS_T1_TIMING )
+
+
+
+/**
+ * @brief Configuration of a GPIO as BITS input module
+ *
+ * @see MBG_GPIO_TYPE_BITS_IN
+ */
+typedef struct
+{
+ uint32_t format; /**< signal type, enum MBG_GPIO_BITS_FORMATS */
+ uint32_t reserved;
+ uint32_t csc_limit; /**< max. cycle slip [1/1000 cycle units] */
+
+ union
+ {
+ struct
+ {
+ uint8_t ssm; /**< minimum E1 SSM ( 0...15 ) for acceptance */
+ uint8_t sa_bits; /**< Sa Bits group ( 4...8 ) carrying SSM */
+ uint16_t reserve;
+ } e1; /**< used with E1 formats */
+
+ struct
+ {
+ uint8_t min_boc;
+ uint8_t reserve_0;
+ uint16_t reserve_1;
+ } t1; /**< used with T1 formats */
+
+ uint32_t u32; /**< dummy to force at least 32 bit alignment */
+
+ } quality;
+
+ uint32_t err_msk; /**< controls which types of error can be ignored, see enum MBG_GPIO_BITS_ERR */
+ uint32_t flags; /**< currently always 0 */
+
+} MBG_GPIO_BITS_IN_SETTINGS;
+
+
+/**
+ * @brief Definitions for MBG_GPIO_BITS_IN_SETTINGS::err_msk
+ */
+enum MBG_GPIO_BITS_ERR
+{
+ MBG_GPIO_BITS_ERR_LOS, /**< loss of signal error */
+ MBG_GPIO_BITS_ERR_LOF, /**< loss of frame */
+ N_MBG_GPIO_BITS_ERR /**< number of formats */
+};
+
+#define MSK_MBG_GPIO_BITS_ERR_LOS ( 1UL << MBG_GPIO_BITS_ERR_LOS )
+#define MSK_MBG_GPIO_BITS_ERR_LOF ( 1UL << MBG_GPIO_BITS_ERR_LOF )
+
+
+
+/**
+ * @brief Supported options of a BITS GPIO input
+ *
+ * @see MBG_GPIO_TYPE_BITS_IN
+ */
+typedef struct
+{
+ uint32_t supp_fmts; /**< bit mask of supported formats, @see enum MBG_GPIO_BITS_FORMATS */
+ uint32_t reserved; /**< currently always 0 */
+
+} MBG_GPIO_BITS_IN_SUPP;
+
+
+
+/**
+ * @brief A generic structure used to configure a GPIO port
+ */
+typedef struct
+{
+ uint32_t type; /**< GPIO type, @see enum MBG_GPIO_TYPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t flags; /**< currently always 0 */
+
+ union /**< settings depending on the GPIO ::type, @see enum MBG_GPIO_TYPES */
+ {
+ MBG_GPIO_FREQ_IN_SETTINGS freq_in; /** if ::type is MBG_GPIO_TYPE_FREQ_IN */
+ MBG_GPIO_FREQ_OUT_SETTINGS freq_out; /** if ::type is MBG_GPIO_TYPE_FREQ_OUT */
+ MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; /** if ::type is MBG_GPIO_TYPE_FIXED_FREQ_OUT */
+ MBG_GPIO_BITS_IN_SETTINGS bits_in; /** if ::type is MBG_GPIO_TYPE_BITS_IN */
+ // MBG_GPIO_BITS_OUT_SETTINGS bits_out; /** if ::type is MBG_GPIO_TYPE_BITS_OUT */
+ } u;
+
+} MBG_GPIO_SETTINGS;
+
+
+
+/**
+ * @brief A generic structure used to describe a GPIO ports limiting values
+ */
+typedef struct
+{
+ uint32_t type; /**< GPIO type, @see enum MBG_GPIO_TYPES */
+ uint32_t reserved; /**< currently always 0 */
+ uint32_t supp_flags; /**< supported flags */
+
+ union /**< limits depending on the GPIO ::type, @see enum MBG_GPIO_TYPES */
+ {
+ MBG_GPIO_FREQ_IN_SUPP freq_in; /** if ::type is MBG_GPIO_TYPE_FREQ_IN */
+ MBG_GPIO_FREQ_OUT_SUPP freq_out; /** if ::type is MBG_GPIO_TYPE_FREQ_OUT */
+ MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; /** if ::type is MBG_GPIO_TYPE_FIXED_FREQ_OUT */
+ MBG_GPIO_BITS_IN_SUPP bits_in; /** if ::type is MBG_GPIO_TYPE_BITS_IN */
+ // MBG_GPIO_BITS_OUT_SUPP bits_out; /** if ::type is MBG_GPIO_TYPE_BITS_OUT */
+ } u;
+
+} MBG_GPIO_LIMITS;
+
+
+
+/**
+ * @brief A structure used to configure a specific GPIO port
+ */
+typedef struct
+{
+ uint32_t idx; /**< port number, 0..(MBG_GPIO_CFG_LIMITS::num_io - 1) */
+ MBG_GPIO_SETTINGS settings; /**< configuration settings */
+
+} MBG_GPIO_SETTINGS_IDX;
+
+
+
+/**
+ * @brief A structure used query the current GPIO port settings and capabilities
+ */
+typedef struct
+{
+ MBG_GPIO_SETTINGS settings; /**< current configuration */
+ MBG_GPIO_LIMITS limits; /**< supp. and max. values */
+
+} MBG_GPIO_INFO;
+
+
+
+/**
+ * @brief A structure used to query configuration and capabilities of a specific GPIO port
+ */
+typedef struct
+{
+ uint32_t idx; /**< port number, 0..(MBG_GPIO_CFG_LIMITS::num_io - 1) */
+ MBG_GPIO_INFO info; /**< current settings and capabilities of this GPIO port */
+
+} MBG_GPIO_INFO_IDX;
+
+
+
+/** @} group_gpio */
+
+
+/**
+ * @defgroup group_evt_log Event logging support
+ *
+ * @note This is only available if GPS_HAS_EVT_LOG is set in RECEIVER_INFO::features.
+ *
+ * @{ */
+
+/** @brief Number of event log entries that can be stored and yet have been saved */
+typedef struct
+{
+ uint32_t used; /**< current number of saved log entries */
+ uint32_t max; /**< max number of log entries which can be saved */
+} MBG_NUM_EVT_LOG_ENTRIES;
+
+#define _mbg_swab_mbg_num_evt_log_entries( _p ) \
+{ \
+ _mbg_swab32( &(_p)->used ); \
+ _mbg_swab32( &(_p)->max ); \
+}
+
+
+typedef uint16_t MBG_EVT_CODE;
+#define _mbg_swab_evt_code( _p ) _mbg_swab16( _p );
+
+typedef uint16_t MBG_EVT_INFO;
+#define _mbg_swab_evt_info( _p ) _mbg_swab16( _p );
+
+/** @brief An event log entry */
+ typedef struct
+ {
+ uint32_t time; /**< like time_t, seconds since 1970 */
+ MBG_EVT_CODE code; /**< event ID or'ed with severity level */
+ MBG_EVT_INFO info; /**< optional event info, depending on event ID */
+ } MBG_EVT_LOG_ENTRY;
+
+#define _mbg_swab_mbg_evt_log_entry( _p ) \
+{ \
+ _mbg_swab32( &(_p)->time ); \
+ _mbg_swab_evt_code( &(_p)->code ); \
+ _mbg_swab_evt_info( &(_p)->info ); \
+}
+
+
+// MBG_EVT_LOG_ENTRY::code is a combination of some bits used for the ID,
+// plus some bits used for the severity/level. The sum of bits must not
+// exceed (8 * sizeof MBG_EVT_LOG_ENTRY::code):
+
+#define MBG_EVT_ID_BITS 13
+#define MBG_EVT_LVL_BITS 3
+
+#define MBG_EVT_ID_MASK ( (MBG_EVT_CODE) ( 1UL << MBG_EVT_ID_BITS ) - 1 )
+#define MBG_EVT_LVL_MASK ( (MBG_EVT_CODE) ( 1UL << MBG_EVT_LVL_BITS ) - 1 )
+
+
+// Combine an ID and Level to a code which can be stored
+// in the code field:
+#define _mbg_mk_evt_code( _id, _lvl ) \
+ ( (MBG_EVT_CODE) ( (MBG_EVT_CODE)(_id) | ( (MBG_EVT_CODE)(_lvl) << MBG_EVT_ID_BITS ) ) )
+
+// Extract the event ID from the code field:
+#define _mbg_get_evt_id( _code ) \
+ ( (_code) & MBG_EVT_ID_MASK )
+
+// Extract the severity level from the code field:
+#define _mbg_get_evt_lvl( _code ) \
+ ( ( (_code) >> MBG_EVT_ID_BITS ) & MBG_EVT_LVL_MASK )
+
+
+/** @brief Enumeration of event IDs */
+enum
+{
+ MBG_EVT_ID_NONE, /**< no event (empty entry) */
+ MBG_EVT_ID_POW_UP_RES, /**< power up reset */
+ MBG_EVT_ID_WDOG_RES, /**< watchdog reset */
+ MBG_EVT_ID_COLD_BOOT, /**< entering cold boot mode */
+ MBG_EVT_ID_WARM_BOOT, /**< entering warm boot mode */
+ MBG_EVT_ID_NORMAL_OP, /**< entering normal operation */
+ MBG_EVT_ID_ANT_DISCONN, /**< antenna disconnect detected */
+ MBG_EVT_ID_ANT_SHORT, /**< antenna short circuit detected */
+ MBG_EVT_ID_ANT_OK, /**< antenna OK after failure */
+ MBG_EVT_ID_LOW_SATS, /**< no satellites can be received though antenna not failing */
+ N_MBG_EVT_ID
+};
+
+
+#define ENG_EVT_ID_NAME_NONE "No event"
+#define ENG_EVT_ID_NAME_POW_UP_RES "Power Up Reset"
+#define ENG_EVT_ID_NAME_WDOG_RES "Watchdog Reset"
+#define ENG_EVT_ID_NAME_COLD_BOOT "Cold Boot"
+#define ENG_EVT_ID_NAME_WARM_BOOT "Warm Boot"
+#define ENG_EVT_ID_NAME_NORMAL_OP "Normal Operation"
+#define ENG_EVT_ID_NAME_ANT_DISCONN "Antenna Disconn."
+#define ENG_EVT_ID_NAME_ANT_SHORT "Ant. Short-Circ."
+#define ENG_EVT_ID_NAME_ANT_OK "Antenna OK"
+#define ENG_EVT_ID_NAME_LOW_SATS "Few Sats Only"
+
+
+#define MBG_EVT_ID_NAMES_ENG \
+{ \
+ ENG_EVT_ID_NAME_NONE, \
+ ENG_EVT_ID_NAME_POW_UP_RES, \
+ ENG_EVT_ID_NAME_WDOG_RES, \
+ ENG_EVT_ID_NAME_COLD_BOOT, \
+ ENG_EVT_ID_NAME_WARM_BOOT, \
+ ENG_EVT_ID_NAME_NORMAL_OP, \
+ ENG_EVT_ID_NAME_ANT_DISCONN, \
+ ENG_EVT_ID_NAME_ANT_SHORT, \
+ ENG_EVT_ID_NAME_ANT_OK, \
+ ENG_EVT_ID_NAME_LOW_SATS \
+}
+
+
+
+/** @brief Enumeration of event severity levels */
+enum
+{
+ MBG_EVT_LVL_NONE,
+ MBG_EVT_LVL_DEBUG,
+ MBG_EVT_LVL_INFO,
+ MBG_EVT_LVL_WARN,
+ MBG_EVT_LVL_ERR,
+ MBG_EVT_LVL_CRIT,
+ N_MBG_EVT_LVL
+};
+
+
+#define ENG_EVT_LVL_NAME_NONE "None"
+#define ENG_EVT_LVL_NAME_DEBUG "Debug"
+#define ENG_EVT_LVL_NAME_INFO "Info"
+#define ENG_EVT_LVL_NAME_WARN "Warn"
+#define ENG_EVT_LVL_NAME_ERR "Err"
+#define ENG_EVT_LVL_NAME_CRIT "Crit."
+
+
+#define MBG_EVT_LVL_NAMES_ENG \
+{ \
+ ENG_EVT_LVL_NAME_NONE, \
+ ENG_EVT_LVL_NAME_DEBUG, \
+ ENG_EVT_LVL_NAME_INFO, \
+ ENG_EVT_LVL_NAME_WARN, \
+ ENG_EVT_LVL_NAME_ERR, \
+ ENG_EVT_LVL_NAME_CRIT \
+}
+
+
+/** @brief Predefined event codes with associated severity levels */
+
+#define MBG_EVT_NONE _mbg_mk_evt_code( MBG_EVT_ID_NONE, MBG_EVT_LVL_NONE )
+#define MBG_EVT_POW_UP_RES _mbg_mk_evt_code( MBG_EVT_ID_POW_UP_RES, MBG_EVT_LVL_WARN )
+#define MBG_EVT_WDOG_RES _mbg_mk_evt_code( MBG_EVT_ID_WDOG_RES, MBG_EVT_LVL_CRIT )
+#define MBG_EVT_COLD_BOOT _mbg_mk_evt_code( MBG_EVT_ID_COLD_BOOT, MBG_EVT_LVL_ERR )
+#define MBG_EVT_WARM_BOOT _mbg_mk_evt_code( MBG_EVT_ID_WARM_BOOT, MBG_EVT_LVL_ERR )
+#define MBG_EVT_NORMAL_OP _mbg_mk_evt_code( MBG_EVT_ID_NORMAL_OP, MBG_EVT_LVL_INFO )
+#define MBG_EVT_ANT_DISCONN _mbg_mk_evt_code( MBG_EVT_ID_ANT_DISCONN, MBG_EVT_LVL_CRIT )
+#define MBG_EVT_ANT_SHORT _mbg_mk_evt_code( MBG_EVT_ID_ANT_SHORT, MBG_EVT_LVL_CRIT )
+#define MBG_EVT_ANT_OK _mbg_mk_evt_code( MBG_EVT_ID_ANT_OK, MBG_EVT_LVL_INFO )
+#define MBG_EVT_LOW_SATS _mbg_mk_evt_code( MBG_EVT_ID_LOW_SATS, MBG_EVT_LVL_WARN )
+
+
+/** @} group_evt_log */
+
+
+/**
+ * @defgroup group_generic_io Generic I/O support.
+ *
+ * The definitions below are used with the GENERIC_IO API.
+ *
+ * This API is <b>NOT</b> supported by all devices, it depends on
+ * the type of the device, and the firmware version. The macro
+ * _pcps_has_generic_io() or the corresponding function
+ * mbg_dev_has_generic_io() should be used by applications to
+ * check whether a particular bus-level device supports this.
+ * @{ */
+
+
+typedef uint16_t GEN_IO_INFO_TYPE;
+
+#define _mbg_swab_gen_io_info_type( _p ) \
+ _mbg_swab16( _p )
+
+
+
+/**
+ * @brief The data structure used with the PCPS_GEN_IO_GET_INFO command
+ *
+ * type specifier in order to query from a device which of the other
+ * specified types is supported, and how many data sets are being
+ * used by the device. The GEN_IO_INFO_TYPE must be passed to the
+ * call which returns a GEN_IO_INFO structure filled by the device.
+ */
+typedef struct
+{
+ GEN_IO_INFO_TYPE type; // a PCPS_GEN_IO_GET_INFO type from the enum above
+ uint16_t num; // supported number of data sets of the specified type
+
+} GEN_IO_INFO;
+
+#define _mbg_swab_gen_io_info( _p ) \
+{ \
+ _mbg_swab_gen_io_info_type( &(_p)->type ); \
+ _mbg_swab16( &(_p)->num ); \
+}
+
+
+
+/**
+ * @brief Data types used with GEN_IO_INFO::type
+ *
+ * The first type specifier, PCPS_GEN_IO_GET_INFO, can
+ * be used to find out which of the other data types are
+ * supported, and how many data sets of the specified type
+ * are supported by a device.
+ */
+enum
+{
+ PCPS_GEN_IO_GET_INFO, /**< GEN_IO_INFO (read only) */
+ PCPS_GEN_IO_CAL_REC_IRIG_RX_COMP, /**< CAL_REC_IRIG_RX_COMP (read/write) */
+ N_PCPS_GEN_IO_TYPE /**< number of known types */
+};
+
+/** @} group_generic_io */
+
/*------------------------------------------------------------------------*/
/*
- * The types below are not used with all devices:
+ * The types below are not used with all devices:
*/
typedef uint16_t ROM_CSUM; /* The ROM checksum */
@@ -3056,18 +4462,18 @@ typedef uint16_t RCV_TIMEOUT; /* [min] (only if HAS_RCV_TIMEOUT) */
typedef uint16_t IGNORE_LOCK; /* (only if GPS_HAS_IGNORE_LOCK) */
/*
- * Originally IGNORE_LOG above has been a boolean value (equal or
+ * Originally IGNORE_LOG above has been a boolean value (equal or
* not equal 0) which was evaluated the same way for all ports.
*
- * Due to special firmware requirements it has been changed to a
- * bit maskable property in order to be able to specify the behaviour
+ * Due to special firmware requirements it has been changed to a
+ * bit maskable property in order to be able to specify the behaviour
* for individual ports.
*
- * In order to keep compatibility with older versions the LSB is used
- * to specify ignore_lock for all ports. The next higher bits are used
- * to specify ignore_lock for an individual port, where the bit position
+ * In order to keep compatibility with older versions the LSB is used
+ * to specify ignore_lock for all ports. The next higher bits are used
+ * to specify ignore_lock for an individual port, where the bit position
* depends on the port number, e.g. 0x02 for COM0, 0x04 for COM1, etc.
- * The macros below can be used to simplify the code:
+ * The macros below can be used to simplify the code:
*/
/* return a bit mask depending on the port number */
@@ -3088,7 +4494,7 @@ typedef uint16_t IGNORE_LOCK; /* (only if GPS_HAS_IGNORE_LOCK) */
/*------------------------------------------------------------------------*/
/*
- * The structures below are used with the SCU multiplexer board
+ * The structures below are used with the SCU multiplexer board
* in a redundant system:
*/
@@ -3097,13 +4503,13 @@ typedef struct
uint32_t hw_id; // hardware identification
uint32_t fw_id; // firmware identification
uint16_t flags; // reserved currently 0
- uint8_t clk0_info; // reference clock 0 type
- uint8_t clk1_info; // reference clock 1 type
+ uint8_t clk0_info; // reference clock 0 type
+ uint8_t clk1_info; // reference clock 1 type
uint16_t epld_status; // epld status word, see defintions below
uint16_t epld_control; // epld control word, see defintions below
} SCU_STAT_INFO;
-typedef struct
+typedef struct
{
uint16_t epld_control_mask; // control mask, determines which bit is to be changed
uint16_t epld_control_value; // control value, determines value of bits to be changed
@@ -3134,7 +4540,7 @@ typedef struct
* Definitions for clk0_info and clk1_info, can be used to determine
* the reference clock type connected to SCU input channel 0 and 1:
*/
-enum
+enum
{
SCU_CLK_INFO_GPS, // ref. clock is GPS receiver
SCU_CLK_INFO_DCF_PZF, // ref. clock is DCF77 PZF receiver
@@ -3146,10 +4552,12 @@ enum
/*------------------------------------------------------------------------*/
-/*
- * GPS receiver modes of operation. Some of the codes combinations
- * are obsolete with recent GPS receivers. However, that doesn't
- * matter since the mode is just read from the receiver:
+/**
+ * @brief Satellite receiver modes of operation.
+ *
+ * @note Some of the code combinations are obsolete with recent
+ * satellite receivers. However, this doesn't matter since the mode
+ * is just read from the receiver.
*/
#define REMOTE 0x10
#define BOOT 0x20
@@ -3173,9 +4581,12 @@ typedef int16_t DAC_VAL;
+/**
+ * @brief Satellite receiver status information
+ */
typedef struct
{
- uint16_t mode; /**< Mode of operation */
+ uint16_t mode; /**< Mode of operation, see predefined codes */
uint16_t good_svs; /**< Numb. of satellites that can currently be received and used */
uint16_t svs_in_view; /**< Numb. of satellites that should be in view according to the almanac data */
DAC_VAL dac_val; /**< Oscillator fine DAC value */
@@ -3196,6 +4607,101 @@ typedef struct
#define OSC_DAC_BIAS ( OSC_DAC_RANGE / 2 )
+
+/**
+ * @brief An enumeration of known satellite navigation systems
+ */
+enum
+{
+ GNSS_TYPE_GPS, /**< GPS, United States */
+ GNSS_TYPE_GLONASS, /**< GLONASS, Russia */
+ GNSS_TYPE_BEIDOU, /**< BEIDOU, China */
+ GNSS_TYPE_GALILEO, /**< GALILEO, Europe */
+ N_GNSS_TYPES /**< Number of defined codes */
+};
+
+#define GNSS_TYPE_STRS \
+{ \
+ "GPS", \
+ "GLONASS", \
+ "BEIDOU" , \
+ "GALILEO" \
+}
+
+#define MBG_GNSS_TYPE_MSK_GPS ( 1UL << GNSS_TYPE_GPS )
+#define MBG_GNSS_TYPE_MSK_GLONASS ( 1UL << GNSS_TYPE_GLONASS )
+#define MBG_GNSS_TYPE_MSK_BEIDOU ( 1UL << GNSS_TYPE_BEIDOU )
+#define MBG_GNSS_TYPE_MSK_GALILEO ( 1UL << GNSS_TYPE_GALILEO )
+
+
+#define N_GNSS_MODE_PRIO 8
+
+typedef struct
+{
+ uint32_t gnss_set; /**< current set of GNSS types */
+ uint8_t prio[N_GNSS_MODE_PRIO]; /**< index 0 for highest priority, use GNSS enumeration above, init with 0xFF if not supported */
+ uint32_t flags; /**< see below */
+} MBG_GNSS_MODE_SETTINGS;
+
+#define _mbg_swab_mbg_gnss_mode_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->gnss_set ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+typedef struct
+{
+ MBG_GNSS_MODE_SETTINGS settings; /**< current GNSS mode settings */
+ uint32_t supp_gnss_types; /**< bit masks of supported GNSS types */
+ uint32_t flags; /**< indicates which of the defined flags are supported by the device */
+} MBG_GNSS_MODE_INFO;
+
+#define _mbg_swab_mbg_gnss_mode_info( _p ) \
+{ \
+ _mbg_swab_mbg_gnss_mode_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_gnss_types ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+/**
+ * @brief Flags used with MBG_GNSS_MODE_SETTINGS::flags and MBG_GNSS_MODE_INFO::flags
+ */
+enum
+{
+ MBG_GNSS_FLAG_EXCLUSIVE, /**< (read only) only one of the supported GNSS systems can be used at the same time */
+ MBG_GNSS_FLAG_HAS_PRIORITY, /**< (read only) priority can be configured using the MBG_GNSS_MODE_SETTINGS::prio field */
+ N_MBG_GNSS_FLAGS
+};
+
+#define MBG_GNSS_FLAG_MSK_EXCLUSIVE ( 1UL << MBG_GNSS_FLAG_EXCLUSIVE )
+#define MBG_GNSS_FLAG_MSK_HAS_PRIORITY ( 1UL << MBG_GNSS_FLAG_HAS_PRIORITY )
+
+
+
+#define MAX_USED_SATS 32
+
+/**
+ * @brief SV information from a certain GNSS type.
+ */
+typedef struct
+{
+ uint8_t gnss_type; /**< GNSS type from the enumeration above */
+ uint8_t reserved;
+ uint16_t good_svs;
+ uint16_t svs_in_view;
+ uint8_t svs[MAX_USED_SATS];
+} GNSS_SAT_INFO;
+
+#define _mbg_swab_gnss_sat_info( _p ) \
+{ \
+ _mbg_swab16( &(_p)->good_svs ); \
+ _mbg_swab16( &(_p)->svs_in_view ); \
+}
+
+
#ifndef _IDENT_DEFINED
typedef union
@@ -3216,8 +4722,7 @@ typedef struct
}
/**
- * The type below is used to configure the length of the
- * antenna cable in [m]:
+ * @brief A data type used to configure the length of an antenna cable [m]
*/
typedef uint16_t ANT_CABLE_LEN;
@@ -3225,28 +4730,36 @@ typedef uint16_t ANT_CABLE_LEN;
-/* Configuration data for an optional LAN interface.
+/**
+ * @defgroup group_ip4_cfg Simple configuration and status
+ * of an optional LAN interface.
*
- * This is only supported if the flag GPS_HAS_LAN_IP4
- * is set in RECEIVER_INFO::features.
- */
-
+ * @note This is only supported if the flag GPS_HAS_LAN_IP4 is set
+ * in RECEIVER_INFO::features.
+ *
+ * @{ */
-/* Basic network settings */
+/**
+ * @brief An IPv4 address
+ */
typedef uint32_t IP4_ADDR;
#define _mbg_swab_ip4_addr( _p ) \
_mbg_swab32( _p );
+/**
+ * @brief Settings of an IPv4 network interface
+ */
typedef struct
{
- IP4_ADDR ip_addr;
- IP4_ADDR netmask;
- IP4_ADDR broad_addr;
- IP4_ADDR gateway;
- uint32_t flags; /* see below */
+ IP4_ADDR ip_addr; /**< the IP address */
+ IP4_ADDR netmask; /**< the network mask */
+ IP4_ADDR broad_addr; /**< the broadcast address */
+ IP4_ADDR gateway; /**< the default gateway */
+ uint16_t flags; /**< flags as specified below */
+ uint16_t vlan_cfg; /**< VLAN configuration, see below */
} IP4_SETTINGS;
@@ -3256,10 +4769,44 @@ typedef struct
_mbg_swab_ip4_addr( &(_p)->netmask ); \
_mbg_swab_ip4_addr( &(_p)->broad_addr ); \
_mbg_swab_ip4_addr( &(_p)->gateway ); \
- _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab16( &(_p)->flags ); \
+ _mbg_swab16( &(_p)->vlan_cfg ); \
}
+/**
+ * @brief Definitions used with IP4_SETTINGS::vlan_cfg
+ *
+ * @note IP4_SETTINGS::vlan_cfg contains a combination of
+ * a VLAN ID number plus a VLAN priority code.
+ */
+#define VLAN_ID_BITS 12 //< number of bits to hold the ID
+#define N_VLAN_ID ( 1 << VLAN_ID_BITS ) //< number of ID values
+#define MIN_VLAN_ID 0 //< minimum ID value
+#define MAX_VLAN_ID ( N_VLAN_ID - 1 ) //< maximum ID value
+
+// vlan_id = ( vlan_cfg >> VLAN_ID_SHIFT ) & VLAN_ID_MSK
+#define VLAN_ID_SHIFT 0
+#define VLAN_ID_MSK ( ( 1 << VLAN_ID_BITS ) - 1 )
+
+
+#define VLAN_PRIORITY_BITS 3 //< number of bits to hold priority
+#define N_VLAN_PRIORITY ( 1 << VLAN_PRIORITY_BITS ) //< number of priority values
+#define MIN_VLAN_PRIORITY 0 //< minimum priority
+#define MAX_VLAN_PRIORITY ( N_VLAN_PRIORITY - 1 ) //< maximum priority
+
+// vlan_priority = ( vlan_cfg >> VLAN_PRIORITY_SHIFT ) & VLAN_PRIORITY_MSK
+#define VLAN_PRIORITY_SHIFT ( ( 8 * sizeof( uint16_t ) ) - VLAN_PRIORITY_BITS )
+#define VLAN_PRIORITY_MSK ( ( 1 << VLAN_PRIORITY_BITS ) - 1 )
+
+/**
+ * @brief Macros used to encode/decode packed vlan_cfg variables
+ */
+#define _decode_vlan_id( _cfg ) ( ( (_cfg) >> VLAN_ID_SHIFT ) & VLAN_ID_MSK )
+#define _decode_vlan_priority( _cfg ) ( ( (_cfg) >> VLAN_PRIORITY_SHIFT ) & VLAN_PRIORITY_MSK )
+#define _encode_vlan_cfg( _id, _prty ) ( ( (_id) << VLAN_ID_SHIFT ) | ( (_prty) << VLAN_PRIORITY_SHIFT ) )
+
+
#if 0 //##++ currently not used
/* Misc configuration */
@@ -3288,62 +4835,94 @@ typedef struct
-/* LAN interface information */
+/**
+ * @brief A structure to holds the MAC address of a LAN interface
+ */
+typedef struct
+{
+ uint8_t b[6];
+} MBG_MAC_ADDR;
+
+
+/**
+ * @brief LAN interface information
+ *
+ * This structure can be retrieved from a device
+ * to check the device's capabilities.
+ */
typedef struct
{
- uint16_t type; /* codes see below */
- uint8_t mac_addr[6]; /* MAC address */
- uint16_t ver_code; /* high byte.low byte, in hex */
- char ver_str[GPS_ID_STR_SIZE];
- char sernum[GPS_ID_STR_SIZE];
- uint32_t rsvd; /* reserved, currently always 0 */
- uint32_t flags; /* reserved, currently always 0 */
+ uint16_t type; //< type of LAN interface, see below
+ MBG_MAC_ADDR mac_addr; //< MAC address
+ uint16_t ver_code; //< version number, high byte.low byte, in hex
+ char ver_str[GPS_ID_STR_SIZE]; //< version string
+ char sernum[GPS_ID_STR_SIZE]; //< serial number
+ uint32_t rsvd_0; //< reserved, currently always 0
+ uint16_t flags; //< flags as specified below
+ uint16_t rsvd_1; //< reserved, currently always 0
+
} LAN_IF_INFO;
#define _mbg_swab_lan_if_info( _p ) \
{ \
_mbg_swab16( &(_p)->type ); \
_mbg_swab16( &(_p)->ver_code ); \
- _mbg_swab32( &(_p)->rsvd ); \
- _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab32( &(_p)->rsvd_0 ); \
+ _mbg_swab16( &(_p)->flags ); \
+ _mbg_swab16( &(_p)->rsvd_1 ); \
}
-/* codes used with LAN_IF_INFO::type: */
-
-enum
+/**
+ * @brief Codes used with LAN_IF_INFO::type
+ */
+enum
{
- LAN_IF_TYPE_XPORT,
- LAN_IF_TYPE_PTP,
- N_LAN_IF_TYPE
+ LAN_IF_TYPE_XPORT, //< LAN interface on an XPORT
+ LAN_IF_TYPE_PTP, //< LAN interface is a special PTP interface
+ N_LAN_IF_TYPE //< number of defined LAN interface types
};
-/* Flags used with IP4_SETTINGS::flags and LAN_IF_INFO::flags: */
-
+/**
+ * @brief Flags used with IP4_SETTINGS::flags and LAN_IF_INFO::flags
+ */
enum
{
- IP4_BIT_DHCP,
- IP4_BIT_LINK, // used only to report state
- N_IP4_BIT
+ IP4_BIT_DHCP, //< DHCP supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
+ IP4_BIT_LINK, //< used only in IP4_SETTINGS to report link state
+ IP4_BIT_VLAN, //< VLAN supported (LAN_IF_INFO) / enabled (IP4_SETTINGS)
+ N_IP4_BIT //< number of defined flag bits
};
#define IP4_MSK_DHCP ( 1UL << IP4_BIT_DHCP )
#define IP4_MSK_LINK ( 1UL << IP4_BIT_LINK )
+#define IP4_MSK_VLAN ( 1UL << IP4_BIT_VLAN )
+/** @} group_ip4_cfg */
+
+
+/**
+ * @defgroup group_ptp Definitions used with PTP/IEEE1588
+ *
+ * @{ */
+
+/**
+ * @brief Enumeration of protocols possibly used with PTP
+ */
enum
{
- PTP_NW_PROT_BIT_RESERVED,
- PTP_NW_PROT_BIT_UDP_IPV4,
- PTP_NW_PROT_BIT_UDP_IPV6,
- PTP_NW_PROT_BIT_IEEE_802_3,
- PTP_NW_PROT_BIT_DEVICE_NET,
- PTP_NW_PROT_BIT_CONTROL_NET,
- PTP_NW_PROT_BIT_PROFINET,
- N_PTP_NW_PROT
+ PTP_NW_PROT_BIT_RESERVED, //< reserved
+ PTP_NW_PROT_BIT_UDP_IPV4, //< IPv4
+ PTP_NW_PROT_BIT_UDP_IPV6, //< IPv6
+ PTP_NW_PROT_BIT_IEEE_802_3, //< Ethernet (raw layer 2)
+ PTP_NW_PROT_BIT_DEVICE_NET, //< DeviceNet
+ PTP_NW_PROT_BIT_CONTROL_NET, //< ControlNet
+ PTP_NW_PROT_BIT_PROFINET, //< ProfiNet
+ N_PTP_NW_PROT //< number of defined protocols
};
#define PTP_NW_PROT_MSK_RESERVED ( 1UL << PTP_NW_PROT_BIT_RESERVED )
@@ -3354,38 +4933,58 @@ enum
#define PTP_NW_PROT_MSK_CONTROL_NET ( 1UL << PTP_NW_PROT_BIT_CONTROL_NET )
#define PTP_NW_PROT_MSK_PROFINET ( 1UL << PTP_NW_PROT_BIT_PROFINET )
-#if !defined( DEFAULT_PTP_NW_PROT_MASK )
- #define DEFAULT_PTP_NW_PROT_MASK ( PTP_NW_PROT_MSK_UDP_IPV4 | PTP_NW_PROT_MSK_IEEE_802_3 )
-#endif
-
+/**
+ * @brief Name strings for the protocols possibly used with PTP
+ */
#define PTP_NW_PROT_STRS \
{ \
"Reserved", \
- "UDP/IPv4", \
- "UDP/IPv6", \
- "IEEE 802.3", \
+ "UDP/IPv4 (L3)", \
+ "UDP/IPv6 (L3)", \
+ "IEEE 802.3 (L2)", \
"DeviceNet", \
"ControlNet", \
"PROFINET" \
}
+/**
+ * @brief Short name strings for the protocols possibly used with PTP
+ */
+#define PTP_NW_PROT_STRS_SHORT \
+{ \
+ "RSV", \
+ "IP4", \
+ "IP6", \
+ "ETH", \
+ "DN", \
+ "CN", \
+ "PN" \
+}
+
+/**
+ * @brief Possible states of a PTP port
+ */
enum
{
- PTP_PORT_STATE_UNINITIALIZED,
- PTP_PORT_STATE_INITIALIZING,
- PTP_PORT_STATE_FAULTY,
- PTP_PORT_STATE_DISABLED,
- PTP_PORT_STATE_LISTENING,
- PTP_PORT_STATE_PRE_MASTER,
- PTP_PORT_STATE_MASTER,
- PTP_PORT_STATE_PASSIVE,
- PTP_PORT_STATE_UNCALIBRATED,
- PTP_PORT_STATE_SLAVE,
- N_PTP_PORT_STATE
+ PTP_PORT_STATE_UNINITIALIZED, //< uninitialized
+ PTP_PORT_STATE_INITIALIZING, //< currently initializing
+ PTP_PORT_STATE_FAULTY, //< faulty
+ PTP_PORT_STATE_DISABLED, //< disabled
+ PTP_PORT_STATE_LISTENING, //< listening for PTP packets
+ PTP_PORT_STATE_PRE_MASTER, //< going to become master
+ PTP_PORT_STATE_MASTER, //< master
+ PTP_PORT_STATE_PASSIVE, //< passive
+ PTP_PORT_STATE_UNCALIBRATED, //< uncalibrated
+ PTP_PORT_STATE_SLAVE, //< slave
+ N_PTP_PORT_STATE //< number of defined port states
};
+
+/**
+ * @brief Name strings for the PTP port states
+ */
#define PTP_PORT_STATE_STRS \
{ \
"UNINITIALIZED", \
@@ -3401,40 +5000,60 @@ enum
}
+/**
+ * @brief An entry for a table of parameters which can not be accessed by an enumerated index
+ */
typedef struct
{
- uint8_t value;
- char *name;
+ uint8_t value; //< the parameter value
+ const char *name; //< the parameter name
} PTP_TABLE;
+/**
+ * @brief An enumeration of PTP delay mechanisms
+ *
+ * @note This is different than the numeric values specified
+ * in the published specs for IEEE1588. In addition, the specs
+ * define 0x14 for "disabled".
+ */
enum
{
- PTP_DELAY_MECH_BIT_E2E, // in PTP2 specs: 0x01
- PTP_DELAY_MECH_BIT_P2P, // in PTP2 specs: 0x02
- N_PTP_DELAY_MECH // additionally the specs define 0xFE for disabled
+ PTP_DELAY_MECH_BIT_E2E, //< End-to-End (in PTP2 specs: 0x01)
+ PTP_DELAY_MECH_BIT_P2P, //< Peer-to-Peer (in PTP2 specs: 0x02)
+ N_PTP_DELAY_MECH //< number of defined delay mechanisms
};
#define PTP_DELAY_MECH_MSK_E2E ( 1UL << PTP_DELAY_MECH_BIT_E2E )
#define PTP_DELAY_MECH_MSK_P2P ( 1UL << PTP_DELAY_MECH_BIT_P2P )
-#if !defined( DEFAULT_PTP_DELAY_MECH_MASK )
- #define DEFAULT_PTP_DELAY_MECH_MASK ( PTP_DELAY_MECH_MSK_E2E )
-#endif
+
+/**
+ * @brief Name strings for the PTP delay mechanisms
+ */
+
+#define PTP_DELAY_MECH_NAME_E2E "E2E"
+#define PTP_DELAY_MECH_NAME_P2P "P2P"
#define PTP_DELAY_MECH_NAMES \
{ \
- "E2E", \
- "P2P" \
+ PTP_DELAY_MECH_NAME_E2E, \
+ PTP_DELAY_MECH_NAME_P2P \
}
-#define PTP_CLOCK_ACCURACY_RESERVED_OFFSET 0x20
+#define PTP_CLOCK_ACCURACY_NUM_BIAS 0x20
+/**
+ * @brief An enumeration of accuracy classes used with PTP
+ *
+ * @note This enumeration does not start at 0 but with a bias
+ * specified by PTP_CLOCK_ACCURACY_NUM_BIAS.
+ */
enum
{
- PTP_CLOCK_ACCURACY_25ns = PTP_CLOCK_ACCURACY_RESERVED_OFFSET,
+ PTP_CLOCK_ACCURACY_25ns = PTP_CLOCK_ACCURACY_NUM_BIAS,
PTP_CLOCK_ACCURACY_100ns,
PTP_CLOCK_ACCURACY_250ns,
PTP_CLOCK_ACCURACY_1us,
@@ -3460,8 +5079,13 @@ enum
};
-// Attention: Substract offset of PTP_CLOCK_ACCURACY_RESERVED_OFFSET when
-// using the enum above as index for the initializer below!
+/**
+ * @brief Name strings for PTP accuracy classes
+ *
+ * @note The enumeration does not start at 0 but with a bias
+ * specified by PTP_CLOCK_ACCURACY_NUM_BIAS, so this bias needs
+ * to be accounted for when accessing a string table.
+ */
#define PTP_CLOCK_ACCURACY_STRS \
{ \
"< 25 ns", \
@@ -3490,6 +5114,9 @@ enum
+/**
+ * @brief Codes to specify the type of a time source used with PTP
+ */
#define PTP_TIME_SOURCE_ATOMIC_CLOCK 0x10
#define PTP_TIME_SOURCE_GPS 0x20
#define PTP_TIME_SOURCE_TERRESTRIAL_RADIO 0x30
@@ -3501,6 +5128,9 @@ enum
+/**
+ * @brief A table of PTP time source codes plus associated name strings
+ */
#define PTP_TIME_SOURCE_TABLE \
{ \
{ PTP_TIME_SOURCE_ATOMIC_CLOCK, "Atomic Clock" }, \
@@ -3515,72 +5145,202 @@ enum
}
+/**
+ * @brief An enumeration of roles which can be taken by a PTP node
+ *
+ * @note A role in this context specifies a certain mode of operation.
+ * Depending on its specification a devices may not be able to take
+ * each of the specified roles.
+ */
+enum
+{
+ PTP_ROLE_MULTICAST_SLAVE, //< slave in multicast mode
+ PTP_ROLE_UNICAST_SLAVE, //< slave in unicast mode
+ PTP_ROLE_MULTICAST_MASTER, //< multicast master
+ PTP_ROLE_UNICAST_MASTER, //< unicast master
+ PTP_ROLE_MULTICAST_AUTO, //< multicast master or slave (auto selection)
+ N_PTP_ROLES //< number of defined roles
+};
+
+#define PTP_ROLE_MSK_MULTICAST_SLAVE ( 1UL << PTP_ROLE_MULTICAST_SLAVE )
+#define PTP_ROLE_MSK_UNICAST_SLAVE ( 1UL << PTP_ROLE_UNICAST_SLAVE )
+#define PTP_ROLE_MSK_MULTICAST_MASTER ( 1UL << PTP_ROLE_MULTICAST_MASTER )
+#define PTP_ROLE_MSK_UNICAST_MASTER ( 1UL << PTP_ROLE_UNICAST_MASTER )
+#define PTP_ROLE_MSK_MULTICAST_AUTO ( 1UL << PTP_ROLE_MULTICAST_AUTO )
+
+#define PTP_ROLE_MSK_SLAVES ( PTP_ROLE_MSK_MULTICAST_SLAVE | PTP_ROLE_MSK_UNICAST_SLAVE )
+#define PTP_ROLE_MSK_MASTERS ( PTP_ROLE_MSK_MULTICAST_MASTER | PTP_ROLE_MSK_UNICAST_MASTER )
+
+
+/**
+ * @brief Name strings for defined PTP roles
+ */
+#define PTP_ROLE_STRS \
+{ \
+ "Multicast Slave", \
+ "Unicast Slave", \
+ "Multicast Master", \
+ "Unicast Master", \
+ "Multicast (Auto)" \
+}
+
+/**
+ * @brief Short name strings for defined PTP roles
+ */
+#define PTP_ROLE_STRS_SHORT \
+{ \
+ "MCS", \
+ "UCS", \
+ "MCM", \
+ "UCM", \
+ "MC" \
+}
-/* PTP configuration stuff */
+/**
+ * @brief A PTP clock identity
+ *
+ * @note This usually consists of a 6 byte MAC address with
+ * 2 fixed bytes inserted, or all ones as wildcard.
+ */
typedef struct
{
uint8_t b[8];
-} PTP_CLOCK_IDENTITY;
+} PTP_CLOCK_ID;
+
+#define _mbg_swab_ptp_clock_id( _p ) _nop_macro_fnc() // nothing to swap
+
+#define PTP_CLOCK_ID_WILDCARD { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
+
+
+/**
+ * @brief A PTP port ID
+ *
+ * @note This usually consists of a 6 byte MAC address with
+ * 2 fixed bytes inserted, or all ones as wildcard.
+ */
+typedef uint16_t PTP_PORT_ID;
+
+#define _mbg_swab_ptp_port_id( _p ) _mbg_swab16( _p )
+#define PTP_PORT_ID_WILDCARD 0xFFFF
+/**
+ * @brief An enumeration of time scales used with PTP
+ *
+ * @note The standard time scale used by PTP is TAI, which is a linear time scale.
+ * The protocol provides a UTC offset to be able to convert TAI to compute UTC, which
+ * can observe leap seconds. For the arbitrary time scale the UTC offset is unspecified.
+ */
+enum
+{
+ PTP_TIMESCALE_PTP, /* default */
+ PTP_TIMESCALE_ARB,
+ N_PTP_TIMESCALE
+};
+
+
+/**
+ * @brief Name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAME_PTP "PTP Standard (TAI)"
+#define PTP_TIMESCALE_NAME_ARB "Arbitrary"
+
+/**
+ * @brief Short name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAME_PTP_SHORT "PTP"
+#define PTP_TIMESCALE_NAME_ARB_SHORT "Arb"
+
+
+/**
+ * @brief A table of name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAMES \
+{ \
+ PTP_TIMESCALE_NAME_PTP, \
+ PTP_TIMESCALE_NAME_ARB \
+}
+
+/**
+ * @brief A table of short name strings for the PTP time scales
+ */
+#define PTP_TIMESCALE_NAMES_SHORT \
+{ \
+ PTP_TIMESCALE_NAME_PTP_SHORT, \
+ PTP_TIMESCALE_NAME_ARB_SHORT \
+}
+
+
+
+/**
+ * @brief A structure to used to read the status of the PTP protocol stack
+ */
typedef struct
{
- uint16_t network_protocol; // enum
- uint8_t ptp_proto_version; // PTP v1 or v2
- uint8_t port_state; // enum
- uint32_t flags;
- NANO_TIME offset;
+ //##++++ Do we need a port identifier ??
+ uint16_t nw_prot; /**< one of the enumerated protocols (@see N_PTP_NW_PROT) */
+ uint8_t ptp_prot_version; /**< PTP protocol version, 1, or 2, usually 2 for v2 */
+ uint8_t port_state; /**< one of the enumerated port states (@see N_PTP_PORT_STATE ) */
+ uint32_t flags; /**< bit masks as defined below */
+ NANO_TIME offset; /**< estimated time offset from the upstream time source */
NANO_TIME path_delay;
NANO_TIME mean_path_delay;
NANO_TIME delay_asymmetry;
- PTP_CLOCK_IDENTITY gm_identity;
+ PTP_CLOCK_ID gm_id; /**< identifier ot the upstream time source */
uint16_t clock_offset_scaled_log_variance;
uint8_t clock_class;
- uint8_t clock_accuracy; // enum
+ uint8_t clock_accuracy; /**< one of the enumerated accuracy class codes (@see N_PTP_CLOCK_ACCURACY) */
- uint32_t num_clients;
- uint32_t num_masters;
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+ uint32_t reserved_2; /**< reserved, currently always 0 */
- uint8_t domain_number;
- uint8_t time_source; // enum
- uint8_t delay_mech;
- int8_t log_delay_req_intv;
+ uint8_t domain_number; /**< the PTP clock domain number, 0:3 */
+ uint8_t time_source; /**< one of the defined codes PTP_TIME_SOURCE_... */
+ uint8_t delay_mech; /**< PTP_DELAY_MECH_BIT_E2E or PTP_DELAY_MECH_BIT_P2P */
+ int8_t log_delay_req_intv;
- int16_t utc_offset;
- DAC_VAL osc_dac_cal;
+ int16_t utc_offset; /**< UTC offset observed against TAI */
+ DAC_VAL osc_dac_cal; /**< disciplination value of the oscillator */
+
+ uint32_t reserved_3; /**< reserved, currently always 0 */
- uint32_t reserved;
} PTP_STATE;
#define _mbg_swab_ptp_state( _p ) \
{ \
- _mbg_swab16( &(_p)->network_protocol ); \
+ _mbg_swab16( &(_p)->nw_prot ); \
_mbg_swab32( &(_p)->flags ); \
_mbg_swab_nano_time( &(_p)->offset ); \
_mbg_swab_nano_time( &(_p)->path_delay ); \
_mbg_swab_nano_time( &(_p)->mean_path_delay ); \
_mbg_swab_nano_time( &(_p)->delay_asymmetry ); \
+ _mbg_swab_ptp_clock_id( &(_p)->gm_id ); \
_mbg_swab16( &(_p)->clock_offset_scaled_log_variance ); \
- _mbg_swab32( &(_p)->num_clients ); \
- _mbg_swab32( &(_p)->num_masters ); \
- _mbg_swab32( &(_p)->utc_offset ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab16( &(_p)->utc_offset ); \
_mbg_swab_dac_val( &(_p)->osc_dac_cal ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
}
+/**
+ * @brief Flag bits used with PTP_STATE::flags
+ */
enum
{
- PTP_FLAG_BIT_SLAVE_ONLY,
- PTP_FLAG_BIT_IS_SLAVE,
- PTP_FLAG_BIT_TIMESCALE_IS_PTP,
- PTP_FLAG_BIT_LS_ANN,
- PTP_FLAG_BIT_LS_ANN_NEG,
- N_PTP_FLAG_BIT
+ PTP_FLAG_BIT_SLAVE_ONLY, /**< the port can only be slave */
+ PTP_FLAG_BIT_IS_SLAVE, /**< the port is currently slave */
+ PTP_FLAG_BIT_TIMESCALE_IS_PTP, /**< the timescale is PTP standard, not arbitrary */
+ PTP_FLAG_BIT_LS_ANN, /**< a leap second is being announced */
+ PTP_FLAG_BIT_LS_ANN_NEG, /**< the announced leap second is negative */
+ PTP_FLAG_BIT_IS_UNICAST, /**< the port currently operates in unicast mode */
+ N_PTP_FLAG_BIT /**< the number of defined flag bits */
};
#define PTP_FLAG_MSK_SLAVE_ONLY ( 1UL << PTP_FLAG_BIT_SLAVE_ONLY )
@@ -3588,110 +5348,378 @@ enum
#define PTP_FLAG_MSK_TIMESCALE_IS_PTP ( 1UL << PTP_FLAG_BIT_TIMESCALE_IS_PTP )
#define PTP_FLAG_MSK_LS_ANN ( 1UL << PTP_FLAG_BIT_LS_ANN )
#define PTP_FLAG_MSK_LS_ANN_NEG ( 1UL << PTP_FLAG_BIT_LS_ANN_NEG )
+#define PTP_FLAG_MSK_IS_UNICAST ( 1UL << PTP_FLAG_BIT_IS_UNICAST )
-#define PTP_SYNC_INTERVAL_MIN -6
-#define PTP_SYNC_INTERVAL_MAX 6
-
-#define PTP_DELAY_REQ_INTERVAL_MIN -6
-#define PTP_DELAY_REQ_INTERVAL_MAX 6
-
+/**
+ * @brief A structure used to configure a PTP port
+ */
typedef struct
{
- uint16_t network_protocol; // enum, only 1 or 3
- uint8_t profile; // currently only 0 = default
- uint8_t domain_number; // 0:3
+ //##++++ Do we need a port identifier ??
+ uint16_t nw_prot; /**< one of the enumerated and supported protocols (@see N_PTP_NW_PROT) */
+ uint8_t profile; /**< PTP profile, currently only 0 = default */
+ uint8_t domain_number; /**< the PTP clock domain number, 0:3 */
- uint8_t delay_mechanism; // 0 (E2E) or 1 (P2P), unless disabled
- uint8_t reserved_0;
- uint8_t priority_1;
- uint8_t priority_2;
+ uint8_t delay_mech; /**< PTP_DELAY_MECH_BIT_E2E or PTP_DELAY_MECH_BIT_P2P, if supported */
+ uint8_t ptp_role; /**< one of the enumerated PTP roles (@see N_PTP_ROLES) */
+ uint8_t priority_1; /**< priority 1 */
+ uint8_t priority_2; /**< priority 2 */
uint8_t dflt_clk_class_unsync_cold; // 6:255
uint8_t dflt_clk_class_unsync_warm; // 6:255
uint8_t dflt_clk_class_sync_cold; // 6:255
uint8_t dflt_clk_class_sync_warm; // 6:255
- uint8_t reserved_1; // currently always 0
- uint8_t reserved_2; // currently always 0
- int16_t sync_interval; // log 2
+ uint8_t reserved_1; /**< reserved, currently always 0 */
+ uint8_t reserved_2; /**< reserved, currently always 0 */
+ int16_t sync_intv; /**< log2 of the sync interval [s] */
- int16_t announce_interval; // log 2
- int16_t delay_request_interval; // log 2
+ int16_t ann_intv; /**< log2 of the announce interval [s] */
+ int16_t delay_req_intv; /**< log2 of the delay request interval [s] */
- uint32_t upper_bound; // [ns] sync state set to false if above this limit
- uint32_t lower_bound; // [ns] sync state set to true if below this limit
+ uint32_t upper_bound; /**< sync state set to false if above this limit [ns] */
+ uint32_t lower_bound; /**< sync state set to true if below this limit [ns] */
- uint32_t reserved_3; // currently always 0
- uint32_t flags; // (see below)
+ uint32_t reserved_3; /**< reserved, currently always 0 */
+ uint32_t flags; /**< bit masks as defined below */
} PTP_CFG_SETTINGS;
-#define _mbg_swab_ptp_cfg_settings( _p ) \
-{ \
- _mbg_swab16( &(_p)->network_protocol ); \
- _mbg_swab16( &(_p)->sync_interval ); \
- _mbg_swab16( &(_p)->announce_interval ); \
- _mbg_swab16( &(_p)->delay_request_interval ); \
- _mbg_swab32( &(_p)->upper_bound ); \
- _mbg_swab32( &(_p)->lower_bound ); \
- _mbg_swab32( &(_p)->reserved_1 ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_ptp_cfg_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->nw_prot ); \
+ _mbg_swab16( &(_p)->sync_intv ); \
+ _mbg_swab16( &(_p)->ann_intv ); \
+ _mbg_swab16( &(_p)->delay_req_intv ); \
+ _mbg_swab32( &(_p)->upper_bound ); \
+ _mbg_swab32( &(_p)->lower_bound ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->flags ); \
}
+/**
+ * @brief A structure to used to query the current configuration and capabilities of a PTP port
+ */
typedef struct
{
- PTP_CFG_SETTINGS settings;
+ PTP_CFG_SETTINGS settings; /**< the current configuration */
- uint8_t ptp_proto_version; // PTP v1 or v2
- uint8_t reserved_1; // currently always 0
- uint16_t reserved_2; // currently always 0
+ uint8_t ptp_proto_version; /**< PTP protocol version, 1, or 2, usually 2 for v2 */
+ uint8_t reserved_1; /**< reserved, currently always 0 */
+ uint16_t reserved_2; /**< reserved, currently always 0 */
- int16_t sync_interval_min; // log 2
- int16_t sync_interval_max; // log 2
- int16_t announce_interval_min; // log 2
- int16_t announce_interval_max; // log 2
- int16_t delay_request_interval_min; // log 2
- int16_t delay_request_interval_max; // log 2
+ int16_t sync_intv_min; /**< log2 of minimum sync interval [s] */
+ int16_t sync_intv_max; /**< log2 of maximum sync interval [s] */
+ int16_t ann_intv_min; /**< log2 of minimum announce interval [s] */
+ int16_t ann_intv_max; /**< log2 of maximum announce interval [s] */
+ int16_t delay_req_intv_min; /**< log2 of minimum delay request interval [s] */
+ int16_t delay_req_intv_max; /**< log2 of maximum delay request interval [s] */
- uint32_t supported_flags; // (see below)
- uint32_t supported_network_protocols;
- uint32_t supported_profiles;
- uint32_t supported_delay_mechanisms;
+ uint32_t supp_flags; /**< a bit mask of supported features (see below) */
+ uint32_t supp_nw_prot; /**< a bit mask of supported network protocols */
+ uint32_t supp_profiles; /**< a bit mask of supported profiles */
+ uint32_t supp_delay_mech; /**< a bit mask of supported delay mechanisms */
} PTP_CFG_INFO;
-#define _mbg_swab_ptp_cfg_info( _p ) \
-{ \
- _mbg_swab_ptp_cfg_settings( &(_p)->settings ); \
- _mbg_swab16( &(_p)->sync_interval_min ); \
- _mbg_swab16( &(_p)->sync_interval_max ); \
- _mbg_swab16( &(_p)->announce_interval_min ); \
- _mbg_swab16( &(_p)->announce_interval_max ); \
- _mbg_swab16( &(_p)->delay_request_interval_min ); \
- _mbg_swab16( &(_p)->delay_request_interval_max ); \
- _mbg_swab32( &(_p)->supported_flags ); \
- _mbg_swab32( &(_p)->supported_profiles ); \
- _mbg_swab32( &(_p)->supported_delay_mechanisms ); \
+#define _mbg_swab_ptp_cfg_info( _p ) \
+{ \
+ _mbg_swab_ptp_cfg_settings( &(_p)->settings ); \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab16( &(_p)->sync_intv_min ); \
+ _mbg_swab16( &(_p)->sync_intv_max ); \
+ _mbg_swab16( &(_p)->ann_intv_min ); \
+ _mbg_swab16( &(_p)->ann_intv_max ); \
+ _mbg_swab16( &(_p)->delay_req_intv_min ); \
+ _mbg_swab16( &(_p)->delay_req_intv_max ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->supp_nw_prot ); \
+ _mbg_swab32( &(_p)->supp_profiles ); \
+ _mbg_swab32( &(_p)->supp_delay_mech ); \
}
-// flags used with PTP_CFG_SETTINGS::flags and PTP_CFG_INFO::supported_flags:
-// possibly also: can be master (i.e not slave only), v1 hw compat, ...
+/**
+ * @brief Flags used with PTP_CFG_SETTINGS::flags and PTP_CFG_INFO::supp_flags
+ */
enum
{
- PTP_CFG_BIT_TIME_SCALE_IS_PTP, // time scale is PTP/TAI, else arbitrary
- PTP_CFG_BIT_V1_HW_COMPAT,
- N_PTP_CFG_BIT
+ PTP_CFG_BIT_TIME_SCALE_IS_PTP, /**< time scale is PTP/TAI, else arbitrary */
+ PTP_CFG_BIT_V1_HW_COMPAT, /**< maybe required for certain NIC chips, not used by Meinberg */
+ PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE, /**< the PTP port can take the role of a unicast slave */
+ PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER, /**< the PTP port can take the role of a multicast master */
+ PTP_CFG_BIT_CAN_BE_UNICAST_MASTER, /**< the PTP port can take the role of a unicast master */
+ PTP_CFG_BIT_CAN_BE_MULTICAST_AUTO, /**< the PTP port can automatically become multicast master or slave */
+ N_PTP_CFG_BIT /**< the number of defined bits */
};
-#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
-#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_BIT_V1_HW_COMPAT )
+#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
+#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_BIT_V1_HW_COMPAT )
+#define PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE ( 1UL << PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE )
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER ( 1UL << PTP_CFG_BIT_CAN_BE_MULTICAST_MASTER )
+#define PTP_CFG_MSK_CAN_BE_UNICAST_MASTER ( 1UL << PTP_CFG_BIT_CAN_BE_UNICAST_MASTER )
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO ( 1UL << PTP_CFG_BIT_CAN_BE_MULTICAST_AUTO )
+
+
+/** @brief A bit mask of the role bits within the flag bits */
+#define PTP_CFG_MSK_SUPPORT_PTP_ROLES ( PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE | \
+ PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER | \
+ PTP_CFG_MSK_CAN_BE_UNICAST_MASTER | \
+ PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO )
+
+/** @brief A bit mask of the unicast role bits within the flag bits */
+#define PTP_CFG_MSK_SUPPORT_PTP_UNICAST ( PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE | \
+ PTP_CFG_MSK_CAN_BE_UNICAST_MASTER )
+/**
+ * @brief Derive a "supported PTP roles" bit mask from PTP_CFG_INFO::supp_flags
+ *
+ * There's no explicite flag to indicate that the role of a multicast slave
+ * is supported, since this role is always supported. The sequence of flags
+ * indicating that a specific optional role is supported matches the enumerated
+ * roles above, but don't start at bit 0. So we compine the optional flag bits
+ * with the LSB always set for the implicite multicast slave role to yield
+ * a bit mask which according to the enumerated roles.
+ */
+#define _get_supp_ptp_role_idx_msk( _f ) \
+ ( 1UL | ( ( (_f) & PTP_CFG_MSK_SUPPORT_PTP_ROLES ) >> ( PTP_CFG_BIT_CAN_BE_UNICAST_SLAVE - 1 ) ) )
+
+
+/**
+ * @brief Flags used with PTP_CFG_SETTINGS::profile and PTP_CFG_INFO::supp_profiles
+ */
+enum
+{
+ PTP_PROFILE_CUSTOM, /**< customizable, always supported */
+ PTP_PROFILE_DFLT_E2E, /**< pure IEEE1588-2008 (PTPv2) with E2E */
+ PTP_PROFILE_DFLT_P2P, /**< pure IEEE1588-2008 (PTPv2) with P2P */
+ PTP_PROFILE_POWER, /**< IEEE C37.238 profile extension */
+ PTP_PROFILE_TELECOM, /**< ITU-T G.8265.1 profile extension */
+ N_PTP_PROFILES /**< number of supported profiles */
+};
+
+#define PTP_MSK_PROFILE_DEFAULT ( 1UL << PTP_PROFILE_DEFAULT )
+#define PTP_MSK_PROFILE_POWER ( 1UL << PTP_PROFILE_POWER )
+#define PTP_MSK_PROFILE_TELECOM ( 1UL << PTP_PROFILE_TELECOM )
+
+
+/**
+ * @brief Name strings for defined PTP profiles
+ */
+#define PTP_PROFILE_STRS \
+{ \
+ "Default", \
+ "Power", \
+ "Telecom" \
+}
+
+
+
+/**
+ * @brief Additional parameters for Power Profile
+ */
+#define PTP_POWER_PROFILE_GM_ID_MIN 3
+#define PTP_POWER_PROFILE_GM_ID_MAX 255
+
+typedef struct
+{
+ uint32_t network_incaccuracy; /**< Pre-defined network inaccuracy from master in [ns] */
+ uint8_t grandmaster_id; /**< [PTP_POWER_PROFILE_GM_ID_MIN..PTP_POWER_PROFILE_GM_ID_MAX] */
+ uint8_t reserved_1;
+ uint16_t reserved_2;
+
+} PTP_POWER_PROFILE_CFG;
+
+
+
+/**
+ * @brief A host's fully qualified domain name (FQDN), or a numeric IP address string
+ *
+ * In theory each single component (host name, domain name, top level domain name)
+ * of a FQDN can have up to 63 characters, but the overall length is limited to
+ * 255 characters. We specify one more character for the trailing 0.
+ */
+typedef char MBG_HOSTNAME[256];
+
+
+/**
+ * @brief Limits to be considered when specifying PTP unicast masters
+ */
+typedef struct
+{
+ uint16_t n_supp_master; /**< number of unicast masters which can be specified */
+ int16_t sync_intv_min; /**< log2 of minimum sync interval [s] */
+ int16_t sync_intv_max; /**< log2 of maximum sync interval [s] */
+ int16_t ann_intv_min; /**< log2 of minimum announce interval [s] */
+ int16_t ann_intv_max; /**< log2 of maximum announce interval [s] */
+ int16_t delay_req_intv_min; /**< log2 of minimum delay request interval [s] */
+ int16_t delay_req_intv_max; /**< log2 of maximum delay request interval [s] */
+ uint16_t reserved_0; /**< reserved, currently always 0 */
+ uint32_t supp_flags; /**< a bit mask indicating which flags are supported */
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+
+} PTP_UC_MASTER_CFG_LIMITS;
+
+#define _mbg_swab_ptp_uc_master_cfg_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->n_supp_master ); \
+ _mbg_swab16( &(_p)->sync_intv_min ); \
+ _mbg_swab16( &(_p)->sync_intv_max ); \
+ _mbg_swab16( &(_p)->ann_intv_min ); \
+ _mbg_swab16( &(_p)->ann_intv_max ); \
+ _mbg_swab16( &(_p)->delay_req_intv_min ); \
+ _mbg_swab16( &(_p)->delay_req_intv_max ); \
+ _mbg_swab16( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+}
+
+
+/**
+ * @brief Specification of unicast masters
+ *
+ * This structure is used on a unicast slave to specify the settings of
+ * a unicast master polled by the slave. The number of unicast masters
+ * which can be specified depends on the capabilities of the slave device
+ * and is returned in PTP_UC_MASTER_CFG_LIMITS::n_supp_master.
+ */
+typedef struct
+{
+ MBG_HOSTNAME gm_host; /**< grandmaster's hostname or IP address */
+ PTP_CLOCK_ID gm_clock_id; /**< use clock ID of master port, or PTP_CLOCK_ID_WILDCARD */
+ PTP_PORT_ID gm_port_id; /**< use target port ID of master port (e.g. 135) or PTP_PORT_ID_WILDCARD */
+ int16_t sync_intv; /**< sync interval [log2 s] */
+ int16_t ann_intv; /**< announce interval [log2 s] */
+ int16_t delay_req_intv; /**< delay request interval [log2 s]*/
+ int32_t fix_offset; /**< constant time offset to be compensated [ns] */
+ uint16_t message_duration; /**< time period until master stops sending messages [s] */
+ uint16_t reserved_0; /**< reserved, currently always 0 */
+ uint32_t reserved_1; /**< reserved, currently always 0 */
+ uint32_t flags; /**< reserved, currently always 0 */
+
+} PTP_UC_MASTER_SETTINGS;
+
+#define _mbg_swab_ptp_uc_master_settings( _p ) \
+{ \
+ _mbg_swab_ptp_clock_id( &(_p)->gm_clock_id ); \
+ _mbg_swab_ptp_port_id( &(_p)->gm_port_id ); \
+ _mbg_swab16( &(_p)->sync_intv ); \
+ _mbg_swab16( &(_p)->ann_intv ); \
+ _mbg_swab16( &(_p)->delay_req_intv ); \
+ _mbg_swab32( &(_p)->fix_offset ); \
+ _mbg_swab16( &(_p)->message_duration ); \
+ _mbg_swab16( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+/**
+ * @brief Specification of a certain unicast master
+ */
+typedef struct
+{
+ uint32_t idx; /**< index, 0..(PTP_UC_MASTER_CFG_LIMITS::n_supp_master - 1) */
+ PTP_UC_MASTER_SETTINGS settings; /**< specification for the unicast master with that index */
+
+} PTP_UC_MASTER_SETTINGS_IDX;
+
+#define _mbg_swab_ptp_uc_master_settings_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_ptp_uc_master_settings( &(_p)->settings ); \
+}
+
+
+/**
+ * @brief Capabilities and current settings of a unicast master
+ */
+typedef struct
+{
+ PTP_UC_MASTER_SETTINGS settings; /**< current settings */
+ uint32_t reserved; /**< reserved, currently always 0 */
+ uint32_t flags; /**< reserved, currently always 0 */
+
+} PTP_UC_MASTER_INFO;
+
+#define _mbg_swab_ptp_uc_master_info( _p ) \
+{ \
+ _mbg_swab_ptp_uc_master_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+/**
+ * @brief Capabilities and current settings of a specific unicast master
+ */
+typedef struct
+{
+ uint32_t idx; /**< index, 0..(PTP_UC_MASTER_CFG_LIMITS::n_supp_master - 1) */
+ PTP_UC_MASTER_INFO info; /**< capabilities and current settings */
+
+} PTP_UC_MASTER_INFO_IDX;
+
+#define _mbg_swab_ptp_uc_master_info_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_ptp_uc_master_info( &(_p)->info ); \
+}
+
+
+/** @} group_ptp */
+
+
+/**
+ * @defgroup group_lno Definitions used with LNO devices
+ *
+ * @{ */
+
+#define MAX_LNO_OUTPUT 4
+
+typedef struct
+{
+ uint16_t sine_lvl[MAX_LNO_OUTPUT]; /**< signal levels at the outputs */
+
+ uint16_t max_sine_lvl; /**< max level of an output, e.g. 1024 */
+ uint8_t n_outputs; /**< actual number of outputs [0 .. MAX_LNO_OUTPUT-1] */
+ uint8_t out_enb_state; /**< e.g. bit 0 is set if corresponding output 0 is enabled, etc. */
+
+ uint16_t reserved_0; /**< reserved, currently always 0 */
+ uint16_t flags; /**< status flags as described below */
+
+} LNO_STATE;
+
+#define _mbg_swab_lno_state( _p ) \
+{ \
+ int i; \
+ \
+ for ( i = 0; i < MAX_LNO_OUTPUT; i++ ) \
+ _mbg_swab16( &(_p)->sine_lvl[i] ); \
+ \
+ _mbg_swab_16( &(_p)->max_sine_lvl ); \
+ _mbg_swab_16( &(_p)->reserved_0 ); \
+ _mbg_swab_16( &(_p)->flags ); \
+}
+
+
+/**
+ * @brief Flags used with LNO_STATE::flags
+ */
+enum
+{
+ LNO_FLAG_BIT_PLL_LOCKED, /**< PLL is locked */
+ N_LNO_FLAG_BIT /**< the number of defined bits */
+};
+
+#define LNO_FLAG_PLL_LOCKED ( 1UL << LNO_FLAG_BIT_PLL_LOCKED )
+
+/** @} group_lno */
/*------------------------------------------------------------------------*/
@@ -3786,20 +5814,52 @@ typedef struct
/**
- UTC correction parameters
-*/
+ * @brief GPS UTC correction parameters
+ *
+ * UTC correction parameters basically as sent by the GPS satellites.
+ *
+ * The CSUM field is only used by the card's firmware to check the
+ * consistency of the structure in non-volatile memory.
+ *
+ * The field labeled valid indicates if the parameter set is valid, i.e.
+ * if it contains data received from the satellites.
+ *
+ * t0t, A0 and A1 contain fractional correction parameters for the current
+ * GPS-UTC time offset in addition to the whole seconds. This is evaluated
+ * by the receivers' firmware to convert GPS time to UTC time.
+ *
+ * The delta_tls field contains the current full seconds offset between
+ * GPS time and UTC, which corresponds to the number of leap seconds inserted
+ * into the UTC time scale since GPS was put into operation in January 1980.
+ *
+ * delta_tlfs holds the number of "future" leap seconds, i.e. the UTC offset
+ * after the next leap second event defined by WNlsf and DNt.
+ *
+ * The fields WNlsf and DNt specify the GPS week number and the day number
+ * in that week at the end of which a leap second is scheduled.
+ *
+ * @note: The satellites transmit WNlsf only as a signed 8 bit value, so it
+ * can only define a point in time which is ± 127 weeks off the current time.
+ * The firmware tries to expand this based on the current week number, but
+ * the result is ambiguous if the leap second occurs or occurred more
+ * than 127 weeks in the future or past.
+ *
+ * So the leap second date should only be evaluated if the fields delta_tls
+ * and delta_tlsf are different, in which case there is an actual leap second
+ * announcement inside the ± 127 week range.
+ */
typedef struct
{
- CSUM csum; /**< Checksum of the remaining bytes */
- int16_t valid; /**< Flag indicating UTC parameters are valid */
+ CSUM csum; /**< Checksum of the remaining bytes */
+ int16_t valid; /**< Flag indicating UTC parameters are valid */
- T_GPS t0t; /**< Reference Time UTC Parameters [sec] */
- double A0; /**< +- Clock Correction Coefficient 0 [sec] */
- double A1; /**< +- Clock Correction Coefficient 1 [sec/sec] */
+ T_GPS t0t; /**< Reference Time UTC Parameters [wn|sec] */
+ double A0; /**< +- Clock Correction Coefficient 0 [sec] */
+ double A1; /**< +- Clock Correction Coefficient 1 [sec/sec] */
- uint16_t WNlsf; /**< Week number of nearest leap second */
- int16_t DNt; /**< The day number at the end of which leap second is inserted */
- int8_t delta_tls; /**< Current UTC offset to GPS system time [sec] */
+ uint16_t WNlsf; /**< Week number of nearest leap second */
+ int16_t DNt; /**< The day number at the end of which a leap second occurs */
+ int8_t delta_tls; /**< Current UTC offset to GPS system time [sec] */
int8_t delta_tlsf; /**< Future UTC offset to GPS system time after next leap second transition [sec] */
} UTC;
@@ -3860,7 +5920,7 @@ enum
GPS_PLATFORM_AIRBORNE_4G,
N_GPS_PLATFORMS
};
-
+
#define GPS_PLATFORM_STRS \
{ \
@@ -3881,11 +5941,11 @@ enum
{
TIME_MODE_DISABLED,
TIME_MODE_SURVEY_IN,
- TIME_MODE_FIXED
+ TIME_MODE_FIXED
};
-
+
typedef struct
{
uint32_t time_mode;
@@ -3900,12 +5960,12 @@ typedef struct
} NAV_TIME_MODE_SETTINGS;
-/**
- Navigation Engine settings to set configuration
+/**
+ Navigation Engine settings to set configuration
parameters of a dynamic platform model.
*/
typedef struct
-{
+{
uint8_t dynamic_platform;
uint8_t fix_mode;
int8_t min_elevation;
@@ -3918,12 +5978,11 @@ typedef struct
} NAV_ENGINE_SETTINGS;
-/* End of header body */
-
-
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
+/* End of header body */
#endif /* _GPSDEFS_H */
diff --git a/c/mbglib/include/gpsserio.h b/c/mbglib/include/gpsserio.h
new file mode 100644
index 0000000..5971d12
--- /dev/null
+++ b/c/mbglib/include/gpsserio.h
@@ -0,0 +1,982 @@
+
+/**************************************************************************
+ *
+ * $Id: gpsserio.h 1.40.1.1 2012/06/15 07:58:42Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for gpsserio.c.
+ *
+ * This file defines structures and codes to be used to access
+ * Meinberg GPS clocks via their serial interface COM0. COM0 should
+ * be set to a high baud rate, default is 19200.
+ *
+ * Standard Meinberg GPS serial operation is to send the Meinberg
+ * standard time string automatically once per second, once per
+ * minute, or on request per ASCII '?'.
+ *
+ * GPS parameter setup or parameter readout uses blocks of binary
+ * data which have to be isolated from the standard string. A block
+ * of data starts with a SOH code (ASCII Start Of Header, 0x01)
+ * followed by a message header with constant length and a block of
+ * data with variable length.
+ *
+ * The first field (cmd) of the message header holds the command
+ * code rsp. the type of data to be transmitted. The next field (len)
+ * gives the number of data bytes that follow the header. This number
+ * ranges from 0 to sizeof( MSG_DATA ). The third field (data_csum)
+ * holds a checksum of all data bytes and the last field of the header
+ * finally holds the checksum of the header itself.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: gpsserio.h $
+ * Revision 1.40.1.1 2012/06/15 07:58:42Z martin
+ * Preliminary support for NACK received status.
+ * Revision 1.40 2012/04/11 16:03:29 martin
+ * Fixed some doxygen stuff.
+ * Revision 1.39 2012/03/08 15:34:18Z martin
+ * Added default setting for _USE_USB_IO.
+ * Revision 1.38 2012/03/06 15:33:43 martin
+ * Added support for SCU and LNO.
+ * Account for modified chk_tstr() parameters.
+ * Revision 1.37 2011/11/25 14:59:17Z martin
+ * Account for some renamed evt_log library symbols.
+ * Revision 1.36 2011/11/25 10:37:10 martin
+ * Added commands and data structures to support log events.
+ * Revision 1.35 2011/07/29 09:46:54 daniel
+ * Use native alignment only.
+ * Added command code GPS_XMR_INSTANCES.
+ * Support GPIO configuration.
+ * Support for USB.
+ * Revision 1.34 2011/04/15 13:12:02 martin
+ * Added initializer for command name table.
+ * Unified mutex stuff using macros from mbgmutex.h.
+ * Revision 1.33 2010/09/07 07:18:08 daniel
+ * New codes and structures for multi GNSS support.
+ * Defines to support reading raw IRIG data.
+ * Revision 1.32 2009/08/26 09:02:21 daniel
+ * Added new commands GPS_NAV_ENG_SETTINGS and
+ * GPS_GLNS_ALM.
+ * Revision 1.31 2009/08/24 13:32:33Z martin
+ * Renamed symbol MBGEXTIO_TIMEOUT_SOCKET to MBGEXTIO_RCV_TIMEOUT_SOCKET.
+ * Support new timeout handling distinguishing between character timeout
+ * and message timeout. Timeout values are now expected in milliseconds.
+ * Revision 1.30 2009/07/02 09:19:31 martin
+ * Moved definitions related to LAN interface configuration to gpsdefs.h.
+ * Revision 1.29 2009/03/10 17:00:29 martin
+ * Support configurable time scales.
+ * Don't pack structure MBG_MSG_CTL but use default alignment.
+ * Revision 1.28 2008/09/04 12:47:10Z martin
+ * Moved generic serial I/O stuff to mbgserio.h.
+ * Preliminarily support chk_tstr.
+ * Revision 1.27 2008/04/07 10:49:13Z martin
+ * Added cmd GPS_CLR_UCAP_BUFF.
+ * Revision 1.26 2007/02/27 09:51:45 martin
+ * Modified mutex macros for Windows.
+ * Added type TZCODE which is used by the binary protocol but
+ * has a different size than PCPS_TZCODE.
+ * Now _USE_PCPSDEFS by default for non-firmware apps.
+ * Fixed comments on GPS_OPT_SETTINGS and GPS_OPT_INFO.
+ * Revision 1.25 2007/02/06 16:31:04Z martin
+ * Modified comment for PZF_PCPS_TIME which can now also
+ * be sent to a device.
+ * Added mutex support.
+ * Added SVNO to the buffer union.
+ * Added support for OPT_SETTINGS.
+ * Added XMULTI_REF_... definitions.
+ * Modified some comments.
+ * Revision 1.24 2006/12/21 10:54:14Z martin
+ * Moved macro _IS_MBG_FIRMWARE to words.h.
+ * Cleaned up definitions of default I/O macros.
+ * Revision 1.23 2006/12/12 15:53:58 martin
+ * Added structure LAN_IF_INFO and associated codes.
+ * Added cmd codes GPS_IRIG_RX_SETTINGS and GPS_IRIG_RX_INFO.
+ * Added new member irig_rx_info to union MSG_DATA.
+ * Added cmd code GPS_REF_OFFS and associated definitions.
+ * Added cmd code GPS_DEBUG_STATUS.
+ * Define MBG_HANDLE for DOS even without v24tools.
+ * Revision 1.22 2006/11/02 08:57:56 martin
+ * Added a typedef to avoid firmware build errors.
+ * Revision 1.21 2006/10/25 12:25:35Z martin
+ * Support serial I/O under Windows.
+ * Removed obsolete definitions.
+ * Updated function prototypes.
+ * Revision 1.20 2006/08/24 13:00:08Z martin
+ * Added conditional support for network socket I/O and encrypted packets.
+ * Serial I/O is now also conditional only.
+ * Added/renamed/redefined structures as required.
+ * Revision 1.19 2006/06/15 10:39:49Z martin
+ * Added some special types to the MSG_DATA union which have
+ * previously been defined as generic uint16_t types.
+ * Removed MBG_OPT_SETTINGS and MBG_OPT_INFO from
+ * the MSG_DATA union since those types are not used with
+ * the binary protocol.
+ * Revision 1.18 2006/05/18 09:43:35Z martin
+ * New cmd code GPS_IGNORE_LOCK.
+ * Added command codes for PZF receivers.
+ * Renamed IRIG_... symbols to IRIG_TX_... in order to distinguish
+ * from IRIG input configuration which might be available in the future.
+ * Added some fields to the MSG_DATA union.
+ * Renamed MSG_BUFF field "data" to "msg_data" in order to avoid
+ * conflict with reserved word in some environments.
+ * Rewrote inclusion control macros.
+ * Replace control of inclusion of function prototypes by new symbol
+ * _USE_GPSSERIO_FNC which can be fully overridden.
+ * Updated lots of comments.
+ * Revision 1.17 2005/09/08 14:47:05Z martin
+ * Changed type of MSG_RCV_CTL::flags from int to ulong
+ * to avoid compiler warnings.
+ * Revision 1.16 2005/04/26 10:53:53Z martin
+ * Updated function prototypes.
+ * Revision 1.15 2004/12/28 11:02:20Z martin
+ * Redefined interface data types using C99 fixed-size definitions.
+ * Replaced received_header by flags in MSG_RCV_CTL.
+ * Defined flag bits and corresponding bit masks.
+ * Updated function prototypes.
+ * Revision 1.14 2004/07/08 08:28:30 martin
+ * New cmd code GPS_RCV_TIMEOUT which is only supported if
+ * feature mask GPS_HAS_RCV_TIMEOUT is set.
+ * Revision 1.13 2004/06/16 14:13:50 martin
+ * Changed name of symbol which controls inclusion of function prototypes.
+ * Don't include function prototypes by default if compiling firmware.
+ * Conditionally support private data structures, automatically include
+ * those definitions if compiling firmware.
+ * The data portion of MSG_BUFF is now a union whose maximum size
+ * can be overridden by a preprocessor value.
+ * Added MBG_OPT_SETTINGS and MBG_OPT_INFO to the buffer union.
+ * Updated function prototypes.
+ * Revision 1.12 2004/04/16 09:16:00Z andre
+ * Added command code GPS_MULTI_REF_STATUS.
+ * Revision 1.11 2004/03/26 11:08:28Z martin
+ * Compile function prototypes conditionally only.
+ * if symbol _INCL_GPSSERIO_FNC is defined.
+ * New structure MSG_RCV_CTL to support binary
+ * protocol on several ports.
+ * Added support for IPv4 LAN interface configuration.
+ * Support MULTI_REF_SETTINGS/MULTI_REF_INFO.
+ * Added command code to query ROM checksum.
+ * Modified some comments.
+ * Updated function prototypes.
+ * Revision 1.10 2002/08/21 07:39:32Z werner
+ * POUT_PROG -> POUT_INFO
+ * Revision 1.9 2002/01/29 15:29:16Z MARTIN
+ * Renamed cmd code GPS_IRIG_CFG to GPS_IRIG_SETTINGS.
+ * Added new cmd codes GPS_RECEIVER_INFO...GPS_IRIG_INFO
+ * and updated msg buffer union with corresponding fields.
+ * Removed obsolete types OPT_FEATURES, IRIG_CFG and
+ * associated definitions.
+ * Modified some comments.
+ * Revision 1.8 2001/04/06 11:51:24 Andre
+ * transfercodes and structures for IRIG parameter and installed
+ * options added
+ * Revision 1.7 2001/03/30 10:47:04Z MARTIN
+ * New file header.
+ * Control alignment of structures from new file use_pack.h.
+ * Modified syntax and some comments.
+ *
+ **************************************************************************/
+
+#ifndef _GPSSERIO_H
+#define _GPSSERIO_H
+
+
+/* Other headers to be included */
+
+#include <gpsdefs.h>
+#include <use_pack.h>
+
+
+/*
+ * The following macros control parts of the build process.
+ * The default values are suitable for most cases but can be
+ * overridden by global definitions, if required.
+ */
+
+#if _IS_MBG_FIRMWARE
+ // This handle type in not used by the firmware.
+ // However, we define it to avoid build errors.
+ typedef int MBG_HANDLE;
+
+#endif
+
+
+#ifndef _USE_MUTEX
+ #if defined( MBG_TGT_WIN32 )
+ #define _USE_MUTEX 1
+ #elif defined( MBG_TGT_UNIX )
+ #define _USE_MUTEX 1
+ #endif
+#endif
+
+#ifndef _USE_MUTEX
+ #define _USE_MUTEX 0 // not used by default
+#endif
+
+
+/* Control whether network socket communication shall be supported */
+#ifndef _USE_SOCKET_IO
+ #define _USE_SOCKET_IO 0 // not supported by default
+#endif
+
+/* Control whether serial port communication shall be supported */
+#ifndef _USE_SERIAL_IO
+ #if _IS_MBG_FIRMWARE
+ #define _USE_SERIAL_IO 0 // Firmware provides its own serial I/O functions
+ #else
+ #define _USE_SERIAL_IO 1 // supported by default
+ #endif
+#endif
+
+/* Control whether USB communication shall be supported */
+#if defined( MBG_TGT_LINUX )
+ #ifndef _USE_USB_IO // may be overridden by project settings
+ #define _USE_USB_IO 0 // not supported by default
+ #endif
+#else
+ // USB I/O requires libusb and is currently only supported under Linux.
+ // So for non-Linux targets force _USE_USB_IO to 0.
+ #define _USE_USB_IO 0 // not supported by default
+#endif
+
+
+/* Control inclusion of secudefs.h */
+#if _USE_SOCKET_IO
+ // Network socket I/O always requires secudefs, so make sure
+ // this is defined correctly.
+ #ifdef _USE_ENCRYPTION
+ #undef _USE_ENCRYPTION
+ #endif
+ #define _USE_ENCRYPTION 1
+#else
+ // If no socket I/O is used then secudefs aren't required, either.
+ #ifndef _USE_ENCRYPTION
+ #define _USE_ENCRYPTION 0
+ #endif
+#endif
+
+/* Control inclusion of pcpsdefs.h */
+#ifndef _USE_PCPSDEFS
+ #if _IS_MBG_FIRMWARE
+ // for firmware depend on the target system
+ #if defined( _CC51 )
+ #define _USE_PCPSDEFS 1
+ #else
+ #define _USE_PCPSDEFS 0
+ #endif
+ #else
+ // otherwise include it by default
+ #define _USE_PCPSDEFS 1
+ #endif
+#endif
+
+/* Control inclusion of non-public declarations */
+#ifndef _USE_GPSPRIV
+ /* by default do include if building a GPS firmware */
+ #define _USE_GPSPRIV _IS_MBG_FIRMWARE
+#endif
+
+/* Control inclusion of function prototypes */
+#ifndef _USE_GPSSERIO_FNC
+ /* by default don't include if building a firmware */
+ #define _USE_GPSSERIO_FNC ( !_IS_MBG_FIRMWARE )
+#endif
+
+#ifndef _USE_RCV_TSTAMP
+ #define _USE_RCV_TSTAMP ( !_IS_MBG_FIRMWARE )
+#endif
+
+
+#if _USE_MUTEX
+ #include <mbgmutex.h>
+#endif
+
+#if _USE_SERIAL_IO
+ #include <mbgserio.h>
+#endif
+
+#if _USE_USB_IO
+ #include <mbgusbio.h>
+#endif
+
+#if _USE_SOCKET_IO
+ #if defined( MBG_TGT_UNIX )
+ #include <netdb.h>
+ #endif
+#endif
+
+#if _USE_ENCRYPTION
+ #include <secudefs.h>
+ #include <aes128.h>
+#endif
+
+#if _USE_PCPSDEFS
+ #include <pcpsdefs.h>
+#endif
+
+#if _USE_GPSPRIV
+ #include <gpspriv.h>
+#endif
+
+#if _USE_RCV_TSTAMP
+ #include <mbg_tmo.h>
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _GPSSERIO
+ #define _ext
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+// We don't use pragma pack() here but native alignment.
+
+
+/* Status codes of check_transfer() function. */
+
+#define TR_COMPLETE 2
+#define TR_RECEIVING 1
+#define TR_WAITING 0
+#define TR_TIMEOUT -1
+#define TR_CSUM_HDR -2
+#define TR_CSUM_DATA -3
+#define TR_DECRYPTION -4
+#define TR_OPEN_ERR -5
+#define TR_IO_ERR -6
+#define TR_AUTH_ERR -7
+#define TR_RCVD_NACK -8
+
+
+/* The code below is sent before a message header. */
+
+#define START_OF_HEADER 0x01 /* ASCII SOH */
+
+
+/* The control codes defined below are to be or'ed with a command/type code. */
+
+#define GPS_REQACK 0x8000 /* to GPS rcvr: request acknowledge */
+#define GPS_ACK 0x4000 /* from GPS rcvr: acknowledge a command */
+#define GPS_NACK 0x2000 /* from GPS rcvr: error receiving command */
+
+#define GPS_CTRL_MSK 0xF000 /* masks control code from command */
+
+
+/**< @defgroup group_gps_cmds_serial GPS commands passed via serial port
+ *
+ * These codes specify commands/types of data to be supplied to
+ * the GPS receiver:
+ */
+/* clock auto-message to host */
+/* | host request, clock response */
+/* | | host download to clock */
+/* | | | */
+enum /* | | | */
+{ /* system data */
+ GPS_AUTO_ON = 0x000, /* | | | X | no param, enable auto-msgs from GPS rcvr */
+ GPS_AUTO_OFF, /* | | | X | no param, disable auto-msgs from GPS rcvr */
+ GPS_SW_REV, /* | | X | | SW_REV, software revision */
+ GPS_BVAR_STAT, /* | | X | | BVAR_STAT, status of buffered variables */
+ GPS_TIME, /* | X | | X | TTM, current time or capture, or init board time */
+ GPS_POS_XYZ, /* | | X | X | XYZ, current position in ECEF coords */
+ GPS_POS_LLA, /* | | X | X | LLA, current position in geographic coords */
+ GPS_TZDL, /* | | X | X | TZDL, time zone / daylight saving */
+ GPS_PORT_PARM, /* | | X | X | PORT_PARM, (obsolete, use PORT_SETTINGS etc. ) */
+ GPS_SYNTH, /* | | X | X | SYNTH synthesizer's frequency and phase */
+ GPS_ANT_INFO, /* | X | X | | ANT_INFO, time diff after antenna disconnect */
+ GPS_UCAP, /* | X | X | | TTM, user capture events */
+ GPS_ENABLE_FLAGS, /* | | X | X | ENABLE_FLAGS, when to enable serial, pulses, and synth */
+ GPS_STAT_INFO, /* | | X | | STAT_INFO, request SV, mode and DAC info */
+ GPS_SWITCH_PARMS, /* | | X | X | (obsolete, use GPS_POUT_PROG_IDX) */
+ GPS_STRING_PARMS, /* | | X | X | (obsolete, use GPS_PORT_INFO/GPS_PORT_SETTINGS */
+ GPS_ANT_CABLE_LENGTH, /* | | X | X | ANT_CABLE_LEN, length of antenna cable */
+ GPS_SYNC_OUTAGE_DELAY, /* | | X | X | (customized firmware only) */
+ GPS_PULSE_INFO, /* | | X | X | (customized firmware only) */
+ GPS_OPT_FEATURES, /* | | X | | (obsolete, use GPS_RECEIVER_INFO) */
+ GPS_IRIG_TX_SETTINGS, /* | | X | X | IRIG_SETTINGS, (only if GPS_HAS_IRIG_TX) */
+ GPS_RECEIVER_INFO, /* | | X | | RECEIVER_INFO, model specific info */
+ GPS_STR_TYPE_INFO_IDX, /* | | X | | STR_TYPE_INFO_IDX, names and modes of supp. string types */
+ GPS_PORT_INFO_IDX, /* | | X | | PORT_INFO_IDX, port settings + additional info */
+ GPS_PORT_SETTINGS_IDX, /* | | X | X | PORT_SETTINGS_IDX, settings for specified port */
+ GPS_POUT_INFO_IDX, /* | | X | | POUT_INFO_IDX, pout settings + additional info */
+ GPS_POUT_SETTINGS_IDX, /* | | X | X | POUT_SETTINGS_IDX, programmable pulse output cfg */
+ GPS_IRIG_TX_INFO, /* | | X | | IRIG_INFO, (only if GPS_HAS_IRIG_TX) */
+ GPS_MULTI_REF_SETTINGS,/* | | X | X | MULTI_REF_SETTINGS, (only if HAS_MULTI_REF) */
+ GPS_MULTI_REF_INFO, /* | | X | | MULTI_REF_INFO, (only if HAS_MULTI_REF) */
+ GPS_ROM_CSUM, /* | | X | | ROM_CSUM, (not supported by all devices) */
+ GPS_MULTI_REF_STATUS, /* | | X | | MULTI_REF_STATUS, (only if HAS_MULTI_REF) */
+ GPS_RCV_TIMEOUT, /* | | X | X | RCV_TIMEOUT, [min] (only if HAS_RCV_TIMEOUT) */
+ GPS_IGNORE_LOCK, /* | | X | X | IGNORE_LOCK, if != 0 always claim to be sync */
+ GPS_IRIG_RX_SETTINGS, /* | | X | X | IRIG_SETTINGS, (only if GPS_HAS_IRIG_RX) */
+ GPS_IRIG_RX_INFO, /* | | X | | IRIG_INFO, (only if GPS_HAS_IRIG_RX) */
+ GPS_REF_OFFS, /* | | X | X | MBG_REF_OFFS, (only if GPS_HAS_REF_OFFS) */
+ GPS_DEBUG_STATUS, /* | | X | | MBG_DEBUG_STATUS, (only if GPS_HAS_DEBUG_STATUS) */
+ GPS_XMR_SETTINGS_IDX, /* | | X | X | XMULTI_REF_SETTINGS_IDX, (only if GPS_HAS_XMULTI_REF) */
+ GPS_XMR_INFO_IDX, /* | | X | | XMULTI_REF_INFO_IDX, (only if GPS_HAS_XMULTI_REF) */
+ GPS_XMR_STATUS_IDX, /* | | X | | XMULTI_REF_STATUS_IDX, (only if GPS_HAS_XMULTI_REF) */
+ GPS_OPT_SETTINGS, /* | | X | X | MBG_OPT_SETTINGS, (only if GPS_HAS_OPT_SETTINGS) */
+ GPS_OPT_INFO, /* | | X | | MBG_OPT_INFO, (only if GPS_HAS_OPT_SETTINGS) */
+ GPS_CLR_UCAP_BUFF, /* | | | X | command only, no data */
+ GPS_TIME_SCALE, /* | | X | X | MBG_TIME_SCALE_{SETTINGS|INFO}, (only if GPS_HAS_TIME_SCALE) */
+ GPS_NAV_ENG_SETTINGS, /* | | X | X | NAV_ENGINE_SETTINGS, (only if GPS_HAS_NAV_ENGINE_SETTINGS) */
+ GPS_RAW_IRIG_DATA, /* | | X | | MBG_RAW_IRIG_DATA, (only if GPS_HAS_RAW_IRIG_DATA) */
+ GPS_GPIO_CFG_LIMITS, /* | | X | | MBG_GPIO_CFG_LIMITS, only if GPS_HAS_GPIO */
+ GPS_GPIO_INFO_IDX, /* | | X | | MBG_GPIO_INFO_IDX, cfg. and capabilities, only if GPS_HAS_GPIO */
+ GPS_GPIO_SETTINGS_IDX, /* | | X | X | MBG_GPIO_SETTINGS_IDX, cfg. of a specific port, only if PCPS_HAS_GPIO */
+ GPS_XMR_INSTANCES, /* | | X | X | XMULTI_REF_INSTANCES (only if GPS_HAS_XMULTI_REF) */
+ GPS_CLR_EVT_LOG, /* | | | X | clear log command, no data (only if GPS_HAS_EVT_LOG) */
+ GPS_NUM_EVT_LOG_ENTRIES, /* | | X | | MBG_NUM_EVT_LOG_ENTRIES, num. of log entries (only if GPS_HAS_EVT_LOG) */
+ GPS_FIRST_EVT_LOG_ENTRY, /* | | X | | read oldest MBG_EVT_LOG_ENTRY (only if GPS_HAS_EVT_LOG) */
+ GPS_NEXT_EVT_LOG_ENTRY, /* | | X | | read next MBG_EVT_LOG_ENTRY (only if GPS_HAS_EVT_LOG) */
+ GPS_LNO_STATUS, /* | | X | | read LNO status */
+
+ /* GPS data */
+ GPS_CFGH = 0x100, /* | | X | X | CFGH, SVs' configuration and health codes */
+ GPS_ALM, /* | | X | X | req: uint16_t SV num, SV_ALM, one SV's almanac */
+ GPS_EPH, /* | | X | X | req: uint16_t SV num, SV_EPH, one SV's ephemeris */
+ GPS_UTC, /* | | X | X | UTC, GPS UTC correction parameters */
+ GPS_IONO, /* | | X | X | IONO, GPS ionospheric correction parameters */
+ GPS_ASCII_MSG, /* | | X | | ASCII_MSG, the GPS ASCII message */
+
+ /* Glonass data */
+ GPS_GLNS_ALM = 0x200, /* | | X | X | ** preliminary ** */ //##++
+ GPS_GNSS_SAT_INFO, /* | | X | | GNSS_SAT_INFO, request SVs */
+ GPS_GNSS_MODE, /* | | X | X | MBG_GNSS_MODE_{SETTINGS|INFO}, GNSS operation mode */
+
+ /* Misc data */
+ GPS_IP4_SETTINGS = 0x800, /* | X | X | IP4_SETTINGS, cfg of optional LAN interface */
+ GPS_LAN_IF_INFO, /* | X | | LAN_IF_INFO, LAN interface info */
+
+ /* misc data (SCU) */
+ GPS_SCU_STAT = 0x820, /* | X | X | X | SCU_STAT_{SETTINGS|INFO}, SCU board control */
+
+ GPS_CRYPTED_PACKET = 0x880, /* | X | X | X | encrypted binary packet */
+ GPS_CRYPTED_RAW_PACKET, /* | X | X | X | encrypted binary raw packet */
+
+ GPS_SECU_INFO = 0x900, /* | | X | | encryption method for LAN interface */
+ GPS_SECU_SETTINGS, /* | | X | X | reserved for public key LAN interface */
+ GPS_SECU_PUBLIC_KEY, /* | | | | settings and password for LAN interface */
+
+ /* PZF data */
+ PZF_PCPS_TIME = 0xA00, /* | | X | X | PCPS_TIME, date/time/status */
+ PZF_TR_DISTANCE, /* | | X | X | TR_DISTANCE, dist. from transmitter [km] */
+ PZF_TZCODE, /* | | X | X | TZCODE, time zone code */
+ PZF_CORR_INFO /* | | X | | CORR_INFO, correlation info */
+};
+
+/*
+ * Caution: If GPS_ALM, GPS_EPH or a code named ..._IDX is sent to retrieve
+ * some data from a device then an uint16_t parameter must be also supplied
+ * in order to specify the index number of the data set to be returned.
+ * The valid index range depends on the command code.
+ *
+ * For GPS_ALM and GPS_EPH the index is the SV number which may be 0 or
+ * MIN_SVNO to MAX_SVNO. If the number is 0, ALL almanacs (32) are returned.
+ */
+
+
+typedef struct
+{
+ GPS_CMD cmd_code;
+ const char *cmd_name;
+} GPS_CMD_NAME_TABLE_ENTRY;
+
+#define GPS_CMD_NAME_TABLE_ENTRIES \
+{ \
+ { GPS_AUTO_ON, "GPS_AUTO_ON" }, \
+ { GPS_AUTO_OFF, "GPS_AUTO_OFF" }, \
+ { GPS_SW_REV, "GPS_SW_REV" }, \
+ { GPS_BVAR_STAT, "GPS_BVAR_STAT" }, \
+ { GPS_TIME, "GPS_TIME" }, \
+ { GPS_POS_XYZ, "GPS_POS_XYZ" }, \
+ { GPS_POS_LLA, "GPS_POS_LLA" }, \
+ { GPS_TZDL, "GPS_TZDL" }, \
+ { GPS_PORT_PARM, "GPS_PORT_PARM" }, \
+ { GPS_SYNTH, "GPS_SYNTH" }, \
+ { GPS_ANT_INFO, "GPS_ANT_INFO" }, \
+ { GPS_UCAP, "GPS_UCAP" }, \
+ { GPS_ENABLE_FLAGS, "GPS_ENABLE_FLAGS" }, \
+ { GPS_STAT_INFO, "GPS_STAT_INFO" }, \
+ { GPS_SWITCH_PARMS, "GPS_SWITCH_PARMS" }, \
+ { GPS_STRING_PARMS, "GPS_STRING_PARMS" }, \
+ { GPS_ANT_CABLE_LENGTH, "GPS_ANT_CABLE_LENGTH" }, \
+ { GPS_SYNC_OUTAGE_DELAY, "GPS_SYNC_OUTAGE_DELAY" }, \
+ { GPS_PULSE_INFO, "GPS_PULSE_INFO" }, \
+ { GPS_OPT_FEATURES, "GPS_OPT_FEATURES" }, \
+ { GPS_IRIG_TX_SETTINGS, "GPS_IRIG_TX_SETTINGS" }, \
+ { GPS_RECEIVER_INFO, "GPS_RECEIVER_INFO" }, \
+ { GPS_STR_TYPE_INFO_IDX, "GPS_STR_TYPE_INFO_IDX" }, \
+ { GPS_PORT_INFO_IDX, "GPS_PORT_INFO_IDX" }, \
+ { GPS_PORT_SETTINGS_IDX, "GPS_PORT_SETTINGS_IDX" }, \
+ { GPS_POUT_INFO_IDX, "GPS_POUT_INFO_IDX" }, \
+ { GPS_POUT_SETTINGS_IDX, "GPS_POUT_SETTINGS_IDX" }, \
+ { GPS_IRIG_TX_INFO, "GPS_IRIG_TX_INFO" }, \
+ { GPS_MULTI_REF_SETTINGS, "GPS_MULTI_REF_SETTINGS" }, \
+ { GPS_MULTI_REF_INFO, "GPS_MULTI_REF_INFO" }, \
+ { GPS_ROM_CSUM, "GPS_ROM_CSUM" }, \
+ { GPS_MULTI_REF_STATUS, "GPS_MULTI_REF_STATUS" }, \
+ { GPS_RCV_TIMEOUT, "GPS_RCV_TIMEOUT" }, \
+ { GPS_IGNORE_LOCK, "GPS_IGNORE_LOCK" }, \
+ { GPS_IRIG_RX_SETTINGS, "GPS_IRIG_RX_SETTINGS" }, \
+ { GPS_IRIG_RX_INFO, "GPS_IRIG_RX_INFO" }, \
+ { GPS_REF_OFFS, "GPS_REF_OFFS" }, \
+ { GPS_DEBUG_STATUS, "GPS_DEBUG_STATUS" }, \
+ { GPS_XMR_SETTINGS_IDX, "GPS_XMR_SETTINGS_IDX" }, \
+ { GPS_XMR_INFO_IDX, "GPS_XMR_INFO_IDX" }, \
+ { GPS_XMR_STATUS_IDX, "GPS_XMR_STATUS_IDX" }, \
+ { GPS_OPT_SETTINGS, "GPS_OPT_SETTINGS" }, \
+ { GPS_OPT_INFO, "GPS_OPT_INFO" }, \
+ { GPS_CLR_UCAP_BUFF, "GPS_CLR_UCAP_BUFF" }, \
+ { GPS_TIME_SCALE, "GPS_TIME_SCALE" }, \
+ { GPS_NAV_ENG_SETTINGS, "GPS_NAV_ENG_SETTINGS" }, \
+ { GPS_RAW_IRIG_DATA, "GPS_RAW_IRIG_DATA" }, \
+ { GPS_GPIO_CFG_LIMITS, "GPS_GPIO_CFG_LIMITS" }, \
+ { GPS_GPIO_INFO_IDX, "GPS_GPIO_INFO_IDX" }, \
+ { GPS_GPIO_SETTINGS_IDX, "GPS_GPIO_SETTINGS_IDX" }, \
+ { GPS_XMR_INSTANCES, "GPS_XMR_INSTANCES" }, \
+ { GPS_CLR_EVT_LOG, "GPS_CLR_EVT_LOG" }, \
+ { GPS_NUM_EVT_LOG_ENTRIES, "GPS_NUM_EVT_LOG_ENTRIES" }, \
+ { GPS_FIRST_EVT_LOG_ENTRY, "GPS_FIRST_EVT_LOG_ENTRY" }, \
+ { GPS_NEXT_EVT_LOG_ENTRY, "GPS_NEXT_EVT_LOG_ENTRY" }, \
+ { GPS_LNO_STATUS, "GPS_LNO_STATUS" }, \
+ \
+ /* GPS data */ \
+ { GPS_CFGH, "GPS_CFGH" }, \
+ { GPS_ALM, "GPS_ALM" }, \
+ { GPS_EPH, "GPS_EPH" }, \
+ { GPS_UTC, "GPS_UTC" }, \
+ { GPS_IONO, "GPS_IONO" }, \
+ { GPS_ASCII_MSG, "GPS_ASCII_MSG" }, \
+ \
+ /* Glonass data */ \
+ { GPS_GLNS_ALM, "GPS_GLNS_ALM" }, \
+ { GPS_GNSS_SAT_INFO, "GPS_GNSS_SAT_INFO" }, \
+ { GPS_GNSS_MODE, "GPS_GNSS_MODE" }, \
+ \
+ /* Misc data */ \
+ { GPS_IP4_SETTINGS, "GPS_IP4_SETTINGS" }, \
+ { GPS_LAN_IF_INFO, "GPS_LAN_IF_INFO" }, \
+ \
+ /* misc data (SCU) */ \
+ { GPS_SCU_STAT, "GPS_SCU_STAT" }, \
+ \
+ { GPS_CRYPTED_PACKET, "GPS_CRYPTED_PACKET" }, \
+ { GPS_CRYPTED_RAW_PACKET, "GPS_CRYPTED_RAW_PACKET" }, \
+ \
+ { GPS_SECU_INFO, "GPS_SECU_INFO" }, \
+ { GPS_SECU_SETTINGS, "GPS_SECU_SETTINGS" }, \
+ { GPS_SECU_PUBLIC_KEY, "GPS_SECU_PUBLIC_KEY" }, \
+ \
+ /* PZF data */ \
+ { PZF_PCPS_TIME, "PZF_PCPS_TIME" }, \
+ { PZF_TR_DISTANCE, "PZF_TR_DISTANCE" }, \
+ { PZF_TZCODE, "PZF_TZCODE" }, \
+ { PZF_CORR_INFO, "PZF_CORR_INFO" }, \
+ { 0, NULL } \
+}
+
+
+/* A structure holding the number of a SV and the SV's almanac. */
+
+typedef struct
+{
+ SVNO svno;
+ ALM alm;
+} SV_ALM;
+
+
+
+/* A structure holding the number of a SV and the SV's ephemeris. */
+
+typedef struct
+{
+ SVNO svno;
+ EPH eph;
+} SV_EPH;
+
+
+
+#if _USE_PCPSDEFS
+
+/* Attention: this differs from PCPS_TZCODE defined in pcpsdefs.h */
+typedef uint16_t TZCODE;
+
+#endif
+
+
+
+/* The message header */
+
+typedef struct
+{
+ GPS_CMD cmd;
+ uint16_t len;
+ CSUM data_csum;
+ CSUM hdr_csum;
+} MSG_HDR;
+
+
+
+/* A union combining all kinds of parameters to be read from or written */
+/* to the GPS receiver. The size of the union corresponds to the maximum */
+/* size of the data part of a message. */
+
+typedef union
+{
+ /* common types */
+ uint16_t us;
+ double d;
+ SVNO svno;
+
+ /* user data */
+ SW_REV sw_rev;
+ BVAR_STAT bvar_stat;
+ TTM ttm;
+ XYZ xyz;
+ LLA lla;
+ TZDL tzdl;
+ PORT_PARM port_parm;
+ SYNTH synth;
+ ANT_INFO ant_info;
+ TTM ucap;
+ ENABLE_FLAGS enable_flags;
+ STAT_INFO stat_info;
+ ANT_CABLE_LEN ant_cable_len;
+ IRIG_SETTINGS irig_tx_settings;
+ RECEIVER_INFO receiver_info;
+ STR_TYPE_INFO_IDX str_type_info_idx;
+ PORT_INFO_IDX port_info_idx;
+ PORT_SETTINGS_IDX port_settings_idx;
+ POUT_INFO_IDX pout_info_idx;
+ POUT_SETTINGS_IDX pout_settings_idx;
+ IRIG_INFO irig_tx_info;
+ MULTI_REF_SETTINGS multi_ref_settings;
+ MULTI_REF_INFO multi_ref_info;
+ ROM_CSUM rom_csum;
+ MULTI_REF_STATUS multi_ref_status;
+ RCV_TIMEOUT rcv_timeout;
+ IGNORE_LOCK ignore_lock;
+ IRIG_SETTINGS irig_rx_settings;
+ IRIG_INFO irig_rx_info;
+ MBG_REF_OFFS ref_offs;
+ MBG_DEBUG_STATUS debug_status;
+ XMULTI_REF_SETTINGS_IDX xmulti_ref_settings_idx;
+ XMULTI_REF_INFO_IDX xmulti_ref_info_idx;
+ XMULTI_REF_STATUS_IDX xmulti_ref_status_idx;
+ MBG_OPT_SETTINGS opt_settings;
+ MBG_OPT_INFO opt_info;
+ MBG_TIME_SCALE_INFO time_scale_info;
+ MBG_TIME_SCALE_SETTINGS time_scale_settings;
+ NAV_ENGINE_SETTINGS nav_engine_settings;
+ MBG_RAW_IRIG_DATA raw_irig_data;
+ GNSS_SAT_INFO gnss_sat_info; //##++++++
+ MBG_GNSS_MODE_INFO gnss_mode_info; //##++++++
+ MBG_GNSS_MODE_SETTINGS gnss_mode_settings; //##++++++
+ MBG_GPIO_CFG_LIMITS gpio_cfg_limits;
+ MBG_GPIO_INFO_IDX gpio_info_idx;
+ MBG_GPIO_SETTINGS_IDX gpio_settings_idx;
+ XMULTI_REF_INSTANCES xmulti_ref_instances;
+ MBG_NUM_EVT_LOG_ENTRIES num_evt_log_entries;
+ MBG_EVT_LOG_ENTRY evt_log_entry;
+ LNO_STATE lno_state;
+
+ /* GPS system data */
+ CFGH cfgh;
+ SV_ALM sv_alm;
+ SV_EPH sv_eph;
+ UTC utc;
+ IONO iono;
+ ASCII_MSG ascii_msg;
+
+ /* Misc data */
+ IP4_SETTINGS ip4_settings;
+ LAN_IF_INFO lan_if_info;
+
+ /* Misc data (SCU) */
+ SCU_STAT_INFO scu_stat_info;
+ SCU_STAT_SETTINGS scu_stat_settings;
+
+#if _USE_PCPSDEFS
+ PCPS_TIME pcps_time;
+ TR_DISTANCE tr_distance;
+ TZCODE tzcode;
+ CORR_INFO corr_info;
+#endif
+
+#if _USE_ENCRYPTION
+ SECU_SETTINGS secu_settings;
+#endif
+
+#if _USE_GPSPRIV
+ _mbg_gps_types_priv
+#endif
+
+} MSG_DATA;
+
+
+#ifndef MAX_MSG_DATA_SIZE
+ #ifndef ADD_MSG_DATA_SIZE
+ #if _USE_ENCRYPTION
+ #define ADD_MSG_DATA_SIZE AES_BLOCK_SIZE // round up to full paragraphs
+ #else
+ #define ADD_MSG_DATA_SIZE 0
+ #endif
+ #endif
+
+ #define MAX_MSG_DATA_SIZE ( sizeof( MSG_DATA ) + ADD_MSG_DATA_SIZE )
+#endif
+
+
+
+/* The structures below define parts of a binary message packet which */
+/* are used with encrypted messages, */
+
+typedef struct
+{
+ MSG_HDR hdr;
+
+ #if _USE_ENCRYPTION
+ uint8_t aes_initvect[AES_BLOCK_SIZE];
+ #else
+ // In this case this structure is just a dummy to avoid
+ // a compiler error with the function prototypes.
+ #endif
+
+} CRYPT_MSG_PREFIX;
+
+
+
+#if _USE_ENCRYPTION
+
+typedef struct
+{
+ uint8_t aes_initvect[AES_BLOCK_SIZE];
+
+ struct
+ {
+ MSG_HDR enc_hdr;
+
+ union
+ {
+ uint8_t bytes[MAX_MSG_DATA_SIZE];
+ MSG_DATA msg_data;
+ } enc_msg;
+
+ } enc_msg;
+
+} CRYPT_MSG_DATA;
+
+#endif
+
+
+
+/* A buffer holding a message header plus data part of a message */
+/* For portability reasons the CMSG_BUFF structure defined below */
+/* should be preferred for coding. */
+
+typedef struct
+{
+ MSG_HDR hdr;
+
+ union
+ {
+ uint8_t bytes[MAX_MSG_DATA_SIZE];
+ MSG_DATA msg_data;
+
+ #if _USE_ENCRYPTION
+ CRYPT_MSG_DATA crypt_msg_data;
+ #endif
+
+ } u;
+
+} MBG_MSG_BUFF;
+
+
+
+/* The structure below is used to control the reception of messages */
+
+typedef struct
+{
+ MBG_MSG_BUFF *pmb; /* points to unencrypted message buffer */
+ int buf_size; /* size of buffer, including header */
+ uint8_t *cur; /* points to current pos inside receive buffer */
+ int cnt; /* the number of bytes to receive */
+ ulong flags; /* flags if header already completed */
+ #if _USE_RCV_TSTAMP
+ MBG_TMO_TIME tstamp;
+ #endif
+ #if _USE_CHK_TSTR
+ void (*chk_tstr_fnc)( char c, CHK_TSTR_ARG *arg ); /* optional handler for normal, non-protocol data */
+ CHK_TSTR_ARG *chk_tstr_arg;
+ #endif
+
+} MBG_MSG_RCV_CTL;
+
+
+/* The flag bits below and the corresponding bit masks are used
+ for MBG_MSG_RCV_CTL::flags: */
+
+enum
+{
+ MBG_MSG_RCV_CTL_BIT_RCVD_HDR,
+ MBG_MSG_RCV_CTL_BIT_MSG_TOO_LONG,
+ MBG_MSG_RCV_CTL_BIT_OVERFLOW,
+ MBG_MSG_RCV_CTL_BIT_DECRYPT_ERR,
+ MBG_MSG_RCV_CTL_BIT_DECRYPTED,
+ N_MBG_MSG_RCV_CTL_BIT
+};
+
+#define MBG_MSG_RCV_CTL_RCVD_HDR ( 1UL << MBG_MSG_RCV_CTL_BIT_RCVD_HDR )
+#define MBG_MSG_RCV_CTL_MSG_TOO_LONG ( 1UL << MBG_MSG_RCV_CTL_BIT_MSG_TOO_LONG )
+#define MBG_MSG_RCV_CTL_OVERFLOW ( 1UL << MBG_MSG_RCV_CTL_BIT_OVERFLOW )
+#define MBG_MSG_RCV_CTL_DECRYPT_ERR ( 1UL << MBG_MSG_RCV_CTL_BIT_DECRYPT_ERR )
+#define MBG_MSG_RCV_CTL_DECRYPTED ( 1UL << MBG_MSG_RCV_CTL_BIT_DECRYPTED )
+
+
+typedef struct
+{
+ MBG_MSG_BUFF *pmb;
+ int buf_size;
+ int xfer_mode;
+
+ #if _USE_MUTEX
+ MBG_MUTEX xmt_mutex;
+ #endif
+
+} MBG_MSG_XMT_CTL;
+
+
+// codes used with MBG_MSG_CTL::xfer_mode:
+
+enum
+{
+ MBG_XFER_MODE_NORMAL,
+ MBG_XFER_MODE_ENCRYTED,
+ N_MBG_XFER_MODE
+};
+
+
+
+#if _USE_SOCKET_IO
+
+#if !defined ( MBGEXTIO_RCV_TIMEOUT_SOCKET )
+ #define MBGEXTIO_RCV_TIMEOUT_SOCKET 2000 // [ms]
+#endif
+
+#define LAN_XPT_PORT 10001
+
+#ifndef INVALID_SOCKET
+ #define INVALID_SOCKET -1
+#endif
+
+typedef struct
+{
+ int sockfd;
+ struct sockaddr_in addr;
+
+} SOCKET_IO_STATUS;
+
+#endif // _USE_SOCKET_IO
+
+
+#if _USE_SERIAL_IO
+
+#endif // _USE_SERIAL_IO
+
+
+
+typedef struct
+{
+ MBG_MSG_RCV_CTL rcv;
+ MBG_MSG_XMT_CTL xmt;
+
+ int conn_type;
+ int io_error;
+ ulong msg_rcv_timeout; // binary message receive timeout [ms]
+ ulong char_rcv_timeout; // serial character receive timeout [ms]
+
+ #if _USE_ENCRYPTION
+ uint8_t aes_initvect[AES_BLOCK_SIZE];
+ uint8_t aes_keyvect[AES_BLOCK_SIZE];
+ #endif
+
+ #if _USE_SOCKET_IO
+ SECU_SETTINGS secu_settings;
+ #endif
+
+ #if _USE_SERIAL_IO || _USE_SOCKET_IO || _USE_USB_IO
+ union
+ {
+ #if _USE_SOCKET_IO
+ SOCKET_IO_STATUS sockio;
+ #endif
+
+ #if _USE_SERIAL_IO
+ SERIAL_IO_STATUS serio;
+ #endif
+
+ #if _USE_USB_IO
+ USB_IO_STATUS usbio;
+ #endif
+ } st;
+ #endif
+
+} MBG_MSG_CTL;
+
+
+// codes used with MBG_MSG_CTL::conn_type:
+
+enum
+{
+ MBG_CONN_TYPE_SERIAL,
+ MBG_CONN_TYPE_SOCKET,
+ MBG_CONN_TYPE_USB,
+ N_MBG_CONN_TYPE
+};
+
+
+
+/* function prototypes: */
+
+#if _USE_GPSSERIO_FNC
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ CSUM msg_csum_update( CSUM csum, uint8_t *p, int n ) ;
+ CSUM msg_csum( uint8_t *p, int n ) ;
+ CSUM msg_hdr_csum( MSG_HDR *pmh ) ;
+ int chk_hdr_csum( MSG_HDR *pmh ) ;
+ int chk_data_csum( MBG_MSG_BUFF *pmb ) ;
+ int encrypt_message( MBG_MSG_CTL *pmctl, CRYPT_MSG_PREFIX *pcmp, MBG_MSG_BUFF *pmb ) ;
+ int decrypt_message( MBG_MSG_CTL *pmctl ) ;
+ void set_encryption_mode( MBG_MSG_CTL *pmctl, int mode, const char *key ) ;
+ int xmt_tbuff( MBG_MSG_CTL *pmctl ) ;
+ int xmt_cmd( MBG_MSG_CTL *pmctl, GPS_CMD cmd ) ;
+ int xmt_cmd_us( MBG_MSG_CTL *pmctl, GPS_CMD cmd, uint16_t us ) ;
+ int check_transfer( MBG_MSG_RCV_CTL *prctl, uint8_t c ) ;
+
+/* ----- function prototypes end ----- */
+
+#endif // _USE_GPSSERIO_FNC
+
+/* End of header body */
+
+
+#undef _ext
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GPSSERIO_H */
+
diff --git a/c/mbglib/include/gpsutils.h b/c/mbglib/include/gpsutils.h
index d57085b..476a5c1 100644
--- a/c/mbglib/include/gpsutils.h
+++ b/c/mbglib/include/gpsutils.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: gpsutils.h 1.6 2005/02/18 10:32:33Z martin REL_M $
+ * $Id: gpsutils.h 1.4.1.2 2010/07/15 09:19:04Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,10 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: gpsutils.h $
- * Revision 1.6 2005/02/18 10:32:33Z martin
- * Check more predefined macros to determine if compiling for Windows.
- * Revision 1.5 2003/02/04 09:18:48Z MARTIN
- * Updated function prototypes.
+ * Revision 1.4.1.2 2010/07/15 09:19:04Z martin
+ * Use DEG character definition from pcpslstr.h.
+ * Revision 1.4.1.1 2003/05/15 09:40:25Z martin
+ * Changed degree string/char for QNX.
* Revision 1.4 2002/12/12 16:08:11 martin
* Definitions for degree character.
* Requires mbggeo.h.
@@ -43,18 +43,6 @@
/* Start of header body */
-#define ANSI_C_DEGREE '°' // single char
-#define ANSI_S_DEGREE "°" // string
-
-#if defined( _Windows ) || defined( _WINDOWS ) \
- || defined( WIN32 ) || defined( __linux )
- #define C_DEGREE ANSI_C_DEGREE
- #define S_DEGREE ANSI_S_DEGREE
-#else
- #define C_DEGREE 'ø'
- #define S_DEGREE "ø"
-#endif
-
/* function prototypes: */
@@ -74,9 +62,7 @@ extern "C" {
void swap_iono_doubles( IONO *ionop ) ;
void swap_pos_doubles( POS *posp ) ;
void sprint_dms( char *s, DMS *pdms, int prec ) ;
- void sprint_alt( char *s, double alt ) ;
void sprint_pos_geo( char *s, POS *ppos, const char *sep, int prec ) ;
- void sprint_fixed_freq( char *s, FIXED_FREQ_INFO *p_ff ) ;
/* ----- function prototypes end ----- */
diff --git a/c/mbglib/include/mbg_arch.h b/c/mbglib/include/mbg_arch.h
index dc97477..28edaf5 100644
--- a/c/mbglib/include/mbg_arch.h
+++ b/c/mbglib/include/mbg_arch.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_arch.h 1.2 2009/03/19 15:14:15Z martin REL_M martin $
+ * $Id: mbg_arch.h 1.3.1.4 2011/06/27 16:12:59Z martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,14 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_arch.h $
- * Revision 1.2 2009/03/19 15:14:15Z martin
+ * Revision 1.3.1.4 2011/06/27 16:12:59Z martin
+ * Revision 1.3.1.3 2011/04/12 12:55:28 martin
+ * Include words.h.
+ * Revision 1.3.1.2 2011/02/09 15:46:48 martin
+ * Revision 1.3.1.1 2011/02/09 15:26:58 martin
+ * Revision 1.3 2009/06/12 13:12:37Z martin
+ * Fixed compiler warning.
+ * Revision 1.2 2009/03/19 15:14:15 martin
* Fixed byte swapping of doubles for SPARC architecture.
* Revision 1.1 2008/12/05 13:47:42 martin
* Initial revision.
@@ -21,6 +28,11 @@
#define _MBG_ARCH_H
#include <mbg_tgt.h>
+#include <words.h>
+
+#if !defined( MBG_TGT_KERNEL )
+ #include <stdlib.h>
+#endif
#if defined( MBG_ARCH_SPARC )
@@ -38,7 +50,7 @@
#include <asm/byteorder.h>
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
#include <asm/unaligned.h>
#define _mbg_put_unaligned( _v, _p ) put_unaligned( _v, _p )
@@ -53,12 +65,12 @@
// define some default macros assuming no special handling is required
// to access unaligned data.
-#if !defined( _pcps_put_unaligned )
- #define _pcps_put_unaligned( _v, _p ) ((void)( *(_p) = (_v) ))
+#if !defined( _mbg_put_unaligned )
+ #define _mbg_put_unaligned( _v, _p ) ((void)( *(_p) = (_v) ))
#endif
-#if !defined( _pcps_get_unaligned )
- #define _pcps_get_unaligned( _p ) (*(_p))
+#if !defined( _mbg_get_unaligned )
+ #define _mbg_get_unaligned( _p ) (*(_p))
#endif
@@ -116,7 +128,7 @@ void mbg_swab_double( double *p )
__swab64p( p );
#else // ... so we do the swapping manually
double d = 0;
- int i;
+ size_t i;
for ( i = 0; i < sizeof( double); i++ )
BYTE_OF( d, i ) = BYTE_OF( *p, ( sizeof( double) - 1 - i ) );
diff --git a/c/mbglib/include/mbg_tgt.h b/c/mbglib/include/mbg_tgt.h
index 28aebf8..10c5de3 100644
--- a/c/mbglib/include/mbg_tgt.h
+++ b/c/mbglib/include/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.19 2009/06/09 10:03:58Z daniel REL_M $
+ * $Id: mbg_tgt.h 1.24.1.1 2011/10/21 14:08:50Z martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,25 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.19 2009/06/09 10:03:58Z daniel
+ * Revision 1.24.1.1 2011/10/21 14:08:50Z martin
+ * Changes for QNX.
+ * Revision 1.24 2011/08/23 10:21:23 martin
+ * New symbol _NO_MBG_API_ATTR which can be used with functions
+ * which are going to be exported by a DLL, but actually aren't, yet.
+ * Revision 1.23 2011/08/19 10:47:00 martin
+ * Don't include stddef.h.
+ * Distinguish between different gcc target platforms.
+ * Initial support for IA64 platform.
+ * Support wchar_t for BSD.
+ * Defined _NO_USE_PACK_INTF for Sparc and IA64.
+ * Fixed typo in comment.
+ * Revision 1.22 2009/10/01 08:20:50 martin
+ * Fixed inline code support with different BC versions.
+ * Revision 1.21 2009/09/01 10:34:23Z martin
+ * Don't define __mbg_inline for CVI and undefined targets.
+ * Revision 1.20 2009/08/18 15:14:26 martin
+ * Defined default MBG_INVALID_PORT_HANDLE for non-Windows targets.
+ * Revision 1.19 2009/06/09 10:03:58 daniel
* Preliminary support for ARM architecture.
* Revision 1.18 2009/04/01 14:10:55 martin
* Cleanup for CVI.
@@ -73,8 +91,6 @@
/* Other headers to be included */
-#include <stddef.h>
-
#ifdef _MBG_TGT
#define _ext
#else
@@ -145,6 +161,10 @@
#define MBG_TGT_LINUX
#define _GNU_SOURCE 1
+ #if defined( __KERNEL__ )
+ #define MBG_TGT_KERNEL
+ #endif
+
#elif defined( __FreeBSD__ )
// GCC for target FreeBSD
@@ -157,7 +177,7 @@
#elif defined( __OpenBSD__ )
- // GCC for target FreeBSD
+ // GCC for target OpenBSD
#define MBG_TGT_OPENBSD
#elif defined( __QNX__ )
@@ -189,17 +209,34 @@
#define __mbg_inline __inline__
- #define MBG_TGT_HAS_WCHAR_T defined( MBG_TGT_WIN32 )
+ #define MBG_TGT_HAS_WCHAR_T 1
+
+ #if defined( __i386__ )
+
+ #define MBG_ARCH_I386
+ #define MBG_ARCH_X86
+
+ #elif defined( __x86_64__ )
+
+ #define MBG_ARCH_X86_64
+ #define MBG_ARCH_X86
+
+ #elif defined( __ia64__ )
- #if defined( __sparc__ )
+ #define MBG_ARCH_IA64
+
+ #define _NO_USE_PACK_INTF
+
+ #elif defined( __sparc__ )
#define MBG_ARCH_SPARC
- #define _MBG_ARCH_DEFINED
+ #define MBG_USE_MM_IO_FOR_PCI 1
+
+ #define _NO_USE_PACK_INTF
#elif defined( __arm__ )
#define MBG_ARCH_ARM
- #define _MBG_ARCH_DEFINED
#endif
@@ -211,14 +248,18 @@
#elif defined( _CVI ) || defined( _CVI_ )
- #define __mbg_inline //##++++
+ // Inline code is not supported.
#define MBG_TGT_HAS_WCHAR_T 0
#elif defined( __BORLANDC__ )
#if defined( __cplusplus )
- #define __mbg_inline inline
+ #define __mbg_inline inline // standard C++ syntax
+ #elif ( __BORLANDC__ > 0x410 ) // BC3.1 defines 0x410 !
+ #define __mbg_inline __inline // newer BC versions support this for C
+ #else
+ #define __mbg_inline // up to BC3.1 not supported for C
#endif
#define MBG_TGT_HAS_WCHAR_T defined( MBG_TGT_WIN32 )
@@ -233,30 +274,19 @@
-// Currently we support only Sparc and i386/x86_64 architectures,
-// so unless we have explicitely found sparc we assume i386.
-
-#if !defined( _MBG_ARCH_DEFINED )
- #define MBG_ARCH_I386
-#endif
-
-
-#if !defined( __mbg_inline )
-
- #define __mbg_inline
-
-#endif
-
-
#if defined( MBG_TGT_FREEBSD ) \
|| defined( MBG_TGT_NETBSD ) \
|| defined( MBG_TGT_OPENBSD )
#define MBG_TGT_BSD
+
+ #if defined( _KERNEL )
+ #define MBG_TGT_KERNEL
+ #endif
+
#endif
#if defined( MBG_TGT_LINUX ) \
- || defined( MBG_TGT_BSD ) \
- || defined( MBG_TGT_QNX_NTO )
+ || defined( MBG_TGT_BSD )
#define MBG_TGT_UNIX
#endif
@@ -275,6 +305,7 @@
#endif
#if defined( _KDD_ )
+ #define MBG_TGT_KERNEL
#include <ntddk.h>
#else
// This must not be used for kernel drivers.
@@ -282,14 +313,13 @@
typedef HANDLE MBG_HANDLE;
#define MBG_INVALID_HANDLE INVALID_HANDLE_VALUE
-
- #if defined( MBG_TGT_CVI )
+
+ #if defined( MBG_TGT_CVI )
// CVI uses an own set of functions to support serial ports
typedef int MBG_PORT_HANDLE;
#define MBG_INVALID_PORT_HANDLE -1
#else
typedef HANDLE MBG_PORT_HANDLE;
- #define MBG_INVALID_PORT_HANDLE MBG_INVALID_HANDLE
#endif
// The DWORD_PTR type is not defined in the headers shipping
@@ -335,13 +365,16 @@
#define _MBG_API_ATTR
#endif
+#if !defined( _NO_MBG_API_ATTR )
+ #define _NO_MBG_API_ATTR
+#endif
+
+#if !defined( MBG_INVALID_PORT_HANDLE )
+ #define MBG_INVALID_PORT_HANDLE MBG_INVALID_HANDLE
+#endif
#if !defined( MBG_USE_MM_IO_FOR_PCI )
- #if ( 0 || defined( MBG_ARCH_SPARC ) )
- #define MBG_USE_MM_IO_FOR_PCI 1
- #else
- #define MBG_USE_MM_IO_FOR_PCI 0
- #endif
+ #define MBG_USE_MM_IO_FOR_PCI 0
#endif
@@ -352,8 +385,18 @@
// The macros below are defined in order to be able to check if
// certain C language extensions are available on the target system:
-#define MBG_TGT_C94 ( defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199409L ) )
-#define MBG_TGT_C99 ( defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) )
+#if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199409L )
+ #define MBG_TGT_C94 1
+#else
+ #define MBG_TGT_C94 0
+#endif
+
+
+#if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L )
+ #define MBG_TGT_C99 1
+#else
+ #define MBG_TGT_C99 0
+#endif
// Check if wchar_t is supported
#if !defined( MBG_TGT_HAS_WCHAR_T )
@@ -366,7 +409,7 @@
// However, some functions may be missing (e.g. snwprintf()).
#if !defined( _WCHAR_T ) /* BC3.1 */ \
&& !defined( _WCHAR_T_DEFINED_ ) /* WC11 */
- //##++ #define _WCHAR_T
+ #define _WCHAR_T
#define wchar_t char
#endif
#endif
diff --git a/c/mbglib/include/mbg_w32.h b/c/mbglib/include/mbg_w32.h
new file mode 100644
index 0000000..3b93e8f
--- /dev/null
+++ b/c/mbglib/include/mbg_w32.h
@@ -0,0 +1,309 @@
+
+/**************************************************************************
+ *
+ * $Id: mbg_w32.h 1.7 2012/05/30 13:28:43Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * OS dependend definitions/redefinitions for Win32.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbg_w32.h $
+ * Revision 1.7 2012/05/30 13:28:43Z martin
+ * Cleanup.
+ * Revision 1.6 2012/05/29 14:39:53Z martin
+ * Runtime support for precise time API introduced with Windows 8.
+ * Revision 1.5 2009/03/26 08:32:26Z martin
+ * Added orgDeviceExtension field for non-PNP driver.
+ * Revision 1.4 2009/01/13 14:45:17Z martin
+ * Added PCPS_DDEV::RegistryPath field for non-PnP driver.
+ * Use PCPS_DDEV::irp and PCPS_DDEV::win32DeviceName also for non-PnP driver.
+ * Added PCPS_DDEV::DriverObject field.
+ * Conditionally added PCPS_DDEV fields required to support programmable IRQs.
+ * Revision 1.3 2007/09/27 10:36:25Z martin
+ * Added macro specifying Windows specific device data.
+ * Added USB support.
+ * Renamed Removed to SurpriseRemoved.
+ * Revision 1.2 2002/01/24 09:48:05Z Udo
+ * check in as lib module
+ * Revision 1.1 2001/09/13 07:12:14Z Udo
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _MBG_W32_H
+#define _MBG_W32_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#if defined( MBG_TGT_WIN32_PNP ) && defined( MBG_TGT_KERNEL )
+ #include <usb100.h>
+ #include <usbdi.h>
+ #include <usbdlib.h>
+#endif
+
+
+#ifdef _MBG_W32
+ #define _ext
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if USE_PGMB_IRQ
+
+ typedef struct
+ {
+ struct _KINTERRUPT *Object;
+ KEVENT *Event;
+ KSPIN_LOCK Spinlock;
+ KDPC *Dpc;
+ } MBG_IRQ_INFO;
+
+ #define _pgmb_irq_vars \
+ MBG_IRQ_INFO Irq;
+
+#else
+
+ #define _pgmb_irq_vars
+
+#endif
+
+
+
+/**
+ * @brief A pointer to a function returning the system time as LARGE_INTEGER.
+ *
+ * This is for kernel mode only. The function can be e.g. the standard Windows
+ * API call KeQuerySystemTime() or the KeQuerySystemTimePrecise() API
+ * call introduced with Windows 8.
+ */
+typedef VOID (*KE_QUERY_SYSTEM_TIME_FNC)(PLARGE_INTEGER CurrentTime);
+
+
+
+#if defined( MBG_TGT_KERNEL )
+
+#if !defined( NTKERNELAPI )
+ #define NTKERNELAPI
+#endif
+
+#if !defined( __in )
+ #define __in
+#endif
+
+#if !defined( _Out_ )
+ #define _Out_
+#endif
+
+
+#if 0 //##++
+ #define _x_evt_msg _evt_msg
+#else
+ #define _x_evt_msg _dbg_evt_msg
+#endif
+
+
+
+// definitions for clock() support in kernel drivers
+
+#define clock_t ulong
+
+#define clock w32_clock
+
+// KeQueryTimeIncrement() returns number of 100nsec increments per tick.
+// There are 10000000 100nsec increments per second.
+#define MBG_TICKS_PER_SEC ( 10000000 / KeQueryTimeIncrement() )
+
+
+/**
+ * @brief Get precise Windows system time as FILETIME.
+ *
+ * @note This function has been introduced with Windows 8,
+ * so it is not available on older Windows versions. Thus
+ * the API call is imported from ntoskrnl.exe at runtime.
+ *
+ * @param CurrentTime pointer to a LARGE_INTEGER to be filled
+ *
+ * @see KE_QUERY_SYSTEM_TIME_FNC
+ * @see import_kernel_precise_time_api()
+ */
+NTKERNELAPI
+VOID
+KeQuerySystemTimePrecise( _Out_ PLARGE_INTEGER CurrentTime);
+
+
+
+#if defined( MBG_TGT_WIN32_PNP )
+
+ #if !defined ( SE_CREATE_SYMBOLIC_LINK_PRIVILEGE )
+
+ // Define some KDD function types which may not be
+ // defined in older DDK headers.
+
+ typedef
+ NTSTATUS
+ IO_COMPLETION_ROUTINE (
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp,
+ PVOID Context
+ );
+
+ typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
+
+
+ typedef
+ NTSTATUS
+ DRIVER_DISPATCH (
+ __in struct _DEVICE_OBJECT *DeviceObject,
+ __in struct _IRP *Irp
+ );
+
+ typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
+
+
+ typedef
+ VOID
+ DRIVER_UNLOAD (
+ __in struct _DRIVER_OBJECT *DriverObject
+ );
+
+ typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
+
+
+ typedef
+ NTSTATUS
+ DRIVER_ADD_DEVICE (
+ __in struct _DRIVER_OBJECT *DriverObject,
+ __in struct _DEVICE_OBJECT *PhysicalDeviceObject
+ );
+
+ typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
+
+ #endif // !defined ( SE_CREATE_SYMBOLIC_LINK_PRIVILEGE )
+
+
+
+ #define MBG_USB_MAX_NUMBER_OF_ENDPOINTS 32
+ #define MBG_USB_MAX_NUMBER_OF_INTERFACES 1
+ #define MBG_USB_DEFAULT_TIMEOUT 5000
+ #define MBG_USB_MAX_CONTROL_TRANSFER_TIMEOUT 5000
+
+
+ #pragma pack( 4 ) //##++++++ this should be obsolete
+
+ typedef struct
+ {
+ long usage_count;
+ int remove_pending;
+ KEVENT event;
+ } USB_REMOVE_LOCK;
+
+
+ typedef struct
+ {
+ int address;
+ USBD_PIPE_HANDLE handle;
+ } USB_ENDPOINT;
+
+
+ typedef struct
+ {
+ int valid;
+ int claimed;
+ USB_ENDPOINT endpoints[MBG_USB_MAX_NUMBER_OF_ENDPOINTS];
+ } USB_INTERFACE;
+
+ #pragma pack()
+
+
+
+ #define _pcps_ddev_data_win_pnp \
+ DEVICE_OBJECT *physical_device_object; \
+ USB_REMOVE_LOCK remove_lock; \
+ \
+ struct \
+ { \
+ USBD_CONFIGURATION_HANDLE handle; \
+ int value; \
+ USB_INTERFACE interfaces[MBG_USB_MAX_NUMBER_OF_INTERFACES]; \
+ } config; \
+ \
+ LONG ref_count; \
+ POWER_STATE power_state; \
+ DEVICE_POWER_STATE device_power_states[PowerSystemMaximum]; \
+ \
+ DEVICE_OBJECT *NextLowerDriver; \
+ BOOLEAN Started; \
+ BOOLEAN SurpriseRemoved; \
+ IO_REMOVE_LOCK RemoveLock; \
+ BOOLEAN PortWasMapped;
+
+#else // if !defined( MBG_TGT_WIN32_PNP )
+
+ // Don't need PNP extensions in non-PNP environment.
+ #define _pcps_ddev_data_win_pnp \
+ UNICODE_STRING *RegistryPath; \
+ PVOID orgDeviceExtension;
+
+#endif // !defined( MBG_TGT_WIN32_PNP )
+
+
+ #define _pcps_ddev_data_win \
+ DRIVER_OBJECT *DriverObject; \
+ DEVICE_OBJECT *DeviceObject; \
+ UNICODE_STRING win32DeviceName; \
+ WCHAR wcs_msg[512]; \
+ IRP *irp; \
+ _pgmb_irq_vars \
+ _pcps_ddev_data_win_pnp
+
+#endif // defined( MBG_TGT_KERNEL )
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ clock_t w32_clock( void ) ;
+ /**
+ * @brief Try to import an API function to read precise Windows system time
+ *
+ * Check if the Windows API call KeQuerySystemTimePrecise() is available
+ * in kernel mode. This function has been introduced with Windows 8, so it
+ * is not available on older Windows versions, and thus the API call is
+ * imported from ntoskrnl.exe at runtime.
+ *
+ * @param fnc address of a function pointer which is set to the imported
+ * API function, or to NULL if the API call is not supported
+ *
+ * @see KeQuerySystemTimePrecise()
+ */
+ void import_kernel_precise_time_api( KE_QUERY_SYSTEM_TIME_FNC *fnc ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+
+#endif /* _MBG_W32_H */
+
diff --git a/c/mbglib/include/mbgdevio.h b/c/mbglib/include/mbgdevio.h
index ff44706..70fcef4 100644
--- a/c/mbglib/include/mbgdevio.h
+++ b/c/mbglib/include/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.37 2009/08/12 14:31:51Z daniel REL_M $
+ * $Id: mbgdevio.h 1.39.1.27 2012/04/11 15:45:12Z martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,80 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
- * Revision 1.37 2009/08/12 14:31:51Z daniel
+ * Revision 1.39.1.27 2012/04/11 15:45:12Z martin
+ * Updated doxygen comments.
+ * Revision 1.39.1.26 2012/04/11 14:49:06 martin
+ * Updated function prototypes.
+ * Revision 1.39.1.25 2011/11/25 15:03:22 martin
+ * Support on-board event logs.
+ * Revision 1.39.1.24 2011/11/23 16:42:03 martin
+ * Updated function prototypes.
+ * Added some comments.
+ * Revision 1.39.1.23.1.4 2011/11/23 16:37:24 martin
+ * Removed tmp. debug code.
+ * Revision 1.39.1.23.1.3 2011/11/23 16:32:53 martin
+ * Modified tmp. debug code.
+ * Revision 1.39.1.23.1.2 2011/11/22 15:13:14 martin
+ * Updated function prototypes.
+ * Revision 1.39.1.23.1.1 2011/11/21 14:16:33 martin
+ * Tmp. debug generic I/O.
+ * Revision 1.39.1.23 2011/11/16 10:09:28 martin
+ * Fixed a bug which caused a crash when generic I/O calls
+ * were used under Windows.
+ * Revision 1.39.1.22 2011/10/21 14:08:28Z martin
+ * Changes for QNX.
+ * Revision 1.39.1.21 2011/09/26 14:03:21 martin
+ * Workaround to make mbgmon (BC) build under Windows.
+ * See diff for details.
+ * Cleaned up CPU set support under Linux.
+ * Updated function prototypes.
+ * Revision 1.39.1.20 2011/07/20 15:52:22Z martin
+ * Conditionally use older IOCTL request buffer structures.
+ * Moved some macros here so they can be used by other modules.
+ * Modified some macros and definitions.
+ * Revision 1.39.1.19 2011/07/19 15:46:39 martin
+ * Revision 1.39.1.18 2011/07/06 11:19:24 martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.39.1.17 2011/06/29 11:10:19 martin
+ * Updated function prototypes.
+ * Revision 1.39.1.16 2011/06/22 10:16:22 martin
+ * Cleaned up handling of pragma pack().
+ * Cleaned up inclusion of header files.
+ * Updated function prototypes.
+ * Revision 1.39.1.15 2011/04/12 12:57:53 martin
+ * Moved mutex definitions to new mbgmutex.h.
+ * Renamed mutex stuff to critical sections.
+ * Revision 1.39.1.14 2011/03/31 13:20:55 martin
+ * Updated function prototypes.
+ * Revision 1.39.1.13 2011/02/15 14:26:22Z martin
+ * Revision 1.39.1.12 2011/02/15 11:22:29 daniel
+ * Updated function prototypes to support PTP unicast configuration
+ * Revision 1.39.1.11 2011/02/02 12:21:39Z martin
+ * Fixed a type.
+ * Revision 1.39.1.10 2011/01/28 09:33:45 martin
+ * Cosmetics.
+ * Revision 1.39.1.9 2010/12/14 11:23:49 martin
+ * Moved definition of MBG_HW_NAME to the header file.
+ * Revision 1.39.1.8 2010/12/14 10:56:35Z martin
+ * Revision 1.39.1.7 2010/08/11 13:48:53 martin
+ * Cleaned up comments.
+ * Revision 1.39.1.6 2010/08/11 12:43:52 martin
+ * Revision 1.39.1.5 2010/07/15 08:40:57 martin
+ * Revision 1.39.1.4 2010/01/08 15:04:17Z martin
+ * Revision 1.39.1.3 2010/01/08 11:24:02Z martin
+ * Compute and check time of day only if any leap second status bit set.
+ * Revision 1.39.1.2 2010/01/08 11:13:57Z martin
+ * Made xhrt leap second check an inline function.
+ * Revision 1.39.1.1 2010/01/07 15:49:37Z martin
+ * Fixed macro to avoid compiler warning.
+ * Revision 1.39 2009/12/15 15:34:59Z daniel
+ * Support reading the raw IRIG data bits for firmware versions
+ * which support this feature.
+ * Revision 1.38.1.2 2009/12/10 09:58:53Z daniel
+ * Revision 1.38.1.1 2009/12/10 09:45:29Z daniel
+ * Revision 1.38 2009/09/29 15:06:26Z martin
+ * Updated function prototypes.
+ * Revision 1.37 2009/08/12 14:31:51 daniel
* New version code 306, compatibility version still 210.
* Revision 1.36 2009/06/19 12:20:31Z martin
* Updated function prototypes.
@@ -140,17 +213,18 @@
/* Other headers to be included */
-#include <mbggeo.h>
#include <mbg_tgt.h>
#include <mbg_arch.h>
+#include <mbgmutex.h>
#include <mbgerror.h>
+#include <mbggeo.h>
#include <pcpsdev.h>
#include <pci_asic.h>
#include <use_pack.h>
#include <time.h>
-#define MBGDEVIO_VERSION 0x0306
+#define MBGDEVIO_VERSION 0x0307
#define MBGDEVIO_COMPAT_VERSION 0x0210
@@ -173,6 +247,9 @@
#define MBG_USE_KERNEL_DRIVER 1
#include <windows.h>
+ #define MBGDEVIO_RET_VAL DWORD
+ #define _mbgdevio_cnv_ret_val( _v ) (_v)
+
#elif defined( MBG_TGT_LINUX )
#if !defined( MBGDEVIO_XHRT_API )
@@ -187,17 +264,32 @@
// as per default.
#define MBG_USE_KERNEL_DRIVER 1
+ #include <sys/ioctl.h>
#include <fcntl.h>
+ #include <sched.h>
+
+ #if MBGDEVIO_USE_THREAD_API
+ #include <pthread.h>
+ #endif
#elif defined( MBG_TGT_BSD )
#define MBG_USE_KERNEL_DRIVER 1
+ #include <sys/ioctl.h>
#include <fcntl.h>
#elif defined( MBG_TGT_OS2 )
#define MBG_USE_KERNEL_DRIVER 1
+#elif defined( MBG_TGT_QNX_NTO )
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+
+ #include <pcpsdrvr.h>
+
#elif defined( MBG_TGT_DOS )
#if !defined( MBG_USE_DOS_TSR )
@@ -213,6 +305,16 @@
#endif
+#if defined( MBG_USE_KERNEL_DRIVER )
+
+ #include <mbgioctl.h>
+
+ #include <stdlib.h>
+ #include <string.h>
+
+#endif
+
+
#if !defined( MBGDEVIO_XHRT_API )
#define MBGDEVIO_XHRT_API 0
#endif
@@ -234,8 +336,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -250,7 +353,7 @@
#if defined( MBG_USE_KERNEL_DRIVER )
- typedef MBG_HANDLE MBG_DEV_HANDLE ;
+ typedef MBG_HANDLE MBG_DEV_HANDLE;
#define MBG_INVALID_DEV_HANDLE MBG_INVALID_HANDLE
@@ -263,36 +366,53 @@
#endif
+#if !defined( MBGDEVIO_RET_VAL )
+ #define MBGDEVIO_RET_VAL int
+#endif
-#if defined( MBG_TGT_LINUX ) && !defined( MBG_ARCH_ARM )
- #include <sched.h>
+#if !defined( _mbgdevio_cnv_ret_val )
+ #define _mbgdevio_cnv_ret_val( _v ) \
+ ( ( (_v) < 0 ) ? (_v) : MBG_SUCCESS )
+#endif
- #define MBG_PROCESS_ID pid_t
- #define _mbg_get_current_process() 0
- #define MBG_CPU_SET cpu_set_t
- #define MBG_CPU_SET_SIZE CPU_SETSIZE
- #define _mbg_cpu_clear( _ps ) CPU_ZERO( (_ps) )
- #define _mbg_cpu_set( _i, _ps ) CPU_SET( (_i), (_ps) )
- #define _mbg_cpu_isset( _i, _ps ) CPU_ISSET( (_i), (_ps) )
+#define _mbgdevio_vars() \
+ MBGDEVIO_RET_VAL rc
- #if MBGDEVIO_USE_THREAD_API
+#define _mbgdevio_ret_val \
+ _mbgdevio_cnv_ret_val( rc )
+
+
+
+/**
+ The type below is used to store a unique ID for a device which
+ is made up of the device model name and its serial number, i.e.:
+ Format: [model_name]_[serial_number], e.g. "GPS170PCI_028210040670"
+ */
+typedef char MBG_HW_NAME[PCPS_CLOCK_NAME_SZ + PCPS_SN_SIZE + 1];
- #include <pthread.h>
- #define MBG_THREAD_ID pthread_t
- #define _mbg_get_current_thread() 0
- #define MBG_THREAD_FNC_ATTR // empty
- #define MBG_THREAD_FNC_RET_VAL void *
- #define _mbg_thread_exit( _v ) return (void *) (_v)
- #define MBG_MUTEX pthread_mutex_t
- #define _mbg_mutex_init( _pm ) pthread_mutex_init( (_pm), NULL )
- #define _mbg_mutex_deinit( _pm ) _nop_macro_fnc()
- #define _mbg_mutex_lock( _pm ) pthread_mutex_lock( (_pm) )
- #define _mbg_mutex_unlock( _pm ) pthread_mutex_unlock( (_pm) )
+#if defined( MBG_TGT_LINUX )
+ #define MBG_PROCESS_ID pid_t
+ #define _mbg_get_current_process() 0
+
+ #if defined( __cpu_set_t_defined )
+ #define MBG_CPU_SET cpu_set_t
+ #define MBG_CPU_SET_SIZE CPU_SETSIZE
+ #define _mbg_cpu_clear( _ps ) CPU_ZERO( (_ps) )
+ #define _mbg_cpu_set( _i, _ps ) CPU_SET( (_i), (_ps) )
+ #define _mbg_cpu_isset( _i, _ps ) CPU_ISSET( (_i), (_ps) )
+ #endif
+
+ #if MBGDEVIO_USE_THREAD_API
+ #define MBG_THREAD_ID pthread_t
+ #define _mbg_get_current_thread() 0
+ #define MBG_THREAD_FNC_ATTR // empty
+ #define MBG_THREAD_FNC_RET_VAL void *
+ #define _mbg_thread_exit( _v ) return (void *) (_v)
#endif
#elif defined( MBG_TGT_WIN32 )
@@ -301,19 +421,13 @@
#define _mbg_get_current_process() GetCurrentProcess()
#define MBG_CPU_SET DWORD_PTR // Attention: this is not used as pointer!
- #define MBG_CPU_SET_SIZE ( sizof( MBG_CPU_SET ) * 8 )
+ #define MBG_CPU_SET_SIZE ( sizeof( MBG_CPU_SET ) * 8 )
#define MBG_THREAD_ID HANDLE
#define _mbg_get_current_thread() GetCurrentThread()
#define MBG_THREAD_FNC_ATTR WINAPI
#define MBG_THREAD_FNC_RET_VAL DWORD
- #define _mbg_thread_exit( _v ) ExitThread( _v )
-
- #define MBG_MUTEX CRITICAL_SECTION
- #define _mbg_mutex_init( _pm ) InitializeCriticalSection( (_pm) )
- #define _mbg_mutex_deinit( _pm ) DeleteCriticalSection( (_pm) )
- #define _mbg_mutex_lock( _pm ) EnterCriticalSection( (_pm) )
- #define _mbg_mutex_unlock( _pm ) LeaveCriticalSection( (_pm) )
+ #define _mbg_thread_exit( _v ) ExitThread( _v ); return (_v)
#endif // target specific
@@ -338,7 +452,7 @@
#endif
#if !defined( MBG_CPU_SET_SIZE )
- #define MBG_CPU_SET_SIZE ( sizof( MBG_CPU_SET ) * 8 )
+ #define MBG_CPU_SET_SIZE ( sizeof( MBG_CPU_SET ) * 8 )
#endif
#if !defined( _mbg_cpu_clear )
@@ -375,26 +489,6 @@
#endif
-#if !defined( MBG_MUTEX )
- #define MBG_MUTEX int
-#endif
-
-#if !defined( _mbg_mutex_init )
- #define _mbg_mutex_init( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_deinit )
- #define _mbg_mutex_deinit( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_lock )
- #define _mbg_mutex_lock( _pm ) _nop_macro_fnc()
-#endif
-
-#if !defined( _mbg_mutex_unlock )
- #define _mbg_mutex_unlock( _pm ) _nop_macro_fnc()
-#endif
-
typedef struct
{
MBG_THREAD_ID thread_id;
@@ -408,7 +502,7 @@ typedef struct
typedef struct
{
PCPS_HR_TIME_CYCLES htc;
- uint64_t tstamp64;
+ uint64_t pcps_hr_tstamp64;
} MBG_XHRT_VARS;
@@ -419,7 +513,7 @@ typedef struct
MBG_PC_CYCLES_FREQUENCY freq_hz;
int ioctl_status;
int sleep_ms;
- MBG_MUTEX mutex;
+ MBG_CRIT_SECT crit_sect;
MBG_DEV_HANDLE dh;
} MBG_XHRT_INFO;
@@ -464,20 +558,6 @@ typedef struct _MBG_DEVICENAME_LIST
-#define _mbg_generic_read_var( _dh, _cmd, _s ) \
- mbg_generic_read( _dh, _cmd, &(_s), sizeof( (_s) ) )
-
-#define _mbg_generic_write_var( _dh, _cmd, _s ) \
- mbg_generic_write( _dh, _cmd, &(_s), sizeof( (_s) ) )
-
-#define _mbg_generic_read_gps_var( _dh, _cmd, _s ) \
- mbg_generic_read_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
-
-#define _mbg_generic_write_gps_var( _dh, _cmd, _s ) \
- mbg_generic_write_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
-
-
-
/* function prototypes: */
#ifdef __cplusplus
@@ -490,83 +570,95 @@ extern "C" {
/* by MAKEHDR, do not remove the comments. */
/**
- Get the version number of the compiled mbgdevio library.
- If the mbgdevio library is built as a DLL/shared object then
- the version number of the compiled library may differ from
- the version number of the import library and header files
- which have been used to build an application.
+ Get the version number of the precompiled DLL/shared object library.
+
+ If this library is used as a DLL/shared object library then the version
+ number can be checked to see if the header files which are actually used
+ to build an application are compatible with the header files which have
+ been used to build the library, and thus the API function are called
+ in the correct way.
- @return The version number
+ @return the version number
- @see ::MBGDEVIO_VERSION defined in mbgdevio.h.
+ @see mbgdevio_check_version()
+ @see ::MBGDEVIO_VERSION defined in mbgdevio.h
*/
_MBG_API_ATTR int _MBG_API mbgdevio_get_version( void ) ;
/**
- Check if the version of the compiled mbgdevio library is compatible
- with a certain version which is passed as parameter.
+ @brief Check if the DLL/shared library is compatible with a given version.
+
+ If this library is used as a DLL/shared object library then the version
+ number can be checked to see if the header files which are actually used
+ to build an application are compatible with the header files which have
+ been used to build the library, and thus the API function are called
+ in the correct way.
- @param header_version Version number to be checked, should be ::MBGDEVIO_VERSION
- defined in mbgdevio.h.
+ @param header_version Version number to be checked, should be ::MBGDEVIO_VERSION
+ from the mbgdevio.h file used to build the application
@return ::MBG_SUCCESS if compatible, ::MBG_ERR_LIB_NOT_COMPATIBLE if not.
- @see ::MBGDEVIO_VERSION defined in mbgdevio.h.
+ @see mbgdevio_get_version()
+ @see ::MBGDEVIO_VERSION defined in mbgdevio.h
*/
_MBG_API_ATTR int _MBG_API mbgdevio_check_version( int header_version ) ;
/**
- Open a device by index, starting from 0.
- This function is <b>out of date</b>, mbg_open_device_by_name()
+ @brief Open a device by index, starting from 0.
+
+ This function is <b>out of date</b>, mbg_open_device_by_name()
should be used instead.
See the <b>note</b> for mbg_find_device() for details.
- @param device_index Index of the device, use 0 for the first device.
+ @param device_index index of the device, use 0 for the first device.
*/
_MBG_API_ATTR MBG_DEV_HANDLE _MBG_API mbg_open_device( unsigned int device_index ) ;
/**
- Get the number of supported devices installed on the computer.
- This function is <b>out of date</b>, mbg_find_devices_with_names()
+ @brief Get the number of supported devices installed on the computer.
+
+ This function is <b>out of date</b>, mbg_find_devices_with_names()
should be used instead.
- <b>Note:</b> This function is out of date since it may not work
+ <b>Note:</b> This function is out of date since it may not work
correctly for Meinberg devices which are disconnected and reconnected
- while the system is running (e.g. USB devices). However, the function
- will be kept for compatibility reasons and works correctly if all
- Meinberg devices are connected at system boot and are not disconnected
+ while the system is running (e.g. USB devices). However, the function
+ will be kept for compatibility reasons and works correctly if all
+ Meinberg devices are connected at system boot and are not disconnected
and reconnected during operation
- @return The number of devices found.
+ @return The number of devices found
@see mbg_find_devices_with_names()
*/
_MBG_API_ATTR int _MBG_API mbg_find_devices( void ) ;
/**
- Return the number of supported devices installed on the system and
- set up a list of unique names of those devices.
+ @brief Allocate memory and set up a list of installed and supported devices.
This function should be used preferably instead of mbg_find_devices().
- @param device_list Pointer to a linked list of type ::MBG_DEVICENAME_LIST
- with device names. The list will be allocated by this
- function and has to be freed after usage by calling
+ @param device_list Pointer to a linked list of type ::MBG_DEVICENAME_LIST
+ with device names. The list will be allocated by this
+ function and has to be freed after usage by calling
mbg_free_device_name_list().
- @param max_devices Maximum number of devices the function should look for
+ @param max_devices Maximum number of devices the function should look for
(can not exceed ::MBG_MAX_DEVICES).
- @return Number of present devices
+ @return number of present devices
@see ::MBG_HW_NAME for the format of the unique names
@see mbg_free_device_name_list()
@see mbg_find_devices()
*/
- _MBG_API_ATTR int _MBG_API mbg_find_devices_with_names( MBG_DEVICENAME_LIST **device_list, int max_devices ) ;
+ _MBG_API_ATTR int _MBG_API mbg_find_devices_with_names( MBG_DEVICENAME_LIST **device_list, int max_devices ) ;
/**
- Free the memory of the ::MBG_DEVICENAME_LIST that has been allocated before
+ @brief Free the memory allocated for a ::MBG_DEVICENAME_LIST.
+
+ The list may have been set up and allocated before
by mbg_find_devices_with_names().
@param *list Linked list of type ::MBG_DEVICENAME_LIST
@@ -576,7 +668,8 @@ extern "C" {
_MBG_API_ATTR void _MBG_API mbg_free_device_name_list( MBG_DEVICENAME_LIST *list) ;
/**
- Return a handle to a device with a certain unique name.
+ @brief Return a handle to a device with a certain unique name.
+
The names of the devices that are installed on the system can be retrieved by
the function mbg_find_devices_with_names().
@@ -595,16 +688,14 @@ extern "C" {
;
/**
- Close a handle to a device and set the handle value to ::MBG_INVALID_DEV_HANDLE.
- If required, unmap mapped memory.
+ @brief Close a handle to a device and set the handle value to ::MBG_INVALID_DEV_HANDLE.
@param dev_handle Handle to a Meinberg device.
*/
_MBG_API_ATTR void _MBG_API mbg_close_device( MBG_DEV_HANDLE *dev_handle ) ;
/**
- Return a ::PCPS_DRVR_INFO structure that provides information
- about the kernel device driver.
+ @brief Read information about the driver handling a given device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_DRVR_INFO structure which is filled up.
@@ -614,7 +705,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_drvr_info( MBG_DEV_HANDLE dh, PCPS_DRVR_INFO *p ) ;
/**
- Return a ::PCPS_DEV structure that provides detailed information about the device.
+ @brief Read detailed device information.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_DEV structure to be filled up
@@ -624,7 +715,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_device_info( MBG_DEV_HANDLE dh, PCPS_DEV *p ) ;
/**
- Return the current state of the on-board::PCPS_STATUS_PORT.
+ @brief Read the current state of the on-board ::PCPS_STATUS_PORT.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_STATUS_PORT value to be filled up
@@ -636,7 +727,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_status_port( MBG_DEV_HANDLE dh, PCPS_STATUS_PORT *p ) ;
/* (Intentionally excluded from Doxygen)
- Generic read function which writes a command code to the device
+ Generic read function which writes a command code to a device
and reads a number of replied data to a generic buffer.
<b>Warning</b>: This is for debugging purposes only!
@@ -658,10 +749,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_generic_read( MBG_DEV_HANDLE dh, int cmd, void *p, int size ) ;
/* (Intentionally excluded from Doxygen)
- Generic read function which writes a GPS command code to the device
+ Generic read function which writes a GPS command code to a device
and reads a number of replied data to a generic buffer.
The macro _pcps_has_gps_data() or the API call mbg_dev_has_gps_data()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
<b>Warning</b>: This is for debugging purposes only!
The specialized API calls should be used preferably.
@@ -683,8 +774,8 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_generic_read_gps( MBG_DEV_HANDLE dh, int cmd, void *p, int size ) ;
/* (Intentionally excluded from Doxygen)
- Generic write function which writes a command code plus an
- associated number of data bytes to the device.
+ Generic write function which writes a command code plus an
+ associated number of data bytes to a device.
<b>Warning</b>: This is for debugging purposes only!
The specialized API calls should be used preferably.
@@ -705,10 +796,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_generic_write( MBG_DEV_HANDLE dh, int cmd, const void *p, int size ) ;
/* (Intentionally excluded from Doxygen)
- Generic write function which writes a GPS command code plus an
- associated number of data bytes to the device.
+ Generic write function which writes a GPS command code plus an
+ associated number of data bytes to a device.
The macro _pcps_has_gps_data() or the API call mbg_dev_has_gps_data()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
<b>Warning</b>: This is for debugging purposes only!
The specialized API calls should be used preferably.
@@ -732,7 +823,7 @@ extern "C" {
/* (Intentionally excluded from Doxygen)
Write and/or read generic data to/from a device.
The macro _pcps_has_generic_io() or the API call mbg_dev_has_generic_io()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
<b>Warning</b>: This call is for debugging purposes and internal use only!
@@ -747,13 +838,15 @@ extern "C" {
_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 ) ;
/**
- Read a ::PCPS_TIME structure returning the current date/time/status.
- The returned time is local time according to the card's time zone setting,
+ @brief Read a ::PCPS_TIME structure returning the current date/time/status.
+
+ The returned time is local time according to the card's time zone setting,
with a resolution of 10 ms (i.e. 10ths of seconds).
- This call is supported by any device manufactured by Meinberg. However,
- for higher accuracy and resolution the mbg_get_hr_time..() group of calls
- should be used preferably if supported by the specific device.
+ This call is supported by any device manufactured by Meinberg.
+ However, for higher accuracy and resolution the mbg_get_hr_time..() or
+ mbg_get_fast_hr_timestamp..() group of calls should be used preferably
+ if supported by the device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_TIME structure to be filled up
@@ -767,9 +860,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
/**
- Set a device's on-board clock manually by passing a ::PCPS_STIME structure
- The macro _pcps_can_set_time() checks whether this call
- is supported by a specific card.
+ @brief Set the device's on-board clock to a given date and time.
+
+ The macro _pcps_can_set_time() checks whether this call
+ is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_STIME structure to be written
@@ -781,18 +875,20 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_time( MBG_DEV_HANDLE dh, const PCPS_STIME *p ) ;
/**
- Read a ::PCPS_TIME structure returning the date/time/status reporting
- when the device was synchronized the last time to its time source,
- e.g. the DCF77 signal or the GPS satellites.
- The macro _pcps_has_sync_time() or the API call mbg_dev_has_sync_time()
- check whether this call is supported by a specific card.
+ @brief Read the time when the device has last recently synchronized.
+
+ Fills a ::PCPS_TIME structure with the date/time/status reporting
+ when the device was synchronized the last time to its time source,
+ e.g. the DCF77 signal, the GPS satellites, or similar.
+ The macro _pcps_has_sync_time() or the API call mbg_dev_has_sync_time()
+ check whether this call is supported by a device.
- The macro _pcps_has_sync_time() checks whether this call
- is supported by a specific card.
+ The macro _pcps_has_sync_time() checks whether this call
+ is supported by a device.
- <b>Note:</b> If that information is not available on the board then
- the value of the returned ::PCPS_TIME::sec field is set to 0xFF.
- The macro _pcps_time_is_read() can be used to check whether the
+ <b>Note:</b> If that information is not available on the board then
+ the value of the returned ::PCPS_TIME::sec field is set to 0xFF.
+ The macro _pcps_time_is_read() can be used to check whether the
returned information is valid, or not available.
@param dh Valid handle to a Meinberg device
@@ -805,11 +901,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_sync_time( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
/**
- Wait until the next second change, then return a ::PCPS_TIME
- structure similar to mbg_get_time().
+ @brief Wait until the next second change, then return current time.
- <b>Note:</b> This API call is supported under Windows only.
- The call blocks until the kernel driver detects a second change
+ Returns time in a ::PCPS_TIME structure similar to mbg_get_time().
+
+ <b>Note:</b> This API call is supported under Windows only.
+ The call blocks until the kernel driver detects a second change
reported by the device.
@param dh Valid handle to a Meinberg device
@@ -822,16 +919,18 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_time_sec_change( MBG_DEV_HANDLE dh, PCPS_TIME *p ) ;
/**
- Read a ::PCPS_HR_TIME (High Resolution time) structure returning
+ @brief Read the card's current time with high resolution, plus status.
+
+ Fills up a ::PCPS_HR_TIME (High Resolution time) structure containing
the current %UTC time (seconds since 1970), %UTC offset, and status.
- The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
- check whether this call is supported by a specific card.
+ The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
+ check whether this call is supported by a device.
- <b>Note:</b> This API call provides a higher accuracy and resolution
- than mbg_get_time(). However, it does not account for the latency
- which is introduced when accessing the board.
+ <b>Note:</b> This API call provides a higher accuracy and resolution
+ than mbg_get_time(). However, it does not account for the latency
+ which is introduced when accessing the board.
The mbg_get_hr_time_cycles() and mbg_get_hr_time_comp() calls
- provides mechanisms to account for and/or compensate the latency.
+ provide ways to account for and/or compensate the latency.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_HR_TIME structure to be filled up
@@ -846,10 +945,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_hr_time( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p ) ;
/* (Intentionally excluded from Doxygen )
- Write a high resolution time stamp ::PCPS_TIME_STAMP to the clock
+ Write a high resolution time stamp ::PCPS_TIME_STAMP to a device
to configure a %UTC time when the clock shall generate an event.
- The macro _pcps_has_event_time() or the API call mbg_dev_has_event_time()
- check whether this call is supported by a specific card.
+ The macro _pcps_has_event_time() or the API call mbg_dev_has_event_time()
+ check whether this call is supported by a device.
<b>Note:</b> This is only supported by some special firmware.
@@ -863,13 +962,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_event_time( MBG_DEV_HANDLE dh, const PCPS_TIME_STAMP *p ) ;
/**
- Read the configuration of a device's serial port.
- The macro _pcps_has_serial() checks whether this call
- is supported by a specific card.
+ @brief Read the serial port configuration from an old type of device.
+
+ <b>Note:</b> Direct usage of this function is obsolete.
- <b>Note:</b> This function is supported only by a certain class
- of devices, so it should not be called directly. The generic
- function mbg_get_serial_settings() should be used instead.
+ The generic API function mbg_get_serial_settings() should be used instead
+ which fully supports the capabilities of current devices.
+
+ The macro _pcps_has_serial() checks whether this call
+ is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_SERIAL structure to be filled up
@@ -882,13 +983,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_serial( MBG_DEV_HANDLE dh, PCPS_SERIAL *p ) ;
/**
- Write the configuration of a device's serial port.
- The macro _pcps_has_serial() checks whether this call
- is supported by a specific card.
+ @brief Write the serial port configuration to an old type of device.
+
+ <b>Note:</b> Direct usage of this function is obsolete.
- <b>Note:</b> This function is supported only by a certain class
- of devices, so it should not be called directly. The generic
- function mbg_save_serial_settings() should be used instead.
+ The generic API function mbg_save_serial_settings() should be used instead
+ which fully supports the capabilities of current devices.
+
+ The macro _pcps_has_serial() checks whether this call
+ is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_SERIAL structure to be written
@@ -901,13 +1004,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_serial( MBG_DEV_HANDLE dh, const PCPS_SERIAL *p ) ;
/**
- Read the card's time zone/daylight saving configuration code.
- That tzcode is supported by some simpler cards and only allows only
- a very basic configuration.
- The macro _pcps_has_tzcode() or the API call mbg_dev_has_tzcode()
- check whether this call is supported by a specific card.
+ @brief Read time zone/daylight saving configuration code from a device.
+
+ The APIs using TZCODE are only supported by some simpler cards
+ and allow just a very basic configuration.
+
+ The macro _pcps_has_tzcode() or the API call mbg_dev_has_tzcode()
+ check whether this call is supported by a device.
+
Other cards may support the mbg_get_pcps_tzdl() or mbg_get_gps_tzdl()
- calls instead which allow for a more detailed configuration of the
+ calls instead which allow for a more detailed configuration of the
time zone and daylight saving settings.
@param dh Valid handle to a Meinberg device
@@ -924,13 +1030,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_tzcode( MBG_DEV_HANDLE dh, PCPS_TZCODE *p ) ;
/**
- Write the card's time zone/daylight saving configuration code.
- That tzcode is supported by some simpler cards and only allows only
- a very basic configuration.
- The macro _pcps_has_tzcode() or the API call mbg_dev_has_tzcode()
- check whether this call is supported by a specific card.
+ @brief Write time zone/daylight saving configuration code to a device.
+
+ The APIs using TZCODE are only supported by some simpler cards
+ and allow just a very basic configuration.
+
+ The macro _pcps_has_tzcode() or the API call mbg_dev_has_tzcode()
+ check whether this call is supported by a device.
+
Other cards may support the mbg_set_pcps_tzdl() or mbg_set_gps_tzdl()
- calls instead which allow for a more detailed configuration of the
+ calls instead which allow for a more detailed configuration of the
time zone and daylight saving settings.
@param dh Valid handle to a Meinberg device
@@ -947,12 +1056,17 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_tzcode( MBG_DEV_HANDLE dh, const PCPS_TZCODE *p ) ;
/**
- Read the card's time zone/daylight saving parameters using the
- ::PCPS_TZDL structure.
- The macro _pcps_has_pcps_tzdl() or the API call mbg_dev_has_pcps_tzdl()
- check whether this call is supported by a specific card.
- Other cards may support the mbg_get_tzcode() or mbg_get_gps_tzdl()
- calls instead.
+ @brief Read time zone/daylight saving parameters from a device.
+
+ This function fills up a ::PCPS_TZDL structure which supports a more
+ detailed configuration of time zone and daylight saving than the TZCODE
+ structure.
+
+ The macro _pcps_has_pcps_tzdl() or the API call mbg_dev_has_pcps_tzdl()
+ check whether this call is supported by a device.
+
+ Other cards may support the mbg_get_tzcode() or mbg_get_gps_tzdl()
+ calls instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_TZDL structure to be filled up
@@ -968,12 +1082,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_pcps_tzdl( MBG_DEV_HANDLE dh, PCPS_TZDL *p ) ;
/**
- Write the card's time zone/daylight saving parameters using the
- ::PCPS_TZDL structure.
- The macro _pcps_has_pcps_tzdl() or the API call mbg_dev_has_pcps_tzdl()
- check whether this call is supported by a specific card.
- Other cards may support the mbg_set_tzcode() or mbg_set_gps_tzdl()
- calls instead.
+ @brief Write time zone/daylight saving parameters to a device.
+
+ This function passes a ::PCPS_TZDL structure to a device which supports
+ a more detailed configuration of time zone and daylight saving than the
+ TZCODE structure.
+
+ The macro _pcps_has_pcps_tzdl() or the API call mbg_dev_has_pcps_tzdl()
+ check whether this call is supported by a device.
+ Other cards may support the mbg_set_tzcode() or mbg_set_gps_tzdl()
+ calls instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_TZDL structure to be written
@@ -989,10 +1107,14 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_pcps_tzdl( MBG_DEV_HANDLE dh, const PCPS_TZDL *p ) ;
/**
- Read the reference time offset from %UTC for clocks which can't determine
- that offset automatically, e.g. from an IRIG input signal.
- The macro _pcps_has_ref_offs() or the API call mbg_dev_has_ref_offs()
- check whether this call is supported by a specific card.
+ @brief Read the %UTC offset configuration of the reference time from a device.
+
+ This parameter is used to specify the %UTC offset of an incoming
+ reference time signal if a kind of time signal e.g. an IRIG input
+ signal) does not provide this information.
+
+ The macro _pcps_has_ref_offs() or the API call mbg_dev_has_ref_offs()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::MBG_REF_OFFS value to be filled up
@@ -1006,10 +1128,14 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_ref_offs( MBG_DEV_HANDLE dh, MBG_REF_OFFS *p ) ;
/**
- Write the reference time offset from %UTC for clocks which can't determine
- that offset automatically, e.g. from an IRIG input signal.
- The macro _pcps_has_ref_offs() or the API call mbg_dev_has_ref_offs()
- check whether this call is supported by a specific card.
+ @brief Write the %UTC offset configuration of the reference time to a device.
+
+ This parameter is used to specify the %UTC offset of an incoming
+ reference time signal if a kind of time signal e.g. an IRIG input
+ signal) does not provide this information.
+
+ The macro _pcps_has_ref_offs() or the API call mbg_dev_has_ref_offs()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::MBG_REF_OFFS value to be written
@@ -1023,11 +1149,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_ref_offs( MBG_DEV_HANDLE dh, const MBG_REF_OFFS *p ) ;
/**
- Read a ::MBG_OPT_INFO structure containing optional settings, controlled by flags.
- The ::MBG_OPT_INFO structure contains a mask of supported flags plus the current
+ @brief Read a ::MBG_OPT_INFO structure containing optional settings, controlled by flags.
+
+ The ::MBG_OPT_INFO structure contains a mask of supported flags plus the current
settings of those flags.
- The macro _pcps_has_opt_flags() or the API call mbg_dev_has_opt_flags()
- check whether this call is supported by a specific card.
+ The macro _pcps_has_opt_flags() or the API call mbg_dev_has_opt_flags()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::MBG_OPT_INFO structure to be filled up
@@ -1040,11 +1167,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_opt_info( MBG_DEV_HANDLE dh, MBG_OPT_INFO *p ) ;
/**
- Write a ::MBG_OPT_SETTINGS structure contains optional settings, controlled by flags.
- The macro _pcps_has_opt_flags() or the API call mbg_dev_has_opt_flags()
- check whether this call is supported by a specific card.
- The ::MBG_OPT_INFO structure should be read first to check which of the specified
- flags is supported by a specific card.
+ @brief Write a ::MBG_OPT_SETTINGS structure containing optional device settings.
+
+ The macro _pcps_has_opt_flags() or the API call mbg_dev_has_opt_flags()
+ check whether this call is supported by a device.
+ The ::MBG_OPT_INFO structure should be read first to check which of the specified
+ flag is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::MBG_OPT_SETTINGS structure to be written
@@ -1057,16 +1185,21 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_opt_settings( MBG_DEV_HANDLE dh, const MBG_OPT_SETTINGS *p ) ;
/**
- Read an ::IRIG_INFO structure containing the configuration of an IRIG input
- plus the possible settings supported by that input.
- The macro _pcps_is_irig_rx() or the API call mbg_dev_is_irig_rx()
- check whether this call is supported by a specific card.
+ @brief Read the current IRIG input settings plus the supported settings.
+
+ Calling this function directly is usually obsolete. The function
+ mbg_get_all_irig_rx_info() should be used instead which also reads some
+ other associated parameters affecting the behaviour of the IRIG input.
+
+ The macro _pcps_is_irig_rx() or the API call mbg_dev_is_irig_rx()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an ::IRIG_INFO structure to be filled up
@return ::MBG_SUCCESS or error code returned by device I/O control function.
+ @see mbg_get_all_irig_rx_info()
@see mbg_set_irig_rx_settings()
@see mbg_dev_is_irig_rx()
@see mbg_dev_has_irig_tx()
@@ -1076,10 +1209,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_irig_rx_info( MBG_DEV_HANDLE dh, IRIG_INFO *p ) ;
/**
- Write an ::IRIG_SETTINGS structure containing the configuration of an IRIG input.
- The macro _pcps_is_irig_rx() or the API call mbg_dev_is_irig_rx()
- check whether this call is supported by a specific card.
- The ::IRIG_INFO structure should be read first to determine the possible
+ @brief Write an ::IRIG_SETTINGS structure to a device to configure an IRIG input.
+
+ Calling this function directly is usually obsolete. The function
+ mbg_set_all_irig_rx_info() should be used instead which also writes some
+ other associated parameters affecting the behaviour of the IRIG input.
+
+ The macro _pcps_is_irig_rx() or the API call mbg_dev_is_irig_rx()
+ check whether this call is supported by a device.
+ The ::IRIG_INFO structure should be read first to determine the possible
settings supported by this card's IRIG input.
@param dh Valid handle to a Meinberg device
@@ -1087,6 +1225,7 @@ extern "C" {
@return ::MBG_SUCCESS or error code returned by device I/O control function.
+ @see mbg_set_all_irig_rx_info()
@see mbg_get_irig_rx_info()
@see mbg_dev_is_irig_rx()
@see mbg_dev_has_irig_tx()
@@ -1096,7 +1235,48 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_irig_rx_settings( MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p ) ;
/**
- Check if a specific device supports the mbg_get_irig_ctrl_bits() call.
+ @brief Read all IRIG input configuration information from a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param pdev Pointer to the device's ::PCPS_DEV structure
+ @param p_irig_info Pointer to a ::IRIG_SETTINGS structure to be written
+ @param p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be written
+ @param p_opt_info Pointer to a ::MBG_OPT_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_save_all_irig_rx_settings()
+ @see mbg_set_irig_rx_settings()
+ @see mbg_set_ref_offs()
+ @see mbg_set_opt_settings()
+*/
+ _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 ) ;
+
+ /**
+ @brief Write all IRIG input configuration settings to a device.
+
+ The macro _pcps_is_irig_rx() or the API call mbg_dev_is_irig_rx()
+ check whether this call is supported by a device.
+ The ::IRIG_INFO structure should be read first to determine the possible
+ settings supported by this card's IRIG input.
+
+ @param dh Valid handle to a Meinberg device
+ @param pdev Pointer to the device's ::PCPS_DEV structure
+ @param p_irig_settings Pointer to a ::IRIG_SETTINGS structure to be written
+ @param p_ref_offs Pointer to a ::MBG_REF_OFFS structure to be written
+ @param p_opt_settings Pointer to a ::MBG_OPT_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_all_irig_rx_info()
+ @see mbg_set_irig_rx_settings()
+ @see mbg_set_ref_offs()
+ @see mbg_set_opt_settings()
+*/
+ _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 ) ;
+
+ /**
+ @brief Check if a device supports the mbg_get_irig_ctrl_bits() call.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -1108,14 +1288,27 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_ctrl_bits( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a ::MBG_IRIG_CTRL_BITS type which contains the control function
- bits of the latest IRIG input frame. Those bits may carry some
- well-known information, as in the IEEE1344 code, but may also contain
- some customized information, depending on the IRIG frame type and
- the configuration of the IRIG generator. So these bits are returned
- as-is and must be interpreted by the application.
+ @brief Read the control function bits received from an incoming IRIG signal.
+
+ This function fills a ::MBG_IRIG_CTRL_BITS structure with the control function
+ bits decoded from the incoming IRIG signal.
+
+ The meaning of these bits depends on the type of IRIG code frame format.
+
+ In some IRIG formats these bits provide some well-known information which can
+ also be evaluated by the device. For example, in IEEE 1344 or IEEE C37.118 code
+ the control function bits are used to provide the year number, UTC offset,
+ DST status, leap second warning, etc.
+
+ For most IRIG code formats, however, these bits are reserved, i.e. not used
+ at all, or application defined, depending on the configuration of the IRIG
+ generator providing the IRIG signal.
+
+ In the latter case the application has to evaluate the received control function
+ bits and can use this function to retrieve these bits from the receiver device.
+
The macro _pcps_has_irig_ctrl_bits() or the API call mbg_dev_has_irig_ctrl_bits()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::MBG_IRIG_CTRL_BITS type to be filled up
@@ -1124,10 +1317,66 @@ extern "C" {
@see mbg_dev_has_irig_ctrl_bits()
*/
- _MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p ) ;
+ _MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p ) ;
/**
- Check if a specific device supports the mbg_get_irig_time() call.
+ @brief Check if a device supports the mbg_get_raw_irig_data() call.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_raw_irig_data()
+ @see mbg_get_raw_irig_data_on_sec_change()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_raw_irig_data( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Read raw IRIG data from an IRIG receiver.
+
+ This function fills a ::MBG_RAW_IRIG_DATA structure with the raw data bits received
+ from the incoming IRIG signal. This enables an application itself to decode the
+ information provided by the IRIG signal.
+
+ The macro _pcps_has_raw_irig_data() or the API call mbg_dev_has_raw_irig_data()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_RAW_IRIG_DATA type to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_raw_irig_data()
+ @see mbg_get_raw_irig_data_on_sec_change()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_raw_irig_data( MBG_DEV_HANDLE dh, MBG_RAW_IRIG_DATA *p ) ;
+
+ /**
+ @brief Wait for second changeover then read raw IRIG data from an IRIG receiver.
+
+ This function waits until the second of the device's on-board time rolls over, and
+ then reads the last recent raw IRIG data from the device.
+
+ The macro _pcps_has_raw_irig_data() or the API call mbg_dev_has_raw_irig_data()
+ check whether this call is supported by a device.
+
+ <b>Note:</b> The mbg_get_time_sec_change() function called by this function is
+ supported under Windows only, so this function can also only be used under Windows.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_RAW_IRIG_DATA type to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_raw_irig_data()
+ @see mbg_get_raw_irig_data()
+ @see mbg_get_time_sec_change()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_raw_irig_data_on_sec_change( MBG_DEV_HANDLE dh, MBG_RAW_IRIG_DATA *p ) ;
+
+ /**
+ @brief Check if a device supports the mbg_get_irig_time() call.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -1139,12 +1388,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_time( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a ::PCPS_IRIG_TIME type which returns the raw IRIG day-of-year number
+ @brief Read the IRIG time and day-of-year number from an IRIG receiver.
+
+ Fills up a ::PCPS_IRIG_TIME structure with the raw IRIG day-of-year number
and time decoded from the latest IRIG input frame. If the configured IRIG code
also contains the year number then the year number is also returned, otherwise
the returned year number is 0xFF.
+
The macro _pcps_has_irig_time() or the API call mbg_dev_has_irig_time()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_IRIG_TIME type to be filled up
@@ -1153,12 +1405,13 @@ extern "C" {
@see mbg_dev_has_irig_time()
*/
- _MBG_API_ATTR int _MBG_API mbg_get_irig_time( MBG_DEV_HANDLE dh, PCPS_IRIG_TIME *p ) ;
+ _MBG_API_ATTR int _MBG_API mbg_get_irig_time( MBG_DEV_HANDLE dh, PCPS_IRIG_TIME *p ) ;
/**
- Clear the card's on-board time capture FIFO buffer.
- The macro _pcps_can_clr_ucap_buff() or the API call mbg_dev_can_clr_ucap_buff()
- check whether this call is supported by a specific card.
+ @brief Clear a device's on-board time capture FIFO buffer.
+
+ The macro _pcps_can_clr_ucap_buff() or the API call mbg_dev_can_clr_ucap_buff()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@@ -1171,10 +1424,14 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_clr_ucap_buff( MBG_DEV_HANDLE dh ) ;
/**
- Read a ::PCPS_UCAP_ENTRIES structure to retrieve the number of saved
- user capture events and the maximum capture buffer size.
- The macro _pcps_has_ucap() or the API call mbg_dev_has_ucap()
- check whether this call is supported by a specific card.
+ @brief Read information on a device's event capture buffer.
+
+ Fills a ::PCPS_UCAP_ENTRIES structure with the number of user capture
+ events actually stored in the FIFO buffer, and the maximum number of
+ events that can be held by the buffer.
+
+ The macro _pcps_has_ucap() or the API call mbg_dev_has_ucap()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_UCAP_ENTRIES structure to be filled up
@@ -1188,16 +1445,19 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_ucap_entries( MBG_DEV_HANDLE dh, PCPS_UCAP_ENTRIES *p ) ;
/**
- Retrieve a single time capture event from the on-board FIFO buffer
- using a ::PCPS_HR_TIME structure. The oldest entry of the FIFO is retrieved
- and then removed from the FIFO.
- If no capture event is available in the FIFO buffer then both the seconds
+ @brief Retrieve a single time capture event from the on-board FIFO buffer.
+
+ The capture event is returned in a ::PCPS_HR_TIME structure. The oldest entry
+ in the FIFO is retrieved and then removed from the FIFO.
+
+ If no capture event is available in the FIFO buffer then both the seconds
and the fractions of the returned timestamp are 0.
- The macro _pcps_has_ucap() or the API call mbg_dev_has_ucap()
- check whether this call is supported by a specific card.
+
+ The macro _pcps_has_ucap() or the API call mbg_dev_has_ucap()
+ check whether this call is supported by a device.
<b>Note:</b> This call is very much faster than the older mbg_get_gps_ucap()
- call which is obsolete but still supported for compatibility with
+ call which is obsolete but still supported for compatibility with
older cards.
@param dh Valid handle to a Meinberg device
@@ -1212,14 +1472,17 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_ucap_event( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p ) ;
/**
- Read the card's time zone/daylight saving parameters using the ::TZDL
- structure.
- The macro _pcps_has_tzdl() or the API call mbg_dev_has_tzdl()
- check whether this call is supported by a specific card.
+ @brief Read the card's time zone/daylight saving parameters.
+
+ This function returns the time zone/daylight saving parameters
+ in a ::TZDL structure.
+
+ The macro _pcps_has_tzdl() or the API call mbg_dev_has_tzdl()
+ check whether this call is supported by a device.
- <b>Note:</b> In spite of the function name this call may also be
+ <b>Note:</b> In spite of the function name this call may also be
supported by non-GPS cards. Other cards may support the mbg_get_tzcode()
- or mbg_get_pcps_tzdl() calls instead.
+ or mbg_get_pcps_tzdl() calls instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::TZDL structure to be filled up
@@ -1235,14 +1498,17 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_tzdl( MBG_DEV_HANDLE dh, TZDL *p ) ;
/**
- Write the card's time zone/daylight saving parameters using the ::TZDL
- structure.
- The macro _pcps_has_tzdl() or the API call mbg_dev_has_tzdl()
- check whether this call is supported by a specific card.
+ @brief Write the card's time zone/daylight saving parameters.
- <b>Note:</b> In spite of the function name this call may also be
- supported by non-GPS cards. Other cards may support the mbg_set_tzcode()
- or mbg_set_pcps_tzdl() calls instead.
+ This function writes the time zone/daylight saving parameters
+ in a ::TZDL structure to a device.
+
+ The macro _pcps_has_tzdl() or the API call mbg_dev_has_tzdl()
+ check whether this call is supported by a device.
+
+ <b>Note:</b> In spite of the function name this call may also be
+ supported by non-GPS cards. Other cards may support the mbg_set_tzcode()
+ or mbg_set_pcps_tzdl() calls instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::TZDL structure to be written
@@ -1258,13 +1524,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_tzdl( MBG_DEV_HANDLE dh, const TZDL *p ) ;
/**
- Retrieve the software revision of a GPS receiver.
- This call is obsolete but still supported for compatibility
+ @brief Retrieve the software revision of a GPS receiver.
+
+ This call is obsolete but still supported for compatibility
with older GPS cards.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> The function mbg_get_gps_receiver_info() should
+ <b>Note:</b> The function mbg_get_gps_receiver_info() should
be used instead, if supported by the card.
@param dh Valid handle to a Meinberg device
@@ -1278,11 +1546,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_sw_rev( MBG_DEV_HANDLE dh, SW_REV *p ) ;
/**
- Retrieve the status of the battery buffered GPS variables.
+ @brief Retrieve the status of the battery buffered GPS variables.
+
+ These GPS variables hold some parameters sent by the GPS satellites
+ which are required for proper operation. If the saved set of parameters
+ is not complete then the GPS receiver stays in COLD BOOT mode until
+ all data have been received and thus all data sets are valid.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
- The GPS receiver stays in cold boot mode until all of the
- data sets are valid.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::BVAR_STAT structure to be filled up
@@ -1292,25 +1564,32 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_bvar_stat( MBG_DEV_HANDLE dh, BVAR_STAT *p ) ;
/**
- Read the current board time using a ::TTM structure.
+ @brief Read the current board time using a ::TTM structure.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> This call is pretty slow, so the mbg_get_hr_time_..()
- group of calls should be used preferably.
+ <b>Note:</b> This API call is pretty slow, so the mbg_get_hr_time_..()
+ or mbg_get_fast_hr_timestamp...() group of calls should be used preferably.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::TTM structure to be filled up
@return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_hr_time()
+ @see mbg_get_fast_hr_timestamp()
*/
_MBG_API_ATTR int _MBG_API mbg_get_gps_time( MBG_DEV_HANDLE dh, TTM *p ) ;
/**
- Write a ::TTM structure to a GPS receiver in order to set the
+ @brief Set the time on a GPS receiver device.
+
+ Write a ::TTM structure to a GPS receiver in order to set the
on-board date and time.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::TTM structure to be written
@@ -1320,15 +1599,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_time( MBG_DEV_HANDLE dh, const TTM *p ) ;
/**
- Read a ::PORT_PARM structure to retrieve the configuration
- of the device's serial ports.
+ @brief Read a ::PORT_PARM structure with a device's serial port configuration.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> This function is obsolete since it is only
- supported by a certain class of devices and can handle only
- up to 2 ports. The generic function mbg_get_serial_settings()
- should be used instead.
+ <b>Note:</b> This function is obsolete since it is only
+ supported by a certain class of devices and can handle only
+ up to 2 ports. The generic function mbg_get_serial_settings()
+ should be used instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PORT_PARM structure to be filled up
@@ -1340,15 +1619,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_port_parm( MBG_DEV_HANDLE dh, PORT_PARM *p ) ;
/**
- Write a ::PORT_PARM structure to configure the on-board
- serial ports.
+ @brief Write a ::PORT_PARM structure to configure the on-board serial ports.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> This function is obsolete since it is only
- supported by a certain class of devices and can handle only
- up to 2 ports. The generic function mbg_save_serial_settings()
- should be used instead.
+ <b>Note:</b> This function is obsolete since it is only
+ supported by a certain class of devices and can handle only
+ up to 2 ports. The generic function mbg_save_serial_settings()
+ should be used instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PORT_PARM structure to be written
@@ -1360,13 +1639,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_port_parm( MBG_DEV_HANDLE dh, const PORT_PARM *p ) ;
/**
- Read an ::ANT_INFO structure to retrieve status information of the GPS antenna.
+ @brief Read an ::ANT_INFO structure to retrieve an extended GPS antenna status.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> Normally the antenna connection status can also be
+ <b>Note:</b> Normally the current antenna connection status can also be
determined by evaluation of the ::PCPS_TIME::signal or ::PCPS_HR_TIME::signal
- fields.
+ fields. The "disconnected" status reported by ANT_INFO disappears only if
+ the antenna has been reconnected <b>and</b> the receiver has synchronized
+ to the GPS satellites again.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ANT_INFO structure to be filled up
@@ -1376,14 +1658,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_ant_info( MBG_DEV_HANDLE dh, ANT_INFO *p ) ;
/**
- Read a time capture event from the on-board FIFO buffer using a ::TTM structure.
+ @brief Read a time capture event from the on-board FIFO buffer using a ::TTM structure.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> This call is pretty slow and has been obsoleted by
- mbg_get_ucap_event() which should be used preferably, if supported
- by the card. Anyway, this call is still supported for compatibility
- with older cards.
+ <b>Note:</b> This call is pretty slow and has been obsoleted by
+ mbg_get_ucap_event() which should be used preferably, if supported
+ by the device. Anyway, this call is still supported for compatibility
+ with older devices.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::TTM structure to be filled up
@@ -1397,13 +1680,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_ucap( MBG_DEV_HANDLE dh, TTM *p ) ;
/**
- Read an ::ENABLE_FLAGS structure reporting whether certain outputs
- shall be enabled immediately after the card's power-up, or only
+ @brief Read the ::ENABLE_FLAGS structure controlling when outputs are to be enabled.
+
+ The ::ENABLE_FLAGS structure controls whether certain outputs
+ shall be enabled immediately after the card's power-up, or only
after the card has synchronized to its input signal.
+
The macro _pcps_has_gps_data() or the API call mbg_dev_has_gps_data()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> Not all of the input signals specified for the
+ <b>Note:</b> Not all of the input signals specified for the
::ENABLE_FLAGS structure can be modified individually.
@param dh Valid handle to a Meinberg device
@@ -1417,13 +1703,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_enable_flags( MBG_DEV_HANDLE dh, ENABLE_FLAGS *p ) ;
/**
- Write an ENABLE_FLAGS structure to configure whether certain outputs
- shall be enabled immediately after the card's power-up, or only
+ @brief Write an ENABLE_FLAGS structure to configure when outputs shall be enabled.
+
+ The ::ENABLE_FLAGS structure controls whether certain outputs
+ shall be enabled immediately after the card's power-up, or only
after the card has synchronized to its input signal.
+
The macro _pcps_has_gps_data() or the API call mbg_dev_has_gps_data()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> Not all of the input signals specified for the
+ <b>Note:</b> Not all of the input signals specified for the
ENABLE_FLAGS structure can be modified individually.
@param dh Valid handle to a Meinberg device
@@ -1437,11 +1726,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_enable_flags( MBG_DEV_HANDLE dh, const ENABLE_FLAGS *p ) ;
/**
- Read a ::STAT_INFO structure to retrieve the status of the
- GPS receiver, including mode of operation and numer of
- visible/usable satellites.
+ @brief Read the extended GPS receiver status from a device.
+
+ The ::STAT_INFO structure reports the status of the GPS receiver,
+ including mode of operation and number of visible/usable satellites.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::STAT_INFO structure to be filled up
@@ -1453,9 +1744,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_stat_info( MBG_DEV_HANDLE dh, STAT_INFO *p ) ;
/**
- Sends a ::GPS_CMD to a GPS receiver.
+ @brief Send a ::GPS_CMD to a GPS receiver device.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::GPS_CMD
@@ -1467,10 +1759,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_cmd( MBG_DEV_HANDLE dh, const GPS_CMD *p ) ;
/**
- Read the current GPS receiver position using the ::POS structure
- which contains different coordinate formats.
+ @brief Read the current geographic position from a GPS device.
+
+ The returned ::POS structure contains the current position in
+ ECEF (Earth Centered, Earth Fixed) kartesian coordinates, and in
+ geographic coordinates with different formats, using the WGS84
+ geographic datum.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p Pointer to a ::POS structure to be filled up
@@ -1483,10 +1780,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_pos( MBG_DEV_HANDLE dh, POS *p ) ;
/**
- Preset the GPS receiver position using ::XYZ coordinates
- (ECEF: WGS84 "Earth Centered, Earth fixed" kartesian coordinates).
+ @brief Set the GPS receiver position using ::XYZ coordinates.
+
+ The structure ::XYZ must specify the new position in ECEF
+ (Earth Centered, Earth Fixed) kartesian coordinates.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param p Position in ::XYZ format to be written
@@ -1499,10 +1799,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_pos_xyz( MBG_DEV_HANDLE dh, const XYZ p ) ;
/**
- Preset the GPS receiver position using ::LLA coordinates
- (longitude, latitude, altitude)
+ @brief Set the GPS receiver position using ::LLA coordinates.
+
+ The structure LLA must specify the new position as longitude, latitude,
+ and altitude, using the WGS84 geographic datum.
+
The macro _pcps_is_gps() or the API call mbg_dev_is_gps()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param p Position in ::LLA format to be written
@@ -1515,10 +1818,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_pos_lla( MBG_DEV_HANDLE dh, const LLA p ) ;
/**
- Read the configured length of the GPS antenna cable (::ANT_CABLE_LEN).
- The cable delay is internally compensated by 5ns per meter cable.
+ @brief Read the configured GPS antenna cable length from a device.
+
+ The antenna cable length parameter is used to compensate the propagation
+ delay of the RF signal over the antenna cable, which is about 5 ns/m.
+
The macro _pcps_has_cab_len() or the API call mbg_dev_has_cab_len()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p ::ANT_CABLE_LEN structure to be filled up
@@ -1531,10 +1837,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_ant_cable_len( MBG_DEV_HANDLE dh, ANT_CABLE_LEN *p ) ;
/**
- Write the length of the GPS antenna cable (::ANT_CABLE_LEN).
- The cable delay is internally compensated by 5ns per meter cable.
+ @brief Write the GPS antenna cable length configuration to a device.
+
+ The antenna cable length parameter is used to compensate the propagation
+ delay of the RF signal over the antenna cable, which is about 5 ns/m.
+
The macro _pcps_has_cab_len() or the API call mbg_dev_has_cab_len()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p ::ANT_CABLE_LEN structure to be written
@@ -1547,13 +1856,14 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_ant_cable_len( MBG_DEV_HANDLE dh, const ANT_CABLE_LEN *p ) ;
/**
- Read a ::RECEIVER_INFO structure from a card.
+ @brief Read the ::RECEIVER_INFO structure from a device.
+
The macro _pcps_has_receiver_info() or the API call mbg_dev_has_receiver_info()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> Applications should call mbg_setup_receiver_info()
- preferably, which also sets up a basic ::RECEIVER_INFO structure
- for card which don't provide that structure by themselves.
+ <b>Note:</b> Applications should call mbg_setup_receiver_info()
+ preferably, which also sets up a basic ::RECEIVER_INFO structure
+ for devices which don't provide that structure by themselves.
@param dh Valid handle to a Meinberg device.
@param *p Pointer to a ::RECEIVER_INFO structure to be filled up
@@ -1565,13 +1875,58 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_gps_receiver_info( MBG_DEV_HANDLE dh, RECEIVER_INFO *p ) ;
/**
- Write the configuration for a single serial port using the ::PORT_SETTINGS_IDX
- structure which contains both the ::PORT_SETTINGS and the port index value.
- Except for the parameter types, this call is equivalent to mbg_set_gps_port_settings().
+ @brief Read a ::STR_TYPE_INFO_IDX array of supported string types.
+
+ The function mbg_setup_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO structure passed to this function.
+
+ <b>Note:</b> The function mbg_get_serial_settings() should be used preferably
+ to get retrieve the current port settings and configuration options.
+
+ @param dh Valid handle to a Meinberg device.
+ @param stii Pointer to a an array of string type information to be filled up
+ @param *p_ri Pointer to a ::RECEIVER_INFO structure returned by mbg_setup_receiver_info()
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_setup_receiver_info()
+ @see mbg_get_gps_all_port_info()
+ @see mbg_get_serial_settings()
+*/
+ _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 ) ;
+
+ /**
+ @brief Read a ::PORT_INFO_IDX array of supported serial port configurations.
+
+ The function mbg_setup_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO structure passed to this function.
+
+ <b>Note:</b> The function mbg_get_serial_settings() should be used preferably
+ to get retrieve the current port settings and configuration options.
+
+ @param dh Valid handle to a Meinberg device.
+ @param pii Pointer to a an array of port configuration information to be filled up
+ @param *p_ri Pointer to a ::RECEIVER_INFO structure returned by mbg_setup_receiver_info()
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_setup_receiver_info()
+ @see mbg_get_gps_all_str_type_info()
+ @see mbg_get_serial_settings()
+*/
+ _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 ) ;
+
+ /**
+ @brief Write the configuration for a single serial port to a device.
+
+ The ::PORT_SETTINGS_IDX structure contains both the ::PORT_SETTINGS
+ and the port index value. Except for the parameter types this call is
+ equivalent to mbg_set_gps_port_settings().
+
The macro _pcps_has_receiver_info() or the API call mbg_dev_has_receiver_info()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> The function mbg_save_serial_settings() should be used preferably
+ <b>Note:</b> The function mbg_save_serial_settings() should be used preferably
to write new port configuration to the board.
@param dh Valid handle to a Meinberg device.
@@ -1586,13 +1941,16 @@ extern "C" {
_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 using the ::PORT_SETTINGS
- structure plus the port index.
- Except for the parameter types, this call is equivalent to mbg_set_gps_port_settings_idx().
+ @brief Write the configuration for a single serial port to a device.
+
+ The ::PORT_SETTINGS structure does not contain the port index, so the
+ the port index must be given separately. Except for the parameter types
+ this call is equivalent to mbg_set_gps_port_settings_idx().
+
The macro _pcps_has_receiver_info() or the API call mbg_dev_has_receiver_info()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
- <b>Note:</b> The function mbg_save_serial_settings() should be used preferably
+ <b>Note:</b> The function mbg_save_serial_settings() should be used preferably
to write new port configuration to the board.
@param dh Valid handle to a Meinberg device.
@@ -1608,11 +1966,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_port_settings( MBG_DEV_HANDLE dh, const PORT_SETTINGS *p, int idx ) ;
/**
- Set up a ::RECEIVER_INFO structure for a device.
+ @brief Set up a ::RECEIVER_INFO structure for a device.
+
If the device supports the ::RECEIVER_INFO structure then the structure
- is read from the device, otherwise a structure is set up using
+ is read from the device, otherwise a structure is set up using
default values depending on the device type.
- The function mbg_get_device_info() must have been called before,
+ The function mbg_get_device_info() must have been called before,
and the returned PCPS_DEV structure passed to this function.
@param dh Valid handle to a Meinberg device.
@@ -1627,59 +1986,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_setup_receiver_info( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, RECEIVER_INFO *p ) ;
/**
- Read all serial port settings and supported configuration parameters.
-
- The functions mbg_get_device_info() and mbg_setup_receiver_info()
- must have been called before, and the returned ::PCPS_DEV and
- ::RECEIVER_INFO structures must be passed to this function.
-
- The complementary function mbg_save_serial_settings() should be used
- to write the modified serial port configuration back to the board.
-
- @param dh Valid handle to a Meinberg device.
- @param *pdev Pointer to a ::PCPS_DEV structure.
- @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure to be filled up.
- @param *p_ri Pointer to a ::RECEIVER_INFO structure.
-
- @return ::MBG_SUCCESS or error code returned by device I/O control function.
-
- @see mbg_get_device_info()
- @see mbg_setup_receiver_info()
- @see mbg_save_serial_settings()
-*/
- _MBG_API_ATTR int _MBG_API mbg_get_serial_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, RECEIVER_PORT_CFG *pcfg, const RECEIVER_INFO *p_ri ) ;
-
- /**
- Write the configuration settings for a single serial port to the board.
-
- Modifications to the serial port configuration should be made only
- after mbg_get_serial_settings() had been called to read all serial port
- settings and supported configuration parameters.
- This function has finally to be called once for every serial port
- the configuration of which has been modified.
-
- As also required by mbg_get_serial_settings(), the functions
- mbg_get_device_info() and mbg_setup_receiver_info() must have been
- called before, and the returned ::PCPS_DEV and ::RECEIVER_INFO structures
- must be passed to this function.
+ @brief Read the version code of the on-board PCI/PCIe interface ASIC.
- @param dh Valid handle to a Meinberg device
- @param *pdev Pointer to a ::PCPS_DEV structure
- @param *pcfg Pointer to a ::RECEIVER_PORT_CFG structure
- @param port_num Index of the ::serial port to be saved
-
- @return ::MBG_SUCCESS or error code returned by device I/O control function.
-
- @see mbg_get_serial_settings()
- @see mbg_get_device_info()
- @see mbg_setup_receiver_info()
-*/
- _MBG_API_ATTR int _MBG_API mbg_save_serial_settings( MBG_DEV_HANDLE dh, const PCPS_DEV *pdev, RECEIVER_PORT_CFG *pcfg, int port_num ) ;
-
- /**
- Read the version code of the on-board PCI/PCIe interface ASIC.
The macro _pcps_has_asic_version() or the API call mbg_dev_has_asic_version()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCI_ASIC_VERSION type to be filled up
@@ -1691,9 +2001,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_asic_version( MBG_DEV_HANDLE dh, PCI_ASIC_VERSION *p ) ;
/**
- Read the features of the on-board PCI/PCIe interface ASIC.
+ @brief Read the features of the on-board PCI/PCIe interface ASIC.
+
The macro _pcps_has_asic_features() or the API call mbg_dev_has_asic_features()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p Pointer to a ::PCI_ASIC_FEATURES type to be filled up
@@ -1705,10 +2016,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_asic_features( MBG_DEV_HANDLE dh, PCI_ASIC_FEATURES *p ) ;
/**
- Check if a specific device supports configurable time scales.
+ @brief Check if a device supports configurable time scales.
- By default the cards return UTC and/or local time. However, some cards
- can be configured to return pure GPS time or TAI instead.
+ By default the cards return UTC and/or local time. However, some cards
+ can be configured to return raw GPS time or TAI instead.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -1721,11 +2032,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_time_scale( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a ::MBG_TIME_SCALE_INFO structure from a card telling which time scales
- are supported by a card, and the current settings of the card.
+ @brief Read the current time scale settings and which time scales are supported.
+
+ The ::MBG_TIME_SCALE_INFO structure tells which time scale settings are supported
+ by a device, and which time scale is currently configured.
The macro _pcps_has_time_scale() or the API call mbg_dev_has_time_scale()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
See also the notes for mbg_dev_has_time_scale().
@param dh Valid handle to a Meinberg device
@@ -1739,14 +2052,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_time_scale_info( MBG_DEV_HANDLE dh, MBG_TIME_SCALE_INFO *p ) ;
/**
- Write a ::MBG_TIME_SCALE_SETTINGS structure to a card which determines
- which time scale shall be represented by time stamps read from the card.
+ @brief Write the time scale configuration to a device.
+
+ The ::MBG_TIME_SCALE_SETTINGS structure determines which time scale
+ is to be used for the time stamps which can be read from a device.
The macro _pcps_has_time_scale() or the API call mbg_dev_has_time_scale()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
See also the notes for mbg_dev_has_time_scale().
- The function mbg_get_time_scale_info() should have been called before
+ The function mbg_get_time_scale_info() should have been called before
in order to determine which time scales are supported by the card.
@param dh Valid handle to a Meinberg device
@@ -1760,15 +2075,18 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_time_scale_settings( MBG_DEV_HANDLE dh, MBG_TIME_SCALE_SETTINGS *p ) ;
/**
- Check if a specific device supports reading/writing a GPS UTC parameter
- set via the PC bus (reading/writing these parameters via the serial port
- is supported by all GPS devices).
+ @brief Check if a device support reading/writing of UTC parameters.
+
+ This API call checks if a device supports reading/writing a GPS UTC
+ parameter set via the PC bus. Reading/writing these parameters via the
+ serial port using the Meinberg binary data protocol is supported by all
+ Meinberg GPS devices.
- The UTC parameters are normally received from the satellites' broadcasts
- and contain the current time offset between GPT time and UTC, plus information
- on a pending leap second.
+ The UTC parameter set is usually received from the satellites' broadcasts
+ and contains the current time offset between GPS time and UTC, plus information
+ on a pending leap second event.
- It may be useful to overwrite them to do some tests, or for applications
+ It may be useful to overwrite them to do some tests, or for applications
where a card is freewheeling.
@param dh Valid handle to a Meinberg device
@@ -1782,10 +2100,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_utc_parm( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a ::UTC structure from a card.
+ @brief Read a ::UTC parameter structure from a device.
The macro _pcps_has_utc_parm() or the API call mbg_dev_has_utc_parm()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
See also the notes for mbg_dev_has_utc_parm().
@param dh Valid handle to a Meinberg device
@@ -1799,15 +2117,15 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_utc_parm( MBG_DEV_HANDLE dh, UTC *p ) ;
/**
- Write a ::UTC structure to a card.
+ @brief Write a ::UTC parameter structure to a device.
- This should only be done for testing, or if a card is operated in
- freewheeling mode. If the card receives any satellites the settings
- written to the board are overwritten by the parameters broadcasted
+ This should only be done for testing, or if a card is operated in
+ freewheeling mode. If the receiver is tracking any satellites then the settings
+ written to the device are overwritten by the parameters broadcasted
by the satellites.
The macro _pcps_has_utc_parm() or the API call mbg_dev_has_utc_parm()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
See also the notes for mbg_dev_has_utc_parm().
@param dh Valid handle to a Meinberg device
@@ -1821,22 +2139,24 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_utc_parm( MBG_DEV_HANDLE dh, UTC *p ) ;
/**
- Read a ::PCPS_TIME_CYCLES structure that contains a ::PCPS_TIME structure
+ @brief Read the current time plus the associated PC cycles from a device.
+
+ The ::PCPS_TIME_CYCLES structure contains a ::PCPS_TIME structure
and a PC cycle counter value which can be used to compensate the latency
of the call, i.e. the program execution time until the time stamp has actually
been read from the board.
- This call is supported for any card, similar to mbg_get_time(). However,
- the mbg_get_hr_time_cyles() call should be used preferably if supported by
- the specific card since that call provides much better accuracy than this one.
+ This call is supported for any card, similar to mbg_get_time(). However,
+ the mbg_get_hr_time_cyles() call should be used preferably if supported by
+ the device since that call provides much better accuracy than this one.
- The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
- under Windows, and get_cycles() under Linux. On other operating systems the returned
- cycles value is always 0.
+ The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
+ under Windows, and get_cycles() under Linux. On operating systems or targets which don't
+ provide a cycles counter the returned cycles value is always 0.
- Applications should first pick up their own cycle counter value and then call
- this function. The difference of the cycle counter values corresponds to the
- latency of the call in units of the cycle counter clock frequency, e.g as reported
+ Applications should first pick up their own cycle counter value and then call
+ this function. The difference of the cycle counter values corresponds to the
+ latency of the call in units of the cycle counter clock frequency, e.g as reported
by QueryPerformanceFrequency() under Windows.
@param dh Valid handle to a Meinberg device
@@ -1852,21 +2172,23 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_time_cycles( MBG_DEV_HANDLE dh, PCPS_TIME_CYCLES *p ) ;
/**
- Read a ::PCPS_HR_TIME_CYCLES structure that contains a ::PCPS_HR_TIME structure
+ @brief Read the current high resolution time plus the associated PC cycles from a device.
+
+ The ::PCPS_HR_TIME_CYCLES structure contains a ::PCPS_HR_TIME structure
and a PC cycle counter value which can be used to compensate the latency
of the call, i.e. the program execution time until the time stamp has actually
been read from the board.
- The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
- check whether this call is supported by a specific card.
+ The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
+ check whether this call is supported by a device.
- The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
- under Windows, and get_cycles() under Linux. On other operating systems the returned
- cycles value is always 0.
+ The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
+ under Windows, and get_cycles() under Linux. On operating systems or targets which don't
+ provide a cycles counter the returned cycles value is always 0.
- Applications should first pick up their own cycle counter value and then call
- this function. The difference of the cycle counter values corresponds to the
- latency of the call in units of the cycle counter clock frequency, e.g as reported
+ Applications should first pick up their own cycle counter value and then call
+ this function. The difference of the cycle counter values corresponds to the
+ latency of the call in units of the cycle counter clock frequency, e.g as reported
by QueryPerformanceFrequency() under Windows.
@param dh Valid handle to a Meinberg device
@@ -1882,25 +2204,27 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_hr_time_cycles( MBG_DEV_HANDLE dh, PCPS_HR_TIME_CYCLES *p ) ;
/**
- Read a ::PCPS_HR_TIME structure plus cycle counter value, and correct the
+ @brief Read the current high resolution time, and compensate the call's latency.
+
+ Read a ::PCPS_HR_TIME structure plus cycle counter value, and correct the
time stamp for the latency of the call as described for mbg_get_hr_time_cycles(),
then return the compensated time stamp and optionally the latency.
- The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
- check whether this call is supported by a specific card.
+ The macro _pcps_has_hr_time() or the API call mbg_dev_has_hr_time()
+ check whether this call is supported by a device.
- The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
- under Windows, and get_cycles() under Linux. On other operating systems the returned
- cycles value is always 0.
+ The cycle counter value corresponds to a value returned by QueryPerformanceCounter()
+ under Windows, and get_cycles() under Linux. On operating systems or targets which don't
+ provide a cycles counter the returned cycles value is always 0.
- Applications should first pick up their own cycle counter value and then call
- this function. The difference of the cycle counter values corresponds to the
- latency of the call in units of the cycle counter clock frequency, e.g as reported
+ Applications should first pick up their own cycle counter value and then call
+ this function. The difference of the cycle counter values corresponds to the
+ latency of the call in units of the cycle counter clock frequency, e.g as reported
by QueryPerformanceFrequency() under Windows.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_HR_TIME structure to be filled up
- @param *hns_latency Optional pointer to an int32_t value to return
+ @param *hns_latency Optional pointer to an int32_t value to return
the latency in 100ns units. Pass NULL if not used.
@return ::MBG_SUCCESS or error code returned by device I/O control function.
@@ -1913,10 +2237,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_hr_time_comp( MBG_DEV_HANDLE dh, PCPS_HR_TIME *p, int32_t *hns_latency ) ;
/**
- Read an ::IRIG_INFO structure containing the configuration of an IRIG output
+ @brief Read the current IRIG output settings plus the supported settings.
+
+ The returned ::IRIG_INFO structure contains the configuration of an IRIG output
plus the possible settings supported by that output.
- The macro _pcps_has_irig_tx() or the API call mbg_dev_has_irig_tx()
- check whether this call is supported by a specific card.
+
+ The macro _pcps_has_irig_tx() or the API call mbg_dev_has_irig_tx()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an ::IRIG_INFO structure to be filled up
@@ -1932,9 +2259,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_irig_tx_info( MBG_DEV_HANDLE dh, IRIG_INFO *p ) ;
/**
- Write an ::IRIG_SETTINGS structure containing the configuration of an IRIG output.
- The macro _pcps_has_irig_tx() or the API call mbg_dev_has_irig_tx()
- check whether this call is supported by a specific card.
+ @brief Write an ::IRIG_SETTINGS structure to a device to configure the IRIG output.
+
+ The macro _pcps_has_irig_tx() or the API call mbg_dev_has_irig_tx()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an ::IRIG_INFO structure to be written
@@ -1950,10 +2278,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_irig_tx_settings( MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p ) ;
/**
- Read a ::SYNTH structure containing the configuration of an optional
+ @brief Read the current frequency synthesizer settings from a device.
+
+ Read a ::SYNTH structure containing the configuration of an optional
on-board programmable frequency synthesizer.
- The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
- check whether this call is supported by a specific card.
+
+ The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::SYNTH structure to be filled up
@@ -1968,10 +2299,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_synth( MBG_DEV_HANDLE dh, SYNTH *p ) ;
/**
- Write a ::SYNTH structure containing the configuration of an optional
+ @brief Write some frequency synthesizer settings to a device.
+
+ Write a ::SYNTH structure containing the configuration of an optional
on-board programmable frequency synthesizer.
- The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
- check whether this call is supported by a specific card.
+
+ The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::SYNTH structure to be written
@@ -1986,10 +2320,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_synth( MBG_DEV_HANDLE dh, const SYNTH *p ) ;
/**
- Read a ::SYNTH_STATE structure reporting the current state
- of an optional on-board programmable frequency synthesizer.
- The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
- check whether this call is supported by a specific card.
+ @brief Read the current status of the on-board frequency synthesizer.
+
+ The macro _pcps_has_synth() or the API call mbg_dev_has_synth()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::SYNTH_STATE structure to be filled up
@@ -2004,7 +2338,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_synth_state( MBG_DEV_HANDLE dh, SYNTH_STATE *p ) ;
/**
- Check if a specific device supports the mbg_get_fast_hr_timestamp_...() calls.
+ @brief Check if a device supports the mbg_get_fast_hr_timestamp_...() calls.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2018,7 +2352,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_fast_hr_timestamp( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a high resolution ::PCPS_TIME_STAMP_CYCLES structure via memory mapped access.
+ @brief Read a high resolution ::PCPS_TIME_STAMP_CYCLES structure via memory mapped access.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_TIME_STAMP_CYCLES structure to be filled up
@@ -2029,11 +2363,13 @@ extern "C" {
@see mbg_get_fast_hr_timestamp_comp()
@see mbg_get_fast_hr_timestamp()
*/
- _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_cycles( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP_CYCLES *p ) ;
+ _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 via memory mapped access,
- and compensate the latency of the time stamp before it is returned.
+ @brief Read a high resolution timestamp and compensate the latency of the call.
+
+ The retrieved ::PCPS_TIME_STAMP is read from memory mapped registers,
+ and timestamp is compensated for the call's latency before it is returned.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_TIME_STAMP structure to be filled up
@@ -2048,12 +2384,12 @@ extern "C" {
_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 ::PCPS_TIME_STAMP structure via memory mapped access.
+ @brief Read a high resolution ::PCPS_TIME_STAMP structure via memory mapped access.
This function does not return or evaluate a cycles count, so the latency
of the call can not be determined. However, depending on the timer hardware
used as cycles counter it may take quite some time to read the cycles count
- on some hardware architectures, so this call can be used to yield lower
+ on some hardware architectures, so this call can be used to yield lower
latencies, under the restriction to be unable to determine the exact latency.
@param dh Valid handle to a Meinberg device
@@ -2065,10 +2401,10 @@ extern "C" {
@see mbg_get_fast_hr_timestamp_comp()
@see mbg_get_fast_hr_timestamp_cycles()
*/
- _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p ) ;
+ _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p ) ;
/**
- Check if a specific device is a GPS receiver.
+ @brief Check if a device is a GPS receiver.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2078,7 +2414,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_gps( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device is a DCF77 receiver.
+ @brief Check if a device is a DCF77 receiver.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2088,7 +2424,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_dcf( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device is a MSF receiver.
+ @brief Check if a device is a MSF receiver.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2098,7 +2434,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_msf( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device is a WWVB receiver.
+ @brief Check if a device is a WWVB receiver.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2108,7 +2444,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_wwvb( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device is a long wave signal receiver, e.g. DCF77, MSF or WWVB.
+ @brief Check if a device is any long wave signal receiver.
+
+ Long wave receivers include e.g. DCF77, MSF, WWVB, or JJY.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2118,8 +2456,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_lwr( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device is an IRIG receiver which supports
- configuration of the IRIG input.
+ @brief Check if a device provides a configurable IRIG input.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2134,7 +2471,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_is_irig_rx( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the HR_TIME functions.
+ @brief Check if a device supports the HR_TIME functions.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2148,7 +2485,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_hr_time( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports configuration of antenna cable length.
+ @brief Check if a device supports configuration of antenna cable length.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2161,8 +2498,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_cab_len( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports timezone / daylight saving configuration
- using the ::TZDL structure.
+ @brief Check if a device supports timezone configuration using the ::TZDL structure.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2176,8 +2512,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_tzdl( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports timezone / daylight saving configuration
- using the ::PCPS_TZDL structure.
+ @brief Check if a device supports timezone configuration using the ::PCPS_TZDL structure.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2191,8 +2526,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_pcps_tzdl( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports timezone configuration
- using the ::PCPS_TZCODE type.
+ @brief Check if a device supports timezone configuration using the ::PCPS_TZCODE type.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2206,9 +2540,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_tzcode( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports any kind of timezone configuration.
- This can be used e.g. to check if a specifig dialog or menu has to
- be displayed.
+ @brief Check if a device supports any kind of timezone configuration.
+
+ This can be used e.g. to check if a specifig dialog or menu has to
+ be displayed.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2222,7 +2557,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_tz( MBG_DEV_HANDLE dh, int *p ) ;
/* (Intentionally excluded from Doxygen)
- Check if a specific device supports setting an event time, i.e.
+ Check if a device supports setting an event time, i.e.
configure a %UTC time when the clock shall generate an event.
<b>Note:</b> This is only supported by some special firmware.
@@ -2237,11 +2572,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_event_time( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the ::RECEIVER_INFO structure and related calls.
- Older GPS devices may not support that structure.
+ @brief Check if a device supports the ::RECEIVER_INFO structure and related calls.
+
+ @note Older GPS devices may not support that structure.
- The mbg_get_gps_receiver_info() call uses this call to decide whether a
- ::RECEIVER_INFO can be read directly from a device, or whether a default
+ The mbg_get_gps_receiver_info() call uses this call to decide whether a
+ ::RECEIVER_INFO can be read directly from a device, or whether a default
structure has to be set up using default values depending on the device type.
@param dh Valid handle to a Meinberg device
@@ -2254,8 +2590,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_receiver_info( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the mbg_clr_ucap_buff() call
- used to clear a card's on-board time capture FIFO buffer.
+ @brief Check if a device supports the mbg_clr_ucap_buff() call.
+
+ The mbg_clr_ucap_buff() call can be used to clear a card's on-board
+ time capture FIFO buffer.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2267,10 +2605,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_can_clr_ucap_buff( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the mbg_get_ucap_entries() and
- mbg_get_ucap_event() calls.
+ @brief Check if a device supports the mbg_get_ucap_entries() and mbg_get_ucap_event() calls.
- If the card does not but it is a GPS card then the card provides
+ If the card does not but it is a GPS card then the card provides
a time capture FIFO buffer and the obsolete mbg_get_gps_ucap()
call can be used to retrieve entries from the FIFO buffer.
@@ -2287,8 +2624,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_ucap( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides an IRIG output which can
- be configured.
+ @brief Check if a device provides a configurable IRIG output.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2305,9 +2641,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig_tx( MBG_DEV_HANDLE dh, int *p ) ;
/* (Intentionally excluded from Doxygen)
- Check if a specific device provides a serial output supporting
+ Check if a device provides a serial output supporting
higher baud rates than older cards, i.e. ::DEFAULT_BAUD_RATES_DCF_HS
- rather than ::DEFAULT_BAUD_RATES_DCF.
+ rather than ::DEFAULT_BAUD_RATES_DCF.
The mbg_get_serial_settings() takes care of this, so applications
which use that call as suggested won't need to use this call directly.
@@ -2322,8 +2658,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_serial_hs( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides an input signal level value which
- may be displayed, e.g. DCF77 or IRIG cards.
+ @brief Check if a device provides the level of its inputs signal.
+
+ This is useful to display the signal level of e.g. an IRIG or longwave signal.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2333,8 +2670,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_signal( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides an modulation signal which may be
- displayed, e.g. the second marks of a DCF77 AM receiver.
+ @brief Check if a device provides a modulation signal.
+
+ Modulation signals are e.g. the second marks of a DCF77 AM receiver.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2344,7 +2682,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_mod( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides either an IRIG input or output.
+ @brief Check if a device provides either an IRIG input or output.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2357,8 +2695,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_irig( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides a configurable ref time offset
- required to convert the received time to %UTC.
+ @brief Check if a device provides a configurable ref time offset.
+
+ This may be required to convert the received time to %UTC, if the input
+ signal doesn't specify this (e.g. most IRIG code formats).
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2371,8 +2711,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_ref_offs( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the ::MBG_OPT_INFO/::MBG_OPT_SETTINGS
- structures containing optional settings, controlled by flags.
+ @brief Check if a device supports the ::MBG_OPT_INFO/::MBG_OPT_SETTINGS.
+
+ These structures containing optional settings, controlled by flags.
+ See ::MBG_OPT_SETTINGS and related definitions.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2385,8 +2727,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_opt_flags( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports large configuration data structures
- as have been introducesde with the GPS receivers.
+ @brief Check if a device supports large configuration data structures.
+
+ Such structures have been introduced with the first Meinberg GPS receivers.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2396,7 +2739,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_gps_data( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device provides a programmable frequency synthesizer.
+ @brief Check if a device provides a programmable frequency synthesizer.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2409,7 +2752,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_synth( MBG_DEV_HANDLE dh, int *p ) ;
/* (Intentionally excluded from Doxygen)
- Check if a specific device supports the mbg_generic_io() call.
+ @brief Check if a device supports the mbg_generic_io() call.
<b>Warning</b>: That call is for debugging purposes and internal use only!
@@ -2423,7 +2766,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_generic_io( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the mbg_get_asic_version() call.
+ @brief Check if a device supports the mbg_get_asic_version() call.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2435,7 +2778,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_version( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Check if a specific device supports the mbg_get_asic_features() call.
+ @brief Check if a device supports the mbg_get_asic_features() call.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2447,14 +2790,17 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_asic_features( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read a ::POUT_INFO_IDX array of current settings and configuration
- options of a card's programmable pulse outputs.
+ @brief Read current configuraton and features provided by the programmable pulse outputs.
+
+ Reads a ::POUT_INFO_IDX array of current settings and configuration
+ options of the device's programmable pulse outputs.
+
The function mbg_setup_receiver_info() must have been called before,
and the returned ::RECEIVER_INFO structure passed to this function.
- The function should only be called if the ::RECEIVER_INFO::n_prg_out
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out
field (i.e. the number of programmable outputs on the board) is not 0.
- The array passed to this function to receive the returned data
+ The array passed to this function to receive the returned data
must be able to hold at least ::RECEIVER_INFO::n_prg_out elements.
@param dh Valid handle to a Meinberg device.
@@ -2470,13 +2816,14 @@ extern "C" {
_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 ) ;
/**
- Write the configuration for a single programmable pulse output using
- the ::POUT_SETTINGS_IDX structure which contains both the ::POUT_SETTINGS
- and the output index value.
- Except for the parameter types, this call is equivalent to
- mbg_set_gps_pout_settings().
- The function should only be called if the ::RECEIVER_INFO::n_prg_out field
- (i.e. the number of programmable outputs on the board) is not 0, and the
+ @brief Write the configuration for a single programmable pulse output
+
+ The ::POUT_SETTINGS_IDX structure contains both the ::POUT_SETTINGS
+ and the output index value. Except for the parameter types this call
+ is equivalent to mbg_set_gps_pout_settings().
+
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out field
+ (i.e. the number of programmable outputs on the board) is not 0, and the
output index value must be in the range 0..::RECEIVER_INFO::n_prg_out.
@param dh Valid handle to a Meinberg device.
@@ -2490,12 +2837,15 @@ extern "C" {
_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 using
- the ::POUT_SETTINGS structure plus the index of the output to be configured.
- Except for the parameter types, this call is equivalent to
- mbg_set_gps_pout_settings_idx().
- The function should only be called if the ::RECEIVER_INFO::n_prg_out field
- (i.e. the number of programmable outputs on the board) is not 0, and the
+ @brief Write the configuration for a single programmable pulse output
+
+ The ::POUT_SETTINGS structure does not contain the index of the
+ programmable output to be configured, so the index must explicitely
+ be passed to this function. Except for the parameter types this call
+ is equivalent to mbg_set_gps_pout_settings_idx().
+
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out field
+ (i.e. the number of programmable outputs on the board) is not 0, and the
output index value must be in the range 0..::RECEIVER_INFO::n_prg_out.
@param dh Valid handle to a Meinberg device.
@@ -2510,9 +2860,11 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_gps_pout_settings( MBG_DEV_HANDLE dh, const POUT_SETTINGS *p, int idx ) ;
/**
- Read a card's IRQ status information which includes flags indicating
- whether IRQs are currently enabled, and whether IRQ support by a card
- is possibly unsafe due to the firmware and interface chip version.
+ @brief Read a device's IRQ status information.
+
+ IRQ status information includes flags indicating whether IRQs are
+ actually enabled, and whether IRQ support by a card is possibly
+ unsafe due to the firmware and interface chip version.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PCPS_IRQ_STAT_INFO variable to be filled up
@@ -2522,7 +2874,7 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_irq_stat_info( MBG_DEV_HANDLE dh, PCPS_IRQ_STAT_INFO *p ) ;
/**
- Check if a specific device provides simple LAN interface API calls.
+ @brief Check if a device provides simple LAN interface API calls.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@@ -2537,9 +2889,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_dev_has_lan_intf( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read LAN interface information from a card which supports this.
+ @brief Read LAN interface information from a device.
+
The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::LAN_IF_INFO variable to be filled up
@@ -2554,9 +2907,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_lan_if_info( MBG_DEV_HANDLE dh, LAN_IF_INFO *p ) ;
/**
- Read LAN IPv4 state from a card which supports this.
+ @brief Read LAN IPv4 state from a device.
+
The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::IP4_SETTINGS variable to be filled up
@@ -2571,9 +2925,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_ip4_state( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
/**
- Read LAN IPv4 settings from a card which supports this.
+ @brief Read LAN IPv4 settings from a device.
+
The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::IP4_SETTINGS variable to be filled up
@@ -2588,9 +2943,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_ip4_settings( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
/**
- Write LAN IPv4 settings to a card which supports this.
+ @brief Write LAN IPv4 settings to a device.
+
The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
- check whether this call is supported by a specific card.
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p ::IP4_SETTINGS structure to be written
@@ -2604,70 +2960,439 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_ip4_settings( MBG_DEV_HANDLE dh, const IP4_SETTINGS *p ) ;
/**
- Check if a specific device provides PTP configuration/status calls.
+ @brief Check if a device provides PTP configuration/status calls.
@param dh Valid handle to a Meinberg device
@param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@return ::MBG_SUCCESS or error code returned by device I/O control function.
- @see mbg_get_ptp_state()
- @see mbg_get_ptp_cfg_info()
- @see mbg_set_ptp_cfg_settings()
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_state
+ @see mbg_get_ptp_cfg_info
+ @see mbg_set_ptp_cfg_settings
+ @see mbg_dev_has_ptp_unicast
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p ) ;
/**
- Read PTP/IEEE1588 status from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
- check whether this call is supported by a specific card.
+ @brief Check if a device provides PTP unicast feature/configuration.
@param dh Valid handle to a Meinberg device
- @param *p Pointer to a ::PTP_CFG_INFO variable to be filled up
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
@return ::MBG_SUCCESS or error code returned by device I/O control function.
- @see mbg_dev_has_ptp()
- @see mbg_get_ptp_cfg_info()
- @see mbg_set_ptp_cfg_settings()
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_uc_master_cfg_limits
+ @see mbg_get_all_ptp_uc_master_info
+ @see mbg_set_ptp_uc_master_settings_idx
+ @see mbg_get_ptp_state
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_ptp_unicast( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Read PTP/IEEE1588 status from a device.
+
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_STATE variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_cfg_info
+ @see mbg_set_ptp_cfg_settings
+ @see mbg_dev_has_ptp_unicast
*/
_MBG_API_ATTR int _MBG_API mbg_get_ptp_state( MBG_DEV_HANDLE dh, PTP_STATE *p ) ;
/**
- Read PTP/IEEE1588 config info and current settings from a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
- check whether this call is supported by a specific card.
+ @brief Read PTP/IEEE1588 config info and current settings from a device.
+
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device
@param *p Pointer to a ::PTP_CFG_INFO variable to be filled up
@return ::MBG_SUCCESS or error code returned by device I/O control function.
- @see mbg_dev_has_ptp()
- @see mbg_get_ptp_state()
- @see mbg_set_ptp_cfg_settings()
+ @see mbg_dev_has_ptp
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_state
+ @see mbg_set_ptp_cfg_settings
+ @see mbg_dev_has_ptp_unicast
*/
_MBG_API_ATTR int _MBG_API mbg_get_ptp_cfg_info( MBG_DEV_HANDLE dh, PTP_CFG_INFO *p ) ;
/**
- Write PTP/IEEE1588 configuration settings to a card which supports this.
- The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
- check whether this call is supported by a specific card.
+ @brief Write PTP/IEEE1588 configuration settings to a device.
+
+ The macro _pcps_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a device.
@param dh Valid handle to a Meinberg device.
@param *p ::PTP_CFG_SETTINGS structure to be written
@return ::MBG_SUCCESS or error code returned by device I/O control function.
- @see mbg_dev_has_ptp()
- @see mbg_get_ptp_state()
- @see mbg_get_ptp_cfg_info()
+ @see mbg_dev_has_ptp
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_state
+ @see mbg_get_ptp_cfg_info
+ @see mbg_dev_has_ptp_unicast
*/
_MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p ) ;
/**
- Read the CPU affinity of a process, i.e. on which of the available
- CPUs the process can be executed.
+ @brief Read PTP/IEEE1588 unicast master configuration limits from a device.
+
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_UC_MASTER_CFG_LIMITS variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp_unicast
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_all_ptp_uc_master_info
+ @see mbg_set_ptp_uc_master_settings_idx
+ @see mbg_get_ptp_state
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_ptp_uc_master_cfg_limits( MBG_DEV_HANDLE dh, PTP_UC_MASTER_CFG_LIMITS *p ) ;
+
+ /**
+ @brief Read PTP Unicast master settings and configuration options.
+
+ The function mbg_setup_receiver_info() must have been called before,
+ and the returned ::RECEIVER_INFO structure passed to this function.
+ The function should only be called if the ::RECEIVER_INFO::n_prg_out
+ field (i.e. the number of programmable outputs on the board) is not 0.
+
+ The array passed to this function to receive the returned data
+ must be able to hold at least ::RECEIVER_INFO::n_prg_out elements.
+
+ @param dh Valid handle to a Meinberg device.
+ @param pii Pointer to a an array of ::PTP_UC_MASTER_INFO_IDX structures to be filled up
+ @param p_umsl Pointer to a ::PTP_UC_MASTER_CFG_LIMITS structure returned by mbg_get_ptp_uc_master_cfg_limits()
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp_unicast
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_uc_master_cfg_limits
+ @see mbg_set_ptp_uc_master_settings_idx
+ @see mbg_get_ptp_state
+*/
+ _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 ) ;
+
+ /**
+ @brief Write PTP/IEEE1588 unicast configuration settings to a device.
+
+ The macro _pcps_has_ri_ptp_unicast() or the API call mbg_dev_has_ptp_unicast()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p ::PTP_UC_MASTER_SETTINGS_IDX structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp_unicast
+ @see mbg_get_all_ptp_cfg_info
+ @see mbg_get_ptp_uc_master_cfg_limits
+ @see mbg_get_all_ptp_uc_master_info
+ @see mbg_get_ptp_state
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_ptp_uc_master_settings_idx( MBG_DEV_HANDLE dh, const PTP_UC_MASTER_SETTINGS_IDX *p ) ;
+
+ /**
+ @brief Read both system time and associated device time from the kernel driver.
+
+ The kernel driver reads the current system time plus a HR time structure
+ from a card immediately after each other. The returned info structure also
+ contains some cycles counts to be able to determine the execution times
+ required to read those time stamps.
+
+ The advantage of this call compared to mbg_get_time_info_tstamp() is
+ that this call also returns the card's status. On the other hand, reading
+ the HR time from the card may block e.g. if another application accesses
+ the board.
+
+ This call makes a mbg_get_hr_time_cycles() call internally so the macro
+ _pcps_has_hr_time() or the API call mbg_dev_has_hr_time() can be
+ used to check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_TIME_INFO_HRT variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_hr_time()
+ @see mbg_get_time_info_tstamp()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_time_info_hrt( MBG_DEV_HANDLE dh, MBG_TIME_INFO_HRT *p ) ;
+
+ /**
+ @brief Read both system time and associated device timestamp from the kernel driver.
+
+ This call is similar to mbg_get_time_info_hrt() except that a
+ mbg_get_fast_hr_timestamp_cycles() call is made internally, so the macro
+ _pcps_has_fast_hr_timestamp() or the API call mbg_dev_has_fast_hr_timestamp()
+ can be used to check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_TIME_INFO_TSTAMP variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_fast_hr_timestamp()
+ @see mbg_get_time_info_hrt()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_time_info_tstamp( MBG_DEV_HANDLE dh, MBG_TIME_INFO_TSTAMP *p ) ;
+
+ /**
+ @brief Check if a device supports demodulation of the DCF77 PZF code.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_corr_info()
+ @see mbg_dev_has_tr_distance()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_pzf( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Check if a device supports reading correlation info.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_get_corr_info()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_corr_info( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Check if a device supports configurable distance from transmitter.
+
+ The distance from transmitter parameter is used to compensate
+ the RF propagation delay, mostly with long wave receivers.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_get_tr_distance()
+ @see mbg_set_tr_distance()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_tr_distance( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Read PZF correlation info from a device.
+
+ The macro _pcps_has_corr_info() or the API call mbg_dev_has_corr_info()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::CORR_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_corr_info()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_corr_info( MBG_DEV_HANDLE dh, CORR_INFO *p ) ;
+
+ /**
+ @brief Read configurable "distance from transmitter" parameter from a device.
+
+ The distance from transmitter parameter is used to compensate
+ the RF propagation delay, mostly with long wave receivers.
+
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_set_tr_distance()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_tr_distance( MBG_DEV_HANDLE dh, TR_DISTANCE *p ) ;
+
+ /**
+ @brief Write configurable "distance from transmitter" parameter to a device.
+
+ The distance from transmitter parameter is used to compensate
+ the RF propagation delay, mostly with long wave receivers.
+
+ The macro _pcps_has_tr_distance() or the API call mbg_dev_has_tr_distance()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::TR_DISTANCE variable to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_pzf()
+ @see mbg_dev_has_tr_distance()
+ @see mbg_get_tr_distance()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_set_tr_distance( MBG_DEV_HANDLE dh, const TR_DISTANCE *p ) ;
+
+ /**
+ @brief Check if a device provides a debug status word to be read.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_debug_status()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_debug_status( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Read a debug status word from a device.
+
+ This is mainly supported by IRIG timecode receiver cards, and the status
+ word is intended to provide more detailed information why a card might not
+ synchronize to the incoming timecode signal.
+
+ See ::MBG_DEBUG_STATUS and related definitions for details.
+
+ The macro _pcps_has_debug_status() or the API call mbg_dev_has_debug_status()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_DEBUG_STATUS variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_debug_status()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_debug_status( MBG_DEV_HANDLE dh, MBG_DEBUG_STATUS *p ) ;
+
+ /**
+ @brief Check if a device provides an on-board event log.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_clr_evt_log()
+ @see mbg_get_num_evt_log_entries()
+ @see mbg_get_first_evt_log_entry()
+ @see mbg_get_next_evt_log_entry()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_evt_log( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ @brief Clear the card's on-board event log.
+
+ The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_evt_log()
+ @see mbg_get_num_evt_log_entries()
+ @see mbg_get_first_evt_log_entry()
+ @see mbg_get_next_evt_log_entry()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_clr_evt_log( MBG_DEV_HANDLE dh ) ;
+
+ /**
+ @brief Read details about a device's on-board event log buffer.
+
+ The returned ::MBG_NUM_EVT_LOG_ENTRIES structure tells how many event log
+ entries which can be saved on the board, and how many entries actually
+ have been saved.
+
+ The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log()
+ check whether this call is supported by a device.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_NUM_EVT_LOG_ENTRIES variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_evt_log()
+ @see mbg_clr_evt_log()
+ @see mbg_get_first_evt_log_entry()
+ @see mbg_get_next_evt_log_entry()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_num_evt_log_entries( MBG_DEV_HANDLE dh, MBG_NUM_EVT_LOG_ENTRIES *p ) ;
+
+ /**
+ @brief Read the first (oldest) event log entry from a device.
+
+ @note Subsequent reads should be made using mbg_get_next_evt_log_entry().
+
+ The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log()
+ check whether this call is supported by a device.
+
+ If no (more) event log entry is available on the device then
+ the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_evt_log()
+ @see mbg_clr_evt_log()
+ @see mbg_get_num_evt_log_entries()
+ @see mbg_get_next_evt_log_entry()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_first_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) ;
+
+ /**
+ @brief Read the next event log entry from a device.
+
+ @note The first read should be made using mbg_get_first_evt_log_entry()
+ to set the on-board read index to the oldest entry.
+
+ The macro _pcps_has_evt_log() or the API call mbg_dev_has_evt_log()
+ check whether this call is supported by a device.
+
+ If no (more) event log entry is available on the device then
+ the returned MBG_EVT_LOG_ENTRY::code is MBG_EVT_ID_NONE.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_EVT_LOG_ENTRY variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_evt_log()
+ @see mbg_clr_evt_log()
+ @see mbg_get_num_evt_log_entries()
+ @see mbg_get_first_evt_log_entry()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_next_evt_log_entry( MBG_DEV_HANDLE dh, MBG_EVT_LOG_ENTRY *p ) ;
+
+ /**
+ @brief Read the CPU affinity of a process.
+
+ This means on which of the available CPUs or CPU cores the process can be executed.
@param pid The process ID.
@param *p Pointer to a ::MBG_CPU_SET variable which contains a mask of CPUs.
@@ -2680,8 +3405,10 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_process_affinity( MBG_PROCESS_ID pid, MBG_CPU_SET *p ) ;
/**
- Set the CPU affinity of a process, i.e. on which of the available
- CPUs the process is allowed to be executed.
+ @brief Set the CPU affinity of a process.
+
+ This determines on which of the available CPUs
+ the process is allowed to be executed.
@param pid The process ID.
@param *p Pointer to a ::MBG_CPU_SET variable which contains a mask of CPUs.
@@ -2694,10 +3421,10 @@ extern "C" {
_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 for a single CPU only, i.e. the process
- may only be executed on that single CPU.
+ @brief Set the CPU affinity of a process for a single CPU only.
+
+ This means the process may only be executed on that single CPU.
- @param pid The process ID.
@param cpu_num The number of the CPU.
@return ::MBG_SUCCESS or error code returned by the system call.
@@ -2708,7 +3435,8 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_current_process_affinity_to_cpu( int cpu_num ) ;
/**
- Create a new execution thread for the current process.
+ @brief Create a new execution thread for the current process.
+
This function is only implemented for targets which support threads.
@param p_ti Pointer to a ::MBG_THREAD_INFO structure to be filled up.
@@ -2724,8 +3452,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_thread_create( MBG_THREAD_INFO *p_ti, MBG_THREAD_FNC_RET_VAL (MBG_THREAD_FNC_ATTR *fnc)(void *), void *arg ) ;
/**
- Stop a thread which has been created by mbg_thread_create(). Wait
- until the thread has finished and release all resources.
+ @brief Stop a thread which has been created by mbg_thread_create().
+
+ Wait until the thread has finished and release all resources.
This function is only implemented for targets which support threads.
@param p_ti Pointer to a ::MBG_THREAD_INFO structure associated with the thread.
@@ -2739,8 +3468,11 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_thread_stop( MBG_THREAD_INFO *p_ti ) ;
/**
- Let the current thread sleep for a certain interval unless a signal is
- received indicating the thread should terminate.
+ @brief Let the current thread sleep for a certain interval.
+
+ The sleep is interrupted if a signal is received indicating
+ the thread should terminate.
+
This function is only implemented for targets which support threads.
@param p_ti Pointer to a ::MBG_THREAD_INFO structure associated with the thread.
@@ -2756,8 +3488,11 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_thread_sleep_interruptible( MBG_THREAD_INFO *p_ti, ulong sleep_ms ) ;
/**
- Set the CPU affinity of a single thread, i.e. on which of the available
- CPUs the thread is allowed to be executed.
+ @brief Set the CPU affinity of a single thread.
+
+ This determines on which of the available CPUs the thread
+ is allowed to be executed.
+
This function is only implemented for targets which support thread affinity.
@param p_ti Pointer to a ::MBG_THREAD_INFO structure associated with the thread.
@@ -2772,19 +3507,21 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_thread_set_affinity( MBG_THREAD_INFO *p_ti, MBG_CPU_SET *p ) ;
/**
- Set up a ::MBG_POLL_THREAD_INFO structure and start a new thread
- which runs the mbg_xhrt_poll_thread_fnc() function.
+ @brief Set up a ::MBG_POLL_THREAD_INFO structure and start a new thread.
+
+ The new thread runs the mbg_xhrt_poll_thread_fnc() function.
+
This function is only implemented for targets which support threads.
@param *p_pti Pointer to a ::MBG_POLL_THREAD_INFO structure.
@param dh the handle of the device to be polled.
@param freq_hz The initial cycles frequency, if known, in Hz.
- @param sleep_ms the sleep interval for the poll thread function in ms.
+ @param sleep_ms the sleep interval for the poll thread function in ms.
If this parameter is 0 then the default sleep interval is used.
@return ::MBG_SUCCESS on success,
::MBG_ERR_NOT_SUPP_BY_DEV if the device to poll does not support HR time
- else the result of mbg_thread_create()
+ else the result of mbg_thread_create()
@see mbg_xhrt_poll_thread_fnc()
@see mbg_xhrt_poll_thread_stop()
@@ -2795,12 +3532,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_xhrt_poll_thread_create( MBG_POLL_THREAD_INFO *p_pti, MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY freq_hz, int sleep_ms ) ;
/**
- Stop a polling thread started by mbg_xhrt_poll_thread_create()
- and release all associated resources.
+ @brief Stop a polling thread started by mbg_xhrt_poll_thread_create().
+
+ This call also releases all associated resources.
@param *p_pti Pointer to a ::MBG_POLL_THREAD_INFO structure.
- @return the result of mbg_thread_stop()
+ @return the result of mbg_thread_stop()
@see mbg_xhrt_poll_thread_fnc()
@see mbg_xhrt_poll_thread_create()
@@ -2811,10 +3549,12 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_xhrt_poll_thread_stop( MBG_POLL_THREAD_INFO *p_pti ) ;
/**
- Retrieve a time stamp in PCPS_HR_TIME format which is extrapolated
- using the system's current cycles counter value and a time stamp
- plus associated cycles counter value saved by the polling thread.
+ @brief Retrieve an extrapolated time stamp in PCPS_HR_TIME format.
+
+ The time stamp is extrapolated using the system's current cycles counter value
+ and a time stamp plus associated cycles counter value saved by the polling thread.
See mbg_xhrt_poll_thread_fnc() for details and limitations.
+
This function is only implemented for targets which support threads.
@param *p Pointer to a ::MBG_XHRT_INFO structure used to retrieve data from the polling thread.
@@ -2831,11 +3571,13 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_xhrt_time_as_pcps_hr_time( MBG_XHRT_INFO *p, PCPS_HR_TIME *p_hrt ) ;
/**
- Retrieve a time stamp in FILETIME format which is extrapolated
- using the system's current cycles counter value and a time stamp
- plus associated cycles counter value saved by the polling thread.
+ @brief Retrieve an extrapolated time stamp in FILETIME format.
+
+ The time stamp is extrapolated using the system's current cycles counter value
+ and a time stamp plus associated cycles counter value saved by the polling thread.
See mbg_xhrt_poll_thread_fnc() for details and limitations.
- Since FILETIME is a Windows specific type this function is only
+
+ Since FILETIME is a Windows specific type this function is only
implemented under Windows.
@param *p Pointer to a ::MBG_XHRT_INFO structure used to retrieve data from the polling thread.
@@ -2852,9 +3594,11 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_xhrt_time_as_filetime( MBG_XHRT_INFO *p, FILETIME *p_ft ) ;
/**
- Retrieve the frequency of the system's cycles counter as determined
- by the device polling thread.
+ @brief Retrieve the frequency of the system's cycles counter.
+
+ The frequency is determined by the device polling thread.
See mbg_xhrt_poll_thread_fnc() for details and limitations.
+
This function is only implemented for targets which support threads.
@param *p Pointer to a ::MBG_XHRT_INFO structure used to retrieve data from the polling thread.
@@ -2870,7 +3614,9 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_xhrt_cycles_frequency( MBG_XHRT_INFO *p, MBG_PC_CYCLES_FREQUENCY *p_freq_hz ) ;
/**
- Retrieve the default system's cycles counter frequency from the kernel driver.
+ @brief Retrieve the default system's cycles counter frequency from the kernel driver.
+
+ This API call can be used on systems which don't provide this information in user space.
@param dh handle of the device to which the IOCTL call is sent.
@param *p Pointer of a ::MBG_PC_CYCLES_FREQUENCY variable to be filled up.
@@ -2882,18 +3628,16 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_default_cycles_frequency_from_dev( MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p ) ;
/**
- Retrieve the default system's cycles counter frequency.
- This may not be supported on all taget platforms, in which case the
- returned frequency is 0 and the mbg_get_default_cycles_frequency_from_dev()
- call should be used.
+ @brief Retrieve the system's default cycles counter frequency.
- @param dh handle of the device to which the IOCTL call is sent.
- @param *p Pointer of a ::MBG_PC_CYCLES_FREQUENCY variable to be filled up.
+ @note This may not be supported on all target platforms, in which case the
+ returned frequency is 0 and the mbg_get_default_cycles_frequency_from_dev()
+ call should be used.
- @return the default cycles counter frequency in Hz, or 0 if the value is not available.
+ @return the default cycles counter frequency in Hz, or 0 if the value is not available.
- @see mbg_get_default_cycles_frequency()
- */
+ @see mbg_get_default_cycles_frequency_from_dev()
+*/
_MBG_API_ATTR MBG_PC_CYCLES_FREQUENCY _MBG_API mbg_get_default_cycles_frequency( void ) ;
@@ -2904,6 +3648,296 @@ extern "C" {
#endif
+#if defined( MBG_TGT_WIN32 )
+
+static __mbg_inline
+MBGDEVIO_RET_VAL do_mbg_ioctl( MBG_DEV_HANDLE dh, int ioctl_code,
+ const void *in_p, int in_sz, void *out_p, int out_sz )
+{
+ DWORD ReturnedLength;
+
+ if ( !DeviceIoControl( dh, ioctl_code,
+ (LPVOID) in_p, in_sz, out_p, out_sz,
+ &ReturnedLength,
+ NULL
+ ) )
+ {
+ DWORD rc = GetLastError();
+
+#if 0 //##++++++++++++++++++++++++
+// We can't call mbgsvctl_log_mbgdevio_error() here (for now).
+// Is is defined in mbgsvctl.h, and including mbgsvc.h here,
+// or copying the prototype here results in DLL import/export
+// mismatch errors.
+
+ // do not report a USB device timeout error
+ if ( rc != _mbg_err_to_os( MBG_ERR_USB_ACCESS ) )
+ mbgsvctl_log_mbgdevio_error( ioctl_code, rc );
+#endif
+
+ return rc;
+ }
+
+ return MBG_SUCCESS;
+
+} // do_mbg_ioctl
+
+ #define _do_mbg_ioctl( _dh, _ioctl, _p, _in_sz, _out_sz ) \
+ do_mbg_ioctl( _dh, _ioctl, (LPVOID) _p, _in_sz, (LPVOID) _p, _out_sz )
+
+#elif defined( MBG_TGT_UNIX )
+
+ #define _do_mbg_ioctl( _dh, _ioctl, _p, _in_sz, _out_sz ) \
+ ioctl( _dh, _ioctl, _p )
+
+#endif
+
+
+
+// The code below depends on whether the target device is accessed via
+// IOCTLs to a device driver, or the hardware is accessed directly.
+
+#if defined( _MBGIOCTL_H ) // using IOCTL to access device driver
+
+/**
+ @brief Send a generic IOCTL command to the driver.
+
+ @param dh Valid handle to a Meinberg device
+ @param info Additional information for the kernel driver depending on
+ the IOCTL code, i.e. the low level function to be called: <br>
+ one of the PCPS_... commands with IOCTL_PCPS_GENERIC_{READ|WRITE}<br>
+ one of the PC_GPS_... commands with IOCTL_PCPS_GENERIC_{READ|WRITE}_GPS<br>
+ one of the PCPS_GEN_IO_... enumeration codes with IOCTL_PCPS_GENERIC_IO
+ @param ioctl One of the IOCTL_GENERIC_... codes telling the kernel driver
+ which low level function to use, e.g. normal read or write,
+ large (GPS) data read or write, or generic I/O.
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+*/
+ static __mbg_inline
+ int mbgdevio_do_gen_io( MBG_DEV_HANDLE dh, int info, unsigned int ioctl_code,
+ const void *in_p, int in_sz,
+ void *out_p, int out_sz )
+ {
+ _mbgdevio_vars();
+
+ // Generic IOCTL calls always need to pass some info beside
+ // the I/O buffers down to the driver, which usually is
+ // the command code for the device.
+ // Thus we must always use one of the control structures
+ // IOCTL_GENERIC_REQ or IOCTL_GENERIC_BUFFER, whichever
+ // is appropriate for the target OS.
+
+ #if USE_IOCTL_GENERIC_REQ
+
+ IOCTL_GENERIC_REQ req = { 0 };
+
+ req.info = info;
+ req.in_p = in_p;
+ req.in_sz = in_sz;
+ req.out_p = out_p;
+ req.out_sz = out_sz;
+
+ rc = _do_mbg_ioctl( dh, ioctl_code, &req, sizeof( req ), 0 );
+
+ #else
+
+ IOCTL_GENERIC_BUFFER *p_buff;
+ int buff_size = sizeof( p_buff->ctl )
+ + ( ( in_sz > out_sz ) ? in_sz : out_sz );
+
+ p_buff = (IOCTL_GENERIC_BUFFER *) malloc( buff_size );
+
+ if ( p_buff == NULL )
+ return _mbg_err_to_os( MBG_ERR_NO_MEM );
+
+ p_buff->ctl.info = info;
+ p_buff->ctl.data_size_in = in_sz;
+ p_buff->ctl.data_size_out = out_sz;
+
+ if ( in_p )
+ memcpy( p_buff->data, in_p, in_sz );
+
+ rc = _do_mbg_ioctl( dh, ioctl_code, p_buff,
+ sizeof( IOCTL_GENERIC_CTL ) + in_sz,
+ sizeof( IOCTL_GENERIC_CTL ) + out_sz );
+
+ if ( out_p && ( rc == MBG_SUCCESS ) )
+ memcpy( out_p, p_buff->data, out_sz );
+
+ free( p_buff );
+
+ #endif
+
+ return _mbgdevio_ret_val;
+
+ } // mbgdevio_do_gen_io
+
+
+
+ #define _do_mbgdevio_read( _dh, _cmd, _ioctl, _p, _sz ) \
+ _do_mbg_ioctl( _dh, _ioctl, _p, 0, _sz )
+
+ #define _do_mbgdevio_write( _dh, _cmd, _ioctl, _p, _sz ) \
+ _do_mbg_ioctl( _dh, _ioctl, _p, _sz, 0 )
+
+ #define _do_mbgdevio_read_gps _do_mbgdevio_read
+
+ #define _do_mbgdevio_write_gps _do_mbgdevio_write
+
+
+
+ #define _mbgdevio_read_var( _dh, _cmd, _ioctl, _p ) \
+ _do_mbgdevio_read( _dh, _cmd, _ioctl, _p, sizeof( *(_p) ) )
+
+ #define _mbgdevio_write_var( _dh, _cmd, _ioctl, _p ) \
+ _do_mbgdevio_write( _dh, _cmd, _ioctl, _p, sizeof( *(_p) ) )
+
+ #define _mbgdevio_write_cmd( _dh, _cmd, _ioctl ) \
+ _do_mbgdevio_write( _dh, _cmd, _ioctl, NULL, 0 )
+
+ #define _mbgdevio_read_gps_var _mbgdevio_read_var
+
+ #define _mbgdevio_write_gps_var _mbgdevio_write_var
+
+
+ #define _mbgdevio_gen_read( _dh, _cmd, _p, _sz ) \
+ mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_READ, NULL, 0, _p, _sz )
+
+ #define _mbgdevio_gen_write( _dh, _cmd, _p, _sz ) \
+ mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_WRITE, _p, _sz, NULL, 0 )
+
+ #define _mbgdevio_gen_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz ) \
+ mbgdevio_do_gen_io( _dh, _type, IOCTL_PCPS_GENERIC_IO, _in_p, _in_sz, _out_p, _out_sz )
+
+ #define _mbgdevio_gen_read_gps( _dh, _cmd, _p, _sz ) \
+ mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_READ_GPS, NULL, 0, _p, _sz )
+
+ #define _mbgdevio_gen_write_gps( _dh, _cmd, _p, _sz ) \
+ mbgdevio_do_gen_io( _dh, _cmd, IOCTL_PCPS_GENERIC_WRITE_GPS, _p, _sz, NULL, 0 )
+
+
+#else // accessing hardware device directly
+
+ #define _mbgdevio_chk_cond( _cond ) \
+ { \
+ if ( !(_cond) ) \
+ return _mbg_err_to_os( MBG_ERR_NOT_SUPP_BY_DEV ); \
+ }
+
+ #define _mbgdevio_read( _dh, _cmd, _ioctl, _p, _sz ) \
+ pcps_read_safe( _dh, _cmd, _p, _sz )
+
+ #define _mbgdevio_write( _dh, _cmd, _ioctl, _p, _sz ) \
+ pcps_write_safe( _dh, _cmd, _p, _sz )
+
+ #define _do_mbgdevio_read_gps( _dh, _cmd, _ioctl, _p, _sz ) \
+ pcps_read_gps_safe( _dh, _cmd, _p, _sz )
+
+ #define _mbgdevio_write_gps( _dh, _cmd, _ioctl, _p, _sz ) \
+ pcps_write_gps_safe( _dh, _cmd, _p, _sz )
+
+
+
+//##+++++++++++++++++++
+ #define _mbgdevio_read_var( _dh, _cmd, _ioctl, _p ) \
+ _pcps_read_var_safe( _dh, _cmd, *(_p) )
+
+ #define _mbgdevio_write_var( _dh, _cmd, _ioctl, _p ) \
+ _pcps_write_var_safe( _dh, _cmd, *(_p) )
+
+ #define _mbgdevio_write_cmd( _dh, _cmd, _ioctl ) \
+ _pcps_write_byte_safe( _dh, _cmd );
+
+ #define _mbgdevio_read_gps_var( _dh, _cmd, _ioctl, _p ) \
+ _pcps_read_gps_var_safe( _dh, _cmd, *(_p) )
+
+ #define _mbgdevio_write_gps_var( _dh, _cmd, _ioctl, _p ) \
+ _pcps_write_gps_var_safe( _dh, _cmd, *(_p) )
+
+
+ #define _mbgdevio_gen_read( _dh, _cmd, _p, _sz ) \
+ _mbgdevio_read( _dh, _cmd, -1, _p, _sz )
+
+ #define _mbgdevio_gen_write( _dh, _cmd, _p, _sz ) \
+ _mbgdevio_write( _dh, _cmd, -1, _p, _sz )
+
+ #define _mbgdevio_gen_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz ) \
+ pcps_generic_io( _dh, _type, _in_p, _in_sz, _out_p, _out_sz );
+
+ #define _mbgdevio_gen_read_gps( _dh, _cmd, _p, _sz ) \
+ _do_mbgdevio_read_gps( _dh, _cmd, -1, _p, _sz )
+
+ #define _mbgdevio_gen_write_gps( _dh, _cmd, _p, _sz ) \
+ _mbgdevio_write_gps( _dh, _cmd, -1, _p, _sz )
+
+#endif
+
+
+
+#define _mbg_generic_read_var( _dh, _cmd, _s ) \
+ mbg_generic_read( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbg_generic_write_var( _dh, _cmd, _s ) \
+ mbg_generic_write( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbg_generic_read_gps_var( _dh, _cmd, _s ) \
+ mbg_generic_read_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbg_generic_write_gps_var( _dh, _cmd, _s ) \
+ mbg_generic_write_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+
+
+#define _mbgdevio_gen_read_var( _dh, _cmd, _s ) \
+ _mbgdevio_gen_read( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbgdevio_gen_write_var( _dh, _cmd, _s ) \
+ _mbgdevio_gen_write( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbgdevio_gen_read_gps_var( _dh, _cmd, _s ) \
+ _mbgdevio_gen_read_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+#define _mbgdevio_gen_write_gps_var( _dh, _cmd, _s ) \
+ _mbgdevio_gen_write_gps( _dh, _cmd, &(_s), sizeof( (_s) ) )
+
+
+
+#if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_UNIX )
+
+static __mbg_inline
+void mbg_chk_tstamp64_leap_sec( uint64_t *tstamp64, PCPS_TIME_STATUS_X *status )
+{
+ if ( *status & ( PCPS_LS_ANN | PCPS_LS_ENB ) )
+ {
+ time_t t = (uint32_t) ( *tstamp64 >> 32 );
+ struct tm tm = *gmtime( &t );
+
+ // Handle leap second and status
+ if ( tm.tm_hour == 0 && tm.tm_min == 0 && tm.tm_sec == 0 )
+ {
+ if ( *status & PCPS_LS_ANN )
+ {
+ // Set leap second enabled flag on rollover to the leap second and clear announce flag
+ *status &= ~PCPS_LS_ANN;
+ *status |= PCPS_LS_ENB;
+
+ // Decrement interpolated second to avoid automated overflow during the leap second.
+ // Second 59 appears for the second time.
+ *tstamp64 -= PCPS_HRT_BIN_FRAC_SCALE;
+ }
+ else
+ if ( *status & PCPS_LS_ENB ) // Clear bits when leap second expires and 0:00:00 UTC is reached
+ *status &= ~( PCPS_LS_ANN | PCPS_LS_ENB );
+ }
+ }
+
+} // mbg_chk_tstamp64_leap_sec
+
+#endif // defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_UNIX )
+
+
static __mbg_inline
void mbg_init_pc_cycles_frequency( MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p )
@@ -2937,9 +3971,9 @@ void uint64_to_pcps_time_stamp( PCPS_TIME_STAMP *ts, uint64_t n )
#endif
-
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/mbgerror.h b/c/mbglib/include/mbgerror.h
index f51636c..4f1bb22 100644
--- a/c/mbglib/include/mbgerror.h
+++ b/c/mbglib/include/mbgerror.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgerror.h 1.4 2008/12/05 13:28:50Z martin REL_M $
+ * $Id: mbgerror.h 1.5 2011/03/31 10:56:17Z martin REL_M $
* $Name: $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
@@ -12,7 +12,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgerror.h $
- * Revision 1.4 2008/12/05 13:28:50Z martin
+ * Revision 1.5 2011/03/31 10:56:17Z martin
+ * Added MBG_ERR_COPY_TO_USER and MBG_ERR_COPY_FROM_USER.
+ * Revision 1.4 2008/12/05 13:28:50 martin
* Added new code MBG_ERR_IRQ_UNSAFE.
* Revision 1.3 2008/02/26 14:50:14Z daniel
* Added codes:
@@ -101,11 +103,15 @@
#define MBG_ERR_IRQ_UNSAFE -38 /**< The enabled IRQs are unsafe with this firmware/ASIC version */
-// Codes used with DOS TSRs only:
+// Legacy codes used with DOS TSRs only:
#define MBG_ERR_INV_INTNO -40 /**< Invalid interrupt number */
#define MBG_ERR_NO_DRIVER -41 /**< A driver could not be found */
#define MBG_ERR_DRV_VERSION -42 /**< The driver is too old */
+
+#define MBG_ERR_COPY_TO_USER -43 /**< kernel driver failed to copy data from kernel to user space */
+#define MBG_ERR_COPY_FROM_USER -44 /**< kernel driver failed to copy data from use to kernel space */
+
/** @} */ // endgroup
// Depending on the operating system, the codes above have to be converted before
diff --git a/c/mbglib/include/mbgextio.h b/c/mbglib/include/mbgextio.h
new file mode 100644
index 0000000..11d6ad4
--- /dev/null
+++ b/c/mbglib/include/mbgextio.h
@@ -0,0 +1,265 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgextio.h 1.8.2.14 2012/04/11 15:59:07Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for mbgextio.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgextio.h $
+ * Revision 1.8.2.14 2012/04/11 15:59:07Z martin
+ * Updated doxygen comments.
+ * Revision 1.8.2.13 2012/03/13 16:27:45 martin
+ * Revision 1.8.2.12 2012/03/13 10:48:00Z martin
+ * Updated function prototypes.
+ * Revision 1.8.2.11 2012/03/09 10:26:30 martin
+ * Updated function prototypes.
+ * Revision 1.8.2.10 2012/03/08 15:52:45Z martin
+ * Revision 1.8.2.9 2012/03/08 15:48:45 martin
+ * Revision 1.8.2.8 2012/03/08 15:35:16Z martin
+ * Support USB I/O.
+ * Updated function prototypes.
+ * Revision 1.8.2.7 2012/03/08 13:29:50 martin
+ * Updated function prototypes.
+ * Revision 1.8.2.6 2011/11/28 15:46:44 martin
+ * Updated function prototypes.
+ * Revision 1.8.2.5 2011/11/25 15:11:21 martin
+ * Account for renamed event log library symbols.
+ * Revision 1.8.2.4 2011/11/21 16:34:17 marvin
+ * new function: support event log
+ * Revision 1.8.2.3 2011/08/31 09:10:21 marvin
+ * Updated function prototypes.
+ * Revision 1.8.2.2 2011/08/23 10:17:08 martin
+ * Updated function prototypes.
+ * Revision 1.8.2.1 2011/08/19 13:05:34 martin
+ * Started to migrate to opaque stuctures.
+ * Revision 1.8 2011/04/08 11:26:09 martin
+ * New macros _ttm_time_set_unavail() and _ttm_time_is_avail().
+ * Revision 1.7 2009/10/02 14:21:08 martin
+ * Updated function prototypes.
+ * Revision 1.6 2009/10/01 11:13:42Z martin
+ * Updated function prototypes.
+ * Revision 1.5 2009/03/10 17:03:09Z martin
+ * Updated function prototypes.
+ * Revision 1.4 2008/09/04 14:13:19Z martin
+ * Added macro _mbgextio_xmt_msg().
+ * Updated function prototypes.
+ * Removed obsolete code.
+ * Revision 1.3 2007/02/27 10:30:06Z martin
+ * Added some global variables.
+ * Updated function prototypes.
+ * Revision 1.2 2006/12/21 10:56:35 martin
+ * Updated function prototypes.
+ * Revision 1.1 2006/08/24 12:40:37 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGEXTIO_H
+#define _MBGEXTIO_H
+
+
+/* Other headers to be included */
+
+#include <gpsserio.h>
+#include <time.h>
+
+#ifdef _MBGEXTIO
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+
+// The macros below can be used to set a TTM variable to a state
+// indicating "time not available", and to check this state.
+// This can be used for example to indicate if a capture event
+// could have been read from a device, or not.
+#define _ttm_time_set_unavail( _t ) do { (_t)->tm.sec = (uint8_t) 0xFF; } while ( 0 )
+#define _ttm_time_is_avail( _t ) ( (uint8_t) (_t)->tm.sec != (uint8_t) 0xFF )
+
+
+#if _USE_SERIAL_IO
+ #if !defined( DEFAULT_DEV_NAME )
+ #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_DOS )
+ #define DEFAULT_DEV_NAME "COM1"
+ #elif defined( MBG_TGT_LINUX )
+ #define DEFAULT_DEV_NAME "/dev/ttyS0"
+ #endif
+ #endif
+#endif // _USE_SERIAL_IO
+
+
+#if !_USE_USB_IO
+ // just to avoid build errors if USB not supported
+ struct usb_device
+ {
+ int dummy;
+ };
+#endif
+
+
+#if !defined MBGEXTIO_READ_BUFFER_SIZE
+ #if _USE_SOCKET_IO || _USE_USB_IO
+ #define MBGEXTIO_READ_BUFFER_SIZE 1000
+ #else
+ #define MBGEXTIO_READ_BUFFER_SIZE 10
+ #endif
+#endif
+
+
+_ext uint32_t mbg_baud_rates[N_MBG_BAUD_RATES]
+#ifdef _DO_INIT
+ = MBG_BAUD_RATES
+#endif
+;
+
+_ext const char *mbg_baud_rate_strs[N_MBG_BAUD_RATES]
+#ifdef _DO_INIT
+ = MBG_BAUD_STRS
+#endif
+;
+
+_ext const char *mbg_framing_strs[N_MBG_FRAMINGS]
+#ifdef _DO_INIT
+ = MBG_FRAMING_STRS
+#endif
+;
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ _NO_MBG_API_ATTR MBG_MSG_CTL * _MBG_API mbgextio_open_socket( const char *host, const char *passwd ) ;
+ _NO_MBG_API_ATTR MBG_MSG_CTL * _MBG_API mbgextio_open_serial( const char *dev, uint32_t baud_rate, const char *framing ) ;
+ _NO_MBG_API_ATTR MBG_MSG_CTL * _MBG_API mbgextio_open_usb( struct usb_device *usbdev ) ;
+ _NO_MBG_API_ATTR void _MBG_API mbgextio_close_connection( MBG_MSG_CTL **ppmctl ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_force_connection( const char *dev ) ;
+ _NO_MBG_API_ATTR MBG_MSG_BUFF * _MBG_API mbgextio_get_rcv_buffer_addr( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR size_t _MBG_API mbgextio_get_rcv_buffer_size( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR MBG_MSG_BUFF * _MBG_API mbgextio_get_xmt_buffer_addr( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR size_t _MBG_API mbgextio_get_xmt_buffer_size( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR void _MBG_API mbgextio_set_char_rcv_timeout( MBG_MSG_CTL *pmctl, ulong new_timeout ) ;
+ _NO_MBG_API_ATTR ulong _MBG_API mbgextio_get_char_rcv_timeout( const MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR void _MBG_API mbgextio_set_msg_rcv_timeout( MBG_MSG_CTL *pmctl, ulong new_timeout ) ;
+ _NO_MBG_API_ATTR ulong _MBG_API mbgextio_get_msg_rcv_timeout( const MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_xmt_msg( MBG_MSG_CTL *pmctl, GPS_CMD cmd, const void *p, size_t n_bytes ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_rcv_msg( MBG_MSG_CTL *pmctl, GPS_CMD cmd ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_xmt_cmd( MBG_MSG_CTL *pmctl, GPS_CMD cmd ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_xmt_cmd_us( MBG_MSG_CTL *pmctl, GPS_CMD cmd, uint16_t us ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_req_data( MBG_MSG_CTL *pmctl, GPS_CMD cmd ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_req_data_idx( MBG_MSG_CTL *pmctl, GPS_CMD cmd, uint16_t idx ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_receiver_info( MBG_MSG_CTL *pmctl, RECEIVER_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_sw_rev( MBG_MSG_CTL *pmctl, SW_REV *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_bvar_stat( MBG_MSG_CTL *pmctl, BVAR_STAT *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_time( MBG_MSG_CTL *pmctl, TTM *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_time( MBG_MSG_CTL *pmctl, const TTM *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_pos_lla( MBG_MSG_CTL *pmctl, LLA lla ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_pos_lla( MBG_MSG_CTL *pmctl, const LLA lla ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_tzdl( MBG_MSG_CTL *pmctl, TZDL *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_tzdl( MBG_MSG_CTL *pmctl, const TZDL *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_port_parm( MBG_MSG_CTL *pmctl, PORT_PARM *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_synth( MBG_MSG_CTL *pmctl, SYNTH *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_synth( MBG_MSG_CTL *pmctl, const SYNTH *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_ant_info( MBG_MSG_CTL *pmctl, ANT_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_ucap( MBG_MSG_CTL *pmctl, TTM *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_enable_flags( MBG_MSG_CTL *pmctl, ENABLE_FLAGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_enable_flags( MBG_MSG_CTL *pmctl, const ENABLE_FLAGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_stat_info( MBG_MSG_CTL *pmctl, STAT_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_ant_cable_len( MBG_MSG_CTL *pmctl, ANT_CABLE_LEN *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_ant_cable_len( MBG_MSG_CTL *pmctl, const ANT_CABLE_LEN *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_irig_tx_info( MBG_MSG_CTL *pmctl, IRIG_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_irig_tx_settings( MBG_MSG_CTL *pmctl, const IRIG_SETTINGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_irig_rx_info( MBG_MSG_CTL *pmctl, IRIG_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_irig_rx_settings( MBG_MSG_CTL *pmctl, const IRIG_SETTINGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_ref_offs( MBG_MSG_CTL *pmctl, MBG_REF_OFFS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_ref_offs( MBG_MSG_CTL *pmctl, const MBG_REF_OFFS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_debug_status( MBG_MSG_CTL *pmctl, MBG_DEBUG_STATUS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_opt_info( MBG_MSG_CTL *pmctl, MBG_OPT_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_opt_settings( MBG_MSG_CTL *pmctl, const MBG_OPT_SETTINGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_str_type_info_idx( MBG_MSG_CTL *pmctl, STR_TYPE_INFO_IDX *p, uint16_t idx ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_all_str_type_info( MBG_MSG_CTL *pmctl, STR_TYPE_INFO_IDX stii[], const RECEIVER_INFO *p_ri ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_port_info_idx( MBG_MSG_CTL *pmctl, PORT_INFO_IDX *p, uint16_t idx ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_all_port_info( MBG_MSG_CTL *pmctl, PORT_INFO_IDX pii[], const RECEIVER_INFO *p_ri ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_port_settings_idx( MBG_MSG_CTL *pmctl, const PORT_SETTINGS *p, uint16_t idx ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_pout_info_idx( MBG_MSG_CTL *pmctl, POUT_INFO_IDX *p, uint16_t idx ) ;
+ /**
+ Read all programmable output settings from a non-bus level device.
+
+ The function mbgextio_get_receiver_info()
+ must have been called before, and the returned ::RECEIVER_INFO
+ structures must be passed to this function.
+
+ The complementary function mbgextio_save_pout_settings() should
+ be used to write the modified configuration back to the device.
+
+ @param pmctl Valid handle to a Meinberg device.
+ @param *pii Pointer to a ::POUT_INFO_IDX structure to be filled up.
+ @param *p_ri Pointer to a ::RECEIVER_INFO structure.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbgextio_set_pout_settings_idx()
+ @see mbgextio_get_receiver_info()
+*/
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_all_pout_info( MBG_MSG_CTL *pmctl, POUT_INFO_IDX *pii, const RECEIVER_INFO *p_ri ) ;
+
+ /**
+ Write the configuration settings for a single programmable output via serial connection to the board.
+
+ Modifications to the programmable output configuration should be made only
+ after mbgextio_get_all_pout_info() had been called to read all programmable
+ output settings and supported configuration parameters.
+ This function has finally to be called once for every programmable output
+ the configuration of which has been modified.
+
+ @param pmctl Valid handle to a Meinberg device via serial connection
+ @param p Pointer to a ::POUT_INFO_IDX structure
+ @param idx Index of the programmable output to be configured
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbgextio_get_all_pout_info()
+ @see mbgextio_get_receiver_info()
+*/
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_pout_settings_idx( MBG_MSG_CTL *pmctl, const POUT_SETTINGS *p, uint16_t idx ) ;
+
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_clr_ucap_buff( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_time_scale_info( MBG_MSG_CTL *pmctl, MBG_TIME_SCALE_INFO *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_set_time_scale_settings( MBG_MSG_CTL *pmctl, const MBG_TIME_SCALE_SETTINGS *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_clr_evt_log( MBG_MSG_CTL *pmctl ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_num_evt_log_entries( MBG_MSG_CTL *pmctl, MBG_NUM_EVT_LOG_ENTRIES *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_first_evt_log_entry( MBG_MSG_CTL *pmctl, MBG_EVT_LOG_ENTRY *p ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgextio_get_next_evt_log_entry( MBG_MSG_CTL *pmctl, MBG_EVT_LOG_ENTRY *p ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+#define _mbgextio_xmt_msg( _pmctl, _cmd, _s ) \
+ mbgextio_xmt_msg( _pmctl, _cmd, _s, sizeof( *(_s) ) )
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGEXTIO_H */
diff --git a/c/mbglib/include/mbggeo.h b/c/mbglib/include/mbggeo.h
index ca6414d..c3bdb40 100644
--- a/c/mbglib/include/mbggeo.h
+++ b/c/mbglib/include/mbggeo.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbggeo.h 1.10 2008/09/03 14:54:28Z martin REL_M $
+ * $Id: mbggeo.h 1.11 2011/06/22 10:18:10Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -22,7 +22,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbggeo.h $
- * Revision 1.10 2008/09/03 14:54:28Z martin
+ * Revision 1.11 2011/06/22 10:18:10Z martin
+ * Cleaned up handling of pragma pack().
+ * Revision 1.10 2008/09/03 14:54:28 martin
* Added macros to swap endianess of structures.
* Revision 1.9 2008/01/17 09:31:33 daniel
* Made comments compatible for doxygen parser.
@@ -62,8 +64,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -284,8 +287,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/mbgioctl.h b/c/mbglib/include/mbgioctl.h
new file mode 100644
index 0000000..d7b8fd6
--- /dev/null
+++ b/c/mbglib/include/mbgioctl.h
@@ -0,0 +1,954 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgioctl.h 1.24.1.15 2012/07/20 11:44:59Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions used with device driver IOCTL.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgioctl.h $
+ * Revision 1.24.1.15 2012/07/20 11:44:59Z martin
+ * Revision 1.24.1.14 2012/01/25 09:46:31 martin
+ * Revision 1.24.1.13 2012/01/23 08:43:53 daniel
+ * test version using alternative way of using generic IO.
+ * Revision 1.24.1.12 2011/11/25 15:03:23Z martin
+ * Support on-board event logs.
+ * Revision 1.24.1.11 2011/11/22 15:47:27 martin
+ * Support debug status.
+ * Revision 1.24.1.10 2011/07/20 15:49:00 martin
+ * Conditionally use older IOCTL request buffer structures.
+ * Revision 1.24.1.9 2011/07/19 12:31:59 martin
+ * Relaxed required priority level for generic read functions.
+ * Revision 1.24.1.8 2011/07/18 10:18:49 martin
+ * Revision 1.24.1.7 2011/07/15 14:50:11 martin
+ * Revision 1.24.1.6 2011/07/14 14:54:01 martin
+ * Modified generic IOCTL handling such that for calls requiring variable sizes
+ * a fixed request block containing input and output buffer pointers and sizes is
+ * passed down to the kernel driver. This simplifies implementation under *BSD
+ * and also works for other target systems.
+ * Revision 1.24.1.5 2011/07/06 11:19:28 martin
+ * Support reading CORR_INFO, and reading/writing TR_DISTANCE.
+ * Revision 1.24.1.4 2011/06/29 10:52:00 martin
+ * New code IOCTL_DEV_HAS_PZF.
+ * Revision 1.24.1.3 2011/06/21 15:03:29 martin
+ * Support PTP unicast configuration.
+ * Changed the names of a few IOCTL codes to follow general naming conventions.
+ * Added definitions to support privilege level requirements for IOCTLs.
+ * Use native alignment to avoid problems on Sparc and IA64.
+ * Added definitions to set up a table of all known
+ * IOCTL codes and names.
+ * Use MBG_TGT_KERNEL instead of _KDD_.
+ * Fixed a typo.
+ * Revision 1.24.1.2 2011/03/22 11:19:46 martin
+ * Use IOTYPE 'Z' under *BSD since this means passthrough on NetBSD.
+ * Revision 1.24.1.1 2011/02/15 11:21:21 daniel
+ * Added ioctls to support PTP unicast configuration
+ * Revision 1.24 2009/12/15 15:34:59Z daniel
+ * Support reading the raw IRIG data bits for firmware versions
+ * which support this feature.
+ * Revision 1.23 2009/09/29 15:08:41Z martin
+ * Support retrieving time discipline info.
+ * Revision 1.22 2009/08/17 13:48:17 martin
+ * Moved specific definition of symbol _HAVE_IOCTL_WITH_SIZE from
+ * mbgdevio.c here and renamed it to _MBG_SUPP_VAR_ACC_SIZE.
+ * Revision 1.21 2009/06/19 12:18:53 martin
+ * Added PCPS_GIVE_IRIG_TIME command and associated definitions.
+ * Fixed a declaration which might have led to syntax errors.
+ * Revision 1.20 2009/06/09 10:02:36Z daniel
+ * Support PTP configuration and state.
+ * Support simple LAN interface configuration.
+ * Revision 1.19 2009/03/19 15:17:59 martin
+ * Support reading MM timestamps without cycles.
+ * Support UTC parms and configurable time scales.
+ * For consistent naming renamed IOCTL_GET_FAST_HR_TIMESTAMP
+ * to IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES.
+ * Added IOCTL_DEV_HAS_IRIG_CTRL_BITS and IOCTL_GET_IRIG_CTRL_BITS.
+ * Revision 1.18 2008/12/11 10:32:56Z martin
+ * Added _cmd_from_ioctl_code() macro for Linux.
+ * Added IOCTL codes for .._has_asic_version() and .._has_asic_features().
+ * Added IOCTL codes for ..._is_msf(), .._is_lwr(), .._is_wwvb().
+ * Added IOCTL codes IOCTL_GET_IRQ_STAT_INFO, IOCTL_GET_CYCLES_FREQUENCY,
+ * IOCTL_HAS_FAST_HR_TIMESTAMP, and IOCTL_GET_FAST_HR_TIMESTAMP.
+ * Revision 1.17 2008/01/17 09:35:15 daniel
+ * Added ioctl calls IOCTL_GET_MAPPED_MEM_ADDR and
+ * IOCTL_UNMAP_MAPPED_MEM.
+ * Cleanup for PCI ASIC version and features.
+ * Revision 1.16 2007/09/25 10:37:04Z martin
+ * Added macro _cmd_from_ioctl_code() for Windows.
+ * Revision 1.15 2007/05/21 15:00:01Z martin
+ * Unified naming convention for symbols related to ref_offs.
+ * Revision 1.14 2007/03/02 10:27:03 martin
+ * Preliminary support for *BSD.
+ * Preliminary _cmd_from_ioctl().
+ * Revision 1.13 2006/03/10 10:36:54 martin
+ * Added support for programmable pulse outputs.
+ * Revision 1.12 2005/06/02 10:22:05Z martin
+ * Added IOCTL code IOCTL_GET_SYNTH_STATE.
+ * Added IOCTL codes IOCTL_DEV_HAS_GENERIC_IO,
+ * IOCTL_PCPS_GENERIC_IO, and IOCTL_GET_SYNTH_STATE.
+ * Revision 1.11 2005/01/14 10:21:11Z martin
+ * Added IOCTLs which query device features.
+ * Revision 1.10 2004/12/09 11:03:36Z martin
+ * Support configuration of on-board frequency synthesizer.
+ * Revision 1.9 2004/11/09 12:49:41Z martin
+ * Modifications were required in order to be able to configure IRIG
+ * settings of cards which provide both IRIG input and output.
+ * The existing codes have been renamed with .._RX.. and are used to
+ * configure the IRIG receiver (input). New codes have been defined
+ * used to configure the IRIG transmitter.
+ * Renamed IOCTL_GET_GPS_STAT to IOCTL_GET_GPS_BVAR_STAT.
+ * Use more specific data types than generic types.
+ * Modified IOCTL codes used for hardware debugging.
+ * Revision 1.8 2004/09/06 15:46:04Z martin
+ * Changed definition of IOCTL codes to support syntax used
+ * with Linux kernel 2.6.x.
+ * Account for renamed symbols.
+ * Revision 1.7 2004/04/07 10:08:11 martin
+ * Added IOCTL codes used to trigger hardware debug events.
+ * Revision 1.6 2003/12/22 15:37:18Z martin
+ * Added codes to read ASIC version, and read times
+ * with associated cycle counter values.
+ * Revision 1.5 2003/06/19 09:02:30Z martin
+ * New codes IOCTL_GET_PCPS_UCAP_ENTRIES and IOCTL_GET_PCPS_UCAP_EVENT.
+ * Renamed IOCTL_PCPS_CLR_CAP_BUFF to IOCTL_PCPS_CLR_UCAP_BUFF.
+ * Cleaned up IOCTL code names related to PCPS_TZDL.
+ * Reordered upper IOCTL code numbers again.
+ * Revision 1.4 2003/04/09 13:50:39Z martin
+ * Re-organized IOCTL codes.
+ * Supports Win32.
+ * Added missing pragma pack().
+ * Revision 1.3 2003/02/14 13:20:08Z martin
+ * Include mbggeo.h instead of mygeo.h.
+ * Revision 1.2 2001/11/30 09:52:48 martin
+ * Added support for event_time which, however, requires
+ * a custom GPS firmware.
+ * Revision 1.1 2001/03/05 16:34:22 MARTIN
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _MBGIOCTL_H
+#define _MBGIOCTL_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <mbggeo.h>
+#include <pcpsdev.h>
+#include <pci_asic.h>
+
+
+#define USE_DEBUG_PORT defined( MBG_ARCH_X86 )
+
+
+#if defined( MBG_TGT_LINUX )
+
+ #include <linux/ioctl.h>
+
+ // a magic number used to generate IOCTL cmd codes
+ #define IOTYPE 'M'
+
+ #define _MBG_IO _IO
+ #define _MBG_IOR _IOR
+ #define _MBG_IOW _IOW
+
+ #define _cmd_from_ioctl_code( _ioc ) \
+ _IOC_NR( _ioc )
+
+#elif defined( MBG_TGT_BSD )
+
+ #include <sys/ioccom.h>
+
+ // Under NetBSD 'Z' marks passthrough IOCTLs, under FreeBSD the code
+ // does not seem to matter, so we use 'Z' anyway.
+ #define IOTYPE 'Z'
+
+ #define _MBG_IO _IO
+ #define _MBG_IOR _IOR
+ #define _MBG_IOW _IOW
+
+#elif defined( MBG_TGT_WIN32 )
+
+ #if !defined( _MBG_SUPP_VAR_ACC_SIZE )
+ // Windows supports IOCTL commands where the sizes of
+ // input and output buffer can be specified dynamically.
+ #define _MBG_SUPP_VAR_ACC_SIZE 1
+ #endif
+
+ #if !defined( MBG_TGT_KERNEL )
+ #include <windows.h>
+ #include <winioctl.h>
+ #endif
+
+ #if !defined( MBG_TGT_WIN32_NON_PNP )
+ #ifdef _MBGIOCTL
+ #include <initguid.h> // instance the GUID
+ #else
+ #include <guiddef.h> // just define the GUID
+ #endif
+ #endif
+
+ #ifdef DEFINE_GUID // don't break compiles of drivers that
+ // include this header but don't want the
+ // GUIDs
+
+ // ClassGuid = { 78A1C341-4539-11d3-B88D-00C04FAD5171 }
+ DEFINE_GUID( GUID_MEINBERG_DEVICE,
+ 0x78A1C341L, 0x4539, 0x11D3,
+ 0xB8, 0x8D, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71 );
+ #endif
+
+ // Device type in the "User Defined" range."
+ #define PCPS_TYPE 40000
+
+ // IOCTL function codes from 0x800 to 0xFFF are for customer use.
+ #define _MBG_IOCTL_BIAS 0x930
+
+ #define _MBG_IO( _t, _n ) \
+ CTL_CODE( PCPS_TYPE, _MBG_IOCTL_BIAS + _n, METHOD_BUFFERED, FILE_READ_ACCESS )
+
+ #define _MBG_IOR( _t, _n, _sz ) \
+ _MBG_IO( _t, _n )
+
+ #define _MBG_IOW _MBG_IOR
+
+ #define _cmd_from_ioctl_code( _ioc ) \
+ ( ( ( (_ioc) >> 2 ) & 0x0FFF ) - _MBG_IOCTL_BIAS )
+
+#endif
+
+
+#if !defined( _MBG_SUPP_VAR_ACC_SIZE )
+ // Many operating systems don't support specifying the sizes of IOCTL
+ // input and output buffers dynamically, so we disable this by default.
+ #define _MBG_SUPP_VAR_ACC_SIZE 0
+#endif
+
+
+#ifdef _MBGIOCTL
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+// We must use native alignment here!
+
+
+// The structure below is used by the IOCTL_PCPS_GENERIC_... calls.
+
+#if defined( MBG_TGT_LINUX )
+ #if defined( MBG_ARCH_ARM ) || defined( MBG_ARCH_SPARC )
+ #define USE_IOCTL_GENERIC_REQ 0
+ #endif
+#endif
+
+#if defined( MBG_TGT_WIN32 )
+ // required for 32bit/64 bit compatibility
+ #define USE_IOCTL_GENERIC_REQ 0
+#endif
+
+#if !defined( USE_IOCTL_GENERIC_REQ )
+ #define USE_IOCTL_GENERIC_REQ 1
+#endif
+
+
+#if USE_IOCTL_GENERIC_REQ
+
+// This does not yet work properly under Linux/Sparc where the kernel may be 64 bit
+// while user space is 32 bit, which leads to different sizes for pointers and size_t.
+
+typedef struct
+{
+ ulong info;
+ const void *in_p;
+ size_t in_sz;
+ void *out_p;
+ size_t out_sz;
+
+} IOCTL_GENERIC_REQ;
+
+#define _MBG_IOG( _t, _n, _s ) _MBG_IOW( _t, _n, _s )
+
+#else
+
+// The structure below is used by the IOCTL_PCPS_GENERIC_... calls.
+typedef struct
+{
+ uint32_t info;
+ uint32_t data_size_in;
+ uint32_t data_size_out;
+} IOCTL_GENERIC_CTL;
+
+typedef struct
+{
+ IOCTL_GENERIC_CTL ctl;
+ uint8_t data[1];
+} IOCTL_GENERIC_BUFFER;
+
+#define _MBG_IOG( _t, _n, _s ) _MBG_IO( _t, _n )
+
+#endif
+
+
+
+// read general driver info, device info, and status port
+#define IOCTL_GET_PCPS_DRVR_INFO _MBG_IOR( IOTYPE, 0x00, PCPS_DRVR_INFO )
+#define IOCTL_GET_PCPS_DEV _MBG_IOR( IOTYPE, 0x01, PCPS_DEV )
+#define IOCTL_GET_PCPS_STATUS_PORT _MBG_IOR( IOTYPE, 0x02, PCPS_STATUS_PORT )
+
+// Generic read/write operations. We define _MBG_IOW codes since these calls
+// eventually pass a generic request structure IOCTL_GENERIC_REQ to the driver.
+#define IOCTL_PCPS_GENERIC_READ _MBG_IOG( IOTYPE, 0x03, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_WRITE _MBG_IOG( IOTYPE, 0x04, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_READ_GPS _MBG_IOG( IOTYPE, 0x05, IOCTL_GENERIC_REQ )
+#define IOCTL_PCPS_GENERIC_WRITE_GPS _MBG_IOG( IOTYPE, 0x06, IOCTL_GENERIC_REQ )
+
+// normal direct read/write operations
+#define IOCTL_GET_PCPS_TIME _MBG_IOR( IOTYPE, 0x10, PCPS_TIME )
+#define IOCTL_SET_PCPS_TIME _MBG_IOW( IOTYPE, 0x11, PCPS_STIME )
+
+#define IOCTL_GET_PCPS_SYNC_TIME _MBG_IOR( IOTYPE, 0x12, PCPS_TIME )
+
+#define IOCTL_GET_PCPS_TIME_SEC_CHANGE _MBG_IOR( IOTYPE, 0x13, PCPS_TIME )
+
+#define IOCTL_GET_PCPS_HR_TIME _MBG_IOR( IOTYPE, 0x14, PCPS_HR_TIME )
+
+// the next one is supported with custom GPS firmware only:
+#define IOCTL_SET_PCPS_EVENT_TIME _MBG_IOW( IOTYPE, 0x15, PCPS_TIME_STAMP )
+
+#define IOCTL_GET_PCPS_SERIAL _MBG_IOR( IOTYPE, 0x16, PCPS_SERIAL )
+#define IOCTL_SET_PCPS_SERIAL _MBG_IOW( IOTYPE, 0x17, PCPS_SERIAL )
+
+#define IOCTL_GET_PCPS_TZCODE _MBG_IOR( IOTYPE, 0x18, PCPS_TZCODE )
+#define IOCTL_SET_PCPS_TZCODE _MBG_IOW( IOTYPE, 0x19, PCPS_TZCODE )
+
+#define IOCTL_GET_PCPS_TZDL _MBG_IOR( IOTYPE, 0x1A, PCPS_TZDL )
+#define IOCTL_SET_PCPS_TZDL _MBG_IOW( IOTYPE, 0x1B, PCPS_TZDL )
+
+#define IOCTL_GET_REF_OFFS _MBG_IOR( IOTYPE, 0x1C, MBG_REF_OFFS )
+#define IOCTL_SET_REF_OFFS _MBG_IOW( IOTYPE, 0x1D, MBG_REF_OFFS )
+
+#define IOCTL_GET_MBG_OPT_INFO _MBG_IOR( IOTYPE, 0x1E, MBG_OPT_INFO )
+#define IOCTL_SET_MBG_OPT_SETTINGS _MBG_IOW( IOTYPE, 0x1F, MBG_OPT_SETTINGS )
+
+#define IOCTL_GET_PCPS_IRIG_RX_INFO _MBG_IOR( IOTYPE, 0x20, IRIG_INFO )
+#define IOCTL_SET_PCPS_IRIG_RX_SETTINGS _MBG_IOW( IOTYPE, 0x21, IRIG_SETTINGS )
+
+#define IOCTL_PCPS_CLR_UCAP_BUFF _MBG_IO( IOTYPE, 0x22 )
+#define IOCTL_GET_PCPS_UCAP_ENTRIES _MBG_IOR( IOTYPE, 0x23, PCPS_UCAP_ENTRIES )
+#define IOCTL_GET_PCPS_UCAP_EVENT _MBG_IOR( IOTYPE, 0x24, PCPS_HR_TIME )
+
+
+#define IOCTL_GET_GPS_TZDL _MBG_IOR( IOTYPE, 0x25, TZDL )
+#define IOCTL_SET_GPS_TZDL _MBG_IOW( IOTYPE, 0x26, TZDL )
+
+#define IOCTL_GET_GPS_SW_REV _MBG_IOR( IOTYPE, 0x27, SW_REV )
+
+#define IOCTL_GET_GPS_BVAR_STAT _MBG_IOR( IOTYPE, 0x28, BVAR_STAT )
+
+#define IOCTL_GET_GPS_TIME _MBG_IOR( IOTYPE, 0x29, TTM )
+#define IOCTL_SET_GPS_TIME _MBG_IOW( IOTYPE, 0x2A, TTM )
+
+#define IOCTL_GET_GPS_PORT_PARM _MBG_IOR( IOTYPE, 0x2B, PORT_PARM )
+#define IOCTL_SET_GPS_PORT_PARM _MBG_IOW( IOTYPE, 0x2C, PORT_PARM )
+
+#define IOCTL_GET_GPS_ANT_INFO _MBG_IOR( IOTYPE, 0x2D, ANT_INFO )
+
+#define IOCTL_GET_GPS_UCAP _MBG_IOR( IOTYPE, 0x2E, TTM )
+
+#define IOCTL_GET_GPS_ENABLE_FLAGS _MBG_IOR( IOTYPE, 0x2F, ENABLE_FLAGS )
+#define IOCTL_SET_GPS_ENABLE_FLAGS _MBG_IOW( IOTYPE, 0x30, ENABLE_FLAGS )
+
+#define IOCTL_GET_GPS_STAT_INFO _MBG_IOR( IOTYPE, 0x31, STAT_INFO )
+
+#define IOCTL_SET_GPS_CMD _MBG_IOW( IOTYPE, 0x32, GPS_CMD )
+
+#define IOCTL_GET_GPS_IDENT _MBG_IOR( IOTYPE, 0x33, IDENT )
+
+#define IOCTL_GET_GPS_POS _MBG_IOR( IOTYPE, 0x34, POS )
+#define IOCTL_SET_GPS_POS_XYZ _MBG_IOW( IOTYPE, 0x35, XYZ )
+#define IOCTL_SET_GPS_POS_LLA _MBG_IOW( IOTYPE, 0x36, LLA )
+
+#define IOCTL_GET_GPS_ANT_CABLE_LEN _MBG_IOR( IOTYPE, 0x37, ANT_CABLE_LEN )
+#define IOCTL_SET_GPS_ANT_CABLE_LEN _MBG_IOW( IOTYPE, 0x38, ANT_CABLE_LEN )
+
+#define IOCTL_GET_GPS_RECEIVER_INFO _MBG_IOR( IOTYPE, 0x39, RECEIVER_INFO )
+#define IOCTL_GET_GPS_ALL_STR_TYPE_INFO _MBG_IOG( IOTYPE, 0x3A, IOCTL_GENERIC_REQ ) // variable size
+#define IOCTL_GET_GPS_ALL_PORT_INFO _MBG_IOG( IOTYPE, 0x3B, IOCTL_GENERIC_REQ ) // variable size
+
+#define IOCTL_SET_GPS_PORT_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x3C, PORT_SETTINGS_IDX )
+
+#define IOCTL_GET_PCI_ASIC_VERSION _MBG_IOR( IOTYPE, 0x3D, PCI_ASIC_VERSION )
+
+#define IOCTL_GET_PCPS_TIME_CYCLES _MBG_IOR( IOTYPE, 0x3E, PCPS_TIME_CYCLES )
+#define IOCTL_GET_PCPS_HR_TIME_CYCLES _MBG_IOR( IOTYPE, 0x3F, PCPS_HR_TIME_CYCLES )
+
+#define IOCTL_GET_PCPS_IRIG_TX_INFO _MBG_IOR( IOTYPE, 0x40, IRIG_INFO )
+#define IOCTL_SET_PCPS_IRIG_TX_SETTINGS _MBG_IOW( IOTYPE, 0x41, IRIG_SETTINGS )
+
+#define IOCTL_GET_SYNTH _MBG_IOR( IOTYPE, 0x42, SYNTH )
+#define IOCTL_SET_SYNTH _MBG_IOW( IOTYPE, 0x43, SYNTH )
+
+
+#define IOCTL_DEV_IS_GPS _MBG_IOR( IOTYPE, 0x44, int )
+#define IOCTL_DEV_IS_DCF _MBG_IOR( IOTYPE, 0x45, int )
+#define IOCTL_DEV_IS_IRIG_RX _MBG_IOR( IOTYPE, 0x46, int )
+
+#define IOCTL_DEV_HAS_HR_TIME _MBG_IOR( IOTYPE, 0x47, int )
+#define IOCTL_DEV_HAS_CAB_LEN _MBG_IOR( IOTYPE, 0x48, int )
+#define IOCTL_DEV_HAS_TZDL _MBG_IOR( IOTYPE, 0x49, int )
+#define IOCTL_DEV_HAS_PCPS_TZDL _MBG_IOR( IOTYPE, 0x4A, int )
+#define IOCTL_DEV_HAS_TZCODE _MBG_IOR( IOTYPE, 0x4B, int )
+#define IOCTL_DEV_HAS_TZ _MBG_IOR( IOTYPE, 0x4C, int )
+#define IOCTL_DEV_HAS_EVENT_TIME _MBG_IOR( IOTYPE, 0x4D, int )
+#define IOCTL_DEV_HAS_RECEIVER_INFO _MBG_IOR( IOTYPE, 0x4E, int )
+#define IOCTL_DEV_CAN_CLR_UCAP_BUFF _MBG_IOR( IOTYPE, 0x4F, int )
+#define IOCTL_DEV_HAS_UCAP _MBG_IOR( IOTYPE, 0x50, int )
+#define IOCTL_DEV_HAS_IRIG_TX _MBG_IOR( IOTYPE, 0x51, int )
+#define IOCTL_DEV_HAS_SERIAL_HS _MBG_IOR( IOTYPE, 0x52, int )
+#define IOCTL_DEV_HAS_SIGNAL _MBG_IOR( IOTYPE, 0x53, int )
+#define IOCTL_DEV_HAS_MOD _MBG_IOR( IOTYPE, 0x54, int )
+#define IOCTL_DEV_HAS_IRIG _MBG_IOR( IOTYPE, 0x55, int )
+#define IOCTL_DEV_HAS_REF_OFFS _MBG_IOR( IOTYPE, 0x56, int )
+#define IOCTL_DEV_HAS_OPT_FLAGS _MBG_IOR( IOTYPE, 0x57, int )
+#define IOCTL_DEV_HAS_GPS_DATA _MBG_IOR( IOTYPE, 0x58, int )
+#define IOCTL_DEV_HAS_SYNTH _MBG_IOR( IOTYPE, 0x59, int )
+#define IOCTL_DEV_HAS_GENERIC_IO _MBG_IOR( IOTYPE, 0x5A, int )
+
+#define IOCTL_PCPS_GENERIC_IO _MBG_IOG( IOTYPE, 0x5B, IOCTL_GENERIC_REQ )
+
+#define IOCTL_GET_SYNTH_STATE _MBG_IOR( IOTYPE, 0x5C, SYNTH_STATE )
+
+#define IOCTL_GET_GPS_ALL_POUT_INFO _MBG_IOG( IOTYPE, 0x5D, IOCTL_GENERIC_REQ ) // variable size
+#define IOCTL_SET_GPS_POUT_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x5E, POUT_SETTINGS_IDX )
+
+#define IOCTL_GET_MAPPED_MEM_ADDR _MBG_IOR( IOTYPE, 0x5F, PCPS_MAPPED_MEM )
+#define IOCTL_UNMAP_MAPPED_MEM _MBG_IOR( IOTYPE, 0x60, PCPS_MAPPED_MEM )
+
+#define IOCTL_GET_PCI_ASIC_FEATURES _MBG_IOR( IOTYPE, 0x61, PCI_ASIC_FEATURES )
+
+#define IOCTL_DEV_HAS_PCI_ASIC_FEATURES _MBG_IOR( IOTYPE, 0x62, int )
+#define IOCTL_DEV_HAS_PCI_ASIC_VERSION _MBG_IOR( IOTYPE, 0x63, int )
+
+#define IOCTL_DEV_IS_MSF _MBG_IOR( IOTYPE, 0x64, int )
+#define IOCTL_DEV_IS_LWR _MBG_IOR( IOTYPE, 0x65, int )
+#define IOCTL_DEV_IS_WWVB _MBG_IOR( IOTYPE, 0x66, int )
+
+#define IOCTL_GET_IRQ_STAT_INFO _MBG_IOR( IOTYPE, 0x67, PCPS_IRQ_STAT_INFO )
+#define IOCTL_GET_CYCLES_FREQUENCY _MBG_IOR( IOTYPE, 0x68, MBG_PC_CYCLES_FREQUENCY )
+
+#define IOCTL_DEV_HAS_FAST_HR_TIMESTAMP _MBG_IOR( IOTYPE, 0x69, int )
+#define IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES _MBG_IOR( IOTYPE, 0x6A, PCPS_TIME_STAMP_CYCLES )
+#define IOCTL_GET_FAST_HR_TIMESTAMP _MBG_IOR( IOTYPE, 0x6B, PCPS_TIME_STAMP )
+
+#define IOCTL_DEV_HAS_GPS_TIME_SCALE _MBG_IOR( IOTYPE, 0x6C, int )
+#define IOCTL_GET_GPS_TIME_SCALE_INFO _MBG_IOR( IOTYPE, 0x6D, MBG_TIME_SCALE_INFO )
+#define IOCTL_SET_GPS_TIME_SCALE_SETTINGS _MBG_IOW( IOTYPE, 0x6E, MBG_TIME_SCALE_SETTINGS )
+
+#define IOCTL_DEV_HAS_GPS_UTC_PARM _MBG_IOR( IOTYPE, 0x6F, int )
+#define IOCTL_GET_GPS_UTC_PARM _MBG_IOR( IOTYPE, 0x70, UTC )
+#define IOCTL_SET_GPS_UTC_PARM _MBG_IOW( IOTYPE, 0x71, UTC )
+
+#define IOCTL_DEV_HAS_IRIG_CTRL_BITS _MBG_IOR( IOTYPE, 0x72, int )
+#define IOCTL_GET_IRIG_CTRL_BITS _MBG_IOR( IOTYPE, 0x73, MBG_IRIG_CTRL_BITS )
+
+#define IOCTL_DEV_HAS_LAN_INTF _MBG_IOR( IOTYPE, 0x74, int )
+#define IOCTL_GET_LAN_IF_INFO _MBG_IOR( IOTYPE, 0x75, LAN_IF_INFO )
+#define IOCTL_GET_IP4_STATE _MBG_IOR( IOTYPE, 0x76, IP4_SETTINGS )
+#define IOCTL_GET_IP4_SETTINGS _MBG_IOR( IOTYPE, 0x77, IP4_SETTINGS )
+#define IOCTL_SET_IP4_SETTINGS _MBG_IOW( IOTYPE, 0x78, IP4_SETTINGS )
+
+#define IOCTL_DEV_IS_PTP _MBG_IOR( IOTYPE, 0x79, int )
+#define IOCTL_DEV_HAS_PTP _MBG_IOR( IOTYPE, 0x7A, int )
+#define IOCTL_GET_PTP_STATE _MBG_IOR( IOTYPE, 0x7B, PTP_STATE )
+#define IOCTL_GET_PTP_CFG_INFO _MBG_IOR( IOTYPE, 0x7C, PTP_CFG_INFO )
+#define IOCTL_SET_PTP_CFG_SETTINGS _MBG_IOW( IOTYPE, 0x7D, PTP_CFG_SETTINGS )
+
+#define IOCTL_DEV_HAS_IRIG_TIME _MBG_IOR( IOTYPE, 0x7E, int )
+#define IOCTL_GET_IRIG_TIME _MBG_IOR( IOTYPE, 0x7F, PCPS_IRIG_TIME )
+
+#define IOCTL_GET_TIME_INFO_HRT _MBG_IOR( IOTYPE, 0x80, MBG_TIME_INFO_HRT )
+#define IOCTL_GET_TIME_INFO_TSTAMP _MBG_IOR( IOTYPE, 0x81, MBG_TIME_INFO_TSTAMP )
+
+#define IOCTL_DEV_HAS_RAW_IRIG_DATA _MBG_IOR( IOTYPE, 0x82, int )
+#define IOCTL_GET_RAW_IRIG_DATA _MBG_IOR( IOTYPE, 0x83, MBG_RAW_IRIG_DATA )
+
+#define IOCTL_DEV_HAS_PTP_UNICAST _MBG_IOR( IOTYPE, 0x84, int )
+#define IOCTL_PTP_UC_MASTER_CFG_LIMITS _MBG_IOR( IOTYPE, 0x85, PTP_UC_MASTER_CFG_LIMITS )
+#define IOCTL_GET_ALL_PTP_UC_MASTER_INFO _MBG_IOG( IOTYPE, 0x86, IOCTL_GENERIC_REQ ) // variable size
+#define IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX _MBG_IOW( IOTYPE, 0x87, PTP_UC_MASTER_SETTINGS_IDX )
+
+#define IOCTL_DEV_HAS_PZF _MBG_IOR( IOTYPE, 0x88, int )
+#define IOCTL_DEV_HAS_CORR_INFO _MBG_IOR( IOTYPE, 0x89, int )
+#define IOCTL_DEV_HAS_TR_DISTANCE _MBG_IOR( IOTYPE, 0x8A, int )
+#define IOCTL_GET_CORR_INFO _MBG_IOR( IOTYPE, 0x8B, CORR_INFO )
+#define IOCTL_GET_TR_DISTANCE _MBG_IOR( IOTYPE, 0x8C, TR_DISTANCE )
+#define IOCTL_SET_TR_DISTANCE _MBG_IOW( IOTYPE, 0x8D, TR_DISTANCE )
+
+#define IOCTL_DEV_HAS_DEBUG_STATUS _MBG_IOR( IOTYPE, 0x8E, int )
+#define IOCTL_GET_DEBUG_STATUS _MBG_IOR( IOTYPE, 0x8F, MBG_DEBUG_STATUS )
+
+#define IOCTL_DEV_HAS_EVT_LOG _MBG_IOR( IOTYPE, 0x90, int )
+#define IOCTL_CLR_EVT_LOG _MBG_IO( IOTYPE, 0x91 )
+#define IOCTL_GET_NUM_EVT_LOG_ENTRIES _MBG_IOR( IOTYPE, 0x92, MBG_NUM_EVT_LOG_ENTRIES )
+#define IOCTL_GET_FIRST_EVT_LOG_ENTRY _MBG_IOR( IOTYPE, 0x93, MBG_EVT_LOG_ENTRY )
+#define IOCTL_GET_NEXT_EVT_LOG_ENTRY _MBG_IOR( IOTYPE, 0x94, MBG_EVT_LOG_ENTRY )
+
+
+// The codes below are subject to changes without notice. They may be supported
+// by some kernel drivers, but usage is restricted to Meinberg software development.
+// Unrestricted usage may cause system malfunction !!
+#define IOCTL_MBG_DBG_GET_PORT_ADDR _MBG_IOR( IOTYPE, 0xF0, uint16_t )
+#define IOCTL_MBG_DBG_SET_PORT_ADDR _MBG_IOW( IOTYPE, 0xF1, uint16_t )
+#define IOCTL_MBG_DBG_SET_BIT _MBG_IOW( IOTYPE, 0xF2, uint8_t )
+#define IOCTL_MBG_DBG_CLR_BIT _MBG_IOW( IOTYPE, 0xF3, uint8_t )
+#define IOCTL_MBG_DBG_CLR_ALL _MBG_IO( IOTYPE, 0xF4 )
+
+
+
+/**
+ * @brief An initializer for a table of IOCTL codes and associated names.
+ *
+ * This can e.g. be assigned to an array of MBG_CODE_NAME_TABLE_ENTRY elements
+ * and may be helpful when debugging.
+ */
+#define MBG_IOCTL_CODE_TABLE \
+{ \
+ { IOCTL_GET_PCPS_DRVR_INFO, "IOCTL_GET_PCPS_DRVR_INFO" }, \
+ { IOCTL_GET_PCPS_DEV, "IOCTL_GET_PCPS_DEV" }, \
+ { IOCTL_GET_PCPS_STATUS_PORT, "IOCTL_GET_PCPS_STATUS_PORT" }, \
+ { IOCTL_PCPS_GENERIC_READ, "IOCTL_PCPS_GENERIC_READ" }, \
+ { IOCTL_PCPS_GENERIC_WRITE, "IOCTL_PCPS_GENERIC_WRITE" }, \
+ { IOCTL_PCPS_GENERIC_READ_GPS, "IOCTL_PCPS_GENERIC_READ_GPS" }, \
+ { IOCTL_PCPS_GENERIC_WRITE_GPS, "IOCTL_PCPS_GENERIC_WRITE_GPS" }, \
+ { IOCTL_GET_PCPS_TIME, "IOCTL_GET_PCPS_TIME" }, \
+ { IOCTL_SET_PCPS_TIME, "IOCTL_SET_PCPS_TIME" }, \
+ { IOCTL_GET_PCPS_SYNC_TIME, "IOCTL_GET_PCPS_SYNC_TIME" }, \
+ { IOCTL_GET_PCPS_TIME_SEC_CHANGE, "IOCTL_GET_PCPS_TIME_SEC_CHANGE" }, \
+ { IOCTL_GET_PCPS_HR_TIME, "IOCTL_GET_PCPS_HR_TIME" }, \
+ { IOCTL_SET_PCPS_EVENT_TIME, "IOCTL_SET_PCPS_EVENT_TIME" }, \
+ { IOCTL_GET_PCPS_SERIAL, "IOCTL_GET_PCPS_SERIAL" }, \
+ { IOCTL_SET_PCPS_SERIAL, "IOCTL_SET_PCPS_SERIAL" }, \
+ { IOCTL_GET_PCPS_TZCODE, "IOCTL_GET_PCPS_TZCODE" }, \
+ { IOCTL_SET_PCPS_TZCODE, "IOCTL_SET_PCPS_TZCODE" }, \
+ { IOCTL_GET_PCPS_TZDL, "IOCTL_GET_PCPS_TZDL" }, \
+ { IOCTL_SET_PCPS_TZDL, "IOCTL_SET_PCPS_TZDL" }, \
+ { IOCTL_GET_REF_OFFS, "IOCTL_GET_REF_OFFS" }, \
+ { IOCTL_SET_REF_OFFS, "IOCTL_SET_REF_OFFS" }, \
+ { IOCTL_GET_MBG_OPT_INFO, "IOCTL_GET_MBG_OPT_INFO" }, \
+ { IOCTL_SET_MBG_OPT_SETTINGS, "IOCTL_SET_MBG_OPT_SETTINGS" }, \
+ { IOCTL_GET_PCPS_IRIG_RX_INFO, "IOCTL_GET_PCPS_IRIG_RX_INFO" }, \
+ { IOCTL_SET_PCPS_IRIG_RX_SETTINGS, "IOCTL_SET_PCPS_IRIG_RX_SETTINGS" }, \
+ { IOCTL_PCPS_CLR_UCAP_BUFF, "IOCTL_PCPS_CLR_UCAP_BUFF" }, \
+ { IOCTL_GET_PCPS_UCAP_ENTRIES, "IOCTL_GET_PCPS_UCAP_ENTRIES" }, \
+ { IOCTL_GET_PCPS_UCAP_EVENT, "IOCTL_GET_PCPS_UCAP_EVENT" }, \
+ { IOCTL_GET_GPS_TZDL, "IOCTL_GET_GPS_TZDL" }, \
+ { IOCTL_SET_GPS_TZDL, "IOCTL_SET_GPS_TZDL" }, \
+ { IOCTL_GET_GPS_SW_REV, "IOCTL_GET_GPS_SW_REV" }, \
+ { IOCTL_GET_GPS_BVAR_STAT, "IOCTL_GET_GPS_BVAR_STAT" }, \
+ { IOCTL_GET_GPS_TIME, "IOCTL_GET_GPS_TIME" }, \
+ { IOCTL_SET_GPS_TIME, "IOCTL_SET_GPS_TIME" }, \
+ { IOCTL_GET_GPS_PORT_PARM, "IOCTL_GET_GPS_PORT_PARM" }, \
+ { IOCTL_SET_GPS_PORT_PARM, "IOCTL_SET_GPS_PORT_PARM" }, \
+ { IOCTL_GET_GPS_ANT_INFO, "IOCTL_GET_GPS_ANT_INFO" }, \
+ { IOCTL_GET_GPS_UCAP, "IOCTL_GET_GPS_UCAP" }, \
+ { IOCTL_GET_GPS_ENABLE_FLAGS, "IOCTL_GET_GPS_ENABLE_FLAGS" }, \
+ { IOCTL_SET_GPS_ENABLE_FLAGS, "IOCTL_SET_GPS_ENABLE_FLAGS" }, \
+ { IOCTL_GET_GPS_STAT_INFO, "IOCTL_GET_GPS_STAT_INFO" }, \
+ { IOCTL_SET_GPS_CMD, "IOCTL_SET_GPS_CMD" }, \
+ { IOCTL_GET_GPS_IDENT, "IOCTL_GET_GPS_IDENT" }, \
+ { IOCTL_GET_GPS_POS, "IOCTL_GET_GPS_POS" }, \
+ { IOCTL_SET_GPS_POS_XYZ, "IOCTL_SET_GPS_POS_XYZ" }, \
+ { IOCTL_SET_GPS_POS_LLA, "IOCTL_SET_GPS_POS_LLA" }, \
+ { IOCTL_GET_GPS_ANT_CABLE_LEN, "IOCTL_GET_GPS_ANT_CABLE_LEN" }, \
+ { IOCTL_SET_GPS_ANT_CABLE_LEN, "IOCTL_SET_GPS_ANT_CABLE_LEN" }, \
+ { IOCTL_GET_GPS_RECEIVER_INFO, "IOCTL_GET_GPS_RECEIVER_INFO" }, \
+ { IOCTL_GET_GPS_ALL_STR_TYPE_INFO, "IOCTL_GET_GPS_ALL_STR_TYPE_INFO" }, \
+ { IOCTL_GET_GPS_ALL_PORT_INFO, "IOCTL_GET_GPS_ALL_PORT_INFO" }, \
+ { IOCTL_SET_GPS_PORT_SETTINGS_IDX, "IOCTL_SET_GPS_PORT_SETTINGS_IDX" }, \
+ { IOCTL_GET_PCI_ASIC_VERSION, "IOCTL_GET_PCI_ASIC_VERSION" }, \
+ { IOCTL_GET_PCPS_TIME_CYCLES, "IOCTL_GET_PCPS_TIME_CYCLES" }, \
+ { IOCTL_GET_PCPS_HR_TIME_CYCLES, "IOCTL_GET_PCPS_HR_TIME_CYCLES" }, \
+ { IOCTL_GET_PCPS_IRIG_TX_INFO, "IOCTL_GET_PCPS_IRIG_TX_INFO" }, \
+ { IOCTL_SET_PCPS_IRIG_TX_SETTINGS, "IOCTL_SET_PCPS_IRIG_TX_SETTINGS" }, \
+ { IOCTL_GET_SYNTH, "IOCTL_GET_SYNTH" }, \
+ { IOCTL_SET_SYNTH, "IOCTL_SET_SYNTH" }, \
+ { IOCTL_DEV_IS_GPS, "IOCTL_DEV_IS_GPS" }, \
+ { IOCTL_DEV_IS_DCF, "IOCTL_DEV_IS_DCF" }, \
+ { IOCTL_DEV_IS_IRIG_RX, "IOCTL_DEV_IS_IRIG_RX" }, \
+ { IOCTL_DEV_HAS_HR_TIME, "IOCTL_DEV_HAS_HR_TIME" }, \
+ { IOCTL_DEV_HAS_CAB_LEN, "IOCTL_DEV_HAS_CAB_LEN" }, \
+ { IOCTL_DEV_HAS_TZDL, "IOCTL_DEV_HAS_TZDL" }, \
+ { IOCTL_DEV_HAS_PCPS_TZDL, "IOCTL_DEV_HAS_PCPS_TZDL" }, \
+ { IOCTL_DEV_HAS_TZCODE, "IOCTL_DEV_HAS_TZCODE" }, \
+ { IOCTL_DEV_HAS_TZ, "IOCTL_DEV_HAS_TZ" }, \
+ { IOCTL_DEV_HAS_EVENT_TIME, "IOCTL_DEV_HAS_EVENT_TIME" }, \
+ { IOCTL_DEV_HAS_RECEIVER_INFO, "IOCTL_DEV_HAS_RECEIVER_INFO" }, \
+ { IOCTL_DEV_CAN_CLR_UCAP_BUFF, "IOCTL_DEV_CAN_CLR_UCAP_BUFF" }, \
+ { IOCTL_DEV_HAS_UCAP, "IOCTL_DEV_HAS_UCAP" }, \
+ { IOCTL_DEV_HAS_IRIG_TX, "IOCTL_DEV_HAS_IRIG_TX" }, \
+ { IOCTL_DEV_HAS_SERIAL_HS, "IOCTL_DEV_HAS_SERIAL_HS" }, \
+ { IOCTL_DEV_HAS_SIGNAL, "IOCTL_DEV_HAS_SIGNAL" }, \
+ { IOCTL_DEV_HAS_MOD, "IOCTL_DEV_HAS_MOD" }, \
+ { IOCTL_DEV_HAS_IRIG, "IOCTL_DEV_HAS_IRIG" }, \
+ { IOCTL_DEV_HAS_REF_OFFS, "IOCTL_DEV_HAS_REF_OFFS" }, \
+ { IOCTL_DEV_HAS_OPT_FLAGS, "IOCTL_DEV_HAS_OPT_FLAGS" }, \
+ { IOCTL_DEV_HAS_GPS_DATA, "IOCTL_DEV_HAS_GPS_DATA" }, \
+ { IOCTL_DEV_HAS_SYNTH, "IOCTL_DEV_HAS_SYNTH" }, \
+ { IOCTL_DEV_HAS_GENERIC_IO, "IOCTL_DEV_HAS_GENERIC_IO" }, \
+ { IOCTL_PCPS_GENERIC_IO, "IOCTL_PCPS_GENERIC_IO" }, \
+ { IOCTL_GET_SYNTH_STATE, "IOCTL_GET_SYNTH_STATE" }, \
+ { IOCTL_GET_GPS_ALL_POUT_INFO, "IOCTL_GET_GPS_ALL_POUT_INFO" }, \
+ { IOCTL_SET_GPS_POUT_SETTINGS_IDX, "IOCTL_SET_GPS_POUT_SETTINGS_IDX" }, \
+ { IOCTL_GET_MAPPED_MEM_ADDR, "IOCTL_GET_MAPPED_MEM_ADDR" }, \
+ { IOCTL_UNMAP_MAPPED_MEM, "IOCTL_UNMAP_MAPPED_MEM" }, \
+ { IOCTL_GET_PCI_ASIC_FEATURES, "IOCTL_GET_PCI_ASIC_FEATURES" }, \
+ { IOCTL_DEV_HAS_PCI_ASIC_FEATURES, "IOCTL_DEV_HAS_PCI_ASIC_FEATURES" }, \
+ { IOCTL_DEV_HAS_PCI_ASIC_VERSION, "IOCTL_DEV_HAS_PCI_ASIC_VERSION" }, \
+ { IOCTL_DEV_IS_MSF, "IOCTL_DEV_IS_MSF" }, \
+ { IOCTL_DEV_IS_LWR, "IOCTL_DEV_IS_LWR" }, \
+ { IOCTL_DEV_IS_WWVB, "IOCTL_DEV_IS_WWVB" }, \
+ { IOCTL_GET_IRQ_STAT_INFO, "IOCTL_GET_IRQ_STAT_INFO" }, \
+ { IOCTL_GET_CYCLES_FREQUENCY, "IOCTL_GET_CYCLES_FREQUENCY" }, \
+ { IOCTL_DEV_HAS_FAST_HR_TIMESTAMP, "IOCTL_DEV_HAS_FAST_HR_TIMESTAMP" }, \
+ { IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES, "IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES" }, \
+ { IOCTL_GET_FAST_HR_TIMESTAMP, "IOCTL_GET_FAST_HR_TIMESTAMP" }, \
+ { IOCTL_DEV_HAS_GPS_TIME_SCALE, "IOCTL_DEV_HAS_GPS_TIME_SCALE" }, \
+ { IOCTL_GET_GPS_TIME_SCALE_INFO, "IOCTL_GET_GPS_TIME_SCALE_INFO" }, \
+ { IOCTL_SET_GPS_TIME_SCALE_SETTINGS, "IOCTL_SET_GPS_TIME_SCALE_SETTINGS" }, \
+ { IOCTL_DEV_HAS_GPS_UTC_PARM, "IOCTL_DEV_HAS_GPS_UTC_PARM" }, \
+ { IOCTL_GET_GPS_UTC_PARM, "IOCTL_GET_GPS_UTC_PARM" }, \
+ { IOCTL_SET_GPS_UTC_PARM, "IOCTL_SET_GPS_UTC_PARM" }, \
+ { IOCTL_DEV_HAS_IRIG_CTRL_BITS, "IOCTL_DEV_HAS_IRIG_CTRL_BITS" }, \
+ { IOCTL_GET_IRIG_CTRL_BITS, "IOCTL_GET_IRIG_CTRL_BITS" }, \
+ { IOCTL_DEV_HAS_LAN_INTF, "IOCTL_DEV_HAS_LAN_INTF" }, \
+ { IOCTL_GET_LAN_IF_INFO, "IOCTL_GET_LAN_IF_INFO" }, \
+ { IOCTL_GET_IP4_STATE, "IOCTL_GET_IP4_STATE" }, \
+ { IOCTL_GET_IP4_SETTINGS, "IOCTL_GET_IP4_SETTINGS" }, \
+ { IOCTL_SET_IP4_SETTINGS, "IOCTL_SET_IP4_SETTINGS" }, \
+ { IOCTL_DEV_IS_PTP, "IOCTL_DEV_IS_PTP" }, \
+ { IOCTL_DEV_HAS_PTP, "IOCTL_DEV_HAS_PTP" }, \
+ { IOCTL_GET_PTP_STATE, "IOCTL_GET_PTP_STATE" }, \
+ { IOCTL_GET_PTP_CFG_INFO, "IOCTL_GET_PTP_CFG_INFO" }, \
+ { IOCTL_SET_PTP_CFG_SETTINGS, "IOCTL_SET_PTP_CFG_SETTINGS" }, \
+ { IOCTL_DEV_HAS_IRIG_TIME, "IOCTL_DEV_HAS_IRIG_TIME" }, \
+ { IOCTL_GET_IRIG_TIME, "IOCTL_GET_IRIG_TIME" }, \
+ { IOCTL_GET_TIME_INFO_HRT, "IOCTL_GET_TIME_INFO_HRT" }, \
+ { IOCTL_GET_TIME_INFO_TSTAMP, "IOCTL_GET_TIME_INFO_TSTAMP" }, \
+ { IOCTL_DEV_HAS_RAW_IRIG_DATA, "IOCTL_DEV_HAS_RAW_IRIG_DATA" }, \
+ { IOCTL_GET_RAW_IRIG_DATA, "IOCTL_GET_RAW_IRIG_DATA" }, \
+ { IOCTL_DEV_HAS_PTP_UNICAST, "IOCTL_DEV_HAS_PTP_UNICAST" }, \
+ { IOCTL_PTP_UC_MASTER_CFG_LIMITS, "IOCTL_PTP_UC_MASTER_CFG_LIMITS" }, \
+ { IOCTL_GET_ALL_PTP_UC_MASTER_INFO, "IOCTL_GET_ALL_PTP_UC_MASTER_INFO" }, \
+ { IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX, "IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX" }, \
+ { IOCTL_DEV_HAS_PZF, "IOCTL_DEV_HAS_PZF" }, \
+ { IOCTL_DEV_HAS_CORR_INFO, "IOCTL_DEV_HAS_CORR_INFO" }, \
+ { IOCTL_DEV_HAS_TR_DISTANCE, "IOCTL_DEV_HAS_TR_DISTANCE" }, \
+ { IOCTL_GET_CORR_INFO, "IOCTL_GET_CORR_INFO" }, \
+ { IOCTL_GET_TR_DISTANCE, "IOCTL_GET_TR_DISTANCE" }, \
+ { IOCTL_SET_TR_DISTANCE, "IOCTL_SET_TR_DISTANCE" }, \
+ { IOCTL_DEV_HAS_DEBUG_STATUS, "IOCTL_DEV_HAS_DEBUG_STATUS" }, \
+ { IOCTL_GET_DEBUG_STATUS, "IOCTL_GET_DEBUG_STATUS" }, \
+ { IOCTL_DEV_HAS_EVT_LOG, "IOCTL_DEV_HAS_EVT_LOG" }, \
+ { IOCTL_CLR_EVT_LOG, "IOCTL_CLR_EVT_LOG" }, \
+ { IOCTL_GET_NUM_EVT_LOG_ENTRIES, "IOCTL_GET_NUM_EVT_LOG_ENTRIES" }, \
+ { IOCTL_GET_FIRST_EVT_LOG_ENTRY, "IOCTL_GET_FIRST_EVT_LOG_ENTRY" }, \
+ { IOCTL_GET_NEXT_EVT_LOG_ENTRY, "IOCTL_GET_NEXT_EVT_LOG_ENTRY" }, \
+ \
+ { IOCTL_MBG_DBG_GET_PORT_ADDR, "IOCTL_MBG_DBG_GET_PORT_ADDR" }, \
+ { IOCTL_MBG_DBG_SET_PORT_ADDR, "IOCTL_MBG_DBG_SET_PORT_ADDR" }, \
+ { IOCTL_MBG_DBG_SET_BIT, "IOCTL_MBG_DBG_SET_BIT" }, \
+ { IOCTL_MBG_DBG_CLR_BIT, "IOCTL_MBG_DBG_CLR_BIT" }, \
+ { 0, NULL } \
+}
+
+
+#if !defined( _cmd_from_ioctl_code )
+ #define _cmd_from_ioctl_code( _ioctl_code ) _ioctl_code
+#endif
+
+
+
+/**
+ * @brief Privilege levels for IOCTL codes.
+ *
+ * IOCTLs can be used to do different things ranging from simply
+ * reading a timestamp up to forcing a GPS receiver into boot mode
+ * which may completely mess up the time keeping on the PC.
+ *
+ * These codes are used to determine a privilege level required
+ * to execute a specific IOCTL command.
+ *
+ * How to determine if a calling process has sufficient privileges
+ * depends strongly on the rights management features provided
+ * by the underlying OS (e.g simple user/group rights, ACLs,
+ * Linux capabilities, Windows privileges) so this needs to be
+ * implemented in the OS-specific code of a driver.
+ *
+ * Implementation should be done in a way which introduces as low
+ * latency as possible when reading time stamps from a device.
+ */
+enum MBG_REQ_PRIVL
+{
+ MBG_REQ_PRIVL_NONE, //< e.g. read date/time/sync status
+ MBG_REQ_PRIVL_EXT_STATUS, //< e.g. read receiver position
+ MBG_REQ_PRIVL_CFG_READ, //< read device config data
+ MBG_REQ_PRIVL_CFG_WRITE, //< write config data to the device
+ MBG_REQ_PRIVL_SYSTEM, //< operations which may affect system operation
+ N_MBG_REQ_PRIVL //< the number of supported privilege levels
+};
+
+
+#if defined( __GNUC__ )
+// Avoid "no previous prototype" with some gcc versions.
+static __mbg_inline
+int ioctl_get_required_privilege( ulong ioctl_code ) __attribute__((always_inline));
+#endif
+
+/**
+ * @brief Determine the privilege level required to execute a specific IOCTL command.
+ *
+ * @param ioctl_code The IOCTL code for which to return the privilege level
+ *
+ * @return One of the enumerated privilege levels
+ * @return -1 for unknown IOCTL codes
+ */
+static __mbg_inline
+int ioctl_get_required_privilege( ulong ioctl_code )
+{
+ // To provide best maintainability the sequence of cases in ioctl_switch()
+ // should match the sequence of the cases here, which also makes sure
+ // commands requiring lowest latency are handled first.
+
+ switch ( ioctl_code )
+ {
+ // Commands requiring lowest latency:
+ case IOCTL_GET_FAST_HR_TIMESTAMP:
+ case IOCTL_GET_PCPS_HR_TIME:
+ case IOCTL_GET_FAST_HR_TIMESTAMP_CYCLES:
+ case IOCTL_GET_PCPS_HR_TIME_CYCLES:
+ case IOCTL_GET_PCPS_UCAP_EVENT:
+ // Other low latency commands:
+ case IOCTL_GET_PCPS_TIME:
+ case IOCTL_GET_PCPS_TIME_CYCLES:
+ case IOCTL_GET_PCPS_STATUS_PORT:
+ case IOCTL_GET_PCPS_TIME_SEC_CHANGE:
+ case IOCTL_GET_GPS_TIME:
+ case IOCTL_GET_GPS_UCAP:
+ case IOCTL_GET_TIME_INFO_HRT:
+ case IOCTL_GET_TIME_INFO_TSTAMP:
+ return MBG_REQ_PRIVL_NONE;
+
+ // Commands returning public status information:
+ case IOCTL_GET_PCPS_DRVR_INFO:
+ case IOCTL_GET_PCPS_DEV:
+ case IOCTL_GET_PCPS_SYNC_TIME:
+ case IOCTL_GET_GPS_SW_REV:
+ case IOCTL_GET_GPS_BVAR_STAT:
+ case IOCTL_GET_GPS_ANT_INFO:
+ case IOCTL_GET_GPS_STAT_INFO:
+ case IOCTL_GET_GPS_IDENT:
+ case IOCTL_GET_GPS_RECEIVER_INFO:
+ case IOCTL_GET_PCI_ASIC_VERSION:
+ case IOCTL_GET_SYNTH_STATE:
+ case IOCTL_GET_PCPS_UCAP_ENTRIES:
+ case IOCTL_GET_PCI_ASIC_FEATURES:
+ case IOCTL_GET_IRQ_STAT_INFO:
+ case IOCTL_GET_CYCLES_FREQUENCY:
+ case IOCTL_GET_IRIG_CTRL_BITS:
+ case IOCTL_GET_IP4_STATE:
+ case IOCTL_GET_PTP_STATE:
+ case IOCTL_GET_CORR_INFO:
+ case IOCTL_GET_DEBUG_STATUS:
+ case IOCTL_GET_NUM_EVT_LOG_ENTRIES:
+ case IOCTL_GET_FIRST_EVT_LOG_ENTRY:
+ case IOCTL_GET_NEXT_EVT_LOG_ENTRY:
+ return MBG_REQ_PRIVL_NONE;
+
+ // Commands returning device capabilities and features:
+ case IOCTL_DEV_IS_GPS:
+ case IOCTL_DEV_IS_DCF:
+ case IOCTL_DEV_IS_MSF:
+ case IOCTL_DEV_IS_WWVB:
+ case IOCTL_DEV_IS_LWR:
+ case IOCTL_DEV_IS_IRIG_RX:
+ case IOCTL_DEV_HAS_HR_TIME:
+ case IOCTL_DEV_HAS_CAB_LEN:
+ case IOCTL_DEV_HAS_TZDL:
+ case IOCTL_DEV_HAS_PCPS_TZDL:
+ case IOCTL_DEV_HAS_TZCODE:
+ case IOCTL_DEV_HAS_TZ:
+ case IOCTL_DEV_HAS_EVENT_TIME:
+ case IOCTL_DEV_HAS_RECEIVER_INFO:
+ case IOCTL_DEV_CAN_CLR_UCAP_BUFF:
+ case IOCTL_DEV_HAS_UCAP:
+ case IOCTL_DEV_HAS_IRIG_TX:
+ case IOCTL_DEV_HAS_SERIAL_HS:
+ case IOCTL_DEV_HAS_SIGNAL:
+ case IOCTL_DEV_HAS_MOD:
+ case IOCTL_DEV_HAS_IRIG:
+ case IOCTL_DEV_HAS_REF_OFFS:
+ case IOCTL_DEV_HAS_OPT_FLAGS:
+ case IOCTL_DEV_HAS_GPS_DATA:
+ case IOCTL_DEV_HAS_SYNTH:
+ case IOCTL_DEV_HAS_GENERIC_IO:
+ case IOCTL_DEV_HAS_PCI_ASIC_FEATURES:
+ case IOCTL_DEV_HAS_PCI_ASIC_VERSION:
+ case IOCTL_DEV_HAS_FAST_HR_TIMESTAMP:
+ case IOCTL_DEV_HAS_GPS_TIME_SCALE:
+ case IOCTL_DEV_HAS_GPS_UTC_PARM:
+ case IOCTL_DEV_HAS_IRIG_CTRL_BITS:
+ case IOCTL_DEV_HAS_LAN_INTF:
+ case IOCTL_DEV_IS_PTP:
+ case IOCTL_DEV_HAS_PTP:
+ case IOCTL_DEV_HAS_IRIG_TIME:
+ case IOCTL_DEV_HAS_RAW_IRIG_DATA:
+ case IOCTL_DEV_HAS_PTP_UNICAST:
+ case IOCTL_DEV_HAS_PZF:
+ case IOCTL_DEV_HAS_CORR_INFO:
+ case IOCTL_DEV_HAS_TR_DISTANCE:
+ case IOCTL_DEV_HAS_DEBUG_STATUS:
+ case IOCTL_DEV_HAS_EVT_LOG:
+ return MBG_REQ_PRIVL_NONE;
+
+ // The next codes are somewhat special since they change something
+ // on the board but do not affect basic operation:
+ case IOCTL_PCPS_CLR_UCAP_BUFF:
+ case IOCTL_SET_PCPS_EVENT_TIME: // supported by some customized firmware only
+ case IOCTL_CLR_EVT_LOG:
+ return MBG_REQ_PRIVL_NONE;
+
+ // Status information which may not be available for everybody:
+ case IOCTL_GET_GPS_POS:
+ return MBG_REQ_PRIVL_EXT_STATUS;
+
+ // Reading device configuration:
+ case IOCTL_GET_PCPS_SERIAL:
+ case IOCTL_GET_PCPS_TZCODE:
+ case IOCTL_GET_PCPS_TZDL:
+ case IOCTL_GET_REF_OFFS:
+ case IOCTL_GET_MBG_OPT_INFO:
+ case IOCTL_GET_PCPS_IRIG_RX_INFO:
+ case IOCTL_GET_GPS_TZDL:
+ case IOCTL_GET_GPS_PORT_PARM:
+ case IOCTL_GET_GPS_ENABLE_FLAGS:
+ case IOCTL_GET_GPS_ANT_CABLE_LEN:
+ case IOCTL_GET_PCPS_IRIG_TX_INFO:
+ case IOCTL_GET_SYNTH:
+ case IOCTL_GET_GPS_TIME_SCALE_INFO:
+ case IOCTL_GET_GPS_UTC_PARM:
+ case IOCTL_GET_LAN_IF_INFO:
+ case IOCTL_GET_IP4_SETTINGS:
+ case IOCTL_GET_PTP_CFG_INFO:
+ case IOCTL_GET_IRIG_TIME:
+ case IOCTL_GET_RAW_IRIG_DATA:
+ case IOCTL_PTP_UC_MASTER_CFG_LIMITS:
+ case IOCTL_GET_TR_DISTANCE:
+ // generic read functions
+ case IOCTL_PCPS_GENERIC_READ:
+ case IOCTL_PCPS_GENERIC_READ_GPS:
+ #if _MBG_SUPP_VAR_ACC_SIZE
+ // These codes are only supported on target systems where a variable size of
+ // the IOCTL buffer can be specified in the IOCTL call. On other systems the
+ // generic IOCTL functions are used instead.
+ case IOCTL_GET_GPS_ALL_STR_TYPE_INFO:
+ case IOCTL_GET_GPS_ALL_PORT_INFO:
+ case IOCTL_GET_GPS_ALL_POUT_INFO:
+ case IOCTL_GET_ALL_PTP_UC_MASTER_INFO:
+ #endif
+ return MBG_REQ_PRIVL_CFG_READ;
+
+ // Writing device configuration:
+ case IOCTL_SET_PCPS_SERIAL:
+ case IOCTL_SET_PCPS_TZCODE:
+ case IOCTL_SET_PCPS_TZDL:
+ case IOCTL_SET_REF_OFFS:
+ case IOCTL_SET_MBG_OPT_SETTINGS:
+ case IOCTL_SET_PCPS_IRIG_RX_SETTINGS:
+ case IOCTL_SET_GPS_TZDL:
+ case IOCTL_SET_GPS_PORT_PARM:
+ case IOCTL_SET_GPS_ENABLE_FLAGS:
+ case IOCTL_SET_GPS_ANT_CABLE_LEN:
+ case IOCTL_SET_GPS_PORT_SETTINGS_IDX:
+ case IOCTL_SET_PCPS_IRIG_TX_SETTINGS:
+ case IOCTL_SET_SYNTH:
+ case IOCTL_SET_GPS_POUT_SETTINGS_IDX:
+ case IOCTL_SET_IP4_SETTINGS:
+ case IOCTL_SET_PTP_CFG_SETTINGS:
+ case IOCTL_SET_PTP_UC_MASTER_SETTINGS_IDX:
+ case IOCTL_SET_TR_DISTANCE:
+ return MBG_REQ_PRIVL_CFG_WRITE;
+
+ // Operations which may severely affect system operation:
+ case IOCTL_SET_PCPS_TIME:
+ case IOCTL_SET_GPS_TIME:
+ case IOCTL_SET_GPS_POS_XYZ:
+ case IOCTL_SET_GPS_POS_LLA:
+ case IOCTL_SET_GPS_TIME_SCALE_SETTINGS:
+ case IOCTL_SET_GPS_UTC_PARM:
+ case IOCTL_SET_GPS_CMD:
+ // generic write operations can do anything
+ case IOCTL_PCPS_GENERIC_WRITE:
+ case IOCTL_PCPS_GENERIC_WRITE_GPS:
+ case IOCTL_PCPS_GENERIC_IO:
+ return MBG_REQ_PRIVL_SYSTEM;
+
+ // The next codes are somewhat special and normally
+ // not used by the driver software:
+ case IOCTL_GET_MAPPED_MEM_ADDR:
+ case IOCTL_UNMAP_MAPPED_MEM:
+ return MBG_REQ_PRIVL_SYSTEM;
+
+ #if USE_DEBUG_PORT
+ // The codes below are used for debugging only.
+ // Unrestricted usage may cause system malfunction !!
+ case IOCTL_MBG_DBG_GET_PORT_ADDR:
+ case IOCTL_MBG_DBG_SET_PORT_ADDR:
+ case IOCTL_MBG_DBG_SET_BIT:
+ case IOCTL_MBG_DBG_CLR_BIT:
+ case IOCTL_MBG_DBG_CLR_ALL:
+ return MBG_REQ_PRIVL_SYSTEM;
+ #endif
+ } // switch
+
+ return -1; // unsupported code, should always be denied
+
+} // ioctl_get_required_privilege
+
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+/* (no header definitions found) */
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _MBGIOCTL_H */
diff --git a/c/mbglib/include/mbgmutex.h b/c/mbglib/include/mbgmutex.h
new file mode 100644
index 0000000..86fd058
--- /dev/null
+++ b/c/mbglib/include/mbgmutex.h
@@ -0,0 +1,259 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgmutex.h 1.2 2012/03/08 12:19:01Z martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Portable macros to deal with spinlocks, mutexes,
+ * and critical sections.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgmutex.h $
+ * Revision 1.2 2012/03/08 12:19:01Z martin
+ * Fixes for Linux kernel and FreeBSD.
+ * Fixed build under DOS and QNX usinc dummy defines.
+ * Don't define macros for semaphore destroy functions
+ * if not required/supported on the target OS.
+ * Revision 1.1 2011/04/15 12:26:59 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGMUTEX_H
+#define _MBGMUTEX_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#ifdef _MBGMUTEX
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( MBG_TGT_KERNEL ) // definitions used in kernel space
+
+ #if defined( MBG_TGT_WIN32 ) // Windows kernel space
+
+ typedef KSPIN_LOCK MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) KeInitializeSpinLock( _spl )
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) KeAcquireSpinLockAtDpcLevel( _spl )
+ #define _mbg_spin_lock_release( _spl ) KeReleaseSpinLockFromDpcLevel( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef FAST_MUTEX MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) ExInitializeFastMutex( _pmtx )
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pmtx ) ExAcquireFastMutex( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) ExReleaseFastMutex( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_LINUX ) // Linux kernel space
+
+ #include <linux/spinlock.h>
+ #include <linux/version.h>
+
+ #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 26 ) )
+ #include <linux/semaphore.h>
+ #else
+ #include <asm/semaphore.h>
+ #endif
+
+ typedef spinlock_t MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) spin_lock_init( _spl )
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) spin_lock( _spl )
+ #define _mbg_spin_lock_release( _spl ) spin_unlock( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef struct semaphore MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) sema_init( _pmtx, 1 )
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pmtx ) down_interruptible( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) up( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_FREEBSD ) // FreeBSD kernel space
+
+ #include <sys/lock.h>
+ #include <sys/mutex.h>
+
+ typedef struct mtx MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) mtx_init( _spl, "mbg_spin_lock", NULL, MTX_SPIN )
+ #define _mbg_spin_lock_destroy( _spl ) mtx_destroy( _spl )
+ #define _mbg_spin_lock_acquire( _spl ) mtx_lock_spin( _spl )
+ #define _mbg_spin_lock_release( _spl ) mtx_unlock_spin( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef struct mtx MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) mtx_init( _pmtx, "mbg_mutex", NULL, MTX_DEF )
+ #define _mbg_mutex_destroy( _pmtx ) mtx_destroy( _pmtx )
+ #define _mbg_mutex_acquire( _pmtx ) mtx_lock( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) mtx_unlock( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #elif defined( MBG_TGT_NETBSD )
+
+ #include <sys/mutex.h>
+
+ // The API used below has been introduced in NetBSD 5.0
+ // For earlier NetBSD versions see 'man 9 lockinit'.
+
+ typedef kmutex_t MBG_SPINLOCK;
+ #define _mbg_spin_lock_init( _spl ) mutex_init( _spl, MUTEX_DEFAULT, IPL_HIGH )
+ #define _mbg_spin_lock_destroy( _spl ) mutex_destroy( _spl )
+ #define _mbg_spin_lock_acquire( _spl ) mutex_spin_enter( _spl )
+ #define _mbg_spin_lock_release( _spl ) mutex_spin_exit( _spl )
+
+ #define _MBG_SPINLOCK_DEFINED 1
+
+
+ typedef kmutex_t MBG_MUTEX;
+ #define _mbg_mutex_init( _pmtx ) mutex_init( _pmtx, MUTEX_DEFAULT, IPL_NONE )
+ #define _mbg_mutex_destroy( _spl ) mutex_destroy( _spl )
+ #define _mbg_mutex_acquire( _pmtx ) mutex_enter( _pmtx )
+ #define _mbg_mutex_release( _pmtx ) mutex_exit( _pmtx )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #endif
+
+#else // user space applications
+
+ #if defined( MBG_TGT_WIN32 ) // Windows user space
+
+ #include <windows.h>
+
+ // definitions used with mutexes
+ typedef HANDLE MBG_MUTEX;
+ #define _mbg_mutex_init( _pm ) *(_pm) = CreateMutex( NULL, FALSE, NULL )
+ #define _mbg_mutex_destroy( _pm ) CloseHandle( *(_pm) ); *(_pm) = INVALID_HANDLE_VALUE
+ #define _mbg_mutex_acquire( _pm ) WaitForSingleObject( *(_pm), INFINITE )
+ #define _mbg_mutex_release( _pm ) ReleaseMutex( *(_pm) )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ // definitions used with critical sections
+ typedef CRITICAL_SECTION MBG_CRIT_SECT;
+ #define _mbg_crit_sect_init( _pcs ) InitializeCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_destroy( _pcs ) DeleteCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_enter( _pcs ) EnterCriticalSection( (_pcs) )
+ #define _mbg_crit_sect_leave( _pcs ) LeaveCriticalSection( (_pcs) )
+
+ #define _MBG_CRIT_SECT_DEFINED 1
+
+ #elif defined( MBG_TGT_UNIX ) // Unix user space use pthread library
+
+ #include <pthread.h>
+
+ // Mutex types:
+ // PTHREAD_MUTEX_INITIALIZER /* Fast */
+ // PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP /* Recursive */
+ // PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* Errorcheck */
+ typedef pthread_mutex_t MBG_MUTEX;
+ #define _mbg_mutex_init( _pm ) pthread_mutex_init( (_pm), NULL )
+ #define _mbg_mutex_destroy( _pm ) pthread_mutex_destroy( (_pm) )
+ #define _mbg_mutex_acquire( _pm ) pthread_mutex_lock( (_pm) )
+ #define _mbg_mutex_release( _pm ) pthread_mutex_unlock( (_pm) )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ // For critical sections use defaults specified below
+
+ #elif defined( MBG_TGT_DOS ) || defined( MBG_TGT_QNX )
+
+ typedef int MBG_MUTEX; // just a dummy declaration
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ #endif
+
+#endif
+
+
+#if !defined( _MBG_SPINLOCK_DEFINED )
+
+ #define _mbg_spin_lock_init( _spl ) _nop_macro_fnc()
+ // _mbg_spin_lock_destroy is not supported
+ #define _mbg_spin_lock_acquire( _spl ) _nop_macro_fnc()
+ #define _mbg_spin_lock_release( _spl ) _nop_macro_fnc()
+
+#endif
+
+
+#if !defined( _MBG_MUTEX_DEFINED )
+
+ #define _MBG_MUTEX_DEFINED 1
+
+ typedef MBG_CRIT_SECT MBG_MUTEX;
+
+ #define _mbg_mutex_init( _pm ) _nop_macro_fnc()
+ // _mbg_mutex_destroy( _pmtx ) is not supported
+ #define _mbg_mutex_acquire( _pm ) _nop_macro_fnc()
+ #define _mbg_mutex_release( _pm ) _nop_macro_fnc()
+
+#endif
+
+
+#if !defined( _MBG_CRIT_SECT_DEFINED )
+
+ // use mutex by default, e.g. with the pthread library
+
+ #define _MBG_CRIT_SECT_DEFINED 1
+
+ typedef MBG_MUTEX MBG_CRIT_SECT;
+ #define _mbg_crit_sect_init _mbg_mutex_init
+ #if defined( _mbg_mutex_destroy )
+ #define _mbg_crit_sect_destroy _mbg_mutex_destroy
+ #endif
+ #define _mbg_crit_sect_enter _mbg_mutex_acquire
+ #define _mbg_crit_sect_leave _mbg_mutex_release
+
+#endif
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+/* (no header definitions found) */
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGMUTEX_H */
diff --git a/c/mbglib/include/mbgpccyc.h b/c/mbglib/include/mbgpccyc.h
new file mode 100644
index 0000000..bebb38e
--- /dev/null
+++ b/c/mbglib/include/mbgpccyc.h
@@ -0,0 +1,305 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgpccyc.h 1.2 2012/03/12 13:45:57Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Portable macros to get a machine's current cycle count.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgpccyc.h $
+ * Revision 1.2 2012/03/12 13:45:57Z martin
+ * Added cycles support for Linux/IA64, FreeBSD and NetBSD
+ * in kernel space.
+ * Use get_cycles() in Linux kernel mode if no special cycles support
+ * is provided for the given hardware platform.
+ * Revision 1.1 2011/06/23 15:36:07 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGPCCYC_H
+#define _MBGPCCYC_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#if defined( MBG_TGT_NETBSD )
+ #if defined( MBG_TGT_KERNEL )
+ #include <machine/cpu.h>
+ #include <machine/cpu_counter.h> /* for cycle counter abstraction */
+ #endif
+#endif
+
+#if defined( MBG_TGT_FREEBSD )
+ #if defined( MBG_TGT_KERNEL )
+ #if defined( MBG_ARCH_X86 )
+ #include <machine/clock.h> /* for symbol 'tsc_freq' */
+ #endif
+ #endif
+#endif
+
+#if defined( MBG_TGT_LINUX )
+ #if defined( MBG_ARCH_IA64 ) && defined( MBG_TGT_KERNEL )
+ #include <asm/ia64regs.h>
+ #endif
+#endif
+
+
+#ifdef _MBGPCCYC
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+/**
+ * @brief Generic types to hold PC cycle counter values.
+ *
+ * The cycle counter value is usually derived from the PC CPU's TSC or some other
+ * timer hardware on the mainboard.
+ */
+#if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_UNIX )
+
+ typedef int64_t MBG_PC_CYCLES;
+ typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
+
+#else
+
+ typedef uint32_t MBG_PC_CYCLES;
+ typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
+
+#endif
+
+
+// MBG_PC_CYCLES and MBG_PC_CYCLES_FREQUENCY are always read in native
+// machine endianess, so no endianess conversion is required.
+#define _mbg_swab_mbg_pc_cycles( _p ) \
+ _nop_macro_fnc()
+
+#define _mbg_swab_mbg_pc_cycles_frequency( _p ) \
+ _nop_macro_fnc()
+
+
+
+#if ( defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD ) ) && defined( MBG_ARCH_X86 )
+
+ static __mbg_inline unsigned long long int mbg_rdtscll( void )
+ {
+ // The code below is a hack to get around issues with
+ // different versions of gcc.
+ //
+ // Normally the inline asm code could look similar to:
+ //
+ // __asm__ volatile ( "rdtsc" : "=A" (x) )
+ //
+ // which would copy the output regs edx:eax as a 64 bit
+ // number to a variable x.
+ //
+ // The "=A" expression should implicitely tell the compiler
+ // the edx and eax registers have been clobbered. However,
+ // this does not seem to work properly at least with gcc 4.1.2
+ // shipped with Centos 5.
+ //
+ // If optimization level 1 or higher is used then function
+ // parameters are also passed in registers. If the inline
+ // code above is used inside a function then the edx register
+ // is clobbered but the gcc 4.1.2 is not aware of this and
+ // assumes edx is unchanged, which may yield faulty results
+ // or even lead to segmentation faults.
+ //
+ // A possible workaround could be to mark edx explicitely as
+ // being clobbered in the asm inline code, but unfortunately
+ // other gcc versions report an error if a register which is
+ // implicitely (by "=A") known to be clobbered is also listed
+ // explicitely to be clobbered.
+ //
+ // So the code below is a workaround which tells the compiler
+ // implicitely that the eax ("=a") and edx ("=d") registers
+ // are being used and thus clobbered.
+
+ union
+ {
+ struct
+ {
+ uint32_t lo;
+ uint32_t hi;
+ } u32;
+
+ uint64_t u64;
+
+ } tsc_val;
+
+ __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
+
+ return tsc_val.u64;
+
+ } // mbg_rdtscll
+
+#endif
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
+{
+#if !defined( OMIT_PC_CYCLES_SUPPORT )
+
+ #if defined( MBG_TGT_WIN32 )
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ *p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
+ #else // user space
+ QueryPerformanceCounter( (LARGE_INTEGER *) p );
+ #endif
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 )
+
+ *p = mbg_rdtscll();
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 ) && defined( MBG_TGT_KERNEL )
+
+ unsigned long result = ia64_getreg( _IA64_REG_AR_ITC );
+ ia64_barrier();
+
+ #ifdef CONFIG_ITANIUM
+ while (unlikely((__s32) result == -1)) {
+ result = ia64_getreg(_IA64_REG_AR_ITC);
+ ia64_barrier();
+ }
+ #endif
+
+ *p = result;
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_TGT_KERNEL )
+
+ *p = get_cycles();
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 )
+
+ *p = mbg_rdtscll();
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #elif defined( MBG_TGT_NETBSD ) && defined ( MBG_TGT_KERNEL )
+
+ *p = cpu_counter(); //##++ or cpu_counter_serializing()
+
+ #define MBG_PC_CYCLES_SUPPORTED 1
+
+ #endif
+
+#endif
+
+
+ #if !defined( MBG_PC_CYCLES_SUPPORTED )
+
+ *p = 0;
+ #define MBG_PC_CYCLES_SUPPORTED 0
+
+ #endif
+
+} // mbg_get_pc_cycles
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+ LARGE_INTEGER li;
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ KeQueryPerformanceCounter( &li );
+ #else // user space
+ QueryPerformanceFrequency( &li );
+ #endif
+
+ *p = li.QuadPart;
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
+
+ *p = ( cpu_khz * 1000 );
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 )
+
+ // we probably can use
+ // ia64_sal_freq_base(unsigned long which, unsigned long *ticks_per_second,
+ // unsigned long *drift_info)
+ // However, this is not tested.
+
+ *p = 0;
+
+ #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL )
+
+ *p = tsc_freq;
+
+ #elif defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL )
+
+ *p = cpu_frequency( curcpu() );
+
+ #else
+
+ *p = 0;
+
+ #endif
+
+} // mbg_get_pc_cycles_frequency
+
+
+
+static __mbg_inline
+MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
+{
+#if 0 && !MBG_PC_CYCLES_SUPPORTED
+ // Cycle counts not supported on this target platform.
+ // Under SPARC this may even result in bus errors
+ // due to alignment of the underlying data structures.
+ return 0;
+#else
+ return *p1 - *p2;
+#endif
+
+} // mbg_delta_pc_cycles
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+/* (no header definitions found) */
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGPCCYC */
diff --git a/c/mbglib/include/mbgserio.h b/c/mbglib/include/mbgserio.h
new file mode 100644
index 0000000..a0d9314
--- /dev/null
+++ b/c/mbglib/include/mbgserio.h
@@ -0,0 +1,192 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgserio.h 1.6.1.5 2011/12/15 14:20:58Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for mbgserio.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgserio.h $
+ * Revision 1.6.1.5 2011/12/15 14:20:58Z martin
+ * Tmp. debug code to test flush under Windows.
+ * Revision 1.6.1.4 2011/12/13 08:36:50Z martin
+ * Got rid of _mbg_open/clos/read/write() macros.
+ * Revision 1.6.1.3 2011/12/13 08:24:56 martin
+ * Removed most _mbgderio_...() function macros.
+ * Revision 1.6.1.2 2011/12/12 17:20:24 martin
+ * Revision 1.6.1.1 2011/12/12 16:12:25 martin
+ * Started to get rid of _mbgserio_read/write macros.
+ * Use functions instead.
+ * Revision 1.6 2011/08/23 10:15:25Z martin
+ * Updated function prototypes.
+ * Revision 1.5 2011/08/04 09:48:55 martin
+ * Support flushing output.
+ * Re-ordered some definitions.
+ * Revision 1.4 2009/09/01 10:54:29 martin
+ * Include mbg_tmo.h for the new portable timeout functions.
+ * Added symbols for return codes in case of an error.
+ * Code cleanup.
+ * Revision 1.3 2009/04/01 14:17:31 martin
+ * Cleanup for CVI.
+ * Revision 1.2 2008/09/04 15:11:36Z martin
+ * Preliminary support for device lists.
+ * Updated function prototypes.
+ * Revision 1.1 2007/11/12 16:48:02 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGSERIO_H
+#define _MBGSERIO_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tmo.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined( MBG_TGT_UNIX )
+ #include <termios.h>
+#endif
+
+#if _USE_CHK_TSTR
+ #include <chk_tstr.h>
+#endif
+
+#if !defined( _USE_SELECT_FOR_SERIAL_IO )
+ #if defined( MBG_TGT_UNIX )
+ #define _USE_SELECT_FOR_SERIAL_IO 1
+ #else
+ #define _USE_SELECT_FOR_SERIAL_IO 0
+ #endif
+#endif
+
+
+#ifdef _MBGSERIO
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#define MBGSERIO_FAIL -1 // Generic I/O error
+#define MBGSERIO_TIMEOUT -2 // timeout
+#define MBGSERIO_INV_CFG -3 // invalid configuration parameters
+
+
+#if !defined( DEFAULT_DEV_NAME )
+ #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_DOS )
+ #define DEFAULT_DEV_NAME "COM1"
+ #elif defined( MBG_TGT_LINUX )
+ #define DEFAULT_DEV_NAME "/dev/ttyS0"
+ #endif
+#endif
+
+
+/*
+ * The following macros control parts of the build process.
+ * The default values are suitable for most cases but can be
+ * overridden by global definitions, if required.
+ */
+
+#if _IS_MBG_FIRMWARE
+
+ // This handle type in not used by the firmware.
+ // However, we define it to avoid build errors.
+ typedef int MBG_HANDLE;
+
+#else
+
+ #if defined( MBG_TGT_CVI )
+
+ #include <rs232.h>
+
+ #elif defined( MBG_TGT_WIN32 )
+
+ #include <windows.h>
+ #include <io.h>
+
+ #elif defined( MBG_TGT_UNIX )
+
+ #include <unistd.h>
+
+ #elif defined( MBG_TGT_DOS )
+
+ #if defined( _USE_V24TOOLS )
+ #include <v24tools.h>
+ #endif
+
+ #endif
+
+#endif
+
+
+
+typedef struct _MBG_STR_LIST
+{
+ char *s;
+ struct _MBG_STR_LIST *next;
+
+} MBG_STR_LIST;
+
+
+
+typedef struct
+{
+ MBG_PORT_HANDLE port_handle; // the handle that will be used for the device
+
+ #if defined( MBG_TGT_WIN32 )
+ DCB old_dcb;
+ COMMTIMEOUTS old_commtimeouts;
+ COMMPROP comm_prop;
+ #endif
+
+ #if defined( MBG_TGT_UNIX )
+ struct termios old_tio;
+ #endif
+
+} SERIAL_IO_STATUS;
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_open( SERIAL_IO_STATUS *pst, const char *dev ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_close( SERIAL_IO_STATUS *pst ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_setup_port_str_list( MBG_STR_LIST **list, int max_devs ) ;
+ _NO_MBG_API_ATTR void _MBG_API mbgserio_free_str_list( MBG_STR_LIST *list ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_set_parms( SERIAL_IO_STATUS *pst, uint32_t baud_rate, const char *framing ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_read( MBG_PORT_HANDLE h, void *buffer, unsigned int count ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_write( MBG_PORT_HANDLE h, const void *buffer, unsigned int count ) ;
+ _NO_MBG_API_ATTR void _MBG_API mbgserio_flush_tx( MBG_PORT_HANDLE h ) ;
+ _NO_MBG_API_ATTR int _MBG_API mbgserio_read_wait( MBG_PORT_HANDLE h, void *buffer, uint count, ulong char_timeout ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGSERIO_H */
diff --git a/c/mbglib/include/mbgsvcio.h b/c/mbglib/include/mbgsvcio.h
index 83ec1ae..95e94a5 100644
--- a/c/mbglib/include/mbgsvcio.h
+++ b/c/mbglib/include/mbgsvcio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsvcio.h 1.16 2009/08/14 09:28:13Z daniel REL_M $
+ * $Id: mbgsvcio.h 1.16.1.2 2010/01/08 15:04:38Z martin TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsvcio.h $
+ * Revision 1.16.1.2 2010/01/08 15:04:38Z martin
+ * Revision 1.16.1.1 2010/01/07 16:24:56Z martin
* Revision 1.16 2009/08/14 09:28:13Z daniel
* New version code 306, compatibility version code still 200.
* Revision 1.15 2009/06/09 08:57:47Z daniel
@@ -53,6 +55,8 @@
/* Other headers to be included */
#include <mbg_tgt.h>
+#include <mbgdevio.h> // for mutex support only
+#include <timecnv.h> // for REF_TIME only
@@ -74,6 +78,7 @@
#define MBGSVCIO_COMPAT_VERSION 0x0200
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -149,6 +154,68 @@ extern "C" {
*/
_MBG_API_ATTR int _MBG_API mbg_get_ref_time_status( void ) ;
+ /**
+ Save the latest date and time from a serial time string
+ plus the associated PC cycles count, so other processes
+ or functions can use the current cycles count together
+ with this data pair to interpolate the time between two
+ time strings.
+
+ This function is (and should only be) called by the time
+ adjustment service.
+
+ @return MBG_SUCCESS always
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_serial_xhrt_data( const REF_TIME_CYCLES *p ) ;
+
+ /**
+ Set the "invalid time" flag (PCPS_INVT) in the status of the
+ saved serial date and time. This is normally done by time
+ adjustment service if the serial string times out, e.g. because
+ the serial device has been disconnected.
+
+ @return MBG_SUCCESS always
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_serial_xhrt_data_invalid( void ) ;
+
+ /**
+ Retrieve the latest date and time from a serial time string
+ plus the associated PC cycles count, so this data pair can
+ be used to interpolate the time between two serial strings
+ using the current cycles count.
+
+ @return MBG_SUCCESS always
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_serial_xhrt_data( uint64_t *tstamp, MBG_XHRT_VARS *vars ) ;
+
+ /**
+ Retrieve a time stamp in PCPS_HR_TIME format which is extrapolated
+ using the system's current cycles counter value and a time stamp
+ plus associated cycles counter value from a serial time string,
+ saved by the time adjustment service.
+
+ @param *p_hrt Pointer to a ::PCPS_HR_TIME structure to be filled up.
+
+ @return MBG_SUCCESS
+
+ @see mbg_get_serial_xhrt_time_as_filetime()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_serial_xhrt_time_as_pcps_hr_time( PCPS_HR_TIME *p_hrt ) ;
+
+ /**
+ Retrieve a time stamp in FILETIME format which is extrapolated
+ using the system's current cycles counter value and a time stamp
+ plus associated cycles counter value from a serial time string,
+ saved by the time adjustment service.
+
+ @param *p_ft Pointer to a ::FILETIME structure to be filled up.
+
+ @return MBG_SUCCESS
+
+ @see mbg_get_serial_xhrt_time_as_pcps_hr_time()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_serial_xhrt_time_as_filetime( FILETIME *p_ft ) ;
+
/* ----- function prototypes end ----- */
diff --git a/c/mbglib/include/mbgsvctl.h b/c/mbglib/include/mbgsvctl.h
new file mode 100644
index 0000000..5887cee
--- /dev/null
+++ b/c/mbglib/include/mbgsvctl.h
@@ -0,0 +1,263 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgsvctl.h 1.28.1.1 2010/09/16 14:01:24Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for servio.c
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgsvctl.h $
+ * Revision 1.28.1.1 2010/09/16 14:01:24Z martin
+ * Branch used to test handle leak under Win Server 2008.
+ * Revision 1.28 2009/12/15 15:35:09Z daniel
+ * Revision 1.27.1.1 2009/12/02 13:50:30Z martin
+ * Revision 1.27 2009/08/14 09:28:41 daniel
+ * New version code 306, compatibility version code still 214.
+ * Revision 1.26 2009/06/09 08:57:47Z daniel
+ * Rev No. 305
+ * Revision 1.25 2009/03/19 09:07:26Z daniel
+ * New version code 304, compatibility version code still 214.
+ * Revision 1.24 2009/01/28 10:38:15Z daniel
+ * Added serial flag SERCLOCK_STRING_PER_MINUTE and
+ * bit mask MSK_SERCLOCK_STRING_PER_MINUTE.
+ * Revision 1.23 2009/01/12 10:14:23Z daniel
+ * New version code 303, compatibility version code still 214.
+ * Changed UINT to uint32_t and LPTSTR to char*.
+ * Added MBGADJTM_CFG parameters allow_timestep_on_refclk_jump
+ * and allow_initial_timestep.
+ * Avoid including mbgdevio.h when MBG_OMIT_MBGDEVIO_H is defined.
+ * Updated function prototypes.
+ * Revision 1.22 2008/01/30 07:53:58Z daniel
+ * New version code 302, compatibility version code still 214.
+ * Added new members to MBGADJTM_CFG structure to
+ * support service event handling.
+ * Revision 1.21 2007/10/16 10:09:51Z daniel
+ * New file version 3,1,0,0, product version 3,1,0,0.
+ * New version code 301, compatibility version code still 214.
+ * Revision 1.20 2007/09/26 14:46:43Z martin
+ * New version code 300, compatibility version code still 214.
+ * Identify selected device by hardware ID instead of device index.
+ * Removed obsolete references to ASCII log file.
+ * Updated function prototypes.
+ * Revision 1.19 2007/03/21 16:46:27Z martin
+ * New version code 219, compatibility version code still 214.
+ * Changes due to renamed library symbols.
+ * Updated function prototypes.
+ * Revision 1.18 2006/10/31 16:24:09Z martin
+ * Added a serial port flag which prevents the read thread from
+ * using special timeout settings.
+ * Revision 1.17 2006/08/09 13:31:11Z martin
+ * New version code 218, compatibility version code still 214.
+ * Revision 1.16 2006/06/08 10:36:10Z martin
+ * New version code 217, compatibility version code still 214.
+ * Revision 1.15 2006/05/23 19:35:15Z martin
+ * Updated function prototypes.
+ * Revision 1.14 2006/05/02 10:08:51Z martin
+ * New version code 216, compatibility version code still 214.
+ * Revision 1.13 2006/01/11 11:45:05Z martin
+ * New version code 215, compatibility version code still 214.
+ * Revision 1.12 2005/12/15 09:02:05Z martin
+ * New version 214 and compatibility version 214.
+ * New service registry parameter "flags" which controls
+ * logging time adjustment details, and starting paused.
+ * Updated function prototypes.
+ * Revision 1.11.1.1 2005/11/28 17:08:34Z martin
+ * Revision 1.11 2005/07/20 07:23:58Z martin
+ * New version 213 and compatibility version 213.
+ * New service cfg parameters notification_limit and
+ * set_mm_timer.
+ * Updated function prototypes.
+ * Revision 1.10 2004/04/27 13:46:40Z martin
+ * New member flags in MBG_SERCLOCK_CFG.
+ * Revision 1.9 2004/04/27 07:17:47Z martin
+ * Changed type of MBG_SERCLOCK_CFG::ref_offs.
+ * Removed function prototypes that are used in exe-File only
+ * New definition MBGSVCIO_COMPAT_VERSION.
+ * Pack structures 1 byte aligned.
+ * Updated function protoypes.
+ * Revision 1.8 2003/12/22 15:55:57Z martin
+ * New DLL interface version number.
+ * Updated function prototypes.
+ * Revision 1.7 2003/12/10 10:41:50Z martin
+ * New DLL interface version number.
+ * Revision 1.6 2003/10/31 11:11:11Z martin
+ * New DLL interface version number.
+ * New structures with config parameters.
+ * Updated function prototypes.
+ * Revision 1.5 2003/09/23 09:58:36Z martin
+ * Updated function prototypes.
+ * Revision 1.4 2003/04/09 15:24:01Z martin
+ * Module renamed from servio.h.
+ * Include standard names and reg paths.
+ * Updated function prototypes.
+ * Revision 1.3 2002/09/30 07:54:35Z martin
+ * Updated function prototypes by MAKEHDR.
+ * Revision 1.2 2002/02/22 10:35:11Z Daniel
+ * Revision 1.1 2002/02/18 10:52:18Z Daniel
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _MBGSVCTL_H
+#define _MBGSVCTL_H
+
+
+/* Other headers to be included */
+
+#if !defined MBG_OMIT_MBGDEVIO_H
+ #include <mbgdevio.h>
+#else
+ typedef void* MBG_DEVICE_LIST;
+#endif
+
+#include <mbg_tgt.h>
+#include <use_pack.h>
+#include <gpsdefs.h>
+
+#if defined( MBG_TGT_WIN32 )
+ #include <rs232.h>
+#else
+ #include <mbgserio.h>
+#endif
+
+
+#ifdef _MBGSVCTL
+ #define _ext
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK ) // set byte alignment
+ #pragma pack( 1 )
+#endif
+
+
+#define MBGSVCTL_VERSION 0x0307
+
+#define MBGSVCTL_COMPAT_VERSION 0x0214
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct
+{
+ char hardware_id[256];
+ DWORD ignore_sync;
+ DWORD sync_radius;
+ DWORD repeat_count;
+ DWORD max_diff;
+ DWORD set_local_time;
+ DWORD gen_statistics;
+ DWORD notification_limit;
+ DWORD set_mm_timer;
+ DWORD evt_handling_enabled;
+ DWORD async_evt_cmd_delay;
+ char async_evt_cmd[256];
+ char sync_evt_cmd[256];
+ DWORD allow_initial_timestep;
+ DWORD allow_timestep_on_refclk_jump;
+ DWORD flags;
+} MBGADJTM_CFG;
+
+// Bit masks used with MBGADJTM_CFG::flags:
+#define MBGADJTM_CFG_LOG_DETAILS 0x00000001
+#define MBGADJTM_CFG_START_PAUSED 0x00000002
+
+
+
+typedef struct
+{
+ COMSTRUCT port;
+ DWORD telegram_type;
+ DWORD ref_type;
+ DWORD flags;
+ MBG_REF_OFFS ref_offs_min;
+} MBG_SERCLOCK_CFG;
+
+
+// Bit masks used with MBG_SERCLOCK_CFG::flags:
+enum
+{
+ SERCLOCK_FORCE_UTC, // string contains always UTC time
+ SERCLOCK_READ_NORMAL, // don't use special timeout settings
+ SERCLOCK_STRING_PER_MINUTE, // account for serial string once per minute
+ N_SERCLOCK_FLAGS
+};
+
+#define MSK_SERCLOCK_FORCE_UTC ( 1UL << SERCLOCK_FORCE_UTC )
+#define MSK_SERCLOCK_READ_NORMAL ( 1UL << SERCLOCK_READ_NORMAL )
+#define MSK_SERCLOCK_STRING_PER_MINUTE ( 1UL << SERCLOCK_STRING_PER_MINUTE )
+
+
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ _MBG_API_ATTR int _MBG_API mbgsvctl_get_version( void ) ;
+ _MBG_API_ATTR int _MBG_API mbgsvctl_check_version( int header_version ) ;
+ _MBG_API_ATTR void _MBG_API mbgsvctl_log_mbgdevio_error( DWORD ioctl, DWORD rc ) ;
+ _MBG_API_ATTR int _MBG_API sprint_system_time( char *ws, SYSTEMTIME *st ) ;
+ _MBG_API_ATTR int _MBG_API mbg_svc_register_event_source( const char *eventlog_name ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_snprint_cfg( char *s, size_t max_len, MBGADJTM_CFG *curr_adjtm_cfg, MBGADJTM_CFG *prev_adjtm_cfg, MBG_SERCLOCK_CFG *curr_serclock_cfg, MBG_SERCLOCK_CFG *prev_serclock_cfg ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_log_msg( DWORD dwIdEvent, DWORD err_code, const char *fmt, const char *info_1, const char *info_2 ) ;
+ _MBG_API_ATTR BOOL _MBG_API mbg_svc_has_admin_rights( void ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_free_device_list( MBG_DEVICE_LIST *devices ) ;
+ _MBG_API_ATTR int _MBG_API mbg_svc_find_devices( void ) ;
+ _MBG_API_ATTR int _MBG_API mbg_svc_find_devices_with_hw_id( MBG_DEVICE_LIST **device_list, int max_devices ) ;
+ _MBG_API_ATTR const char * _MBG_API mbg_svc_get_device_path( unsigned int device_index ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_set_mbgadjtm_cfg( const MBGADJTM_CFG *p ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_mbgadjtm_cfg( MBGADJTM_CFG *p ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_get_mbgadjtm_cfg_default( MBGADJTM_CFG *p ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_set_mbg_serclock_cfg( const MBG_SERCLOCK_CFG *p ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_mbg_serclock_cfg( MBG_SERCLOCK_CFG *p ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_get_mbg_serclock_cfg_default( MBG_SERCLOCK_CFG *p ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_msgs_filename( char *s, size_t size ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_stats_filename( char *s, size_t size ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_adjtm_filename( char *s, size_t size ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_query_status( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_start( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_stop( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_pause( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_continue( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_install( const char *svc_name, DWORD svc_type, DWORD svc_start_type, const char *svc_disp_name, const char *svc_description, const char *svc_exe_path, const char *svc_dependencies ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_remove( const char *svc_name ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_set_autostart( const char *svc_name, BOOL autostart ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_set_description( const char *svc_name, const char *descr ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_set_ctry_code( const DWORD *p ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_ctry_code( DWORD *p ) ;
+ _MBG_API_ATTR void _MBG_API mbg_svc_get_ctry_code_default( DWORD *p ) ;
+ _MBG_API_ATTR const char * _MBG_API mbg_svc_name_time_adjustment( void ) ;
+ _MBG_API_ATTR const char * _MBG_API mbg_svc_name_clock_kernel_driver( void ) ;
+ _MBG_API_ATTR const char * _MBG_API mbg_svc_name_ntp( void ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_get_exe_path( char* svc_exe_path, uint32_t svc_exe_path_max_len, const char *svc_exe_name, const char *subdir ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_install_time_adjustment( void ) ;
+ _MBG_API_ATTR DWORD _MBG_API mbg_svc_uninstall_time_adjustment( void ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USE_PACK ) // set default alignment
+ #pragma pack()
+#endif
+
+/* End of header body */
+
+#undef _ext
+
+#endif // _MBGSVCTL_H
+
diff --git a/c/mbglib/include/mbgtime.h b/c/mbglib/include/mbgtime.h
index 774ee69..541d462 100644
--- a/c/mbglib/include/mbgtime.h
+++ b/c/mbglib/include/mbgtime.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgtime.h 1.12 2009/03/27 14:14:00Z martin TEST $
+ * $Id: mbgtime.h 1.17.1.7 2011/10/21 14:07:52Z martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,30 @@
*
* -----------------------------------------------------------------------
* $Log: mbgtime.h $
- * Revision 1.12 2009/03/27 14:14:00Z martin
+ * Revision 1.17.1.7 2011/10/21 14:07:52Z martin
+ * Changes for QNX.
+ * Revision 1.17.1.6 2011/05/06 09:03:12 martin
+ * Fix for DOS.
+ * Revision 1.17.1.5 2011/05/06 08:07:58Z daniel
+ * include <time.h> for WIN32 target and firmware only
+ * Revision 1.17.1.4 2011/02/09 15:46:48Z martin
+ * Revision 1.17.1.3 2011/01/24 17:09:20 martin
+ * Fixed build under FreeBSD.
+ * Revision 1.17.1.2 2010/08/13 11:57:13 martin
+ * Revision 1.17.1.1 2010/08/13 11:39:20Z martin
+ * Revision 1.17 2010/08/06 13:03:03 martin
+ * Removed obsolete code.
+ * Revision 1.16 2010/07/16 10:22:07Z martin
+ * Moved definitions of HNS_PER_SEC and HNS_PER_MS here.
+ * Conditionally define FILETIME_1970.
+ * Defined MASK_CLOCK_T for ARM/Cortex.
+ * Revision 1.15 2009/10/23 09:55:21 martin
+ * Added MJD numbers for commonly used epochs.
+ * Revision 1.14 2009/08/12 10:28:12 daniel
+ * Added definition NSECS_PER_SEC.
+ * Revision 1.13 2009/06/12 13:31:44Z martin
+ * Fix build errors with arm-linux-gcc.
+ * Revision 1.12 2009/03/27 14:14:00 martin
* Cleanup for CVI.
* Revision 1.11 2009/03/13 09:30:06Z martin
* Include mystd.h in mbgtime.c rather than here. The bit type used
@@ -44,7 +67,13 @@
#include <gpsdefs.h>
-#include <time.h>
+#if _IS_MBG_FIRMWARE \
+ || defined( MBG_TGT_WIN32 ) \
+ || defined( MBG_TGT_DOS ) \
+ || defined( MBG_TGT_QNX_NTO )
+ #include <time.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
@@ -59,12 +88,6 @@ extern "C" {
/* Start of header body */
-#ifdef _166
- #define _const const
-#else
- #define _const
-#endif
-
// The Unix time_t epoche is usually 1970-01-01 00:00 whereas
// the GPS epoche is 1980-01-06 00:00, so the difference is 10 years,
@@ -75,6 +98,31 @@ extern "C" {
// time_t t = ( gps_week * SECS_PER_WEEK ) + sec_of_week + GPS_SEC_BIAS
+// Modified Julian Day (MJD) numbers for some commonly used epochs.
+// To compute the MJD for a given date just compute the days since epoch
+// and add the constant number of days according to the epoch, e.g.:
+// current_unix_mjd = ( time( NULL ) / SECS_PER_DAY ) + MJD_AT_UNIX_EPOCH;
+#define MJD_AT_GPS_EPOCH 44244UL // MJD at 1980-01-06
+#define MJD_AT_UNIX_EPOCH 40587UL // MJD at 1970-01-01
+#define MJD_AT_NTP_EPOCH 40587UL // MJD at 1900-01-01
+
+
+// The constant below defines the Windows FILETIME number (100 ns intervals
+// since 1601-01-01) for 1970-01-01, which is usually the epoche for the time_t
+// type used by the standard C library.
+#if !defined( FILETIME_1970 )
+ // FILETIME represents a 64 bit number, so we need to defined the
+ // constant with an appendix depending on the compiler.
+ #if MBG_TGT_C99 || defined( __GNUC__ )
+ // syntax introduced by C99 standard
+ #define FILETIME_1970 0x019db1ded53e8000ULL // Epoch offset from FILETIME to UNIX
+ #elif defined( MBG_TGT_WIN32 )
+ // MSC-specific syntax
+ #define FILETIME_1970 0x019db1ded53e8000ui64
+ #endif
+#endif
+
+
#if defined( _C166 )
#if _C166 >= 50
#define MASK_CLOCK_T 0x7FFFFFFFL
@@ -103,6 +151,10 @@ extern "C" {
#define MASK_CLOCK_T 0x7FFFFFFFL
#endif
+#if defined( __ARMCC_VERSION )
+ #define MASK_CLOCK_T ( ( (ulong) (clock_t) -1 ) >> 1 )
+#endif
+
#if defined( __GNUC__ )
#if defined( __linux )
#define MASK_CLOCK_T ( ( (ulong) (clock_t) -1 ) >> 1 )
@@ -146,11 +198,24 @@ typedef struct
#define SEC100S_PER_HOUR ( SEC100S_PER_SEC * SECS_PER_HOUR )
#define SEC100S_PER_DAY ( SEC100S_PER_SEC * SECS_PER_DAY )
-#define MSEC_PER_SEC 1000L
+#if !defined( MSEC_PER_SEC )
+ #define MSEC_PER_SEC 1000L
+#endif
+
#define MSEC_PER_MIN ( MSEC_PER_SEC * SECS_PER_MIN )
#define MSEC_PER_HOUR ( MSEC_PER_SEC * SECS_PER_HOUR )
#define MSEC_PER_DAY ( MSEC_PER_SEC * SECS_PER_DAY )
+#define NSECS_PER_SEC 1000000000UL
+
+#if !defined( HNS_PER_SEC )
+ #define HNS_PER_SEC 10000000UL
+#endif
+
+#if !defined( HNS_PER_MS )
+ #define HNS_PER_MS 10000UL
+#endif
+
_ext TM_GPS dhms;
@@ -199,7 +264,7 @@ _ext const char *day_name_ger[]
#endif
;
-_ext _const TM_GPS init_tm
+_ext const TM_GPS init_tm
#ifdef _MBGTIME
= { 1980, 1, 1, 0, 0, 0, 0, 0, 0, 0 }
#endif
diff --git a/c/mbglib/include/mbgutil.h b/c/mbglib/include/mbgutil.h
index 7de28ae..09d53ee 100644
--- a/c/mbglib/include/mbgutil.h
+++ b/c/mbglib/include/mbgutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgutil.h 1.16 2009/08/14 10:11:53Z daniel REL_M $
+ * $Id: mbgutil.h 1.16.1.2 2011/06/22 10:21:57Z martin TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgutil.h $
+ * Revision 1.16.1.2 2011/06/22 10:21:57Z martin
+ * Cleaned up handling of pragma pack().
+ * Revision 1.16.1.1 2011/02/09 15:27:23 martin
+ * Include stdlib.h.
* Revision 1.16 2009/08/14 10:11:53Z daniel
* New version code 306, compatibility version still 110.
* Revision 1.15 2009/06/09 08:57:47Z daniel
@@ -57,6 +61,8 @@
#include <mbggeo.h>
#include <pci_asic.h>
+#include <stdlib.h>
+
#define MBGUTIL_VERSION 0x0306
@@ -92,8 +98,9 @@
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
@@ -166,8 +173,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/messages.h b/c/mbglib/include/messages.h
new file mode 100644
index 0000000..2a3e99e
--- /dev/null
+++ b/c/mbglib/include/messages.h
@@ -0,0 +1,1151 @@
+
+/**************************************************************************
+ *
+ * $Id: messages.h 1.10 2009/12/15 15:35:59Z daniel REL_M $
+ * $Name: $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * This file contains the message definitions for the Win32
+ * syslog support messages for the mbgsvctl DLL.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: messages.h $
+ * Revision 1.10 2009/12/15 15:35:59Z daniel
+ * Support new message codes for GPS mode and antenna status.
+ * Revision 1.10 2009/03/11 10:09:34Z daniel
+ * New codes regarding different time scales
+ * Revision 1.9 2009/01/14 11:31:35Z daniel
+ * Added new codes.
+ * Revision 1.8.1.3 2009/01/05 09:08:08Z daniel
+ * Revision 1.8.1.2 2008/11/21 11:08:45Z daniel
+ * Revision 1.8.1.1 2008/04/17 14:27:00Z daniel
+ * Revision 1.7 2008/02/06 10:01:14Z daniel
+ * 3 new commands
+ * Revision 1.6 2008/02/05 14:57:48Z daniel
+ * Added new code.
+ * Revision 1.5 2008/01/18 14:43:29Z daniel
+ * Adjusted code.
+ * Revision 1.4 2008/01/09 16:24:15Z daniel
+ * New message codes regarding batch file execution on status change.
+ * Revision 1.3 2007/09/26 15:00:11Z martin
+ * Added new language specific message codes and strings.
+ * Revision 1.2 2003/10/28 15:18:02Z martin
+ * Changed default language to unspecified.
+ * Added file header.
+ * Revision 1.1 2002/10/14 10:00:38Z Udo
+ * Initial revision
+ *
+ **************************************************************************/
+
+ /*
+ Microsoft Developer Support
+ Copyright 1992 - 1999 Microsoft Corporation
+
+ This file contains the message definitions for the Win32
+ messages.exe sample program.
+-------------------------------------------------------------------------
+ HEADER SECTION
+
+ The header section defines names and language identifiers for use
+ by the message definitions later in this file. The MessageIdTypedef,
+ SeverityNames, FacilityNames, and LanguageNames keywords are
+ optional and not required.
+
+
+
+ The MessageIdTypedef keyword gives a typedef name that is used in a
+ type cast for each message code in the generated include file. Each
+ message code appears in the include file with the format: #define
+ name ((type) 0xnnnnnnnn) The default value for type is empty, and no
+ type cast is generated. It is the programmer's responsibility to
+ specify a typedef statement in the application source code to define
+ the type. The type used in the typedef must be large enough to
+ accomodate the entire 32-bit message code.
+
+
+
+ The SeverityNames keyword defines the set of names that are allowed
+ as the value of the Severity keyword in the message definition. The
+ set is delimited by left and right parentheses. Associated with each
+ severity name is a number that, when shifted left by 30, gives the
+ bit pattern to logical-OR with the Facility value and MessageId
+ value to form the full 32-bit message code. The default value of
+ this keyword is:
+
+ SeverityNames=(
+ Success=0x0
+ Informational=0x1
+ Warning=0x2
+ Error=0x3
+ )
+
+ Severity values occupy the high two bits of a 32-bit message code.
+ Any severity value that does not fit in two bits is an error. The
+ severity codes can be given symbolic names by following each value
+ with :name
+
+
+
+ The FacilityNames keyword defines the set of names that are allowed
+ as the value of the Facility keyword in the message definition. The
+ set is delimited by left and right parentheses. Associated with each
+ facility name is a number that, when shift it left by 16 bits, gives
+ the bit pattern to logical-OR with the Severity value and MessageId
+ value to form the full 32-bit message code. The default value of
+ this keyword is:
+
+ FacilityNames=(
+ System=0x0FF
+ Application=0xFFF
+ )
+
+ Facility codes occupy the low order 12 bits of the high order
+ 16-bits of a 32-bit message code. Any facility code that does not
+ fit in 12 bits is an error. This allows for 4,096 facility codes.
+ The first 256 codes are reserved for use by the system software. The
+ facility codes can be given symbolic names by following each value
+ with :name
+
+
+ The LanguageNames keyword defines the set of names that are allowed
+ as the value of the Language keyword in the message definition. The
+ set is delimited by left and right parentheses. Associated with each
+ language name is a number and a file name that are used to name the
+ generated resource file that contains the messages for that
+ language. The number corresponds to the language identifier to use
+ in the resource table. The number is separated from the file name
+ with a colon.
+
+LanguageNames=(English=0x409:MSG00409)
+LanguageNames=(Japanese=0x411:MSG00411)
+
+ Any new names in the source file which don't override the built-in
+ names are added to the list of valid languages. This allows an
+ application to support private languages with descriptive names.
+
+
+-------------------------------------------------------------------------
+ MESSAGE DEFINITION SECTION
+
+ Following the header section is the body of the Message Compiler
+ source file. The body consists of zero or more message definitions.
+ Each message definition begins with one or more of the following
+ statements:
+
+ MessageId = [number|+number]
+ Severity = severity_name
+ Facility = facility_name
+ SymbolicName = name
+
+ The MessageId statement marks the beginning of the message
+ definition. A MessageID statement is required for each message,
+ although the value is optional. If no value is specified, the value
+ used is the previous value for the facility plus one. If the value
+ is specified as +number then the value used is the previous value
+ for the facility, plus the number after the plus sign. Otherwise, if
+ a numeric value is given, that value is used. Any MessageId value
+ that does not fit in 16 bits is an error.
+
+ The Severity and Facility statements are optional. These statements
+ specify additional bits to OR into the final 32-bit message code. If
+ not specified they default to the value last specified for a message
+ definition. The initial values prior to processing the first message
+ definition are:
+
+ Severity=Success
+ Facility=Application
+
+ The value associated with Severity and Facility must match one of
+ the names given in the FacilityNames and SeverityNames statements in
+ the header section. The SymbolicName statement allows you to
+ associate a C/C++ symbolic constant with the final 32-bit message
+ code.
+ */
+//
+//
+// DEFAULT MESSAGES
+// -----------------
+//
+//
+// Values are 32 bit values layed out as follows:
+//
+// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+// +---+-+-+-----------------------+-------------------------------+
+// |Sev|C|R| Facility | Code |
+// +---+-+-+-----------------------+-------------------------------+
+//
+// where
+//
+// Sev - is the severity code
+//
+// 00 - Success
+// 01 - Informational
+// 10 - Warning
+// 11 - Error
+//
+// C - is the Customer code flag
+//
+// R - is a reserved bit
+//
+// Facility - is the facility code
+//
+// Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+#define FACILITY_SYSTEM 0x0
+#define FACILITY_STUBS 0x3
+#define FACILITY_RUNTIME 0x2
+#define FACILITY_IO_ERROR_CODE 0x4
+
+
+//
+// Define the severity codes
+//
+#define STATUS_SEVERITY_WARNING 0x2
+#define STATUS_SEVERITY_SUCCESS 0x0
+#define STATUS_SEVERITY_INFORMATIONAL 0x1
+#define STATUS_SEVERITY_ERROR 0x3
+
+
+//
+// MessageId: MBG_ERROR
+//
+// MessageText:
+//
+// %1
+//
+#define MBG_ERROR ((DWORD)0xE0001001L)
+
+//
+// MessageId: MBG_WARNING
+//
+// MessageText:
+//
+// %1
+//
+#define MBG_WARNING ((DWORD)0xA0001002L)
+
+//
+// MessageId: MBG_INFO
+//
+// MessageText:
+//
+// %1
+//
+#define MBG_INFO ((DWORD)0x60001003L)
+
+//
+//
+// DEVICE DRIVER MESSAGES
+// ------------------------
+//
+// NOTE: Changes of the codes below
+// must match to the corresponding
+// codes defined in
+// pcpsdev.h or mbgerror.h !!!!
+//
+// MessageId: MBG_WINERR_STIME
+//
+// MessageText:
+//
+// %1Invalid date, time and status passed to the device.
+//
+#define MBG_WINERR_STIME ((DWORD)0xE0000001L)
+
+//
+// MessageId: MBG_WINERR_CFG
+//
+// MessageText:
+//
+// %1Invalid or unknown parameters have been sent to the device.
+//
+#define MBG_WINERR_CFG ((DWORD)0xE0000002L)
+
+//
+// MessageId: MBG_WINERR_GENERIC
+//
+// MessageText:
+//
+// %1Unknown device error occured.
+//
+#define MBG_WINERR_GENERIC ((DWORD)0xE0000013L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_TIMEOUT
+//
+// MessageText:
+//
+// %1Timeout accessing the board.
+//
+#define MBG_WINERR_PCPS_ERR_TIMEOUT ((DWORD)0xE0000014L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_FW_ID
+//
+// MessageText:
+//
+// %1Invalid firmware ID.
+//
+#define MBG_WINERR_PCPS_ERR_FW_ID ((DWORD)0xE0000015L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_NBYTES
+//
+// MessageText:
+//
+// %1The number of parameter bytes passed to the board did not match the number of bytes expected.
+//
+#define MBG_WINERR_PCPS_ERR_NBYTES ((DWORD)0xE0000016L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_INV_TIME
+//
+// MessageText:
+//
+// %1The board's time is not valid.
+//
+#define MBG_WINERR_PCPS_ERR_INV_TIME ((DWORD)0xE0000017L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_FIFO
+//
+// MessageText:
+//
+// %1The board's FIFO is empty.
+//
+#define MBG_WINERR_PCPS_ERR_FIFO ((DWORD)0xE0000018L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_NOT_READY
+//
+// MessageText:
+//
+// %1Board is temporary unable to respond (during initialization after RESET).
+//
+#define MBG_WINERR_PCPS_ERR_NOT_READY ((DWORD)0xE0000019L)
+
+//
+// MessageId: MBG_WINERR_PCPS_ERR_INV_TYPE
+//
+// MessageText:
+//
+// %1Board did not recognize data type.
+//
+#define MBG_WINERR_PCPS_ERR_INV_TYPE ((DWORD)0xE000001AL)
+
+//
+// MessageId: MBG_WINERR_NO_MEM
+//
+// MessageText:
+//
+// %1Failed to allocate memory.
+//
+#define MBG_WINERR_NO_MEM ((DWORD)0xE000001BL)
+
+//
+// MessageId: MBG_WINERR_CLAIM_RSRC
+//
+// MessageText:
+//
+// %1Failed to claim port or memory resource.
+//
+#define MBG_WINERR_CLAIM_RSRC ((DWORD)0xE000001CL)
+
+//
+// MessageId: MBG_WINERR_DEV_NOT_SUPP
+//
+// MessageText:
+//
+// %1The specified device is not supported by the driver.
+//
+#define MBG_WINERR_DEV_NOT_SUPP ((DWORD)0xE000001DL)
+
+//
+// MessageId: MBG_WINERR_INV_DEVICE_REQUEST
+//
+// MessageText:
+//
+// %1The device request was invalid.
+//
+#define MBG_WINERR_INV_DEVICE_REQUEST ((DWORD)0xE000001EL)
+
+//
+// MessageId: MBG_WINERR_NOT_IMPLEMENTED
+//
+// MessageText:
+//
+// %1The command or feature is not supported by this device.
+//
+#define MBG_WINERR_NOT_IMPLEMENTED ((DWORD)0xE000001FL)
+
+//
+// MessageId: MBG_WINERR_USB_ACCESS
+//
+// MessageText:
+//
+// %1Timeout while trying to access the USB device.
+//
+#define MBG_WINERR_USB_ACCESS ((DWORD)0xE0000020L)
+
+//
+// MessageId: MBG_WINERR_CYCLIC_TIMEOUT
+//
+// MessageText:
+//
+// %1Cyclic event (IRQ, etc.) did not occur.
+//
+#define MBG_WINERR_CYCLIC_TIMEOUT ((DWORD)0xE0000021L)
+
+//
+// MessageId: MBG_WINERR_FUNC_NOT_SUPP_ON_OS
+//
+// MessageText:
+//
+// %1The function is not supported on this operating system.
+//
+#define MBG_WINERR_FUNC_NOT_SUPP_ON_OS ((DWORD)0xE0000022L)
+
+//
+// MessageId: MBG_WINERR_LIB_NOT_COMPATIBLE
+//
+// MessageText:
+//
+// %1The installed version of the DLL is not compatible with version used to build the application.
+//
+#define MBG_WINERR_LIB_NOT_COMPATIBLE ((DWORD)0xE0000023L)
+
+//
+// MessageId: MBG_WINERR_N_COM_EXCEEDS_SUPP
+//
+// MessageText:
+//
+// %1The number of COM ports provided by the device exceeds the maximum supported by the driver.
+//
+#define MBG_WINERR_N_COM_EXCEEDS_SUPP ((DWORD)0xE0000024L)
+
+//
+// MessageId: MBG_WINERR_N_STR_EXCEEDS_SUPP
+//
+// MessageText:
+//
+// %1The number of string formats supported by the device exceeds the maximum supported by the driver.
+//
+#define MBG_WINERR_N_STR_EXCEEDS_SUPP ((DWORD)0xE0000025L)
+
+//
+// MessageId: MBG_WINERR_IRQ_UNSAFE
+//
+// MessageText:
+//
+// %1The enabled IRQ is unsafe with this firmware/ASIC version.
+//
+#define MBG_WINERR_IRQ_UNSAFE ((DWORD)0xE0000026L)
+
+ //
+ //
+ // MBGSVCTL Messages
+ // -----------------
+
+//
+// MessageId: MBG_WINERR_SVC_NOT_STARTED
+//
+// MessageText:
+//
+// %1 failed to be started.%r%rError:%2
+//
+#define MBG_WINERR_SVC_NOT_STARTED ((DWORD)0xE0000100L)
+
+//
+// MessageId: MBG_WINERR_SVC_NOT_STOPPED
+//
+// MessageText:
+//
+// %1 failed to be stopped.%r%rError:%2
+//
+#define MBG_WINERR_SVC_NOT_STOPPED ((DWORD)0xE0000101L)
+
+//
+// MessageId: MBG_WINERR_API_CALL_IN_FUNCTION
+//
+// MessageText:
+//
+// Failed to %1 in %2.%r%rError: %3
+//
+#define MBG_WINERR_API_CALL_IN_FUNCTION ((DWORD)0xE0000102L)
+
+//
+// MessageId: MBG_WINERR_SET_PRIORITY_CLASS
+//
+// MessageText:
+//
+// Failed to set Priority Class.%r%rError: %1
+//
+#define MBG_WINERR_SET_PRIORITY_CLASS ((DWORD)0xE0000103L)
+
+//
+// MessageId: MBG_WINERR_SET_THREAD_PRIORITY
+//
+// MessageText:
+//
+// Failed to set Thread Priority.%r%rError: %1
+//
+#define MBG_WINERR_SET_THREAD_PRIORITY ((DWORD)0xE0000104L)
+
+//
+// MessageId: MBG_WINERR_FAILED_CHECKING_ADMIN_RIGHTS
+//
+// MessageText:
+//
+// Failed to allocate %1 bytes of memory when checking admin rights.
+//
+#define MBG_WINERR_FAILED_CHECKING_ADMIN_RIGHTS ((DWORD)0xE0000105L)
+
+//
+// MessageId: MBG_WINERR_WRITE_PARAMETER_TO_REGISTRY
+//
+// MessageText:
+//
+// Failed to write parameter to registry: "%1".%r%rError: %2
+//
+#define MBG_WINERR_WRITE_PARAMETER_TO_REGISTRY ((DWORD)0xE0000106L)
+
+//
+// MessageId: MBG_WARNING_READ_PARAMETER_FROM_REGISTRY
+//
+// MessageText:
+//
+// Failed to read parameter from registry: "%1".%r%rError: %2
+//
+#define MBG_WARNING_READ_PARAMETER_FROM_REGISTRY ((DWORD)0xA0000107L)
+
+//
+// MessageId: MBG_WINERR_OPEN_SC_MANAGER
+//
+// MessageText:
+//
+// Failed to open SC Manager.
+//
+#define MBG_WINERR_OPEN_SC_MANAGER ((DWORD)0xE0000108L)
+
+//
+// MessageId: MBG_WINERR_QUERY_SERVICE_STATUS
+//
+// MessageText:
+//
+// Failed to query status of service %1.%r%rError: %2
+//
+#define MBG_WINERR_QUERY_SERVICE_STATUS ((DWORD)0xE0000109L)
+
+//
+// MessageId: MBG_WINERR_SVC_NOT_INSTALLED
+//
+// MessageText:
+//
+// %1 failed to be installed.%r%rError:%2
+//
+#define MBG_WINERR_SVC_NOT_INSTALLED ((DWORD)0xE000010AL)
+
+//
+// MessageId: MBG_WARNING_SVC_NOT_REMOVED
+//
+// MessageText:
+//
+// %1 failed to be removed.%r%rError:%2
+//
+#define MBG_WARNING_SVC_NOT_REMOVED ((DWORD)0xA000010BL)
+
+//
+// MessageId: MBG_WARNING_SVC_SET_AUTOSTART
+//
+// MessageText:
+//
+// Failed to set start type of service %1 to AUTO.%r%rError: %2
+//
+#define MBG_WARNING_SVC_SET_AUTOSTART ((DWORD)0xA000010CL)
+
+//
+// MessageId: MBG_WARNING_SVC_SET_START_MANUAL
+//
+// MessageText:
+//
+// Failed to set start type of service %1 to MANUALLY.%r%rError: %2
+//
+#define MBG_WARNING_SVC_SET_START_MANUAL ((DWORD)0xA000010DL)
+
+//
+// MessageId: MBG_WARNING_WRITE_SVC_DESCRIPTION
+//
+// MessageText:
+//
+// Failed to write description of time adjustment service.%r%rError: %1
+//
+#define MBG_WARNING_WRITE_SVC_DESCRIPTION ((DWORD)0xA000010EL)
+
+//
+// MessageId: MBG_WINERR_TIME_GET_DEV_CAPS
+//
+// MessageText:
+//
+// Function timeGetDevCaps() failed.
+//
+#define MBG_WINERR_TIME_GET_DEV_CAPS ((DWORD)0xE000010FL)
+
+//
+// MessageId: MBG_WINERR_QUERY_PERFORMANCE_FREQUENCY
+//
+// MessageText:
+//
+// Function QueryPerformanceFrequency() failed.
+//
+#define MBG_WINERR_QUERY_PERFORMANCE_FREQUENCY ((DWORD)0xE0000110L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_OPEN_REG_KEY_ADJTM_CFG
+//
+// MessageText:
+//
+// Failed to open registry key %1 while getting adjust time cfg.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_OPEN_REG_KEY_ADJTM_CFG ((DWORD)0xA0000111L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_OPEN_REG_KEY_SERIAL_CFG
+//
+// MessageText:
+//
+// Failed to open registry key %1 while getting serial device cfg.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_OPEN_REG_KEY_SERIAL_CFG ((DWORD)0xA0000112L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_OPEN_REG_KEY_COUNTRY_CODE
+//
+// MessageText:
+//
+// Failed to open registry key %1 while getting country code.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_OPEN_REG_KEY_COUNTRY_CODE ((DWORD)0xA0000113L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_OPEN_REG_KEY_INF_PATH
+//
+// MessageText:
+//
+// Failed to open registry key %1 while getting inf path.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_OPEN_REG_KEY_INF_PATH ((DWORD)0xA0000114L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_OPEN_REG_KEY_DEVICE
+//
+// MessageText:
+//
+// Failed to open registry key for device calling %1.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_OPEN_REG_KEY_DEVICE ((DWORD)0xE0000115L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_CREATE_REG_KEY_ADJTM_CFG
+//
+// MessageText:
+//
+// Failed to create registry key %1 when writing time service configuration.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_CREATE_REG_KEY_ADJTM_CFG ((DWORD)0xE0000116L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_CREATE_REG_KEY_SERIAL_CFG
+//
+// MessageText:
+//
+// Failed to create registry key %1 when writing serial device configuration.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_CREATE_REG_KEY_SERIAL_CFG ((DWORD)0xE0000117L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_CREATE_REG_KEY
+//
+// MessageText:
+//
+// Failed to create registry key %1.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_CREATE_REG_KEY ((DWORD)0xE0000118L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_CREATE_REG_KEY_COUNTRY_CODE
+//
+// MessageText:
+//
+// Failed to create registry key %1 when writing country code.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_CREATE_REG_KEY_COUNTRY_CODE ((DWORD)0xE0000119L)
+
+//
+// MessageId: MBG_WARNING_FAILED_TO_CREATE_REG_KEY_ISA_PORTS
+//
+// MessageText:
+//
+// Failed to create registry key %1 when writing isa ports.%r%rError: %2
+//
+#define MBG_WARNING_FAILED_TO_CREATE_REG_KEY_ISA_PORTS ((DWORD)0xE000011AL)
+
+//
+//
+// SERVICE MESSAGES
+// ----------------
+//
+//
+// MessageId: MBG_INFO_SVC_STARTING
+//
+// MessageText:
+//
+// %1 starting.%r%r%2.
+//
+#define MBG_INFO_SVC_STARTING ((DWORD)0x60000200L)
+
+//
+// MessageId: MBG_INFO_LOG_TIME_ADJUSTMENT_DATA_TO_FILE
+//
+// MessageText:
+//
+// Logging time adjustment data to file:%r%1
+//
+#define MBG_INFO_LOG_TIME_ADJUSTMENT_DATA_TO_FILE ((DWORD)0x60000201L)
+
+//
+// MessageId: MBG_INFO_LEAP_SECOND_ANNOUNCEMENT
+//
+// MessageText:
+//
+// %1%2Leap second announcement detected.
+//
+#define MBG_INFO_LEAP_SECOND_ANNOUNCEMENT ((DWORD)0x60000202L)
+
+//
+// MessageId: MBG_INFO_LEAP_SECOND_INSERTED
+//
+// MessageText:
+//
+// %1%2Leap second inserted.
+//
+#define MBG_INFO_LEAP_SECOND_INSERTED ((DWORD)0x60000203L)
+
+//
+// MessageId: MBG_WARNING_TIME_SERVICE_STOPPED
+//
+// MessageText:
+//
+// Time adjustment service stopped.
+//
+#define MBG_WARNING_TIME_SERVICE_STOPPED ((DWORD)0xA0000204L)
+
+//
+// MessageId: MBG_WINERR_TIME_DIFF_EXCEEDS_LIMIT
+//
+// MessageText:
+//
+// Time difference %1 s exceeds limit %2 s.
+//
+#define MBG_WINERR_TIME_DIFF_EXCEEDS_LIMIT ((DWORD)0xE0000205L)
+
+//
+// MessageId: MBG_WARNING_TIME_ADJUSTMENT_DISABLED
+//
+// MessageText:
+//
+// System time adjustment has been found disabled.
+//
+#define MBG_WARNING_TIME_ADJUSTMENT_DISABLED ((DWORD)0xA0000206L)
+
+//
+// MessageId: MBG_WARNING_TIME_ADJUSTMENT_MODIFIED_BY_ANOTHER_PROGRAM
+//
+// MessageText:
+//
+// System time adjustment has been modified by another program: %1.
+//
+#define MBG_WARNING_TIME_ADJUSTMENT_MODIFIED_BY_ANOTHER_PROGRAM ((DWORD)0xA0000207L)
+
+//
+// MessageId: MBG_WARNING_CLOCK_INCONSISTENCY_DETECTED
+//
+// MessageText:
+//
+// Clock inconsistency detected: %r%1.
+//
+#define MBG_WARNING_CLOCK_INCONSISTENCY_DETECTED ((DWORD)0xA0000208L)
+
+//
+// MessageId: MBG_WARNING_NEW_SYSTEM_TIME
+//
+// MessageText:
+//
+// New system time.
+//
+#define MBG_WARNING_NEW_SYSTEM_TIME ((DWORD)0xA0000209L)
+
+//
+// MessageId: MBG_WINERR_REF_CLOCK_FAILURE_DETECTED
+//
+// MessageText:
+//
+// Ref clock failure detected at: %1.
+//
+#define MBG_WINERR_REF_CLOCK_FAILURE_DETECTED ((DWORD)0xE000020AL)
+
+//
+// MessageId: MBG_INFO_REF_CLOCK_FAILURE_ENDED
+//
+// MessageText:
+//
+// Ref clock failure ended at: %1.
+//
+#define MBG_INFO_REF_CLOCK_FAILURE_ENDED ((DWORD)0x6000020BL)
+
+//
+// MessageId: MBG_WINERR_REF_CLOCK_FAILURE_NOTIFICATION
+//
+// MessageText:
+//
+// Ref clock failure persisting for %1.
+//
+#define MBG_WINERR_REF_CLOCK_FAILURE_NOTIFICATION ((DWORD)0xE000020CL)
+
+//
+// MessageId: MBG_WINERR_REF_CLOCK_FAILURE_NOTIFICATION_MORE
+//
+// MessageText:
+//
+// Ref clock failure persisting for more than %1.
+//
+#define MBG_WINERR_REF_CLOCK_FAILURE_NOTIFICATION_MORE ((DWORD)0xE000020DL)
+
+//
+// MessageId: MBG_INFO_CURRENT_REF_TIME
+//
+// MessageText:
+//
+// Current reference time: %1.
+//
+#define MBG_INFO_CURRENT_REF_TIME ((DWORD)0x6000020EL)
+
+//
+// MessageId: MBG_WINERR_CURRENT_REF_TIME
+//
+// MessageText:
+//
+// Current reference time: %1.
+//
+#define MBG_WINERR_CURRENT_REF_TIME ((DWORD)0xE000020FL)
+
+//
+// MessageId: MBG_WARNING_SET_LOCAL_TIME
+//
+// MessageText:
+//
+// Setting system local time to: %1.
+//
+#define MBG_WARNING_SET_LOCAL_TIME ((DWORD)0xA0000210L)
+
+//
+// MessageId: MBG_WARNING_SET_SYSTEM_TIME
+//
+// MessageText:
+//
+// Setting system time to: %1.
+//
+#define MBG_WARNING_SET_SYSTEM_TIME ((DWORD)0xA0000211L)
+
+//
+// MessageId: MBG_WARNING_REF_TIME_INVALID
+//
+// MessageText:
+//
+// %1%2Reference time is invalid.
+//
+#define MBG_WARNING_REF_TIME_INVALID ((DWORD)0xA0000212L)
+
+//
+// MessageId: MBG_WARNING_REF_TIME_SET_MANUAL
+//
+// MessageText:
+//
+// %1%2Reference time has been set manually.
+//
+#define MBG_WARNING_REF_TIME_SET_MANUAL ((DWORD)0xA0000213L)
+
+//
+// MessageId: MBG_INFO_REF_CLOCK_SYNCED
+//
+// MessageText:
+//
+// %1%2Reference time source is synchronized
+//
+#define MBG_INFO_REF_CLOCK_SYNCED ((DWORD)0x60000214L)
+
+//
+// MessageId: MBG_WARNING_REF_CLOCK_NOT_SYNCED
+//
+// MessageText:
+//
+// %1%2Reference time source not synchronized.
+//
+#define MBG_WARNING_REF_CLOCK_NOT_SYNCED ((DWORD)0xA0000215L)
+
+//
+// MessageId: MBG_WARNING_TIME_ADJUSTMENT_DEFAULT_SETTINGS
+//
+// MessageText:
+//
+// One or more settings for the time adjustment service have been set to default values.
+//
+#define MBG_WARNING_TIME_ADJUSTMENT_DEFAULT_SETTINGS ((DWORD)0xA0000216L)
+
+//
+// MessageId: MBG_WARNING_SERIAL_STRING_DEFAULT_SETTINGS
+//
+// MessageText:
+//
+// One or more settings for the serial time string have been set to default values.
+//
+#define MBG_WARNING_SERIAL_STRING_DEFAULT_SETTINGS ((DWORD)0xA0000217L)
+
+//
+// MessageId: MBG_INFO_SERVICE_PARAMETERS_CHANGED
+//
+// MessageText:
+//
+// Time adjustment service parameters have been changed:%r%r%1
+//
+#define MBG_INFO_SERVICE_PARAMETERS_CHANGED ((DWORD)0x60000218L)
+
+//
+// MessageId: MBG_INFO_TIME_ADJUSTMENT_IN_RANGE
+//
+// MessageText:
+//
+// Time adjustment in range: %1 s.
+//
+#define MBG_INFO_TIME_ADJUSTMENT_IN_RANGE ((DWORD)0x60000219L)
+
+//
+// MessageId: MBG_WARNING_TIME_ADJUSTMENT_OUT_OF_RANGE
+//
+// MessageText:
+//
+// Time adjustment out of range: %1.
+//
+#define MBG_WARNING_TIME_ADJUSTMENT_OUT_OF_RANGE ((DWORD)0xA000021AL)
+
+//
+// MessageId: MBG_WINERR_ERROR_OPEN_DEVICE
+//
+// MessageText:
+//
+// Failed to open device "%1".
+//
+#define MBG_WINERR_ERROR_OPEN_DEVICE ((DWORD)0xE000021BL)
+
+//
+// MessageId: MBG_WARNING_READ_DEVICE_INFO
+//
+// MessageText:
+//
+// Failed to read device info from device "%1".
+//
+#define MBG_WARNING_READ_DEVICE_INFO ((DWORD)0xA000021CL)
+
+//
+// MessageId: MBG_WARNING_REF_CLOCK_CHANGED
+//
+// MessageText:
+//
+// Reference time source has been changed:%r%1
+//
+#define MBG_WARNING_REF_CLOCK_CHANGED ((DWORD)0xA000021DL)
+
+//
+// MessageId: MBG_WINERR_FAILED_OPEN_SERIAL_PORT
+//
+// MessageText:
+//
+// Failed to open serial port %1
+//
+#define MBG_WINERR_FAILED_OPEN_SERIAL_PORT ((DWORD)0xE000021EL)
+
+//
+// MessageId: MBG_INFO_SUCCEEDED_OPEN_SERIAL_PORT
+//
+// MessageText:
+//
+// Now succeeded to open serial port %1
+//
+#define MBG_INFO_SUCCEEDED_OPEN_SERIAL_PORT ((DWORD)0x6000021FL)
+
+//
+// MessageId: MBG_WARNING_TIMEOUT_RECEIVING_SERIAL_STRING
+//
+// MessageText:
+//
+// Timeout receiving %1.
+//
+#define MBG_WARNING_TIMEOUT_RECEIVING_SERIAL_STRING ((DWORD)0xA0000220L)
+
+//
+// MessageId: MBG_INFO_SUCCESSFULLY_RECEIVING_SERIAL_STRING
+//
+// MessageText:
+//
+// Successfully receiving %1.
+//
+#define MBG_INFO_SUCCESSFULLY_RECEIVING_SERIAL_STRING ((DWORD)0x60000221L)
+
+//
+// MessageId: MBG_WINERR_DEVICE_REMOVED
+//
+// MessageText:
+//
+// Error reading from device driver.%rThe device "%1" was obviously disconnected from the PC. The system time adjustment has been set to the standard value.
+//
+#define MBG_WINERR_DEVICE_REMOVED ((DWORD)0xE0000222L)
+
+//
+// MessageId: MBG_INFO_DEVICE_RECONNECTED
+//
+// MessageText:
+//
+// The device "%1" has been reattached to the PC and is used by the time adjustment service.
+//
+#define MBG_INFO_DEVICE_RECONNECTED ((DWORD)0x60000223L)
+
+//
+// MessageId: MBG_WINERR_SVC_INVALID_TIME
+//
+// MessageText:
+//
+// Invalid time read from the device:%r%1.
+//
+#define MBG_WINERR_SVC_INVALID_TIME ((DWORD)0xE0000224L)
+
+//
+// MessageId: MBG_WARNING_SVC_STARTING
+//
+// MessageText:
+//
+// %1 starting.%r%r%2.
+//
+#define MBG_WARNING_SVC_STARTING ((DWORD)0xA0000225L)
+
+//
+// MessageId: MBG_WARNING_TIME_SERVICE_PAUSED
+//
+// MessageText:
+//
+// Time adjustment service paused.
+//
+#define MBG_WARNING_TIME_SERVICE_PAUSED ((DWORD)0xA0000226L)
+
+//
+// MessageId: MBG_INFO_TIME_SERVICE_CONTINUED
+//
+// MessageText:
+//
+// Time adjustment service continued.
+//
+#define MBG_INFO_TIME_SERVICE_CONTINUED ((DWORD)0x60000227L)
+
+//
+// MessageId: MBG_INFO_SERIAL_PORT_OPENED_IN_NORMAL_MODE
+//
+// MessageText:
+//
+// Serial port opened in normal mode.
+//
+#define MBG_INFO_SERIAL_PORT_OPENED_IN_NORMAL_MODE ((DWORD)0x60000228L)
+
+//
+// MessageId: MBG_INFO_EXECUTE_CMD_SUCCEEDED
+//
+// MessageText:
+//
+// The command %"%1%" was executed.
+//
+#define MBG_INFO_EXECUTE_CMD_SUCCEEDED ((DWORD)0x60000229L)
+
+//
+// MessageId: MBG_WINERR_EXECUTE_CMD_FAILED
+//
+// MessageText:
+//
+// Failed to execute the command %"%1%".%r%rError: %2
+//
+#define MBG_WINERR_EXECUTE_CMD_FAILED ((DWORD)0xE000022AL)
+
+//
+// MessageId: MBG_WINERR_REF_CLOCK_STEPPED
+//
+// MessageText:
+//
+// The reference time stepped! The time adjustment is pausing.%r%rCurrent reference time: %1
+//
+#define MBG_WINERR_REF_CLOCK_STEPPED ((DWORD)0xA000022BL)
+
+//
+// MessageId: MBG_INFO_REF_CLOCK_STEP_END
+//
+// MessageText:
+//
+// The reference time stepped back into the correct range. The time adjustment continues.%r%rCurrent reference time: %1
+//
+#define MBG_INFO_REF_CLOCK_STEP_END ((DWORD)0x6000022CL)
+
+//
+// MessageId: MBG_WARNING_TIMESCALE_CHANGED
+//
+// MessageText:
+//
+// The time scale of the reference clock changed from "%1" to "%2".
+//
+#define MBG_WARNING_TIMESCALE_CHANGED ((DWORD)0xA000022DL)
+
+//
+// MessageId: MBG_INFO_TIMESCALE_CONFIG
+//
+// MessageText:
+//
+// The time scale of the reference clock is configured to "%1".
+//
+#define MBG_INFO_TIMESCALE_CONFIG ((DWORD)0x6000022EL)
+
+//
+// MessageId: MBG_INFO_GPS_MODE_CHANGED
+//
+// MessageText:
+//
+// The GPS receiver switched to "%1".
+//
+#define MBG_INFO_GPS_MODE_CHANGED ((DWORD)0x6000022FL)
+
+//
+// MessageId: MBG_INFO_GPS_ANT_CONNECTED
+//
+// MessageText:
+//
+// The GPS antenna is connected to the receiver.
+//
+#define MBG_INFO_GPS_ANT_CONNECTED ((DWORD)0x60000230L)
+
+//
+// MessageId: MBG_WARNING_GPS_ANT_FAULTY
+//
+// MessageText:
+//
+// The GPS receiver reports "Antenna Faulty".
+//
+#define MBG_WARNING_GPS_ANT_FAULTY ((DWORD)0xA0000231L)
+
diff --git a/c/mbglib/include/pci_asic.h b/c/mbglib/include/pci_asic.h
index a0f505c..8eb6371 100644
--- a/c/mbglib/include/pci_asic.h
+++ b/c/mbglib/include/pci_asic.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pci_asic.h 1.15 2009/03/27 09:39:15Z martin REL_M $
+ * $Id: pci_asic.h 1.22 2011/10/05 09:46:12Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,23 @@
*
* -----------------------------------------------------------------------
* $Log: pci_asic.h $
- * Revision 1.15 2009/03/27 09:39:15Z martin
+ * Revision 1.22 2011/10/05 09:46:12Z martin
+ * Updated version info for GPS180PEX.
+ * Revision 1.21 2011/09/13 07:36:21Z martin
+ * Updated version info for GPS180PEX.
+ * Revision 1.20 2011/06/30 13:52:26Z martin
+ * Updated version info for GPS180PEX.
+ * Revision 1.19 2011/06/29 08:58:32Z martin
+ * Support PZF180PEX.
+ * Cleaned up handling of pragma pack().
+ * Revision 1.18 2011/04/06 12:31:48 martin
+ * Updated minor versions for PTP270PEX and GPS180PEX.
+ * Revision 1.17 2010/09/10 14:03:25Z martin
+ * Support GPS180PEX and TCR180PEX.
+ * New table initializer to simplify EPLD version checking.
+ * Revision 1.16 2010/04/16 11:12:21Z martin
+ * Updated GPS170PEX ASIC version.
+ * Revision 1.15 2009/03/27 09:39:15 martin
* Increased current ASIC minor number for TCR170PEX to 0x02.
* Renamed some symbols.
* Revision 1.14 2009/03/11 16:54:10Z martin
@@ -65,11 +81,6 @@
#include <words.h>
#include <use_pack.h>
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
-#endif
-
-
#ifdef _PCI_ASIC
#define _ext
#define _DO_INIT
@@ -80,6 +91,11 @@
/* Start of header body */
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
+
typedef struct
{
@@ -261,6 +277,9 @@ enum
PCI_ASIC_MAJOR_PTP270PEX, // PEX EPLD for PTP270PEX
PCI_ASIC_MAJOR_FRC511PEX, // PEX EPLD for FRC511PEX
PCI_ASIC_MAJOR_TCR170PEX, // PEX EPLD for TCR170PEX
+ PCI_ASIC_MAJOR_GPS180PEX, // PEX EPLD for GPS180PEX
+ PCI_ASIC_MAJOR_TCR180PEX, // PEX EPLD for TCR180PEX
+ PCI_ASIC_MAJOR_PZF180PEX, // PEX EPLD for PZF180PEX
N_PCI_ASIC_MAJOR // the number of known codes
};
@@ -272,29 +291,70 @@ enum
*/
#define PCI_ASIC_CURRENT_MINOR_PEX511 0x04
#define PCI_ASIC_REQUIRED_MINOR_PEX511 0x03
-#define PCI_ASIC_FIX_HRT_MINOR_PEX511 0x04 // increases HRT accuracy
-#define PCI_ASIC_FIX_IRQ_MINOR_PEX511 0x03 // fixes IRQ problem
-#define PCI_ASIC_HR_TIME_MINOR_PEX511 0x02 // supports HR time with PEX511
+#define PCI_ASIC_FIX_HRT_MINOR_PEX511 0x04 // increases HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_PEX511 0x03 // fixes IRQ problem
+#define PCI_ASIC_HR_TIME_MINOR_PEX511 0x02 // supports HR time with PEX511
-#define PCI_ASIC_CURRENT_MINOR_GPS170PEX 0x04
+#define PCI_ASIC_CURRENT_MINOR_GPS170PEX 0x05
#define PCI_ASIC_REQUIRED_MINOR_GPS170PEX 0x03
-#define PCI_ASIC_FIX_HRT_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
-#define PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX 0x03 // fixes IRQ problem
+#define PCI_ASIC_ENH_HRT_MINOR_GPS170PEX 0x05 // enhanced MM HRT accuracy
+#define PCI_ASIC_FIX_HRT_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX 0x03 // fixes IRQ problem
#define PCI_ASIC_CURRENT_MINOR_TCR511PEX 0x04
#define PCI_ASIC_REQUIRED_MINOR_TCR511PEX 0x03
-// 0x04 // EPLD sources shared with PEX511 0x04
-#define PCI_ASIC_FIX_IRQ_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
+// 0x04 // EPLD sources shared with PEX511 0x04
+#define PCI_ASIC_FIX_IRQ_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
-#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x01
+#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x02
#define PCI_ASIC_REQUIRED_MINOR_PTP270PEX 0x01
+// 0x02 // increased accuracy of IRIG DCLS slopes
+// 0x01 // supports inversion of ucap slopes
#define PCI_ASIC_CURRENT_MINOR_FRC511PEX 0x01
#define PCI_ASIC_REQUIRED_MINOR_FRC511PEX 0x01
-#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x02
+#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x03
#define PCI_ASIC_REQUIRED_MINOR_TCR170PEX 0x02
-#define PCI_ASIC_FIX_EE_ACCESS_TCR170PEX 0x02 // fixes EE access problem after reset
+#define PCI_ASIC_FIX_EE_ACCESS_TCR170PEX 0x02 // fixes EE access problem after reset
+#define PCI_ASIC_FIX_FO_IN_LEVEL_TCR170PEX 0x03 // correct polarity for fiber optic input
+
+#define PCI_ASIC_CURRENT_MINOR_GPS180PEX 0x05
+#define PCI_ASIC_REQUIRED_MINOR_GPS180PEX 0x01
+// 0x01 // updated VHDL compiler and associated PCI primitives
+// 0x02 // I/O using 3.3V LVTTL
+// 0x03 // GPS TIC pulse len now 1 sample clock
+// 0x04 // Enabled PCI IRQ line which had unintentionally been disabled earlier
+// 0x05 // Increased accuracy of synthesizer output
+
+#define PCI_ASIC_CURRENT_MINOR_TCR180PEX 0x00
+#define PCI_ASIC_REQUIRED_MINOR_TCR180PEX 0x00
+
+#define PCI_ASIC_CURRENT_MINOR_PZF180PEX 0x00
+#define PCI_ASIC_REQUIRED_MINOR_PZF180PEX 0x00
+
+
+typedef struct
+{
+ unsigned int dev_type_num;
+ unsigned int major;
+ unsigned int current_minor;
+ unsigned int required_minor;
+} PCI_ASIC_VERSION_INFO;
+
+#define DEFAULT_PCI_ASIC_VERSION_INFO_TABLE \
+{ \
+ { PCPS_TYPE_PEX511, PCI_ASIC_MAJOR_PEX511, PCI_ASIC_CURRENT_MINOR_PEX511, PCI_ASIC_REQUIRED_MINOR_PEX511 }, \
+ { PCPS_TYPE_GPS170PEX, PCI_ASIC_MAJOR_GPS170PEX, PCI_ASIC_CURRENT_MINOR_GPS170PEX, PCI_ASIC_REQUIRED_MINOR_GPS170PEX }, \
+ { PCPS_TYPE_TCR511PEX, PCI_ASIC_MAJOR_TCR511PEX, PCI_ASIC_CURRENT_MINOR_TCR511PEX, PCI_ASIC_REQUIRED_MINOR_TCR511PEX }, \
+ { PCPS_TYPE_PTP270PEX, PCI_ASIC_MAJOR_PTP270PEX, PCI_ASIC_CURRENT_MINOR_PTP270PEX, PCI_ASIC_REQUIRED_MINOR_PTP270PEX }, \
+ { PCPS_TYPE_FRC511PEX, PCI_ASIC_MAJOR_FRC511PEX, PCI_ASIC_CURRENT_MINOR_FRC511PEX, PCI_ASIC_REQUIRED_MINOR_FRC511PEX }, \
+ { PCPS_TYPE_TCR170PEX, PCI_ASIC_MAJOR_TCR170PEX, PCI_ASIC_CURRENT_MINOR_TCR170PEX, PCI_ASIC_REQUIRED_MINOR_TCR170PEX }, \
+ { PCPS_TYPE_GPS180PEX, PCI_ASIC_MAJOR_GPS180PEX, PCI_ASIC_CURRENT_MINOR_GPS180PEX, PCI_ASIC_REQUIRED_MINOR_GPS180PEX }, \
+ { PCPS_TYPE_TCR180PEX, PCI_ASIC_MAJOR_TCR180PEX, PCI_ASIC_CURRENT_MINOR_TCR180PEX, PCI_ASIC_REQUIRED_MINOR_TCR180PEX }, \
+ { PCPS_TYPE_PZF180PEX, PCI_ASIC_MAJOR_PZF180PEX, PCI_ASIC_CURRENT_MINOR_PZF180PEX, PCI_ASIC_REQUIRED_MINOR_PZF180PEX }, \
+ { 0 } \
+}
/* function prototypes: */
@@ -317,8 +377,9 @@ extern "C" {
#endif
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/pcpsdefs.h b/c/mbglib/include/pcpsdefs.h
index c1db2f5..9f97c0f 100644
--- a/c/mbglib/include/pcpsdefs.h
+++ b/c/mbglib/include/pcpsdefs.h
@@ -1,15 +1,42 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.41 2009/06/19 12:16:42Z martin REL_M $
+ * $Id: pcpsdefs.h 1.48 2011/11/25 15:02:28Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
* Description:
- * General definitions for Meinberg plug-in radio clocks
+ * General definitions for Meinberg plug-in devices.
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
+ * Revision 1.48 2011/11/25 15:02:28Z martin
+ * Support on-board event logs.
+ * Revision 1.47 2011/11/25 10:22:44 martin
+ * Modified handling of pragma pack().
+ * Made command group codes obsolete. They are still supported
+ * when building firmware, though.
+ * Support PTP unicast configuration.
+ * Support GPIO configuration.
+ * Support PZF180PEX.
+ * Added commands to read CORR_INFO, read/write TR_DISTANCE,
+ * PCPS_SYNC_PZF status, and associated structures.
+ * Added an initializer for a table of GPS command code/names.
+ * Added definitions MBG_PCPS_FMT_STATUS.
+ * Updated some comments.
+ * Revision 1.46 2011/01/13 11:44:29Z martin
+ * Moved status port register definitions here.
+ * Revision 1.45 2010/09/06 07:36:24 martin
+ * Support GPS180PEX and TCR180PEX.
+ * Moved some IRIG related definitions to gpsdefs.h.
+ * Revision 1.44 2010/06/30 11:09:49 martin
+ * Added definitions for JJY longwave transmitter.
+ * Renamed MBG_RAW_IRIG_DATA::data field to data_bytes
+ * since "data" is a reserved word for C51 architecture.
+ * Revision 1.43 2010/02/09 11:20:17Z martin
+ * Renamed yet unused CORR_INFO::flags field to signal and updated comments.
+ * Revision 1.42 2010/01/12 14:02:37 daniel
+ * Added definitions to support reading the raw IRIG data bits.
* Revision 1.41 2009/06/19 12:16:42Z martin
* Added PCPS_GIVE_IRIG_TIME command and associated definitions.
* Revision 1.40 2009/06/08 19:29:11 daniel
@@ -196,16 +223,16 @@
#include <use_pack.h>
-/* Start of header body */
+/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
#endif
/**
- * The following codes enumerate the ref time sources
- * from which the clocks receive the reference time.
+ * @brief Enumeration of the ref time signal sources used by Meinberg devices
*/
enum
{
@@ -214,9 +241,10 @@ enum
PCPS_REF_GPS, /**< see http://www.meinberg.de/english/info/gps.htm */
PCPS_REF_IRIG, /**< see http://www.meinberg.de/english/info/irig.htm */
PCPS_REF_MSF, /**< MSF Receiver (UK) */
- PCPS_REF_PTP, /**< PTP Timestamp card */
+ PCPS_REF_PTP, /**< PTP/IEEE1588 network protocol */
PCPS_REF_FRC, /**< Free Running Clock */
PCPS_REF_WWVB, /**< WWVB Receiver (US) */
+ PCPS_REF_JJY, /**< JJY Receiver (Japan) */
N_PCPS_REF /**< number of valid ref time sources */
};
@@ -232,6 +260,7 @@ enum
#define PCPS_REF_NAME_PTP "PTP"
#define PCPS_REF_NAME_FRC "FRC"
#define PCPS_REF_NAME_WWVB "WWVB"
+#define PCPS_REF_NAME_JJY "JJY"
#define PCPS_REF_NAMES_ENG \
@@ -243,7 +272,8 @@ enum
PCPS_REF_NAME_MSF, \
PCPS_REF_NAME_PTP, \
PCPS_REF_NAME_FRC, \
- PCPS_REF_NAME_WWVB \
+ PCPS_REF_NAME_WWVB, \
+ PCPS_REF_NAME_JJY \
}
@@ -256,14 +286,15 @@ enum
{ PCPS_REF_NAME_MSF, NULL }, \
{ PCPS_REF_NAME_PTP, NULL }, \
{ PCPS_REF_NAME_FRC, NULL }, \
- { PCPS_REF_NAME_WWVB, NULL } \
+ { PCPS_REF_NAME_WWVB, NULL }, \
+ { PCPS_REF_NAME_JJY, NULL } \
}
-/**
- PCI vendor ID number (assigned by PCI SIG)
-*/
+/**
+ * @brief Meinberg PCI vendor ID (assigned by PCI SIG)
+ */
#define PCI_VENDOR_MEINBERG 0x1360
/* PCI device ID numbers (assigned by Meinberg) *
@@ -275,34 +306,76 @@ enum
#define PCI_DEV_PCI510 ( ( PCPS_REF_DCF << 8 ) | 0x03 )
#define PCI_DEV_PCI511 ( ( PCPS_REF_DCF << 8 ) | 0x04 )
#define PCI_DEV_PEX511 ( ( PCPS_REF_DCF << 8 ) | 0x05 )
+#define PCI_DEV_PZF180PEX ( ( PCPS_REF_DCF << 8 ) | 0x06 )
#define PCI_DEV_GPS167PCI ( ( PCPS_REF_GPS << 8 ) | 0x01 )
#define PCI_DEV_GPS168PCI ( ( PCPS_REF_GPS << 8 ) | 0x02 )
#define PCI_DEV_GPS169PCI ( ( PCPS_REF_GPS << 8 ) | 0x03 )
#define PCI_DEV_GPS170PCI ( ( PCPS_REF_GPS << 8 ) | 0x04 )
#define PCI_DEV_GPS170PEX ( ( PCPS_REF_GPS << 8 ) | 0x05 )
+#define PCI_DEV_GPS180PEX ( ( PCPS_REF_GPS << 8 ) | 0x06 )
#define PCI_DEV_TCR510PCI ( ( PCPS_REF_IRIG << 8 ) | 0x01 )
#define PCI_DEV_TCR167PCI ( ( PCPS_REF_IRIG << 8 ) | 0x02 )
#define PCI_DEV_TCR511PCI ( ( PCPS_REF_IRIG << 8 ) | 0x03 )
#define PCI_DEV_TCR511PEX ( ( PCPS_REF_IRIG << 8 ) | 0x04 )
#define PCI_DEV_TCR170PEX ( ( PCPS_REF_IRIG << 8 ) | 0x05 )
+#define PCI_DEV_TCR180PEX ( ( PCPS_REF_IRIG << 8 ) | 0x06 )
#define PCI_DEV_PTP270PEX ( ( PCPS_REF_PTP << 8 ) | 0x01 )
#define PCI_DEV_FRC511PEX ( ( PCPS_REF_FRC << 8 ) | 0x01 )
+
+
+// definitions used for the status port register
+// (not to be intermixed with PCPS_TIME_STATUS)
+typedef uint8_t PCPS_STATUS_PORT; /**< see @ref group_status_port "Bitmask" */
+
+/**
+ * @defgroup group_status_port Bit masks of PCPS_STATUS_PORT
+ *
+ * Bit definitions used with the #PCPS_STATUS_PORT register.
+ *
+ * The flags #PCPS_ST_SEC and #PCPS_ST_MIN are cleared whenever the clock
+ * is read, so they are not very reliable in multitasking environments.
+ *
+ * @note The PCPS_ST_IRQF flag originates from old ISA cards.
+ * Some PCI cards also support this, but in case of PCI cards the
+ * associated flag of the PCI interface chip should be checked to see
+ * if a certain card has generated an IRQ on the PC bus.
+ *
+ * The macro _pcps_ddev_has_gen_irq() cares about this and should be used
+ * to determine in a portable way whether a card has generated an IRQ.
+ *
+ * @{ */
+
+#define PCPS_ST_BUSY 0x01 /**< the clock is busy filling the output FIFO */
+#define PCPS_ST_IRQF 0x02 /**< the clock has generated an IRQ on the PC bus (ISA only)*/
+#define PCPS_ST_MOD 0x20 /**< the raw demodulated DCF77 signal */
+#define PCPS_ST_SEC 0x40 /**< seconds have changed since last reading */
+#define PCPS_ST_MIN 0x80 /**< minutes have changed since last reading */
+
+/** @} group_status_port */
+
+/**
+ * A format string to be used with snprintb() which is available on some Unix
+ * systems to print information held in a bit coded variable.
+ */
+#define MBG_PCPS_FMT_STATUS \
+ "\177\20b\0FREER\0b\1DL_ENB\0b\2SYNCD\0b\3DL_ANN\0b\4UTC\0b\5LS_ANN\0b\6IFTM\0b\7INVT" \
+ "\0b\x08LS_ENB\0b\11ANT_FAIL\0b\x0aLS_ANN_NEG\0b\x0bSCALE_GPS\0b\x0cSCALE_TAI\0\0"
+
+
+
/** @defgroup group_cmd_bytes Command bytes used to access the device
- The commands described below can be used to access the Meinberg
- computer peripherals. However, some of the commands have not been
- implemented with older clock models, or firmware versions.
+ The commands described below are used to access computer peripherals
+ manufactured by Meinberg.
- The device driver library contains functions which detect the clocks
- and check which features are supported by a given clock model/firmware
The header files pcpsdev.h and pcpsdrvr.h contain macros which can be
- used to query whether a detected clock supports a feature.
- If checking is required, the name of the macro is given in the
+ used to check if a detected device supports a certain feature or command.
+ If checking is required then the name of the macro is given in the
comments below.
Some commands expect parameters to be passed to the board. In that
@@ -514,15 +587,48 @@ enum
available then the structure is filled with 0s.
_pcps_has_ucap() checks whether supported.
+ - #PCPS_GET_CORR_INFO<br>
+ Read PZF correlation info using a CORR_INFO
+ structure.
+ _pcps_has_pzf() checks whether supported.
+
+ - #PCPS_GET_TR_DISTANCE<br>
+ #PCPS_SET_TR_DISTANCE<br>
+ Read or write distance from the RF transmitter.
+ This is used to compensate the RF propagation delay
+ for PZF receivers.
+ _pcps_has_tr_distance() checks whether supported.
+
+ - #PCPS_CLR_EVT_LOG<br>
+ Clear on-board event log.
+ _pcps_has_evt_log() checks whether supported.
+
+ - #PCPS_NUM_EVT_LOG_ENTRIES<br>
+ Read max number of num event log entries which can
+ be saved on the board, and how many entries actually
+ have been saved.
+ _pcps_has_evt_log() checks whether supported.
+
+ - #PCPS_FIRST_EVT_LOG_ENTRY<br>
+ - #PCPS_NEXT_EVT_LOG_ENTRY<br>
+ Read first (oldest) or next event log entry.
+ _pcps_has_evt_log() checks whether supported.
+
- #PCPS_FORCE_RESET<br>
- Resets the microprocessor on the radio clock
- board. This is for debug purposes only and
- should not be used by standard applications.
+ Resets the microprocessor on the device. This is
+ for special test scenarios only and should not be
+ used by standard applications since this may lock up
+ the PC.
- The command codes listed above are defined below. The commands are
- grouped for bytes having the same high nibble:
- @{
-*/
+ The command codes listed above are defined below.
+
+ @{ */
+
+
+#if _IS_MBG_FIRMWARE //##++
+
+// These group codes are obsolete and should be removed.
+// The explicite command codes defined below should be used instead.
#define PCPS_GIVE_TIME_GROUP 0x00
#define PCPS_SET_TIME_GROUP 0x10
#define PCPS_IRQ_GROUP 0x20
@@ -532,44 +638,39 @@ enum
#define PCPS_CTRL_GROUP 0x60
#define PCPS_CFG2_GROUP 0x70
+#endif
-/* PCPS_GIVE_TIME_GROUP */
-#define PCPS_GIVE_TIME ( PCPS_GIVE_TIME_GROUP | 0x0 )
-#define PCPS_GIVE_TIME_NOCLEAR ( PCPS_GIVE_TIME_GROUP | 0x1 )
-#define PCPS_GIVE_SYNC_TIME ( PCPS_GIVE_TIME_GROUP | 0x2 ) // only supported if _pcps_has_sync_time()
-#define PCPS_GIVE_HR_TIME ( PCPS_GIVE_TIME_GROUP | 0x3 ) // only supported if _pcps_has_hr_time()
-#define PCPS_GIVE_IRIG_TIME ( PCPS_GIVE_TIME_GROUP | 0x4 ) // only supported if _pcps_has_irig_time()
-/* PCPS_SET_TIME_GROUP */
-#define PCPS_SET_TIME ( PCPS_SET_TIME_GROUP | 0x0 )
+#define PCPS_GIVE_TIME 0x00
+#define PCPS_GIVE_TIME_NOCLEAR 0x01
+#define PCPS_GIVE_SYNC_TIME 0x02 // only supported if _pcps_has_sync_time()
+#define PCPS_GIVE_HR_TIME 0x03 // only supported if _pcps_has_hr_time()
+#define PCPS_GIVE_IRIG_TIME 0x04 // only supported if _pcps_has_irig_time()
+
+#define PCPS_SET_TIME 0x10
/* on error, return PCPS_ERR_STIME */
/* Attention: The code below can be used EXCLUSIVELY */
/* with a GPS167PCI with customized CERN firmware !! */
/* _pcps_has_event_time() checks whether supported. */
-#define PCPS_SET_EVENT_TIME ( PCPS_SET_TIME_GROUP | 0x4 )
-
-
-/* PCPS_IRQ_GROUP */
-#define PCPS_IRQ_NONE ( PCPS_IRQ_GROUP | 0x0 )
-#define PCPS_IRQ_1_SEC ( PCPS_IRQ_GROUP | 0x1 )
-#define PCPS_IRQ_1_MIN ( PCPS_IRQ_GROUP | 0x2 )
-#define PCPS_IRQ_10_MIN ( PCPS_IRQ_GROUP | 0x4 )
-#define PCPS_IRQ_30_MIN ( PCPS_IRQ_GROUP | 0x8 )
+#define PCPS_SET_EVENT_TIME 0x14
+#define PCPS_IRQ_NONE 0x20
+#define PCPS_IRQ_1_SEC 0x21
+#define PCPS_IRQ_1_MIN 0x22
+#define PCPS_IRQ_10_MIN 0x24
+#define PCPS_IRQ_30_MIN 0x28
-/* PCPS_CFG_GROUP */
-
-#define PCPS_GET_SERIAL ( PCPS_CFG_GROUP | 0x0 )
-#define PCPS_SET_SERIAL ( PCPS_CFG_GROUP | 0x1 )
+#define PCPS_GET_SERIAL 0x30
+#define PCPS_SET_SERIAL 0x31
/* on error, return PCPS_ERR_CFG */
typedef uint8_t PCPS_SERIAL;
-#define PCPS_GET_TZCODE ( PCPS_CFG_GROUP | 0x2 )
-#define PCPS_SET_TZCODE ( PCPS_CFG_GROUP | 0x3 )
+#define PCPS_GET_TZCODE 0x32
+#define PCPS_SET_TZCODE 0x33
/* on error, return PCPS_ERR_CFG */
typedef uint8_t PCPS_TZCODE;
@@ -590,10 +691,11 @@ enum
#define PCPS_TZCODE_OEZ PCPS_TZCODE_EET_EEST
-#define PCPS_GET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x4 )
-#define PCPS_SET_PCPS_TZDL ( PCPS_CFG_GROUP | 0x5 )
+#define PCPS_GET_PCPS_TZDL 0x34
+#define PCPS_SET_PCPS_TZDL 0x35
/* on error, return PCPS_ERR_CFG */
+
/**
* The structures below can be used to configure a clock's
* time zone/daylight saving setting. This structure is shorter
@@ -644,71 +746,63 @@ typedef struct
-#define PCPS_GET_REF_OFFS ( PCPS_CFG_GROUP | 0x6 )
-#define PCPS_SET_REF_OFFS ( PCPS_CFG_GROUP | 0x7 )
+#define PCPS_GET_REF_OFFS 0x36
+#define PCPS_SET_REF_OFFS 0x37
/* on error, return PCPS_ERR_CFG */
/* The associated type MBG_REF_OFFS is defined in gpsdefs.h. */
-#define PCPS_GET_OPT_INFO ( PCPS_CFG_GROUP | 0x8 )
-#define PCPS_SET_OPT_SETTINGS ( PCPS_CFG_GROUP | 0x9 )
+#define PCPS_GET_OPT_INFO 0x38
+#define PCPS_SET_OPT_SETTINGS 0x39
/* on error, return PCPS_ERR_CFG */
/* The associated structures MBG_OPT_INFO and MBG_OPT_SETTINGS
are defined in gpsdefs.h. */
-#define PCPS_GET_IRIG_RX_INFO ( PCPS_CFG_GROUP | 0xA )
-#define PCPS_SET_IRIG_RX_SETTINGS ( PCPS_CFG_GROUP | 0xB )
+#define PCPS_GET_IRIG_RX_INFO 0x3A
+#define PCPS_SET_IRIG_RX_SETTINGS 0x3B
/* on error, return PCPS_ERR_CFG */
-#define PCPS_GET_IRIG_TX_INFO ( PCPS_CFG_GROUP | 0xC )
-#define PCPS_SET_IRIG_TX_SETTINGS ( PCPS_CFG_GROUP | 0xD )
+#define PCPS_GET_IRIG_TX_INFO 0x3C
+#define PCPS_SET_IRIG_TX_SETTINGS 0x3D
/* on error, return PCPS_ERR_CFG */
/* The associated structures IRIG_INFO and IRIG_SETTINGS
are defined in gpsdefs.h. */
-#define PCPS_GET_SYNTH ( PCPS_CFG_GROUP | 0xE )
-#define PCPS_SET_SYNTH ( PCPS_CFG_GROUP | 0xF )
+#define PCPS_GET_SYNTH 0x3E
+#define PCPS_SET_SYNTH 0x3F
/* on error, return PCPS_ERR_CFG */
/* The associated structure SYNTH is defined in gpsdefs.h. */
+#define PCPS_GIVE_FW_ID_1 0x40
+#define PCPS_GIVE_FW_ID_2 0x41
+#define PCPS_GIVE_SERNUM 0x42
+#define PCPS_GENERIC_IO 0x43
+#define PCPS_GET_SYNTH_STATE 0x44
+#define PCPS_GET_IRIG_CTRL_BITS 0x45
+#define PCPS_GET_RAW_IRIG_DATA 0x46
-/* PCPS_GIVE_DATA_GROUP */
-#define PCPS_GIVE_FW_ID_1 ( PCPS_GIVE_DATA_GROUP | 0x0 )
-#define PCPS_GIVE_FW_ID_2 ( PCPS_GIVE_DATA_GROUP | 0x1 )
-#define PCPS_GIVE_SERNUM ( PCPS_GIVE_DATA_GROUP | 0x2 )
-#define PCPS_GENERIC_IO ( PCPS_GIVE_DATA_GROUP | 0x3 )
-#define PCPS_GET_SYNTH_STATE ( PCPS_GIVE_DATA_GROUP | 0x4 )
-#define PCPS_GET_IRIG_CTRL_BITS ( PCPS_GIVE_DATA_GROUP | 0x5 )
-
-// bit coded return type for PCPS_GET_IRIG_CTRL_BITS
-typedef uint32_t MBG_IRIG_CTRL_BITS;
-#define _mbg_swab_irig_ctrl_bits( _p ) _mbg_swab32( _p )
-
-#define PCPS_GET_STATUS_PORT ( PCPS_GIVE_DATA_GROUP | 0xB )
-#define PCPS_GET_DEBUG_STATUS ( PCPS_GIVE_DATA_GROUP | 0xC )
+#define PCPS_GET_STATUS_PORT 0x4B
+#define PCPS_GET_DEBUG_STATUS 0x4C
// expects sizeof( MBG_DEBUG_STATUS ) chars
-// PCPS_GIVE_DATA_GROUP codes 0x0D, 0x0E, and 0x0F are reserved.
-
+// Command codes 0x4D, 0x4E, and 0x4F are reserved.
-/* PCPS_GPS_DATA_GROUP */
-#define PCPS_READ_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x0 )
-#define PCPS_WRITE_GPS_DATA ( PCPS_GPS_DATA_GROUP | 0x1 )
+#define PCPS_READ_GPS_DATA 0x50
+#define PCPS_WRITE_GPS_DATA 0x51
-/* PCPS_CTRL_GROUP */
-#define PCPS_CLR_UCAP_BUFF ( PCPS_CTRL_GROUP | 0x0 )
-#define PCPS_GIVE_UCAP_ENTRIES ( PCPS_CTRL_GROUP | 0x1 )
-#define PCPS_GIVE_UCAP_EVENT ( PCPS_CTRL_GROUP | 0x2 )
+#define PCPS_CLR_UCAP_BUFF 0x60
+#define PCPS_GIVE_UCAP_ENTRIES 0x61
+#define PCPS_GIVE_UCAP_EVENT 0x62
typedef struct
{
@@ -724,18 +818,32 @@ typedef struct
+#define PCPS_GET_CORR_INFO 0x63 // read CORR_INFO structure, only if _pcps_has_pzf()
+#define PCPS_GET_TR_DISTANCE 0x64 // read TR_DISTANCE, only if _pcps_has_tr_distance()
+#define PCPS_SET_TR_DISTANCE 0x65 // write TR_DISTANCE, only if _pcps_has_tr_distance()
+
+
+#define PCPS_CLR_EVT_LOG 0x66 // clear on-board event log, only if _pcps_has_evt_log()
+#define PCPS_NUM_EVT_LOG_ENTRIES 0x67 // read num event log entries, only if _pcps_has_evt_log()
+#define PCPS_FIRST_EVT_LOG_ENTRY 0x68 // read first (oldest) event log entry, only if _pcps_has_evt_log()
+#define PCPS_NEXT_EVT_LOG_ENTRY 0x69 // read next event log entry, only if _pcps_has_evt_log()
+
+
/**
special -- use with care !
*/
-#define PCPS_FORCE_RESET 0x80
+#define PCPS_FORCE_RESET 0x80
+
+// Command codes 0xF0 through 0xFF are reserved.
+
+/** @} group_cmd_bytes */
-/** @} */
/* Codes returned when commands with parameters have been passed */
/* to the board */
#define PCPS_SUCCESS 0 /**< OK, no error */
#define PCPS_ERR_STIME -1 /**< invalid date/time/status passed */
-#define PCPS_ERR_CFG -2 /**< invalid parms with a PCPS_CFG_GROUP cmd */
+#define PCPS_ERR_CFG -2 /**< invalid parms for a cmd writing config parameters */
@@ -744,7 +852,7 @@ typedef struct
#endif
-/** The size of the plug-in radio clock's on-board FIFO: */
+/** The size of the plug-in card's on-board FIFO */
#define PCPS_FIFO_SIZE 16
typedef int8_t PCPS_BUFF[PCPS_FIFO_SIZE];
@@ -807,8 +915,6 @@ typedef struct
-
-
typedef uint16_t PCPS_TIME_STATUS_X; /**< extended status */
#define _mbg_swab_pcps_time_status_x( _p ) _mbg_swab16( _p )
@@ -940,8 +1046,10 @@ typedef struct PCPS_IRIG_TIME_s
-/* Bit masks used with both PCPS_TIME_STATUS and PCPS_TIME_STATUS_X */
+/**
+ * Bit masks used with both PCPS_TIME_STATUS and PCPS_TIME_STATUS_X
+ */
#define PCPS_FREER 0x01 /**< DCF77 clock running on xtal */
/**< GPS receiver has not verified its position */
@@ -962,20 +1070,29 @@ typedef struct PCPS_IRIG_TIME_s
#define PCPS_INVT 0x80 /**< invalid time because battery was disconn'd */
-/* Bit masks used only with PCPS_TIME_STATUS_X */
-
+/**
+ * Bit masks used only with PCPS_TIME_STATUS_X
+ */
#define PCPS_LS_ENB 0x0100 /**< current second is leap second */
#define PCPS_ANT_FAIL 0x0200 /**< antenna failure */
-#define PCPS_LS_ANN_NEG 0x0400 /**< announced leap second is negative */
+#define PCPS_LS_ANN_NEG 0x0400 /**< announced leap second is negative */
#define PCPS_SCALE_GPS 0x0800 /**< time stamp is GPS scale */
#define PCPS_SCALE_TAI 0x1000 /**< time stamp is TAI scale */
-/* The next two bits are used only if the structure */
-/* PCPS_HR_TIME contains a user capture event */
+/**
+ * Bit masks used only with time stamps representing user capture events
+ */
#define PCPS_UCAP_OVERRUN 0x2000 /**< events interval too short */
#define PCPS_UCAP_BUFFER_FULL 0x4000 /**< events read too slow */
/**
+ * Bit masks used only with time stamps representing the current board time.
+ * A DCF77 PZF receiver can set this bit if it is actually synchronized
+ * using PZF correlation and thus provides higher accuracy than AM receivers.
+ */
+#define PCPS_SYNC_PZF 0x2000 /**< same code as PCPS_UCAP_OVERRUN */
+
+/**
* Immediately after a clock has been accessed, subsequent accesses
* are blocked for up to 1.5 msec to give the clock's microprocessor
* some time to decode the incoming time signal.
@@ -987,9 +1104,9 @@ typedef struct PCPS_IRIG_TIME_s
*/
#define PCPS_IO_BLOCKED 0x8000
-/**
- This bit mask can be used to extract the time scale information out
- of a PCPS_TIME_STATUS_X value.
+/**
+ * This bit mask can be used to extract the time scale information out
+ * of a PCPS_TIME_STATUS_X value.
*/
#define PCPS_SCALE_MASK ( PCPS_SCALE_TAI | PCPS_SCALE_GPS )
@@ -1079,41 +1196,6 @@ enum
#define PCPS_MOD_SHIFT ( PCPS_BD_BITS + PCPS_FR_BITS )
/* num of bits to shift left */
-/**
- * The fixed-length standard time string being sent on the serial
- * output is described below:
- *
- * \<STX\>D:dd.mm.yy;T:d;U:hh.mm.ss;uvwx\<ETX\>
- *
- * where \<STX\> and \<ETX\> represent the ASCII codes 0x02 and 0x03,
- * 'dd.mm.yy' is the format of the current date, 'd' is the current
- * day of week (1..7, 1 == Monday ) and 'hh.mm.ss' is the format of
- * the current time. The characters 'uvwx' reflect the clock's status:
- *
- * u clock status character:
- * '#' clock has not synchronized after reset
- * ' ' (space, 20h) clock has synchronized after reset
- *
- * v clock status character, different for DCF77 or GPS receivers:
- * '*' DCF77 clock currently runs on XTAL
- * GPS receiver has not checked its position
- * ' ' (space, 20h):
- * DCF77 clock is syncronized with transmitter
- * GPS receiver has determined its position
- *
- * x time zone indicator:
- * 'U' UTC Universal Time, Coordinated
- * ' ' MEZ European Standard Time, daylight saving disabled
- * 'S' MESZ European Summertime, daylight saving enabled
- *
- * y anouncement of discontinuity of time, enabled during last hour
- * before discontinuity comes in effect:
- * '!' announcement of start or end of daylight saving
- * 'A' announcement of leap second insertion
- * ' ' (space, 20h): nothing announced
- */
-
-
/**
* Some definitions used with PZF receivers
@@ -1122,36 +1204,73 @@ enum
/* receiver distance from transmitter [km] */
typedef uint16_t TR_DISTANCE;
+#define _mbg_swab_tr_distance( _p ) \
+ _mbg_swab16( _p )
+
+
+
/* correlation status info */
typedef struct
{
- uint8_t val; /**< correlation value */
+ uint8_t val; /**< correlation value, or check count if status == PZF_CORR_CHECK */
uint8_t status; /**< status codes, see below */
char corr_dir; /**< space, '<', or '>' */
- uint8_t flags; /**< reserved, currently always 0 */
+ uint8_t signal; /**< signal level, may always be 0 for devices which do not support this */
} CORR_INFO;
+#define _mbg_swab_corr_info( _p ) \
+ _nop_macro_fnc()
+
+
/** Codes used with CORR_INFO::status: */
enum
{
- PZF_CORR_RAW,
- PZF_CORR_CHECK,
- PZF_CORR_FINE,
+ PZF_CORR_RAW, /**< trying raw correlation, combi receivers running in AM mode */
+ PZF_CORR_CHECK, /**< raw correlation achieved, doing plausibility checks */
+ PZF_CORR_FINE, /**< fine correlation achieved */
N_PZF_CORR_STATE
};
-/**
- * The enumeration below defines the various types of data that can be
- * read from or written to a Meinberg GPS plug-in clock. Access should be
- * done using the functions pcps_read_gps_data() and pcps_write_gps_data()
- * in file pcpsio.c because the size of some of the structures exceeds
- * the size of the clock's on-board FIFO and must therefore be accessed
- * in several portions.
- *
- * The structures to be used are defined in gpsdefs.h. Not all structures
- * are supportet, yet. Check the R/W indicators for details.
- */
+#define PZF_CORR_STATE_NAME_RAW_ENG "Searching"
+#define PZF_CORR_STATE_NAME_CHECK_ENG "Correlating"
+#define PZF_CORR_STATE_NAME_FINE_ENG "Locked"
+
+#define PZF_CORR_STATE_NAME_RAW_GER "suchen"
+#define PZF_CORR_STATE_NAME_CHECK_GER "korrelieren"
+#define PZF_CORR_STATE_NAME_FINE_GER "eingerastet"
+
+
+#define PZF_CORR_STATE_NAMES_ENG \
+{ \
+ PZF_CORR_STATE_NAME_RAW_ENG, \
+ PZF_CORR_STATE_NAME_CHECK_ENG, \
+ PZF_CORR_STATE_NAME_FINE_ENG \
+}
+
+
+#define PZF_CORR_STATE_NAMES_LSTR \
+{ \
+ { PZF_CORR_STATE_NAME_RAW_ENG, PZF_CORR_STATE_NAME_RAW_GER }, \
+ { PZF_CORR_STATE_NAME_CHECK_ENG, PZF_CORR_STATE_NAME_CHECK_GER }, \
+ { PZF_CORR_STATE_NAME_FINE_ENG, PZF_CORR_STATE_NAME_FINE_GER } \
+}
+
+
+
+/** @defgroup group_gps_cmds_bus GPS commands passed via the system bus
+
+ This enumeration defines the various types of data that can be read
+ from or written to Meinberg bus level devices which support this.
+ Access should be done using the functions pcps_read_gps_data()
+ and pcps_write_gps_data() since the size of some of the structures
+ exceeds the size of the device's I/O buffer and must therefore be
+ accessed in several blocks.
+
+ The structures to be used are defined in gpsdefs.h. Not all structures
+ are supported, yet. Check the R/W indicators for details.
+
+ * @{ */
enum
{ // R/W data type description
// system data -----------------------------------------------
@@ -1183,6 +1302,12 @@ enum
PC_GPS_IP4_SETTINGS, // R/W IP4_SETTINGS LAN interface configuration, only if PCPS_HAS_LAN_INTF
PC_GPS_PTP_STATE, // R/- PTP_STATE, only if PCPS_HAS_PTP
PC_GPS_PTP_CFG, // R/W PTP_CFG_{SETTINGS|INFO}, only if PCPS_HAS_PTP
+ PC_GPS_PTP_UC_MASTER_CFG_LIMITS, // R/- PTP_UC_MASTER_CFG_LIMITS, only if can be unicast master
+ PC_GPS_ALL_PTP_UC_MASTER_INFO, // R/- n*PTP_UC_MASTER_INFO_IDX, only if can be unicast master
+ PC_GPS_PTP_UC_MASTER_SETTINGS_IDX, // -/W PTP_UC_MASTER_SETTINGS_IDX, only if can be unicast master
+ PC_GPS_GPIO_CFG_LIMITS, // R/- MBG_GPIO_CFG_LIMITS, only if PCPS_HAS_GPIO
+ PC_GPS_ALL_GPIO_INFO, // R/- n*MBG_GPIO_INFO, all GPIO info, only if PCPS_HAS_GPIO
+ PC_GPS_GPIO_SETTINGS_IDX, // -/W MBG_GPIO_SETTINGS_IDX, GPIO cfg for a specific port, only if PCPS_HAS_GPIO
// GPS data
PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes
@@ -1193,6 +1318,61 @@ enum
PC_GPS_ASCII_MSG // -/- ASCII_MSG the GPS ASCII message
};
+/** @} group_gps_cmds_bus */
+
+
+
+/**
+ * @brief An initializer for a table of code/name entries of GPS commands.
+ *
+ * This can e.g. be assigned to an array of MBG_CODE_NAME_TABLE_ENTRY elements
+ * and may be helpful when debugging.
+ */
+#define MBG_PC_GPS_CMD_TABLE \
+{ \
+ { PC_GPS_TZDL, "PC_GPS_TZDL" }, \
+ { PC_GPS_SW_REV, "PC_GPS_SW_REV" }, \
+ { PC_GPS_BVAR_STAT, "PC_GPS_BVAR_STAT" }, \
+ { PC_GPS_TIME, "PC_GPS_TIME" }, \
+ { PC_GPS_POS_XYZ, "PC_GPS_POS_XYZ" }, \
+ { PC_GPS_POS_LLA, "PC_GPS_POS_LLA" }, \
+ { PC_GPS_PORT_PARM, "PC_GPS_PORT_PARM" }, \
+ { PC_GPS_ANT_INFO, "PC_GPS_ANT_INFO" }, \
+ { PC_GPS_UCAP, "PC_GPS_UCAP" }, \
+ { PC_GPS_ENABLE_FLAGS, "PC_GPS_ENABLE_FLAGS" }, \
+ { PC_GPS_STAT_INFO, "PC_GPS_STAT_INFO" }, \
+ { PC_GPS_CMD, "PC_GPS_CMD" }, \
+ { PC_GPS_IDENT, "PC_GPS_IDENT" }, \
+ { PC_GPS_POS, "PC_GPS_POS" }, \
+ { PC_GPS_ANT_CABLE_LEN, "PC_GPS_ANT_CABLE_LEN" }, \
+ { PC_GPS_RECEIVER_INFO, "PC_GPS_RECEIVER_INFO" }, \
+ { PC_GPS_ALL_STR_TYPE_INFO, "PC_GPS_ALL_STR_TYPE_INFO" }, \
+ { PC_GPS_ALL_PORT_INFO, "PC_GPS_ALL_PORT_INFO" }, \
+ { PC_GPS_PORT_SETTINGS_IDX, "PC_GPS_PORT_SETTINGS_IDX" }, \
+ { PC_GPS_ALL_POUT_INFO, "PC_GPS_ALL_POUT_INFO" }, \
+ { PC_GPS_POUT_SETTINGS_IDX, "PC_GPS_POUT_SETTINGS_IDX" }, \
+ { PC_GPS_TIME_SCALE, "PC_GPS_TIME_SCALE" }, \
+ { PC_GPS_LAN_IF_INFO, "PC_GPS_LAN_IF_INFO" }, \
+ { PC_GPS_IP4_STATE, "PC_GPS_IP4_STATE" }, \
+ { PC_GPS_IP4_SETTINGS, "PC_GPS_IP4_SETTINGS" }, \
+ { PC_GPS_PTP_STATE, "PC_GPS_PTP_STATE" }, \
+ { PC_GPS_PTP_CFG, "PC_GPS_PTP_CFG" }, \
+ { PC_GPS_PTP_UC_MASTER_CFG_LIMITS, "PC_GPS_PTP_UC_MASTER_CFG_LIMITS" }, \
+ { PC_GPS_ALL_PTP_UC_MASTER_INFO, "PC_GPS_ALL_PTP_UC_MASTER_INFO" }, \
+ { PC_GPS_PTP_UC_MASTER_SETTINGS_IDX, "PC_GPS_PTP_UC_MASTER_SETTINGS_IDX" }, \
+ { PC_GPS_GPIO_CFG_LIMITS, "PC_GPS_GPIO_CFG_LIMITS" }, \
+ { PC_GPS_ALL_GPIO_INFO, "PC_GPS_ALL_GPIO_INFO" }, \
+ { PC_GPS_GPIO_SETTINGS_IDX, "PC_GPS_GPIO_SETTINGS_IDX" }, \
+ { PC_GPS_CFGH, "PC_GPS_CFGH" }, \
+ { PC_GPS_ALM, "PC_GPS_ALM" }, \
+ { PC_GPS_EPH, "PC_GPS_EPH" }, \
+ { PC_GPS_UTC, "PC_GPS_UTC" }, \
+ { PC_GPS_IONO, "PC_GPS_IONO" }, \
+ { PC_GPS_ASCII_MSG, "PC_GPS_ASCII_MSG" }, \
+ { 0, NULL } \
+}
+
+
/** codes used with PC_GPS_CMD */
enum
@@ -1204,6 +1384,8 @@ enum
N_PC_GPS_CMD /**< no command, just the number of known commands */
};
+
+
// The type below can be used to store an unambiguous command code.
// In case of the standard PCPS_... commands the lower byte contains
// the command code and the upper byte is 0.
@@ -1212,8 +1394,10 @@ enum
// the associated PC_GPS_... type code.
typedef uint16_t PCPS_CMD_INFO;
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/pcpsdev.h b/c/mbglib/include/pcpsdev.h
index 30015b6..551d097 100644
--- a/c/mbglib/include/pcpsdev.h
+++ b/c/mbglib/include/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.45 2009/06/19 12:15:18Z martin REL_M $
+ * $Id: pcpsdev.h 1.49.1.71 2012/06/01 11:04:30Z daniel TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,14 +17,146 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
- * Revision 1.45 2009/06/19 12:15:18Z martin
+ * Revision 1.49.1.71 2012/06/01 11:04:30Z daniel
+ * temporarily exclude function pointer definition for
+ * KeQuerySystemTime() from x64 builds
+ * Revision 1.49.1.70 2012/05/29 14:37:43Z martin
+ * Runtime support for precise time API introduced with Windows 8.
+ * Revision 1.49.1.69 2012/05/08 10:22:58Z daniel
+ * Bugfix: Use negative sign for delay in KeDelayExecutionThread()
+ * Revision 1.49.1.68 2011/11/28 10:04:39Z martin
+ * PZF180PEX doesn't support TIME_SCALE by default.
+ * Revision 1.49.1.67 2011/11/25 15:03:23 martin
+ * Support on-board event logs.
+ * Revision 1.49.1.66 2011/11/24 14:01:45 martin
+ * Added kernel uptime/sleep for NetBSD.
+ * Revision 1.49.1.65 2011/11/24 08:54:53 martin
+ * Moved macro _must_do_fw_workaround_20ms() here.
+ * Revision 1.49.1.64 2011/11/22 16:27:25 martin
+ * New macro _pcps_has_debug_status().
+ * Revision 1.49.1.63 2011/11/01 12:20:00 martin
+ * Revision 1.49.1.62 2011/11/01 12:14:33 martin
+ * Revision 1.49.1.61 2011/11/01 09:13:05 martin
+ * Revision 1.49.1.60 2011/10/31 08:55:05 martin
+ * Revision 1.49.1.59 2011/10/28 13:51:15 martin
+ * Added some macros to test if specific stat_info stuff is supported.
+ * Revision 1.49.1.58 2011/10/21 14:07:27 martin
+ * Revision 1.49.1.57 2011/09/21 16:03:04 martin
+ * Moved some definitions useful for configuration tools to new file cfg_hlp.h.
+ * Revision 1.49.1.56 2011/09/20 08:31:22 martin
+ * Modified default features for PZF180PEX.
+ * Revision 1.49.1.55 2011/09/12 12:32:38Z martin
+ * Revision 1.49.1.54 2011/09/12 09:45:12 martin
+ * Fixed a typo (missing comma).
+ * Revision 1.49.1.53 2011/08/05 11:02:28 martin
+ * Revision 1.49.1.52 2011/07/19 10:41:48 martin
+ * Revision 1.49.1.51 2011/07/14 13:29:14 martin
+ * Revision 1.49.1.50 2011/07/13 09:44:53 martin
+ * Moved IA64 includes from pcpsdev.h to mbgpccyc.h.
+ * Revision 1.49.1.49 2011/07/06 13:23:24 martin
+ * Revision 1.49.1.48 2011/07/06 11:22:50 martin
+ * Added macros _pcps_has_corr_info() and _pcps_has_tr_distance().
+ * Revision 1.49.1.47 2011/07/05 12:25:19 martin
+ * Revision 1.49.1.46 2011/07/04 10:29:44 martin
+ * Modified a comment.
+ * Revision 1.49.1.45 2011/06/29 14:06:08 martin
+ * Added support for TCR600USB, MSF600USB, and WVB600USB.
+ * Extended bus flag for USB v2 and macro _pcps_is_usb_v2().
+ * New feature ..._HAS_PZF and macro _pcps_has_pzf().
+ * Revision 1.49.1.44 2011/06/29 09:10:26 martin
+ * Renamed PZF600PEX to PZF180PEX.
+ * Revision 1.49.1.43 2011/06/24 10:26:52 martin
+ * Fixed warning under DOS.
+ * Revision 1.49.1.42 2011/06/24 08:07:03Z martin
+ * Moved PC cycles stuff to an new extra header.
+ * Revision 1.49.1.41 2011/06/21 15:17:36 martin
+ * Fixed build under DOS.
+ * Revision 1.49.1.40 2011/06/21 14:23:59Z martin
+ * Cleaned up handling of pragma pack().
+ * Introduced generic MBG_SYS_TIME with nanosecond resolution.
+ * Support struct timespec under Linux, if available.
+ * Revision 1.49.1.39 2011/06/01 09:29:09 martin
+ * Revision 1.49.1.38 2011/05/31 14:20:54 martin
+ * Revision 1.49.1.37 2011/05/16 13:18:38 martin
+ * Use MBG_TGT_KERNEL instead of _KDD_.
+ * Revision 1.49.1.36 2011/05/06 13:47:38Z martin
+ * Support PZF600PEX.
+ * Revision 1.49.1.35 2011/04/19 15:06:24 martin
+ * Added PTP unicast master configuration stuff.
+ * Revision 1.49.1.34 2011/03/29 14:08:45 martin
+ * For compatibility use cpu_counter() instead of cpu_counter_serializing() under NetBSD.
+ * Revision 1.49.1.33 2011/03/28 09:50:18 martin
+ * Modifications for NetBSD from Frank Kardel.
+ * Revision 1.49.1.32 2011/03/25 11:09:43 martin
+ * Optionally support timespec for sys time (USE_TIMESPEC).
+ * Started to support NetBSD.
+ * Revision 1.49.1.31 2011/02/16 10:10:49 martin
+ * Fixed macro syntax for _pcps_time_set_unread().
+ * Revision 1.49.1.30 2011/02/15 14:24:56Z martin
+ * Revision 1.49.1.29 2011/02/10 13:34:21 martin
+ * Revision 1.49.1.28 2011/02/10 13:21:59 martin
+ * Revision 1.49.1.27 2011/02/10 12:26:17 martin
+ * Revision 1.49.1.26 2011/02/09 15:46:49 martin
+ * Revision 1.49.1.25 2011/02/04 14:44:44 martin
+ * Revision 1.49.1.24 2011/02/04 10:10:00 martin
+ * Revision 1.49.1.23 2011/02/02 12:34:10 martin
+ * Revision 1.49.1.22 2011/02/01 17:12:04 martin
+ * Revision 1.49.1.21 2011/01/28 13:11:11 martin
+ * Preliminary implementation of mbg_get_sys_time for FreeBSD traps.
+ * Revision 1.49.1.20 2011/01/28 10:34:37 martin
+ * Moved MBG_TGT_SUPP_MEM_ACC definition here.
+ * Revision 1.49.1.19 2011/01/26 16:39:05 martin
+ * Preliminarily support FreeBSD build.
+ * Revision 1.49.1.18 2011/01/24 17:09:51 martin
+ * Preliminarily fixed build under FreeBSD.
+ * Revision 1.49.1.17 2010/12/14 13:19:58 martin
+ * Fixed doxgen comments.
+ * Revision 1.49.1.16 2010/12/14 12:20:10 martin
+ * Revision 1.49.1.15 2010/11/25 14:54:22 martin
+ * Moved status port register definitions to pcpsdefs.h.
+ * Revision 1.49.1.14 2010/11/11 09:15:38 martin
+ * Added definitions to support DCF600USB.
+ * Revision 1.49.1.13 2010/09/27 13:09:06 martin
+ * Features are now defined using enum and bit masks.
+ * Added initializer for feature names (used for debug).
+ * Revision 1.49.1.12 2010/08/25 12:44:42 martin
+ * Revision 1.49.1.11 2010/08/20 09:34:41Z martin
+ * Added macro _pcps_features().
+ * Revision 1.49.1.10 2010/08/17 15:34:23 martin
+ * Revision 1.49.1.9 2010/08/16 15:41:32 martin
+ * Revision 1.49.1.8 2010/08/13 12:14:46 daniel
+ * Revision 1.49.1.7 2010/08/13 11:57:54Z martin
+ * Revision 1.49.1.6 2010/08/13 11:39:28Z martin
+ * Revision 1.49.1.5 2010/08/13 11:19:41 martin
+ * Implemented portable mbg_get_sys_uptime() and mbg_sleep_sec()
+ * functions and associated types.
+ * Revision 1.49.1.4 2010/08/11 14:32:14 martin
+ * Revision 1.49.1.3 2010/08/11 13:47:42 martin
+ * Cleanup.
+ * Revision 1.49.1.2 2010/07/14 14:50:42 martin
+ * Revision 1.49.1.1 2010/06/30 13:17:18 martin
+ * Support GPS180PEX and TCR180PEX.
+ * Revision 1.49 2010/06/30 13:03:48 martin
+ * Use new preprocessor symbol MBG_ARCH_X86.
+ * Use ulong port addresses for all platforms but x86.
+ * Support mbg_get_pc_cycles() for IA64, but mbg_get_pc_cycles_frequency()
+ * is not yet supported.
+ * Don't pack interface structures on Sparc and IA64 architecture.
+ * Revision 1.48 2010/04/26 14:47:42 martin
+ * Define symbol MBG_PC_CYCLES_SUPPORTED if this is the case.
+ * Revision 1.47 2010/01/12 14:03:22 daniel
+ * Added definitions to support reading the raw IRIG data bits.
+ * Revision 1.46 2009/09/29 15:10:35Z martin
+ * Support generic system time, and retrieving time discipline info.
+ * Added _pcps_has_fast_hr_timestamp() macro and associated feature flag.
+ * Revision 1.45 2009/06/19 12:15:18 martin
* Added has_irig_time feature and associated macros.
* Revision 1.44 2009/06/08 19:30:48 daniel
* Account for new features PCPS_HAS_LAN_INTF and
* PCPS_HAS_PTP.
* Revision 1.43 2009/04/08 08:26:20 daniel
* Define firmware version at which the TCR511PCI starts
- * to support Irig control bits.
+ * to support IRIG control bits.
* Revision 1.42 2009/03/19 14:58:47Z martin
* Tmp. workaround in mbg_delta_pc_cycles() under SPARC which might
* generate bus errors due to unaligned access.
@@ -190,193 +322,464 @@
#ifndef _PCPSDEV_H
#define _PCPSDEV_H
+#include <mbg_tgt.h>
+#include <mbgtime.h>
+#include <mbgpccyc.h>
#include <pcpsdefs.h>
#include <gpsdefs.h>
#include <usbdefs.h>
-#include <mbg_tgt.h>
#include <use_pack.h>
+#if defined( MBG_TGT_WIN32 )
+
+ #include <mbg_w32.h>
+
+#elif defined( MBG_TGT_LINUX )
+
+ #if defined( MBG_TGT_KERNEL )
+ #include <linux/delay.h>
+ #include <linux/time.h>
+ #else
+ #include <unistd.h>
+ #include <time.h>
+ #include <sys/time.h>
+ #include <sys/sysinfo.h>
+ #endif
+
+#elif defined( MBG_TGT_FREEBSD )
+
+ #if defined( MBG_TGT_KERNEL )
+ #include <sys/sysproto.h>
+ #include <sys/pcpu.h>
+ #include <sys/param.h>
+ #include <sys/systm.h>
+ #include <sys/proc.h>
+ #else
+ #include <unistd.h>
+ #include <sys/time.h>
+ #endif
+
+#elif defined( MBG_TGT_NETBSD )
+
+ #if defined( MBG_TGT_KERNEL )
+ #include <sys/param.h> // mstohz
+ #include <sys/kernel.h> // hz
+ #else
+ #include <unistd.h>
+ #include <sys/time.h>
+ #endif
+
+#elif defined( MBG_TGT_QNX_NTO )
+
+ #include <unistd.h>
+
+#elif defined( MBG_TGT_DOS )
+
+ #include <dos.h> // for delay()
+
+#endif
/* Start of header body */
-#if defined( _USE_PACK ) // set byte alignment
- #pragma pack( 1 )
+#if defined( _USE_PACK )
+ #if !defined( _NO_USE_PACK_INTF )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+ #endif
+#endif
+
+
+#if defined( MBG_TGT_UNIX )
+ #define USE_GENERIC_SYS_TIME 1
+#else
+ #define USE_GENERIC_SYS_TIME 0
#endif
+#if USE_GENERIC_SYS_TIME
+ typedef struct
+ {
+ uint64_t sec;
+ uint64_t nsec;
+ } NANO_TIME_64;
+
+ typedef NANO_TIME_64 MBG_SYS_TIME;
+
+#endif
+
+
+
+/**
+ Define generic types to hold PC cycle counter values and system timestamps.
+ The generic types are defined using native types used by the target operating
+ systems.
+
+ The cycle counter value is usually derived from the PC CPU's TSC or some other
+ timer hardware on the mainboard.
+ */
#if defined( MBG_TGT_WIN32 )
- // used with QueryPerformanceCounter()
- typedef int64_t MBG_PC_CYCLES;
- typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
+ #define MBG_TGT_SUPP_MEM_ACC 1
+
+ typedef int64_t MBG_SYS_UPTIME; // [s]
+
+ typedef LARGE_INTEGER MBG_SYS_TIME;
#elif defined( MBG_TGT_LINUX )
- typedef uint64_t MBG_PC_CYCLES;
- typedef uint64_t MBG_PC_CYCLES_FREQUENCY;
+ #define MBG_TGT_SUPP_MEM_ACC 1
+
+ typedef int64_t MBG_SYS_UPTIME; // [s]
+
+#elif defined( MBG_TGT_BSD )
+
+ #define MBG_TGT_SUPP_MEM_ACC 1
+
+ typedef int64_t MBG_SYS_UPTIME; // [s]
+
+ #if defined( MBG_TGT_NETBSD )
+ #ifdef __LP64__
+ #define MBG_MEM_ADDR uint64_t
+ #else
+ #define MBG_MEM_ADDR uint32_t
+ #endif
+ #endif
#elif defined( MBG_TGT_OS2 )
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
+ typedef long MBG_SYS_UPTIME; //## dummy
+
+ typedef uint32_t MBG_SYS_TIME; //## dummy
#elif defined( MBG_TGT_DOS )
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
#define MBG_MEM_ADDR uint32_t // 64 bit not supported, nor required.
+ typedef long MBG_SYS_UPTIME; //## dummy
+
+ typedef uint32_t MBG_SYS_TIME; //## dummy
+
#else // other target OSs which access the hardware directly
- typedef uint32_t MBG_PC_CYCLES; //##++ should differentiate more
- typedef uint32_t MBG_PC_CYCLES_FREQUENCY;
+ typedef long MBG_SYS_UPTIME; //## dummy
+
+ typedef uint32_t MBG_SYS_TIME; //## dummy
#endif
-// MBG_PC_CYCLES and MBG_PC_CYCLES_FREQUENCY are always read in native
-// machine endianess, so no endianess conversion is required.
-#define _mbg_swab_mbg_pc_cycles( _p ) \
- _nop_macro_fnc()
+#if !defined( MBG_TGT_SUPP_MEM_ACC )
+ #define MBG_TGT_SUPP_MEM_ACC 0
+#endif
+
-#define _mbg_swab_mbg_pc_cycles_frequency( _p ) \
+// MBG_SYS_TIME is always read in native machine endianess,
+// so no endianess conversion is required.
+#define _mbg_swab_mbg_sys_time( _p ) \
_nop_macro_fnc()
-#if defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
+/**
+ The structure holds a system timestamp in a format depending on the target OS
+ plus two cycles counter values which can be taken before and after reading
+ the system time. These cycles values can be used to determine the execution
+ time required to read the system time.
+
+ Limitations of the operating system need to be taken into account,
+ e.g. the Windows system time may increase once every ~16 ms only.
+ */
+typedef struct
+{
+ MBG_PC_CYCLES cyc_before; /**< cycles count before sys time is read */
+ MBG_PC_CYCLES cyc_after; /**< cycles count after sys time has been read */
+ MBG_SYS_TIME sys_time; /**< system time stamp */
+} MBG_SYS_TIME_CYCLES;
+
+#define _mbg_swab_mbg_sys_time_cycles( _p ) \
+{ \
+ _mbg_swab_mbg_pc_cycles( &(_p)->cyc_before ); \
+ _mbg_swab_mbg_pc_cycles( &(_p)->cyc_after ); \
+ _mbg_swab_mbg_sys_time( &(_p)->sys_time ); \
+}
+
- static __mbg_inline unsigned long long int mbg_rdtscll( void )
- {
- // The code below is a hack to get around issues with
- // different versions of gcc.
- //
- // Normally the inline asm code could look similar to:
- //
- // __asm__ volatile ( "rdtsc" : "=A" (x) )
- //
- // which would copy the output regs edx:eax as a 64 bit
- // number to a variable x.
- //
- // The "=A" expression should implicitely tell the compiler
- // the edx and eax registers have been clobbered. However,
- // this does not seem to work properly at least with gcc 4.1.2
- // shipped with Centos 5.
- //
- // If optimization level 1 or higher is used then function
- // parameters are also passed in registers. If the inline
- // code above is used inside a function then the edx register
- // is clobbered but the gcc 4.1.2 is not aware of this and
- // assumes edx is unchanged, which may yield faulty results
- // or even lead to segmentation faults.
- //
- // A possible workaround could be to mark edx explicitely as
- // being clobbered in the asm inline code, but unfortunately
- // other gcc versions report an error if a register which is
- // implicitely (by "=A") known to be clobbered is also listed
- // explicitely to be clobbered.
- //
- // So the code below is a workaround which tells the compiler
- // implicitely that the eax ("=a") and edx ("=d") registers
- // are being used and thus clobbered.
-
- union
+
+
+static __mbg_inline
+void mbg_get_sys_time( MBG_SYS_TIME *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ #if defined( MBG_TGT_WIN32_PNP ) && !defined( MBG_TGT_WIN32_PNP_X64 )
+ extern KE_QUERY_SYSTEM_TIME_FNC ke_query_system_time_fnc;
+ ke_query_system_time_fnc( p );
+ #else
+ KeQuerySystemTime( p );
+ #endif
+ #else // user space
{
- struct
- {
- uint32_t lo;
- uint32_t hi;
- } u32;
+ FILETIME ft;
+ GetSystemTimeAsFileTime( &ft );
+ p->LowPart = ft.dwLowDateTime;
+ p->HighPart = ft.dwHighDateTime;
+ }
+ #endif
- uint64_t u64;
+ #elif defined( MBG_TGT_LINUX )
- } tsc_val;
+ #if defined( MBG_TGT_KERNEL )
- __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
+ #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 22 ) ) //##+++++++++++++
+ {
+ // getnstimeofday() supported
+ struct timespec ts;
- return tsc_val.u64;
+ getnstimeofday( &ts );
- } // mbg_rdtscll
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
+ }
+ #else
+ {
+ // getnstimeofday() *not* supported
+ struct timeval tv;
-#endif
+ do_gettimeofday( &tv );
+ p->sec = tv.tv_sec;
+ p->nsec = tv.tv_usec * 1000;
+ }
+ #endif
+ #else // Linux user space
+ {
+ struct timespec ts;
-static __mbg_inline
-void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
-{
- #if defined( MBG_TGT_WIN32 )
+ clock_gettime( CLOCK_REALTIME, &ts );
- #if defined( _KDD_ ) // kernel space
- *p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
- #else // user space
- QueryPerformanceCounter( (LARGE_INTEGER *) p );
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
+ }
#endif
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
+ #elif defined( MBG_TGT_BSD )
+
+ struct timespec ts;
- #if 0 && ( defined( CONFIG_X86_TSC ) || defined( CONFIG_M586TSC ) ) //##++++
- #define _pcps_get_cycles( _c ) \
- _c = get_cycles()
+ #if defined( MBG_TGT_KERNEL )
+ nanotime( &ts );
#else
- *p = mbg_rdtscll();
+ #if defined( MBG_TGT_FREEBSD )
+ clock_gettime( CLOCK_REALTIME_PRECISE, &ts );
+ #else // MBG_TGT_NETBSD, ...
+ clock_gettime( CLOCK_REALTIME, &ts );
+ #endif
#endif
+ p->sec = ts.tv_sec;
+ p->nsec = ts.tv_nsec;
+
#else
*p = 0;
#endif
-} // mbg_get_pc_cycles
+} // mbg_get_sys_time
static __mbg_inline
-void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
+void mbg_get_sys_uptime( MBG_SYS_UPTIME *p )
{
#if defined( MBG_TGT_WIN32 )
- LARGE_INTEGER li;
- #if defined( _KDD_ ) // kernel space
- KeQueryPerformanceCounter( &li );
- #else // user space
- QueryPerformanceFrequency( &li );
- #endif
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+
+ ULONGLONG time_increment = KeQueryTimeIncrement();
+ LARGE_INTEGER tick_count;
+
+ KeQueryTickCount( &tick_count );
+
+ // multiplication by time_increment yields HNS units,
+ // but we need seconds
+ *p = ( tick_count.QuadPart * time_increment ) / HNS_PER_SEC;
- *p = li.QuadPart;
+ #else // user space
+
+ DWORD tickCount;
+ DWORD timeAdjustment;
+ DWORD timeIncrement;
+ BOOL timeAdjustmentDisabled;
+
+ if ( !GetSystemTimeAdjustment( &timeAdjustment, &timeIncrement, &timeAdjustmentDisabled ) )
+ *p = -1; // failed
+
+ // ATTENTION: This is compatible with older Windows versions, but
+ // the returned tick count wraps around to zero after 49.7 days.
+ // A new GetTickCount64() call is available under Windows Vista and newer,
+ // but the function call had to be imported dynamically since otherwise
+ // programs refused to start under pre-Vista versions due to undefined DLL symbol.
+ tickCount = GetTickCount();
+
+ *p = ( ( (MBG_SYS_UPTIME) tickCount ) * timeIncrement ) / HNS_PER_SEC;
+
+ #endif
#elif defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ ) && defined( MBG_ARCH_I386 )
- *p = ( cpu_khz * 1000 );
+ #if defined( MBG_TGT_KERNEL )
+ {
+ // Using a simple 64 bit division may result in a linker error
+ // in kernel mode due to a missing symbol __udivdi3, so we use
+ // a specific inline function do_div().
+ // Also, the jiffies counter is not set to 0 at startup but to
+ // a defined initialization value we need to account for.
+ uint64_t tmp = get_jiffies_64() - INITIAL_JIFFIES;
+ do_div( tmp, HZ );
+ *p = tmp;
+ }
#else
- *p = 0;
+ {
+ struct sysinfo si;
+ int rc = sysinfo( &si );
+ *p = ( rc == 0 ) ? si.uptime : -1;
+ }
+ #endif
+
+ #elif defined( MBG_TGT_BSD )
+
+ #if defined( MBG_TGT_KERNEL )
+ {
+ struct timespec ts;
+ #if 0 //##+++++++
+ {
+ struct bintime bt;
+
+ binuptime( &bt );
+ #if defined( DEBUG )
+ printf( "binuptime: %lli.%09lli\n",
+ (long long) bt.sec,
+ (long long) bt.frac );
+ #endif
+ }
+ #endif
+
+ nanouptime( &ts );
+ #if defined( DEBUG )
+ printf( "nanouptime: %lli.%09lli\n",
+ (long long) ts.tv_sec,
+ (long long) ts.tv_nsec );
+ #endif
+ *p = ts.tv_sec;
+ }
+ #elif defined( MBG_TGT_FREEBSD )
+ {
+ struct timespec ts;
+ // CLOCK_UPTIME_FAST is specific to FreeBSD
+ int rc = clock_gettime( CLOCK_UPTIME_FAST, &ts );
+ *p = ( rc == 0 ) ? ts.tv_sec : -1;
+ }
+ #else // MBG_TGT_NETBSD, ...
+
+ *p = -1; //##++ needs to be implemented
+
#endif
#else
- *p = 0;
+ *p = -1; // not supported
#endif
-} // mbg_get_pc_cycles_frequency
+} // mbg_get_sys_uptime
static __mbg_inline
-MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
+void mbg_sleep_sec( long sec )
{
-#if defined( MBG_ARCH_SPARC )
- // cycle counts are currently not supported under SPARC, so we always return 0.
- return 0;
-#else
- return *p1 - *p2;
-#endif
+ #if defined( MBG_TGT_WIN32 )
+
+ #if defined( MBG_TGT_KERNEL ) // kernel space
+ LARGE_INTEGER delay;
-} // mbg_delta_pc_cycles
+ // we need to pass a negative value to KeDelayExecutionThread()
+ // since the given time is a relative time interval, not absolute
+ // time. See the API docs for KeDelayExecutionThread().
+ delay.QuadPart = - ((LONGLONG) sec * HNS_PER_SEC);
+
+ KeDelayExecutionThread( KernelMode, FALSE, &delay );
+ #else // user space
+ // Sleep() expects milliseconds
+ Sleep( sec * 1000 );
+ #endif
+
+ #elif defined( MBG_TGT_LINUX )
+
+ #if defined( MBG_TGT_KERNEL )
+ // msleep is not defined in older kernels, so we use this
+ // only if it is surely supported.
+ #if ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 16 ) ) //##+++++
+ msleep( sec * 1000 );
+ #else
+ {
+ DECLARE_WAIT_QUEUE_HEAD( tmp_wait );
+ wait_event_interruptible_timeout( tmp_wait, 0, sec * HZ + 1 );
+ }
+ #endif
+ #else
+ sleep( sec );
+ #endif
+
+ #elif defined( MBG_TGT_BSD )
+
+ #if defined( MBG_TGT_KERNEL )
+ #if defined( MBG_TGT_FREEBSD )
+ struct timeval tv = { 0 };
+ int ticks;
+ tv.tv_sec = sec;
+ ticks = tvtohz( &tv );
+ #if defined( DEBUG )
+ printf( "pause: %lli.%06lli (%i ticks)\n",
+ (long long) tv.tv_sec,
+ (long long) tv.tv_usec,
+ ticks );
+ #endif
+ pause( "pause", ticks );
+ #elif defined( MBG_TGT_NETBSD )
+ int timeo = mstohz( sec * 1000 );
+ #if defined( DEBUG )
+ printf( "kpause: %i s (%i ticks)\n", sec, timeo );
+ #endif
+ kpause( "pause", 1, timeo, NULL );
+ #endif
+ #else
+ sleep( sec );
+ #endif
+
+ #elif defined( MBG_TGT_QNX_NTO )
+
+ // Actually only tested under Neutrino.
+ sleep( sec );
+
+ #elif defined( MBG_TGT_DOS )
+
+ delay( (unsigned) ( sec * 1000 ) );
+
+ #else
+
+ // This needs to be implemented for the target OS
+ // and thus will probably yield a linker error.
+ do_sleep_sec( sec );
+
+ #endif
+
+} // mbg_sleep_sec
@@ -387,37 +790,10 @@ MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES
#endif
-typedef uint8_t PCPS_STATUS_PORT; /**< see \ref group_status_port "Bitmask" */
typedef uint8_t MBG_DBG_DATA;
typedef uint16_t MBG_DBG_PORT;
-// ------ definitions used when accessing a clock -------------------
-// (also refer to pcpsdefs.h for more common definitions)
-
-/** @defgroup group_status_port Bit masks of PCPS_STATUS_PORT
-
- These bits are ored with the #PCPS_STATUS_PORT byte.
-
- The flags #PCPS_ST_SEC and #PCPS_ST_MIN are cleared whenever the clock
- is read, so they are very unreliable in multitasking environments
- and should therefore be ignored.
-
- <b>NOTE</b>: On the PCI510 card the signal #PCPS_ST_IRQF has unintentionally
- not been wired. Functions which check if a card has triggered an IRQ
- should check the PCI_ASIC_PCI_IRQF flag provided by the PCI interface.
- The macros used by the mbglib driver library already do so.
- * @{
- */
-
-#define PCPS_ST_BUSY 0x01 /**< the clock is busy filling the output FIFO */
-#define PCPS_ST_IRQF 0x02 /**< the clock has generated an IRQ on the PC bus */
-#define PCPS_ST_MOD 0x20 /**< the DCF77 modulation */
-#define PCPS_ST_SEC 0x40 /**< Seconds have changed since last reading */
-#define PCPS_ST_MIN 0x80 /**< Minutes have changed since last reading */
-
-/** @} */
-
// The following flags describe the bus types which are
// supported by the plugin clocks.
#define PCPS_BUS_ISA 0x0001 // IBM compatible PC/AT ISA bus
@@ -425,27 +801,33 @@ typedef uint16_t MBG_DBG_PORT;
#define PCPS_BUS_PCI 0x0004 // PCI
#define PCPS_BUS_USB 0x0008 // USB
+
// The flags below are or'ed to the PC_BUS_PCI code
// in order to indicate which PCI interface chip is used
// on a PCI card. If no flag is set then the S5933 chip is
// installed which has been used for the first generation
// of Meinberg PCI cards.
+#define PCPS_BUS_PCI_CHIP_S5920 0x8000 // S5920 PCI interface chip.
+#define PCPS_BUS_PCI_CHIP_ASIC 0x4000 // Meinberg's own PCI interface chip.
+#define PCPS_BUS_PCI_CHIP_PEX8311 0x2000 // PEX8311 PCI Express interface chip
+#define PCPS_BUS_PCI_CHIP_MBGPEX 0x1000 // Meinberg's own PCI Express interface chip
-// S5920 PCI interface chip.
-#define PCPS_BUS_PCI_CHIP_S5920 0x8000
-
-// Meinberg's own PCI interface chip.
-#define PCPS_BUS_PCI_CHIP_ASIC 0x4000
-
-// PEX8311 PCI Express interface chip
-#define PCPS_BUS_PCI_CHIP_PEX8311 0x2000
-
-
-// The constant below combines the PCI bus flags.
+// The constants below combine the PCI bus flags:
#define PCPS_BUS_PCI_S5933 ( PCPS_BUS_PCI )
#define PCPS_BUS_PCI_S5920 ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_S5920 )
#define PCPS_BUS_PCI_ASIC ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_ASIC )
#define PCPS_BUS_PCI_PEX8311 ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_PEX8311 )
+#define PCPS_BUS_PCI_MBGPEX ( PCPS_BUS_PCI | PCPS_BUS_PCI_CHIP_MBGPEX )
+
+
+// The flags below are or'ed to the PCPS_BUS_USB code
+// in order to indicate which USB protocol version
+// is supported by the device. If no additional flag is set
+// then the device has a USB v1 interface.
+#define PCPS_BUS_USB_FLAG_V2 0x8000
+
+// The constant below combines the PCI bus flags:
+#define PCPS_BUS_USB_V2 ( PCPS_BUS_USB | PCPS_BUS_USB_FLAG_V2 )
@@ -478,6 +860,13 @@ enum PCPS_TYPES
PCPS_TYPE_FRC511PEX,
PCPS_TYPE_TCR170PEX,
PCPS_TYPE_WWVB51USB,
+ PCPS_TYPE_GPS180PEX,
+ PCPS_TYPE_TCR180PEX,
+ PCPS_TYPE_DCF600USB,
+ PCPS_TYPE_PZF180PEX,
+ PCPS_TYPE_TCR600USB,
+ PCPS_TYPE_MSF600USB,
+ PCPS_TYPE_WVB600USB,
N_PCPS_DEV_TYPE
};
@@ -488,7 +877,7 @@ typedef uint16_t PCPS_DEV_ID;
typedef uint16_t PCPS_REF_TYPE;
typedef uint16_t PCPS_BUS_FLAGS;
-/**
+/**
The structure contains the characteristics of each
of the clocks listed above. These fields are always the
same for a single type of clock and do not change with
@@ -505,10 +894,10 @@ typedef struct
-#if MBG_USE_MM_IO_FOR_PCI
- typedef uint64_t PCPS_PORT_ADDR;
-#else
+#if !defined( MBG_TGT_UNIX ) || defined( MBG_ARCH_X86 )
typedef uint16_t PCPS_PORT_ADDR;
+#else
+ typedef uint64_t PCPS_PORT_ADDR;
#endif
@@ -531,9 +920,11 @@ typedef struct
typedef struct
{
MBG_MEM_ADDR user_virtual_address;
- ulong len;
#if defined( MBG_TGT_LINUX )
- uint32_t pfn_offset;
+ uint64_t len;
+ uint64_t pfn_offset;
+ #else
+ ulong len;
#endif
} PCPS_MAPPED_MEM;
@@ -589,33 +980,114 @@ typedef struct
the possible features.
@{
*/
-#define PCPS_CAN_SET_TIME 0x00000001UL
-#define PCPS_HAS_SERIAL 0x00000002UL
-#define PCPS_HAS_SYNC_TIME 0x00000004UL
-#define PCPS_HAS_TZDL 0x00000008UL
-#define PCPS_HAS_IDENT 0x00000010UL
-#define PCPS_HAS_UTC_OFFS 0x00000020UL
-#define PCPS_HAS_HR_TIME 0x00000040UL
-#define PCPS_HAS_SERNUM 0x00000080UL
-#define PCPS_HAS_TZCODE 0x00000100UL
-#define PCPS_HAS_CABLE_LEN 0x00000200UL
-#define PCPS_HAS_EVENT_TIME 0x00000400UL // custom GPS firmware only
-#define PCPS_HAS_RECEIVER_INFO 0x00000800UL
-#define PCPS_CAN_CLR_UCAP_BUFF 0x00001000UL
-#define PCPS_HAS_PCPS_TZDL 0x00002000UL
-#define PCPS_HAS_UCAP 0x00004000UL
-#define PCPS_HAS_IRIG_TX 0x00008000UL
-#define PCPS_HAS_GPS_DATA_16 0x00010000UL // use 16 bit size specifiers
-#define PCPS_HAS_SYNTH 0x00020000UL
-#define PCPS_HAS_GENERIC_IO 0x00040000UL
-#define PCPS_HAS_TIME_SCALE 0x00080000UL
-#define PCPS_HAS_UTC_PARM 0x00100000UL
-#define PCPS_HAS_IRIG_CTRL_BITS 0x00200000UL
-#define PCPS_HAS_LAN_INTF 0x00400000UL
-#define PCPS_HAS_PTP 0x00800000UL
-#define PCPS_HAS_IRIG_TIME 0x01000000UL
+enum
+{
+ PCPS_BIT_CAN_SET_TIME,
+ PCPS_BIT_HAS_SERIAL,
+ PCPS_BIT_HAS_SYNC_TIME,
+ PCPS_BIT_HAS_TZDL,
+ PCPS_BIT_HAS_IDENT,
+ PCPS_BIT_HAS_UTC_OFFS,
+ PCPS_BIT_HAS_HR_TIME,
+ PCPS_BIT_HAS_SERNUM,
+
+ PCPS_BIT_HAS_TZCODE,
+ PCPS_BIT_HAS_CABLE_LEN,
+ PCPS_BIT_HAS_EVENT_TIME, // custom GPS firmware only
+ PCPS_BIT_HAS_RECEIVER_INFO,
+ PCPS_BIT_CAN_CLR_UCAP_BUFF,
+ PCPS_BIT_HAS_PCPS_TZDL,
+ PCPS_BIT_HAS_UCAP,
+ PCPS_BIT_HAS_IRIG_TX,
+
+ PCPS_BIT_HAS_GPS_DATA_16, // use 16 bit size specifiers
+ PCPS_BIT_HAS_SYNTH,
+ PCPS_BIT_HAS_GENERIC_IO,
+ PCPS_BIT_HAS_TIME_SCALE,
+ PCPS_BIT_HAS_UTC_PARM,
+ PCPS_BIT_HAS_IRIG_CTRL_BITS,
+ PCPS_BIT_HAS_LAN_INTF,
+ PCPS_BIT_HAS_PTP,
+
+ PCPS_BIT_HAS_IRIG_TIME,
+ PCPS_BIT_HAS_FAST_HR_TSTAMP,
+ PCPS_BIT_HAS_RAW_IRIG_DATA,
+ PCPS_BIT_HAS_PZF, // can also demodulate DCF77 PZF
+ PCPS_BIT_HAS_EVT_LOG,
+
+ N_PCPS_FEATURE // must not exceed 32 !!
+};
+
+
+#define PCPS_CAN_SET_TIME ( 1UL << PCPS_BIT_CAN_SET_TIME )
+#define PCPS_HAS_SERIAL ( 1UL << PCPS_BIT_HAS_SERIAL )
+#define PCPS_HAS_SYNC_TIME ( 1UL << PCPS_BIT_HAS_SYNC_TIME )
+#define PCPS_HAS_TZDL ( 1UL << PCPS_BIT_HAS_TZDL )
+#define PCPS_HAS_IDENT ( 1UL << PCPS_BIT_HAS_IDENT )
+#define PCPS_HAS_UTC_OFFS ( 1UL << PCPS_BIT_HAS_UTC_OFFS )
+#define PCPS_HAS_HR_TIME ( 1UL << PCPS_BIT_HAS_HR_TIME )
+#define PCPS_HAS_SERNUM ( 1UL << PCPS_BIT_HAS_SERNUM )
+#define PCPS_HAS_TZCODE ( 1UL << PCPS_BIT_HAS_TZCODE )
+#define PCPS_HAS_CABLE_LEN ( 1UL << PCPS_BIT_HAS_CABLE_LEN )
+#define PCPS_HAS_EVENT_TIME ( 1UL << PCPS_BIT_HAS_EVENT_TIME )
+#define PCPS_HAS_RECEIVER_INFO ( 1UL << PCPS_BIT_HAS_RECEIVER_INFO )
+#define PCPS_CAN_CLR_UCAP_BUFF ( 1UL << PCPS_BIT_CAN_CLR_UCAP_BUFF )
+#define PCPS_HAS_PCPS_TZDL ( 1UL << PCPS_BIT_HAS_PCPS_TZDL )
+#define PCPS_HAS_UCAP ( 1UL << PCPS_BIT_HAS_UCAP )
+#define PCPS_HAS_IRIG_TX ( 1UL << PCPS_BIT_HAS_IRIG_TX )
+#define PCPS_HAS_GPS_DATA_16 ( 1UL << PCPS_BIT_HAS_GPS_DATA_16 )
+#define PCPS_HAS_SYNTH ( 1UL << PCPS_BIT_HAS_SYNTH )
+#define PCPS_HAS_GENERIC_IO ( 1UL << PCPS_BIT_HAS_GENERIC_IO )
+#define PCPS_HAS_TIME_SCALE ( 1UL << PCPS_BIT_HAS_TIME_SCALE )
+#define PCPS_HAS_UTC_PARM ( 1UL << PCPS_BIT_HAS_UTC_PARM )
+#define PCPS_HAS_IRIG_CTRL_BITS ( 1UL << PCPS_BIT_HAS_IRIG_CTRL_BITS )
+#define PCPS_HAS_LAN_INTF ( 1UL << PCPS_BIT_HAS_LAN_INTF )
+#define PCPS_HAS_PTP ( 1UL << PCPS_BIT_HAS_PTP )
+#define PCPS_HAS_IRIG_TIME ( 1UL << PCPS_BIT_HAS_IRIG_TIME )
+#define PCPS_HAS_FAST_HR_TSTAMP ( 1UL << PCPS_BIT_HAS_FAST_HR_TSTAMP )
+#define PCPS_HAS_RAW_IRIG_DATA ( 1UL << PCPS_BIT_HAS_RAW_IRIG_DATA )
+#define PCPS_HAS_PZF ( 1UL << PCPS_BIT_HAS_PZF )
+#define PCPS_HAS_EVT_LOG ( 1UL << PCPS_BIT_HAS_EVT_LOG )
+
+
+
+#define PCPS_FEATURE_NAMES \
+{ \
+ "PCPS_CAN_SET_TIME", \
+ "PCPS_HAS_SERIAL", \
+ "PCPS_HAS_SYNC_TIME", \
+ "PCPS_HAS_TZDL", \
+ "PCPS_HAS_IDENT", \
+ "PCPS_HAS_UTC_OFFS", \
+ "PCPS_HAS_HR_TIME", \
+ "PCPS_HAS_SERNUM", \
+ "PCPS_HAS_TZCODE", \
+ "PCPS_HAS_CABLE_LEN", \
+ "PCPS_HAS_EVENT_TIME", \
+ "PCPS_HAS_RECEIVER_INFO", \
+ "PCPS_CAN_CLR_UCAP_BUFF", \
+ "PCPS_HAS_PCPS_TZDL", \
+ "PCPS_HAS_UCAP", \
+ "PCPS_HAS_IRIG_TX", \
+ "PCPS_HAS_GPS_DATA_16", \
+ "PCPS_HAS_SYNTH", \
+ "PCPS_HAS_GENERIC_IO", \
+ "PCPS_HAS_TIME_SCALE", \
+ "PCPS_HAS_UTC_PARM", \
+ "PCPS_HAS_IRIG_CTRL_BITS", \
+ "PCPS_HAS_LAN_INTF", \
+ "PCPS_HAS_PTP", \
+ "PCPS_HAS_IRIG_TIME", \
+ "PCPS_HAS_FAST_HR_TSTAMP", \
+ "PCPS_HAS_RAW_IRIG_DATA", \
+ "PCPS_HAS_PZF", \
+ "PCPS_HAS_EVT_LOG" \
+}
+
/** @} */
+
+
// The constants below define those features which are available
// in ALL firmware versions which have been shipped with a
// specific clock.
@@ -729,7 +1201,34 @@ typedef struct
#define PCPS_FEAT_WWVB51USB ( PCPS_FEAT_MSF51USB )
-// Some features of the API used to access Meinberg plug-in radio clocks
+#define PCPS_FEAT_GPS180PEX ( PCPS_FEAT_GPS170PEX | PCPS_HAS_FAST_HR_TSTAMP )
+
+#define PCPS_FEAT_TCR180PEX ( PCPS_FEAT_TCR170PEX | PCPS_HAS_FAST_HR_TSTAMP )
+
+#define PCPS_FEAT_DCF600USB ( PCPS_FEAT_USB5131 )
+
+#define PCPS_FEAT_PZF180PEX ( PCPS_FEAT_LVL2 \
+ | PCPS_HAS_TZDL \
+ | PCPS_HAS_HR_TIME \
+ | PCPS_HAS_SERNUM \
+ | PCPS_HAS_RECEIVER_INFO \
+ | PCPS_CAN_CLR_UCAP_BUFF \
+ | PCPS_HAS_UCAP \
+ | PCPS_HAS_GPS_DATA_16 \
+ | PCPS_HAS_GENERIC_IO \
+ | PCPS_HAS_UTC_PARM \
+ | PCPS_HAS_PZF )
+
+#define PCPS_FEAT_TCR600USB ( PCPS_FEAT_TCR51USB \
+ | PCPS_HAS_IRIG_CTRL_BITS \
+ | PCPS_HAS_IRIG_TIME \
+ | PCPS_HAS_RAW_IRIG_DATA )
+
+#define PCPS_FEAT_MSF600USB ( PCPS_FEAT_MSF51USB )
+
+#define PCPS_FEAT_WVB600USB ( PCPS_FEAT_WWVB51USB )
+
+// Some features of the API used to access Meinberg plug-in devices
// have been implemented starting with the special firmware revision
// numbers defined below.
//
@@ -753,14 +1252,20 @@ typedef struct
(_curr_asic_ver), (_req_asic_ver_major), (_req_asic_ver_minor ) ) \
)
+/* command PCPS_GIVE_RAW_IRIG_DATA: */
+#define REV_HAS_RAW_IRIG_DATA_TCR511PEX 0x0111
+#define REV_HAS_RAW_IRIG_DATA_TCR511PCI 0x0111
+#define REV_HAS_RAW_IRIG_DATA_TCR51USB 0x0106
/* command PCPS_GIVE_IRIG_TIME: */
#define REV_HAS_IRIG_TIME_TCR511PEX 0x0109
#define REV_HAS_IRIG_TIME_TCR511PCI 0x0109
+#define REV_HAS_IRIG_TIME_TCR51USB 0x0106
/* command PCPS_GET_IRIG_CTRL_BITS: */
#define REV_HAS_IRIG_CTRL_BITS_TCR511PEX 0x0107
#define REV_HAS_IRIG_CTRL_BITS_TCR511PCI 0x0107
+#define REV_HAS_IRIG_CTRL_BITS_TCR51USB 0x0106
/* This board uses the GPS_DATA interface with 16 bit buffer sizes
instead of the original 8 bit sizes, thus allowing to transfer
@@ -812,12 +1317,12 @@ typedef struct
/* command PCPS_GIVE_TIME_NOCLEAR: */
// This is supported by all clocks but PC31/PS31 with
-// firmware versions before v3.0. If such a card shall
+// firmware versions before v3.0. If such a card shall
// be used then the firmware should be updated to the
// last recent version.
-/**
+/**
The structure has been defined to pass all
information on a clock device from a device driver
to a user program. */
@@ -854,21 +1359,25 @@ typedef struct
#define _pcps_is_lwr( _d ) ( _pcps_is_dcf( _d ) || _pcps_is_msf( _d ) || _pcps_is_wwvb( _d ) )
+// Generic bus types:
#define _pcps_is_isa( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_ISA )
#define _pcps_is_mca( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_MCA )
#define _pcps_is_pci( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_PCI )
#define _pcps_is_usb( _d ) ( _pcps_bus_flags( _d ) & PCPS_BUS_USB )
+// Special bus types:
+#define _pcps_is_usb_v2( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_USB_V2 )
#define _pcps_is_pci_s5933( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5933 )
#define _pcps_is_pci_s5920( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_S5920 )
#define _pcps_is_pci_amcc( _d ) ( _pcps_is_pci_s5920( _d ) || _pcps_is_pci_s5933( _d ) )
#define _pcps_is_pci_asic( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_ASIC )
#define _pcps_is_pci_pex8311( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_PEX8311 )
+#define _pcps_is_pci_mbgpex( _d ) ( _pcps_bus_flags( _d ) == PCPS_BUS_PCI_MBGPEX )
// Access device configuration information:
-#define _pcps_bus_num( _d ) ( (_d)->cfg.bus_num )
-#define _pcps_slot_num( _d ) ( (_d)->cfg.slot_num )
+#define _pcps_bus_num( _d ) ( (_d)->cfg.bus_num )
+#define _pcps_slot_num( _d ) ( (_d)->cfg.slot_num )
#define _pcps_cfg_port_rsrc( _c, _n ) ( (_c)->port[_n] )
#define _pcps_port_rsrc( _d, _n ) _pcps_cfg_port_rsrc( &(_d)->cfg, (_n) )
@@ -884,11 +1393,12 @@ typedef struct
#define _pcps_timeout_clk( _d ) _pcps_cfg_timeout_clk( &(_d)->cfg )
#define _pcps_fw_rev_num( _d ) ( (_d)->cfg.fw_rev_num )
+#define _pcps_features( _d ) ( (_d)->cfg.features )
#define _pcps_fw_id( _d ) ( (_d)->cfg.fw_id )
#define _pcps_sernum( _d ) ( (_d)->cfg.sernum )
-// The macros below handle the clock device's err_flags.
+// The macros below handle the device's err_flags.
#define _pcps_err_flags( _d ) ( (_d)->cfg.err_flags )
#define _pcps_chk_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) & (_msk) )
#define _pcps_set_err_flags( _d, _msk ) ( _pcps_err_flags( _d ) |= (_msk) )
@@ -896,7 +1406,12 @@ typedef struct
// Query whether a special feature is supported:
-#define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 )
+#define _pcps_has_feature( _d, _f ) ( ( (_d)->cfg.features & (_f) ) != 0 )
+
+// Query whether a special feature is supported according to RECEIVER_INFO:
+#define _pcps_has_ri_feature( _p_ri, _f ) ( ( (_p_ri)->features & (_f) ) != 0 )
+
+
#define _pcps_can_set_time( _d ) _pcps_has_feature( (_d), PCPS_CAN_SET_TIME )
#define _pcps_has_serial( _d ) _pcps_has_feature( (_d), PCPS_HAS_SERIAL )
#define _pcps_has_sync_time( _d ) _pcps_has_feature( (_d), PCPS_HAS_SYNC_TIME )
@@ -937,7 +1452,6 @@ typedef struct
#define _pcps_has_mod( _d ) \
( _pcps_is_dcf( _d ) || _pcps_is_msf( _d ) || _pcps_is_wwvb( _d ) )
-
#define _pcps_has_irig( _d ) \
( _pcps_is_irig_rx( _d ) || _pcps_has_irig_tx( _d ) )
@@ -947,6 +1461,9 @@ typedef struct
#define _pcps_has_irig_time( _d ) \
_pcps_has_feature( (_d), PCPS_HAS_IRIG_TIME )
+#define _pcps_has_raw_irig_data( _d ) \
+ _pcps_has_feature( (_d), PCPS_HAS_RAW_IRIG_DATA )
+
#define _pcps_has_ref_offs( _d ) \
_pcps_is_irig_rx( _d )
@@ -969,80 +1486,112 @@ typedef struct
#define _pcps_has_utc_parm( _d ) _pcps_has_feature( (_d), PCPS_HAS_UTC_PARM )
+#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) \
+ || _pcps_is_pci_pex8311( _d ) \
+ || _pcps_is_pci_mbgpex( _d ) )
+
+#define _pcps_has_asic_features( _d ) _pcps_has_asic_version( _d )
+
+#define _pcps_has_fast_hr_timestamp( _d ) _pcps_has_feature( (_d), PCPS_HAS_FAST_HR_TSTAMP )
+
#define _pcps_has_lan_intf( _d ) _pcps_has_feature( (_d), PCPS_HAS_LAN_INTF )
#define _pcps_has_ptp( _d ) _pcps_has_feature( (_d), PCPS_HAS_PTP )
+#define _pcps_has_ri_ptp_unicast( _p_ri ) _pcps_has_ri_feature( (_p_ri), GPS_HAS_PTP_UNICAST )
-#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) || _pcps_is_pci_pex8311( _d ) )
+#define _pcps_has_pzf( _d ) _pcps_has_feature( (_d), PCPS_HAS_PZF )
-#define _pcps_has_asic_features( _d ) _pcps_has_asic_version( _d )
+#define _pcps_has_corr_info( _d ) _pcps_has_pzf( _d )
+#define _pcps_has_tr_distance( _d ) _pcps_has_pzf( _d )
-/**
- The structure is used to return info
- on the device driver.*/
-typedef struct
-{
- uint16_t ver_num; /**< the device driver's version number */
- uint16_t n_devs; /**< the number of radio clocks handled by the driver */
- PCPS_ID_STR id_str; /**< the device driver's ID string */
-} PCPS_DRVR_INFO;
+#define _pcps_has_evt_log( _d ) _pcps_has_feature( (_d), PCPS_HAS_EVT_LOG )
+#define _pcps_has_debug_status( _d ) _pcps_is_irig_rx( _d )
+#define _pcps_has_stat_info( _d ) ( _pcps_is_gps( _d ) || _pcps_has_pzf( _d ) )
-/*
- * The definitions and types below are used to collect
- * all configuration parameters of a clock's serial ports
- * that can be handled by this library:
- */
+#define _pcps_has_stat_info_mode( _d ) _pcps_is_gps( _d )
-// The maximum number of clocks' serial ports and string types
-// that can be handled by the configuration programs:
-#define MAX_PARM_PORT 4
-#define MAX_PARM_STR_TYPE 20
+#define _pcps_has_stat_info_svs( _d ) _pcps_is_gps( _d )
-typedef PORT_INFO_IDX ALL_PORT_INFO[MAX_PARM_PORT];
-typedef STR_TYPE_INFO_IDX ALL_STR_TYPE_INFO[MAX_PARM_STR_TYPE];
-typedef struct
-{
- ALL_PORT_INFO pii;
- ALL_STR_TYPE_INFO stii;
- PORT_PARM tmp_pp;
-} RECEIVER_PORT_CFG;
+// There are some versions of IRIG receiver cards which ignore the TFOM code
+// of an incoming IRIG signal even if an IRIG code has been configured which
+// supports this. In this case these cards synchronize to the incoming IRIG
+// signal even if the TFOM code reports the IRIG generator is not synchronized.
+// The intended behaviour is that the IRIG receiver card changes its status
+// to "freewheeling" in this case, unless it has been configured to ignore
+// the TFOM code of the incoming IRIG signal (see the IFLAGS_DISABLE_TFOM flag
+// defined in gpsdefs.h).
+// The macro below can be used to check based on the device info if a specific
+// card with a specific firmware always ignores the TFOM code:
+#define _pcps_incoming_tfom_ignored( _d ) \
+ ( ( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR167PCI ) && ( _pcps_fw_rev_num( _d ) <= 0x121 ) ) \
+ || ( ( _pcps_type_num( _d ) == PCPS_TYPE_TCR170PEX ) && ( _pcps_fw_rev_num( _d ) <= 0x103 ) ) )
-/*
- * The definitions and types below are used to collect
- * all configuration parameters of a clock's programmable
- * pulse outputs that can be handled by this library:
- */
+// Some Meinberg PCI Express cards have a PCIe interface chip with an extra
+// PCI bridge built into the chip. Unfortunately there are some mainboards out there
+// which do not handle PCI resources behind this PCI bridge correctly. The symptom is
+// usually that both I/O address ranges of these cards get the same base address
+// assigned by the BIOS, and the efeect is that in this case a card is not accessible
+// properly, since both I/O ranges try to respond to the same I/O addresses.
+// As a consequence data read from the card is usually garbage.
+// The only known fix for this is a BIOS update for the mainboard which makes the
+// BIOS handle the card's resources properly.
-#define MAX_PARM_POUT 4
+// The macro below can be used to test if both port base addresses assigned to a card
+// are identical, and thus the BIOS is probably faulty::
+#define _pcps_pci_cfg_err( _d ) \
+ ( _pcps_is_pci( _d ) && ( _pcps_port_base( _d, 1 ) == _pcps_port_base( _d, 0 ) ) )
-typedef POUT_INFO_IDX ALL_POUT_INFO[MAX_PARM_POUT];
+
+
+// There are some versions of GPS PCI firmware which may occasionally return
+// a HR time stamp which is wrong by 20 milliseconds, if the HR time is read
+// right after some GPS data. As a workaround for that bug an application
+// must wait at least 1.5 ms and then just read the PCPS_TIME structure
+// in order to re-initialize the software interface state.
+// This has been fixed in more recent versions of the affected firmware,
+// but this macro can be used to let an application determine whether it
+// must account for this bug with a given card and firmware version.
+#define _must_do_fw_workaround_20ms( _d ) \
+( \
+ ( _pcps_type_num( _d ) == PCPS_TYPE_GPS168PCI && _pcps_fw_rev_num( _d ) < 0x0102 ) || \
+ ( _pcps_type_num( _d ) == PCPS_TYPE_GPS167PCI && _pcps_fw_rev_num( _d ) < 0x0420 ) \
+)
+
+
+
+/**
+ The structure is used to return info
+ on the device driver.*/
+typedef struct
+{
+ uint16_t ver_num; /**< the device driver's version number */
+ uint16_t n_devs; /**< the number of radio clocks handled by the driver */
+ PCPS_ID_STR id_str; /**< the device driver's ID string */
+} PCPS_DRVR_INFO;
// The macros below can be used to mark a PCPS_TIME variable
// as unread, i.e. its contents have not been read from the clock,
// and to check if such a variable is marked as unread.
-#define _pcps_time_set_unread( _t ); { (_t)->sec = 0xFF; }
+#define _pcps_time_set_unread( _t ) do { (_t)->sec = 0xFF; } while ( 0 )
#define _pcps_time_is_read( _t ) ( (uchar) (_t)->sec != 0xFF )
/**
- The structure is used to read current time from
- a device, combined with an associated PC cycle counter value
- to compensate program execution time. The cycle counter value
- is usually derived from the PC CPU's TSC and the type is
- redefined to a common type, depending on the operating system.
- The cycle counter clock frequency usually corresponds to the
- PC CPU clock frequency.*/
+ The structure is used to read the current time from
+ a device, combined with an associated PC cycle counter value
+ to compensate program execution time.
+ */
typedef struct
{
MBG_PC_CYCLES cycles;
@@ -1051,10 +1600,10 @@ typedef struct
-/**
- The structure is used to read a high resolution UTC time stamp
- plus associated PC cycles counter value to compensate the latency.
- */
+/**
+ The structure is used to read a high resolution UTC time stamp
+ plus associated PC cycles counter value to compensate the latency.
+ */
typedef struct
{
MBG_PC_CYCLES cycles;
@@ -1069,14 +1618,11 @@ typedef struct
-/**
- The structure is used to read current high resolution time from
- a device, combined with an associated PC cycle counter value
- to compensate program execution time. The cycle counter value
- is usually derived from the PC CPU's TSC and the type is
- redefined to a common type, depending on the operating system.
- The cycle counter clock frequency usually corresponds to the
- PC CPU clock frequency.*/
+/**
+ The structure is used to read the current high resolution time
+ from a device, combined with an associated PC cycle counter value
+ to compensate program execution time.
+ */
typedef struct
{
MBG_PC_CYCLES cycles;
@@ -1091,6 +1637,50 @@ typedef struct
+/**
+ The structure below can be used to let the kernel driver read
+ the current system time plus the associated HR time from a plugin card
+ as close as possibly, and return the results to a user space application
+ which can then compute the time difference and latencies.
+ This structure also contains the card's status information (e.g. sync status).
+ */
+typedef struct
+{
+ PCPS_HR_TIME_CYCLES ref_hr_time_cycles; /**< HR time read from the card, plus cycles */
+ MBG_SYS_TIME_CYCLES sys_time_cycles; /**< system timestamp plus associated cycles */
+} MBG_TIME_INFO_HRT;
+
+#define _mbg_swab_mbg_time_info_hrt( _p ) \
+{ \
+ _mbg_swab_pcps_hr_time_cycles( &(_p)->ref_hr_time_cycles ); \
+ _mbg_swab_mbg_sys_time_cycles( &(_p)->sys_time_cycles ); \
+}
+
+
+
+/**
+ The structure below can be used to let the kernel driver read
+ the current system time plus an associated HR timestamp from a plugin card
+ as close as possibly, and return the results to a user space application
+ which can then compute the time difference and latencies.
+ Since the card's time stamp is usually taken using the fast memory mapped
+ access this structure does *not* contain the card's status information
+ (e.g. sync status).
+ */
+typedef struct
+{
+ PCPS_TIME_STAMP_CYCLES ref_tstamp_cycles; /**< HR timestamp from the card, plus cycles */
+ MBG_SYS_TIME_CYCLES sys_time_cycles; /**< system timestamp plus associated cycles */
+} MBG_TIME_INFO_TSTAMP;
+
+#define _mbg_swab_mbg_time_info_tstamp( _p ) \
+{ \
+ _mbg_swab_pcps_time_stamp_cycles( &(_p)->ref_tstamp_cycles ); \
+ _mbg_swab_mbg_sys_time_cycles( &(_p)->sys_time_cycles ); \
+}
+
+
+
typedef uint32_t PCPS_IRQ_STAT_INFO;
// Flags used with PCPS_IRQ_STAT_INFO:
@@ -1107,8 +1697,9 @@ typedef uint32_t PCPS_IRQ_STAT_INFO;
( (_v) & 0xFF )
-#if defined( _USE_PACK ) // set default alignment
- #pragma pack()
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
#endif
/* End of header body */
diff --git a/c/mbglib/include/rs232.h b/c/mbglib/include/rs232.h
new file mode 100644
index 0000000..8c8e19e
--- /dev/null
+++ b/c/mbglib/include/rs232.h
@@ -0,0 +1,135 @@
+
+/**************************************************************************
+ *
+ * $Id: rs232.h 1.12 2012/01/12 14:46:06Z martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for template.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: rs232.h $
+ * Revision 1.12 2012/01/12 14:46:06Z martin
+ * Removed German umlauts in old RCS log entries.
+ * Revision 1.11 2006/11/01 15:42:38Z martin
+ * Picked up Andre's new method SetComParameter().
+ * Revision 1.10 2006/10/30 14:47:51Z martin
+ * Updated function prototypes.
+ * Revision 1.9 2004/04/14 08:39:46Z martin
+ * Pack structures 1 byte aligned.
+ * Revision 1.8 2003/10/21 08:24:29Z martin
+ * Changed "bool" to "BOOL" to avoid compiler warnings.
+ * Revision 1.7 2003/10/16 12:44:36Z martin
+ * Don't define class if compiled without _cplusplus.
+ * Revision 1.6 2003/03/27 16:11:17 Daniel
+ * removed obsolete header files
+ * Revision 1.5 2003/03/10 09:26:02Z Daniel
+ * increased buffer size for ComName
+ * Revision 1.4 2002/11/26 10:24:22Z martin
+ * Port handle made public.
+ * New variables which keep transmission times per
+ * bit and per char in 100 nsec units, and bits per char.
+ * Use standard file template.
+ * Revision 1.3 2001/09/12 09:50:12Z Udo
+ * Fehler korrigiert:
+ * Schutz gegen rekursiven Include
+ * undef _ext ergaenzt
+ * Revision 1.2 2001/02/14 11:19:58Z WERNER
+ * Clear_Error Funktion zugefuegt
+ * Revision 1.1 2000/08/29 07:47:38Z WERNER
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _RS232_H
+#define _RS232_H
+
+
+/* Other headers to be included */
+
+#include <use_pack.h>
+
+#include <windows.h>
+
+
+#ifdef _RS232
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK ) // set byte alignment
+ #pragma pack( 1 )
+#endif
+
+
+typedef struct
+{
+ char ComName[7];
+ char Framing[4];
+ long Baudrate;
+} COMSTRUCT;
+
+
+#ifdef __cplusplus
+
+class Comport{
+public:
+ HANDLE Handle;
+ ULONG bits_per_char; // mostly 10 or 11, depending on the framing
+ ULONG bit_time; // 100 nsec units required to transmit 1 bit and 1 char,
+ ULONG char_time; // depending on transmission speed and bits per char.
+
+ class InitException { };
+ Comport( COMSTRUCT *Cpnt ); // Konstruktor
+ ~Comport(void); // Destruktor
+
+ void SetComParameter( COMSTRUCT *Cpnt );
+ int Read( LPSTR lpszBlock, int nMaxLength );
+ int Write( LPSTR lpszBlock, int nMaxLength );
+ BOOL RxClear( void );
+ BOOL TxClear( void );
+ DWORD ClearError( void );
+};
+
+#endif
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ HANDLE mbg_open_serial( const char *device_name ) ;
+ void mbg_log_com_error( DWORD dwErrorFlags, COMSTAT *pComStat ) ;
+ DWORD mbg_clear_comm_error( HANDLE h ) ;
+ int mbg_setup_port_list( int max_port_num, void (*callbackfnc)( const char *dev_name ) ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USE_PACK ) // set default alignment
+ #pragma pack()
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _RS232_H */
+
diff --git a/c/mbglib/include/shmem.h b/c/mbglib/include/shmem.h
new file mode 100644
index 0000000..f59d354
--- /dev/null
+++ b/c/mbglib/include/shmem.h
@@ -0,0 +1,253 @@
+
+/**************************************************************************
+ *
+ * $Id: shmem.h 1.20.1.1 2010/09/16 14:01:12Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and Prototypes for shmem.cpp.
+ * Shared Memory Block
+ *
+ * -----------------------------------------------------------------------
+ * $Log: shmem.h $
+ * Revision 1.20.1.1 2010/09/16 14:01:12Z martin
+ * Branch used to test handle leak under Win Server 2008.
+ * Revision 1.20 2010/06/25 13:49:22Z daniel
+ * Updated function prototypes.
+ * Revision 1.19 2009/08/14 09:18:39Z daniel
+ * Added new enum and parameter in SH_MEM_STATUS
+ * structure to send warnings to the monitor program.
+ * Revision 1.18 2009/03/16 16:50:36Z martin
+ * #include myutil.h to avoid build errors.
+ * Revision 1.17 2009/01/12 13:51:19Z daniel
+ * Added error code MBG_SVC_ERR_REF_TIME_STEP.
+ * Prepared support for the export of high resolution systemtime.
+ * Added structure SH_MEM_SYSTIME.
+ * Updated function prototypes.
+ * Revision 1.16 2006/05/23 19:31:06Z martin
+ * Split shared mem into 2 different struct, one which is written, and
+ * one which is read only by the service.
+ * Introduced ShMemStatus::err_info to indicate errors.
+ * Revision 1.15 2006/05/02 10:34:13Z martin
+ * Cleaned up and re-organized shared memory structure.
+ * Moved some definitions to timecnv.h.
+ * Revision 1.14 2005/06/09 10:35:53Z martin
+ * Moved declarations of serclock_cfg and adjtm_cfg here.
+ * Revision 1.13 2004/04/23 09:44:04Z martin
+ * Pack structures 1 byte aligned.
+ * Renamed shared memory fields.
+ * Made fmt string local to module.
+ * Updated function prototypes.
+ * Revision 1.12 2004/02/12 10:23:33Z martin
+ * Updated function prototypes.
+ * Revision 1.11 2003/12/05 08:57:33Z martin
+ * Made some variables local.
+ * Removed some obsolete variables.
+ * Revision 1.10 2003/10/29 08:18:00Z martin
+ * Removed obsolete fields.
+ * Revision 1.9 2003/09/10 09:14:47Z Daniel
+ * Deleted structure members that were added in mbgsvctl.
+ * Revision 1.8 2003/03/31 16:20:47 martin
+ * Made vars extern "C" to fix linker errors under MSVC++.
+ * Revision 1.7 2002/10/01 07:48:29Z Udo
+ * New members for Sharedmem: CurrState[], clock_type, and tray_icon_started
+ * used by the Tray-Icon program
+ * Revision 1.6 2002/09/26 09:49:02Z martin
+ * Use standard file structure.
+ * Include windows.h for basic data types.
+ * Revision 1.5 2002/08/29 09:20:04Z Daniel
+ * "check_tz" removed
+ * "mode" added
+ *
+ **************************************************************************/
+
+#ifndef _SHMEM_H
+#define _SHMEM_H
+
+/* Other headers to be included */
+
+// #include <mbgsvctl.h>
+#include <timecnv.h>
+// #include <myutil.h>
+#include <use_pack.h>
+
+#if defined( MBG_TGT_WIN32 )
+ #include <messages.h>
+ #include <windows.h>
+#endif
+
+
+#ifdef _SHMEM
+ #define _ext
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK ) // set byte alignment
+ #pragma pack( 1 )
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct
+{
+ DWORD port_number;
+ DWORD baudrate_index;
+ DWORD frame_type;
+ DWORD telegram_type;
+ DWORD mode;
+ DWORD error;
+} SERIAL_PORT_PARM;
+
+
+typedef struct
+{
+ DWORD code;
+ REF_TIME time;
+} ERR_INFO;
+
+// codes used with ERR_INFO::code:
+enum
+{
+ MBG_SVC_NO_ERROR,
+ MBG_SVC_ERR_OPEN_CLOCK_DEV,
+ MBG_SVC_ERR_OPEN_SERIAL_PORT,
+ MBG_SVC_ERR_SAME_REF_TIME,
+ MBG_SVC_ERR_REF_TIME_STEP,
+ N_MBG_SVC_ERR_CODE
+};
+
+
+
+/**
+ The enum and bitmasks used below are or'ed with
+ the "warnings" value of SH_MEM_STATUS
+*/
+enum
+{
+ MBG_SVC_WARNING_SYS_TIME_ADJ,
+ N_MBG_SVC_WARNINGS
+};
+
+
+#define MSK_SVC_WARNING_SYS_TIME_ADJ ( 1UL << MBG_SVC_WARNING_SYS_TIME_ADJ )
+
+
+
+typedef struct
+{
+ DWORD mbgadjtm_version;
+ REF_TIME sys_time;
+ REF_TIME ref_time;
+ REF_TIME last_serial_sync_time;
+ REF_TIME last_set_time;
+ DWORD last_set_time_diff;
+ DWORD last_dyn_correction;
+ DWORD diff;
+ DWORD warnings;
+ ERR_INFO err_info;
+} SH_MEM_STATUS;
+
+
+// The code below is used with SH_MEM_STATUS::last_dyn_correction
+// in order to indicate that the service is waiting for the clock
+// ty synchronize:
+#define SHM_LAST_DYN_WAIT_SYNC 0xFFFF
+
+
+typedef struct
+{
+ DWORD parameters_changed; // read by the service
+} SH_MEM_CMD;
+
+
+typedef struct
+{
+ ULONGLONG LastTimerCount;
+ ULONGLONG LastTimerTime;
+} SH_MEM_SYSTIME;
+
+
+
+_ext SH_MEM_STATUS ShMemStatus;
+_ext SH_MEM_CMD ShMemCmd;
+_ext SH_MEM_SYSTIME ShMemSysTime;
+
+
+#define _clr_err_info() \
+ _memclr( &ShMemStatus.err_info );
+
+
+// clear error only if error code matches
+#define _clr_err_info_code( _code ) \
+{ \
+ if ( ShMemStatus.err_info.code == ( _code ) ) \
+ _clr_err_info(); \
+}
+
+
+#define _set_err_info_code_time( _code, _t ) \
+{ \
+ _clr_err_info(); \
+ ShMemStatus.err_info.code = _code; \
+ ShMemStatus.err_info.time = _t; \
+}
+
+
+#define _set_err_info_code( _code ) \
+{ \
+ _clr_err_info(); \
+ ShMemStatus.err_info.code = _code; \
+}
+
+#define _set_warning_bit( _bit ) \
+{ \
+ ShMemStatus.warnings |= _bit; \
+}
+
+
+#define _clr_warning_bit( _bit ) \
+{ \
+ ShMemStatus.warnings &= ~_bit; \
+}
+
+
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ int ReadShMemStatus( void ) ;
+ int WriteShMemStatus( void ) ;
+ int ReadShMemCmd( void ) ;
+ int WriteShMemCmd( void ) ;
+ int ReadShMemSysTime( void ) ;
+ int WriteShMemSysTime( void ) ;
+ int CreateShMem( void ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USE_PACK ) // set default alignment
+ #pragma pack()
+#endif
+
+/* End of header body */
+
+#undef _ext
+
+#endif /* _SHMEM_H */
+
diff --git a/c/mbglib/include/timecnv.h b/c/mbglib/include/timecnv.h
new file mode 100644
index 0000000..767386e
--- /dev/null
+++ b/c/mbglib/include/timecnv.h
@@ -0,0 +1,362 @@
+
+/**************************************************************************
+ *
+ * $Id: timecnv.h 1.13.1.15 2011/11/07 17:38:23Z martin TRASH $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for timecnv.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: timecnv.h $
+ * Revision 1.13.1.15 2011/11/07 17:38:23Z martin
+ * Revision 1.13.1.14 2011/09/23 14:03:28Z martin
+ * Revision 1.13.1.13 2011/09/23 13:57:02Z martin
+ * Moved temp. code elsewhere.
+ * Revision 1.13.1.12 2011/09/14 14:17:56 martin
+ * Revision 1.13.1.11 2011/09/14 14:13:09Z martin
+ * Temporarily moved definition of MBGADJTM_CFG and related stuff here.
+ * Revision 1.13.1.10 2011/08/25 15:11:30Z marvin
+ * Changed lenght of COMSTRUCT::ComName from 7 to 20 chars for Unix only.
+ * Revision 1.13.1.9 2011/08/18 13:53:39 martin
+ * Revision 1.13.1.8 2011/08/18 12:50:01Z martin
+ * Temporarily moved definition of MBG_SERCLOCK_CFG and related stuff here.
+ * No need to include mbgsvctl.h anymore.
+ * Revision 1.13.1.7 2011/07/19 15:53:13Z martin
+ * Revision 1.13.1.6 2011/07/05 08:36:39Z martin
+ * Cleaned up handling of pragma pack().
+ * Revision 1.13.1.5 2010/11/08 12:25:17 martin
+ * Fixed Windows build.
+ * Revision 1.13.1.4 2010/03/05 10:00:25Z martin
+ * Moved FILETIME_1970, HNS_PER_SEC and HNS_PER_MS to mbgtime.h
+ * Revision 1.13.1.3 2010/03/05 09:38:59 martin
+ * Commented out some specific windows structs and functions.
+ * The constants of this file can be used on unix systems now.
+ * Revision 1.13.1.2 2010/01/08 15:05:11 martin
+ * Revision 1.13.1.1 2010/01/07 16:24:31Z martin
+ * Revision 1.13 2009/03/17 09:27:08Z daniel
+ * Updated function prototypes.
+ * Revision 1.12 2009/01/12 13:57:36Z daniel
+ * Uses ULL instead of LLU.
+ * FILETIME_1970 with 64 bit suffix is different for GnuC and VC.
+ * Added perf_count_on_time in SERIAL_TIME_STRING.
+ * Revision 1.11 2006/05/04 14:13:38Z martin
+ * Added initializers for time string format names.
+ * Added macro _secs_to_hns().
+ * Revision 1.10 2006/05/02 10:39:09Z martin
+ * Moved some definitions here and renamed some symbols.
+ * Added new definitions for unified parsing of time strings.
+ * Cleanup and renamed field in SERIAL_TIME_STRING.
+ * Updated function prototypes.
+ * Revision 1.9 2005/11/15 14:36:33Z martin
+ * Use new type PCPS_TIME_STATUS_X in REF_TIME.
+ * Updated function prototypes.
+ * Revision 1.8 2005/06/09 10:35:18Z martin
+ * Moved declaration of serclock_cfg elsewhere.
+ * Revision 1.7 2004/04/27 07:41:47Z martin
+ * Moved some macros here.
+ * Moved some constants from other files here.
+ * Pack structures 1 byte aligned.
+ * Updated function prototypes.
+ * Revision 1.6 2004/02/12 10:16:21Z martin
+ * Updated function prototypes.
+ * Revision 1.5 2004/01/06 16:26:56Z martin
+ * Updated function prototypes.
+ * Revision 1.4 2003/12/19 16:13:10Z martin
+ * New parameter for GET_REF_TIME_FNC type.
+ * Revision 1.3 2003/09/12 12:47:41Z Daniel
+ * added include file mbgsvctl.h
+ * Revision 1.2 2002/09/30 12:17:12 martin
+ * Added structure SERIAL_TIME_STRING.
+ * Added type of function to get REF_TIME.
+ * Updated function prototypes.
+ * Revision 1.1 2002/08/28 10:47:36Z Daniel
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _TIMECNV_H
+#define _TIMECNV_H
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <gpsdefs.h>
+#include <pcpsdefs.h>
+#include <pcpsutil.h>
+#include <mbgtime.h>
+#include <mbgpccyc.h>
+
+#if defined( MBG_TGT_WIN32 )
+ #include <rs232.h>
+ #include <mbgdevio.h>
+ #include <mbg_serclock_cfg.h>
+#endif //MBG_TGT_WIN32
+
+#include <use_pack.h>
+
+
+#ifdef _TIMECNV
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if defined( _USE_PACK )
+ #pragma pack( 1 ) // set byte alignment
+ #define _USING_BYTE_ALIGNMENT
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// ASCII definitions
+
+#define ASCII_STX 0x02
+#define ASCII_ETX 0x03
+#define ASCII_BEL 0x07
+#define ASCII_BS 0x08
+#define ASCII_LF 0x0A
+#define ASCII_CR 0x0D
+#define ASCII_XON 0x11
+#define ASCII_XOFF 0x13
+
+#define STR_STX "\x2"
+#define STR_ETX "\x3"
+
+
+#define _perf_cnt_to_us( _v ) \
+ ( (double) (_v) * (double) ( HNS_PER_SEC / 10 ) / (double) PerfFrequency )
+
+#define _perf_cnt_to_hns( _v ) \
+ ( (double) (_v) * (double) HNS_PER_SEC / (double) PerfFrequency )
+
+#define _secs_to_hns( _v ) \
+ ( ( (LONGLONG) (_v) ) * HNS_PER_SEC )
+
+#if defined( MBG_TGT_WIN32 )
+// ATTENTION: the declaration below may be tricky. Even though
+// no problems have been observed, yet, the MS docs clearly say
+// there may be alignment problems under 64 bit Windows.
+// If the FILETIME members are not 32 bit aligned then accessing
+// the dwl member below will yield wrong values.
+typedef union
+{
+ FILETIME ft;
+ uint64_t dwl;
+} FT_DWL;
+
+
+
+typedef struct
+{
+ FT_DWL ftdwl; // based on UTC
+ int32_t utc_offs; // [sec]
+ PCPS_TIME_STATUS_X status; // extended status
+} REF_TIME;
+
+
+
+typedef struct
+{
+ REF_TIME rt;
+ MBG_PC_CYCLES cycles;
+} REF_TIME_CYCLES;
+
+
+
+#define MAX_TIMESTR_LEN 150
+
+typedef struct
+{
+ char timestring[MAX_TIMESTR_LEN];
+ REF_TIME sys_time_on_time;
+ MBG_PC_CYCLES sys_cycles_on_time;
+} SERIAL_TIME_STRING;
+
+
+// a pointer to a function that takes a time stamp of the system time
+typedef int (*GET_REF_TIME_FNC)( REF_TIME *tp, LARGE_INTEGER *pli );
+
+#endif //MBG_TGT_WIN32
+
+// supported time string formats
+
+enum
+{
+ SF_MBG_STD,
+ SF_SAT,
+ SF_INTERFLEX,
+ N_SF
+};
+
+
+// Initializers for the time string format names
+
+#define SF_NAME_MBG_STD_ENG "Meinberg Time String"
+#define SF_NAME_MBG_STD_GER "Meinberg Zeittelegramm"
+
+#define SF_NAME_SAT_ENG "SAT Time String"
+#define SF_NAME_SAT_GER "SAT Zeittelegramm"
+
+#define SF_NAME_INTERFLEX_ENG "Interflex Time String"
+#define SF_NAME_INTERFLEX_GER "Interflex Zeittelegramm"
+
+
+#define SF_NAMES_ENG \
+{ \
+ SF_NAME_MBG_STD_ENG, \
+ SF_NAME_SAT_ENG, \
+ SF_NAME_INTERFLEX_ENG \
+}
+
+
+#define SF_NAMES_LSTR \
+{ \
+ { SF_NAME_MBG_STD_ENG, SF_NAME_MBG_STD_GER }, \
+ { SF_NAME_SAT_ENG, SF_NAME_SAT_GER }, \
+ { SF_NAME_INTERFLEX_ENG, SF_NAME_INTERFLEX_GER } \
+}
+
+
+
+// a structure to store the characteristics of a time string
+
+typedef struct
+{
+ const char *chk_fmt; // to check the format, len must be str len
+ char skip_char;
+ char first_char;
+ char on_time_char;
+} TS_SPEC;
+
+
+#define TS_SPEC_MBG_STD \
+{ \
+ STR_STX "D:__.__.__;T:_;U:__.__.__;____" STR_ETX, \
+ '_', \
+ ASCII_STX, \
+ ASCII_STX \
+}
+
+#define TS_SPEC_SAT \
+{ \
+ STR_STX "__.__.__/_/__:__:__________" STR_ETX, \
+ '_', \
+ ASCII_STX, \
+ ASCII_STX \
+}
+
+#define TS_SPEC_INTERFLEX \
+{ \
+ STR_STX "IFD:__.__.__;T:_;U:__.__.__;____" STR_ETX, \
+ '_', \
+ ASCII_STX, \
+ ASCII_STX \
+}
+
+
+// Default initializer for an array of N_SF TS_SPECs
+
+#define DEFAULT_TS_SPECS \
+{ \
+ TS_SPEC_MBG_STD, \
+ TS_SPEC_SAT, \
+ TS_SPEC_INTERFLEX \
+}
+
+#if defined( MBG_TGT_WIN32 )
+
+_ext TS_SPEC ts_spec[N_SF]
+#ifdef _DO_INIT
+ = DEFAULT_TS_SPECS
+#endif
+;
+
+
+_ext ushort year_limit
+#ifdef _DO_INIT
+ = 1990
+#endif
+;
+
+#endif //MBG_TGT_WIN32
+
+
+
+#if defined( MBG_TGT_WIN32 )
+
+static __mbg_inline
+void mbg_pcps_time_stamp_to_filetime( FILETIME *p_ft, const PCPS_TIME_STAMP *p_ts )
+{
+ uint64_t ts64;
+ uint32_t frac;
+
+ frac = frac_sec_from_bin( p_ts->frac, PCPS_HRT_FRAC_SCALE );
+ ts64 = ( (uint64_t) p_ts->sec ) * HNS_PER_SEC + FILETIME_1970 + frac;
+
+ p_ft->dwHighDateTime = (uint32_t) ( ts64 >> 32 );
+ p_ft->dwLowDateTime = (uint32_t) ( ts64 & 0xFFFFFFFFUL );
+
+} // mbg_pcps_time_stamp_to_filetime
+
+
+
+static __mbg_inline
+void mbg_pcps_tstamp64_to_filetime( FILETIME *p_ft, const uint64_t *p_ts64 )
+{
+ PCPS_TIME_STAMP ts;
+
+ uint64_to_pcps_time_stamp( &ts, *p_ts64 );
+ mbg_pcps_time_stamp_to_filetime( p_ft, &ts );
+
+} // mbg_pcps_tstamp64_to_filetime
+
+
+
+/* function prototypes: */
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ int check_time_string( const char *ts, int len, int sf ) ;
+ void decode_str_date_std( SYSTEMTIME *pt, const char *s ) ;
+ void decode_str_wday_std( SYSTEMTIME *pt, const char *s ) ;
+ void decode_str_time_std( SYSTEMTIME *pt, const char *s ) ;
+ int decode_time_str( SYSTEMTIME *pt, long *utc_offs_sec, PCPS_TIME_STATUS_X *status, const char *ts, const MBG_SERCLOCK_CFG *pcfg ) ;
+ void timestring_to_ref_and_sys_filetime( SERIAL_TIME_STRING *sts, REF_TIME *st, REF_TIME *rt, const MBG_SERCLOCK_CFG *pcfg ) ;
+ void systemtime_to_pcps_time( PCPS_TIME *pt, const SYSTEMTIME *pst ) ;
+ void pcps_time_to_systemtime( SYSTEMTIME *pst, const PCPS_TIME *pt ) ;
+ int pcps_time_to_ref_time( REF_TIME *rt, const PCPS_TIME *pt ) ;
+ void pcps_hr_time_to_ref_time( REF_TIME *rt, const PCPS_HR_TIME *hr_time ) ;
+ void pcps_hr_time_to_pcps_time( PCPS_TIME *ptime, const PCPS_HR_TIME *hr_time ) ;
+
+/* ----- function prototypes end ----- */
+
+#endif //MBG_TGT_WIN32
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#if defined( _USING_BYTE_ALIGNMENT )
+ #pragma pack() // set default alignment
+ #undef _USING_BYTE_ALIGNMENT
+#endif
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _TIMECNV_H */
diff --git a/c/mbglib/include/usbdefs.h b/c/mbglib/include/usbdefs.h
index ebb5e4d..e0e21e2 100644
--- a/c/mbglib/include/usbdefs.h
+++ b/c/mbglib/include/usbdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: usbdefs.h 1.9 2009/03/13 09:02:24Z martin REL_M $
+ * $Id: usbdefs.h 1.17 2012/08/08 07:53:29Z daniel TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,24 @@
*
* -----------------------------------------------------------------------
* $Log: usbdefs.h $
- * Revision 1.9 2009/03/13 09:02:24Z martin
+ * Revision 1.17 2012/08/08 07:53:29Z daniel
+ * Added class code and device ID for LIU
+ * Revision 1.16 2012/02/13 09:29:59 paul
+ * added class code for LNO180
+ * Revision 1.15 2011/10/11 06:21:04Z andre
+ * added class code for GPS180
+ * Revision 1.14 2011/10/07 10:13:25Z daniel
+ * New class code and device id for CPE
+ * Revision 1.13 2011/06/29 14:11:23Z martin
+ * Added device IDs for TCR600USB, MSF600USB, and WVB600USB.
+ * Revision 1.12 2011/05/11 07:20:37 daniel
+ * New class code and device id for fan control unit
+ * Revision 1.11 2011/04/13 07:59:11 daniel
+ * New class code and device id for external
+ * synchronization interface device.
+ * Revision 1.10 2010/11/11 09:16:33Z martin
+ * Added device ID for DCF600USB.
+ * Revision 1.9 2009/03/13 09:02:24 martin
* Removed definitions for timeout intervals.
* Revision 1.8 2009/02/18 11:08:44 daniel
* Added new class code and device ID for SCU_USB
@@ -64,6 +81,12 @@ enum
MBG_USB_CLASS_MSF, // MSF Radio Clock
MBG_USB_CLASS_WWVB, // WWVB Radio Clock
MBG_USB_CLASS_SCU, // Meinberg Signal Changeover Unit
+ MBG_USB_CLASS_ESI, // External Synchronization Interface
+ MBG_USB_CLASS_FCU, // Fan Control Unit
+ MBG_USB_CLASS_CPE, // Configurable Port Expander
+ MBG_USB_CLASS_GPS, // GPS Receiver
+ MBG_USB_CLASS_LNO, // Low Phase Noise Option
+ MBG_USB_CLASS_LIU, // Line Interface Unit
N_MBG_USB_CLASS // number of known device class codes
};
@@ -78,17 +101,34 @@ enum
#define USB_DEV_TSU_01 ( ( MBG_USB_CLASS_TSU << 8 ) | 0x01 )
#define USB_DEV_USB5131 ( ( MBG_USB_CLASS_DCF << 8 ) | 0x01 )
+#define USB_DEV_DCF600USB ( ( MBG_USB_CLASS_DCF << 8 ) | 0x02 )
#define USB_DEV_CMC ( ( MBG_USB_CLASS_CMC << 8 ) | 0x01 )
#define USB_DEV_TCR51USB ( ( MBG_USB_CLASS_TCR << 8 ) | 0x01 )
+#define USB_DEV_TCR600USB ( ( MBG_USB_CLASS_TCR << 8 ) | 0x02 )
#define USB_DEV_MSF51USB ( ( MBG_USB_CLASS_MSF << 8 ) | 0x01 )
+#define USB_DEV_MSF600USB ( ( MBG_USB_CLASS_MSF << 8 ) | 0x02 )
#define USB_DEV_WWVB51USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x01 )
+#define USB_DEV_WVB600USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x02 )
#define USB_DEV_SCU_USB ( ( MBG_USB_CLASS_SCU << 8 ) | 0x01 )
+#define USB_DEV_ESI_01 ( ( MBG_USB_CLASS_ESI << 8 ) | 0x01 )
+
+#define USB_DEV_FCU_01 ( ( MBG_USB_CLASS_FCU << 8 ) | 0x01 )
+
+#define USB_DEV_CPE_01 ( ( MBG_USB_CLASS_CPE << 8 ) | 0x01 )
+
+#define USB_DEV_GPS180 ( ( MBG_USB_CLASS_GPS << 8 ) | 0x01 )
+
+#define USB_DEV_LNO180_01 ( ( MBG_USB_CLASS_LNO << 8 ) | 0x01 )
+
+#define USB_DEV_LIU_01 ( ( MBG_USB_CLASS_LIU << 8 ) | 0x01 )
+
+
enum
{
MBGUSB_EP_IDX_HOST_IN, // transfers from device to host
diff --git a/c/mbglib/include/use_pack.h b/c/mbglib/include/use_pack.h
index b162014..16950fa 100644
--- a/c/mbglib/include/use_pack.h
+++ b/c/mbglib/include/use_pack.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: use_pack.h 1.2 2002/02/25 08:50:33Z Andre REL_M $
+ * $Id: use_pack.h 1.3 2011/01/26 10:01:41Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,9 @@
*
* -----------------------------------------------------------------------
* $Log: use_pack.h $
- * Revision 1.2 2002/02/25 08:50:33Z Andre
+ * Revision 1.3 2011/01/26 10:01:41Z martin
+ * Provided a way to suppress packing of structures on a project base.
+ * Revision 1.2 2002/02/25 08:50:33 Andre
* query __ARM added, __SH2 removed
* Revision 1.1 2001/03/30 08:54:33Z MARTIN
* Initial revision
@@ -21,8 +23,16 @@
#ifndef _USE_PACK_H
#define _USE_PACK_H
-#if ( !defined( _C166 ) && !defined( _CC51 ) && !defined( __ARM ) )
- #define _USE_PACK
+#if ( !defined( _C166 ) && \
+ !defined( _CC51 ) && \
+ !defined( __ARM ) )
+
+ // _NO_USE_PACK can be defined for specific projects
+ // to avoid packing of structures.
+ #if ( !defined( _NO_USE_PACK ) )
+ #define _USE_PACK
+ #endif
+
#endif
#endif /* _USE_PACK_H */
diff --git a/c/mbglib/include/words.h b/c/mbglib/include/words.h
index a4337f6..2174160 100644
--- a/c/mbglib/include/words.h
+++ b/c/mbglib/include/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.20 2009/07/02 15:38:12Z martin REL_M $
+ * $Id: words.h 1.29 2012/07/11 16:45:45Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,29 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
- * Revision 1.20 2009/07/02 15:38:12Z martin
+ * Revision 1.29 2012/07/11 16:45:45Z martin
+ * New macros to access individual bytes of long constants.
+ * Revision 1.28 2012/04/05 14:36:18Z martin
+ * Support CVI 2010 compiler which provides C99 types.
+ * Revision 1.27 2011/07/18 10:21:38Z martin
+ * Added definition for MBG_CODE_NAME_TABLE_ENTRY which can
+ * be used to define tables assigning strings to numeric codes.
+ * Revision 1.26 2011/04/06 10:23:03 martin
+ * Added FBYTE_OF() and FWORD_OF() macros.
+ * Modifications required for *BSD.
+ * Revision 1.25 2010/11/17 10:23:09 martin
+ * Define _BIT_REDEFINED if bit type is redefined.
+ * Revision 1.24 2010/11/17 08:44:56Z martin
+ * If supported, use type "bool" to implement "bit".
+ * Revision 1.23 2010/05/27 08:54:30Z martin
+ * Support fixed size data types with Keil RealView compiler for ARM.
+ * Keil RealView ARM targets are always considered as firmware.
+ * Revision 1.22 2009/10/21 07:53:55 martin
+ * Undid changes introduced in 1.21 since they were not consistent
+ * across glibc and/or Linux kernel header versions.
+ * Revision 1.21 2009/10/01 14:00:17 martin
+ * Conditionally define ulong and friends also for Linux/glibc.
+ * Revision 1.20 2009/07/02 15:38:12 martin
* Added new macro _wswap32().
* Revision 1.19 2009/04/14 14:45:45Z martin
* Added BYTE_OF_P() and WORD_OF_P() macros.
@@ -69,7 +91,8 @@
#if defined( _C166 ) || \
defined( _CC51 ) || \
- defined( __ARM )
+ defined( __ARM ) || \
+ defined( __ARMCC_VERSION )
#define _IS_MBG_FIRMWARE 1
#else
#define _IS_MBG_FIRMWARE 0
@@ -80,8 +103,6 @@
#if !_IS_MBG_FIRMWARE
#include <mbg_tgt.h>
-
- typedef unsigned char bit;
#endif
@@ -95,6 +116,14 @@
/* Start of header body */
+// The compilers below support native bit types.
+
+#if defined( _C166 ) || defined( _CC51 )
+ #define _BIT_DEFINED 1
+#endif
+
+
+
// Check whether the target system supports C99 fixed-size types.
#if defined( MBG_TGT_LINUX ) // any Linux target
@@ -113,6 +142,7 @@
#include <sys/types.h>
#define _C99_BIT_TYPES_DEFINED 1
+ #define _MISSING_STDBOOL_H 1
#elif defined( MBG_TGT_QNX ) // QNX 4.x or QNX 6.x
@@ -127,26 +157,27 @@
#endif
+
// If it's not yet clear whether fixed-size types are supported,
// check the build environment which may be multi-platform.
#if !defined( _C99_BIT_TYPES_DEFINED )
#if defined( __WATCOMC__ )
- #if __WATCOMC__ > 1230 // Open Watcom C 1.3 and above
+ #if ( __WATCOMC__ > 1230 ) // Open Watcom C 1.3 and above
#include <stdint.h>
- #define _C99_BIT_TYPES_DEFINED 1
+ #define _C99_BIT_TYPES_DEFINED 1
#elif defined( __WATCOM_INT64__ ) // Watcom C 11, non-QNX
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
- #define _C99_BIT_TYPES_DEFINED 1
+ #define _C99_BIT_TYPES_DEFINED 1
#endif
#endif
#if defined( __BORLANDC__ )
#if ( __BORLANDC__ >= 0x570 ) // at least Borland Developer Studio 2006
- #define _C99_BIT_TYPES_DEFINED 1
+ #define _C99_BIT_TYPES_DEFINED 1
#endif
#endif
@@ -155,6 +186,17 @@
#define _C99_BIT_TYPES_DEFINED 1
#endif
+ #if defined( __ARMCC_VERSION ) // Keil RealView Compiler for ARM
+ #include <stdint.h>
+ #define _C99_BIT_TYPES_DEFINED 1
+ #endif
+
+ #if defined( _CVI_ ) && ( _CVI_ >= 1000 )
+ #include <stdint.h>
+ #define _C99_BIT_TYPES_DEFINED 1
+ #define _MISSING_STDBOOL_H 1
+ #endif
+
#endif
@@ -212,7 +254,7 @@
typedef unsigned char uchar;
-#if !defined( MBG_TGT_LINUX )
+#if !defined( MBG_TGT_LINUX ) && !( defined ( MBG_TGT_NETBSD ) && defined ( MBG_TGT_KERNEL ) )
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
@@ -226,6 +268,43 @@ typedef unsigned long longword;
typedef unsigned long dword;
+#if !defined( _BIT_DEFINED )
+
+ #if _C99_BIT_TYPES_DEFINED
+
+ #if !defined( _MISSING_STDBOOL_H )
+ #include <stdbool.h>
+ #endif
+
+ #if !defined( __bool_true_false_are_defined )
+ #if !defined( __cplusplus )
+ #define bool _Bool
+ #define true 1
+ #define false 0
+ #define __bool_true_false_are_defined 1
+ #endif
+
+ #endif
+
+ typedef bool bit;
+
+ #else
+
+ typedef int bit;
+
+ #endif
+
+ #define _BIT_REDEFINED 1
+
+#endif
+
+
+#define BYTE_0( _x ) ( ( (ulong) (_x) ) & 0xFF )
+#define BYTE_1( _x ) ( ( ( (ulong) (_x) ) >> 8 ) & 0xFF )
+#define BYTE_2( _x ) ( ( ( (ulong) (_x) ) >> 16 ) & 0xFF )
+#define BYTE_3( _x ) ( ( ( (ulong) (_x) ) >> 24 ) & 0xFF )
+
+
#define HI_BYTE( _x ) ( (_x) >> 8 )
#define LO_BYTE( _x ) ( (_x) & 0xFF )
@@ -237,6 +316,9 @@ typedef unsigned long dword;
#define BYTE_OF( _v, _n ) *( ( (uint8_t *) &(_v) ) + (_n) )
#define WORD_OF( _v, _n ) *( ( (uint16_t *) &(_v) ) + (_n) )
+#define FBYTE_OF( _v, _n ) *( ( (uint8_t far *) &(_v) ) + (_n) )
+#define FWORD_OF( _v, _n ) *( ( (uint16_t far *) &(_v) ) + (_n) )
+
// same as above, but taking pointers
#define BYTE_OF_P( _p, _n ) *( ( (uint8_t *) (_p) ) + (_n) )
#define WORD_OF_P( _p, _n ) *( ( (uint16_t *) (_p) ) + (_n) )
@@ -283,6 +365,18 @@ typedef unsigned long dword;
#define _hilo_32( _x ) (_x)
#endif
+
+/**
+ * @brief A table entry which can be used to map codes to names.
+ */
+typedef struct
+{
+ ulong code;
+ const char *name;
+} MBG_CODE_NAME_TABLE_ENTRY;
+
+
+
/* End of header body */
#undef _ext
diff --git a/c/mbglib/lib/bc/mbgdevio.lib b/c/mbglib/lib/bc/mbgdevio.lib
index 5264f83..e45f718 100644
--- a/c/mbglib/lib/bc/mbgdevio.lib
+++ b/c/mbglib/lib/bc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib/bc/mbgsvcio.lib b/c/mbglib/lib/bc/mbgsvcio.lib
index 2c3097b..86b966f 100644
--- a/c/mbglib/lib/bc/mbgsvcio.lib
+++ b/c/mbglib/lib/bc/mbgsvcio.lib
Binary files differ
diff --git a/c/mbglib/lib/bc/mbgutil.lib b/c/mbglib/lib/bc/mbgutil.lib
index 6ca105d..d24e46b 100644
--- a/c/mbglib/lib/bc/mbgutil.lib
+++ b/c/mbglib/lib/bc/mbgutil.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgdevio.lib b/c/mbglib/lib/msc/mbgdevio.lib
index 6078f97..d273251 100644
--- a/c/mbglib/lib/msc/mbgdevio.lib
+++ b/c/mbglib/lib/msc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgsvcio.lib b/c/mbglib/lib/msc/mbgsvcio.lib
index 1c9d738..c4987be 100644
--- a/c/mbglib/lib/msc/mbgsvcio.lib
+++ b/c/mbglib/lib/msc/mbgsvcio.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgsvctl.lib b/c/mbglib/lib/msc/mbgsvctl.lib
new file mode 100644
index 0000000..0a2f61d
--- /dev/null
+++ b/c/mbglib/lib/msc/mbgsvctl.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgutil.lib b/c/mbglib/lib/msc/mbgutil.lib
index ed87b0f..fe570bc 100644
--- a/c/mbglib/lib/msc/mbgutil.lib
+++ b/c/mbglib/lib/msc/mbgutil.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgdevio.lib b/c/mbglib/lib64/msc/mbgdevio.lib
index dd857a7..8e443b7 100644
--- a/c/mbglib/lib64/msc/mbgdevio.lib
+++ b/c/mbglib/lib64/msc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgsvcio.lib b/c/mbglib/lib64/msc/mbgsvcio.lib
index 38971aa..e9c4cd6 100644
--- a/c/mbglib/lib64/msc/mbgsvcio.lib
+++ b/c/mbglib/lib64/msc/mbgsvcio.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgutil.lib b/c/mbglib/lib64/msc/mbgutil.lib
index 32c2e23..82ea1e1 100644
--- a/c/mbglib/lib64/msc/mbgutil.lib
+++ b/c/mbglib/lib64/msc/mbgutil.lib
Binary files differ