diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2016-11-21 12:00:00 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2016-11-21 12:00:00 +0100 |
commit | 0c91c96e055991b5cb83858a56a8133c01028e1c (patch) | |
tree | f67a7c6244001dc9eb28ce0af707d00eea3ea898 | |
parent | dafaea82601c0ba768bb74f5ba3876e809ef3995 (diff) | |
download | ntptest-0c91c96e055991b5cb83858a56a8133c01028e1c.tar.gz ntptest-0c91c96e055991b5cb83858a56a8133c01028e1c.zip |
New option -P to set client poll value sent to server1.4
Also move some Windows-specific code to other files.
-rwxr-xr-x | mbglib/common/gpsdefs.h | 1709 | ||||
-rwxr-xr-x | mbglib/common/mbg_ntp_test_util.c | 6 | ||||
-rwxr-xr-x | mbglib/common/mbg_ntp_test_util.h | 13 | ||||
-rwxr-xr-x | mbglib/common/mbg_tgt.h | 101 | ||||
-rwxr-xr-x | mbglib/common/mbgerror.c | 27 | ||||
-rwxr-xr-x | mbglib/common/mbgerror.h | 12 | ||||
-rwxr-xr-x | mbglib/common/str_util.c | 6 | ||||
-rwxr-xr-x | mbglib/common/timeutil.c | 97 | ||||
-rwxr-xr-x | mbglib/common/timeutil.h | 30 | ||||
-rwxr-xr-x | ntptest.c | 97 |
10 files changed, 1451 insertions, 647 deletions
diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h index d9c6258..c40126c 100755 --- a/mbglib/common/gpsdefs.h +++ b/mbglib/common/gpsdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: gpsdefs.h 1.124.1.173 2016/08/03 08:05:11 thomas-b TEST $ + * $Id: gpsdefs.h 1.124.1.215 2016/11/21 12:22:44 thomas-b TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -13,7 +13,96 @@ * * ----------------------------------------------------------------------- * $Log: gpsdefs.h $ - * Revision 1.124.1.173 2016/08/03 08:05:11 thomas-b + * Revision 1.124.1.215 2016/11/21 12:22:44 thomas-b + * Added enable flags as builtin feature for FDM180 + * Revision 1.124.1.214 2016/11/16 11:00:36 thomas-b + * Added core module type and revision to MBG_EXT_SYS_INFO + * Revision 1.124.1.213 2016/11/10 14:08:17 thomas-b + * Changed string name for GPS_MODEL_NAME_UNKNOWN + * Revision 1.124.1.212 2016/11/08 17:22:11 martin + * Doxygen fixes. + * Revision 1.124.1.211 2016/11/04 11:48:35 paul.kretz + * Support MDU312. + * Revision 1.124.1.210 2016/11/04 07:21:26Z thomas-b + * Added flag, mask, and idx for GPIO, which indicates that a GPIO configuration depends on another GPIO + * Revision 1.124.1.209 2016/11/02 11:54:57 paul.kretz + * added new xfeature MBG_XFEATURE_REQ_TTM + * Revision 1.124.1.208 2016/11/01 09:27:49Z thomas-b + * Added builtin feature for TZDL to FDM180 + * Revision 1.124.1.207 2016/11/01 09:24:12 martin + * *** empty log message *** + * Revision 1.124.1.206 2016/10/25 13:24:37 martin + * *** empty log message *** + * Revision 1.124.1.205 2016/10/25 08:56:40 martin + * Renamed MSK_ICODE_RX_HAS_SHORT_YEAR to MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P5. + * New MSK_ICODE_RX_HAS_ANY_SHORT_YEAR which includes + * all codes providing a year number, either after P5 or after P6. + * Doxygen fixes. + * Changes to builtin feature definitions. + * Revision 1.124.1.204 2016/10/24 08:12:04 martin + * Support MDU180. + * Revision 1.124.1.203 2016/10/20 10:43:20 thomas-b + * Added builtin feature GPS_MODEL_IS_BUS_LVL_DEV + * Revision 1.124.1.202 2016/10/19 10:19:59 thomas-b + * Added define for default user capture network UDP port + * Revision 1.124.1.201 2016/10/19 09:07:28 thomas-b + * Added supported flags for MBG_UCAP_NET_GLB_INFO + * Revision 1.124.1.200 2016/10/13 07:30:10 paul.kretz + * Extended sysinfo proc and fpga types by SAM3s, STM32F4, Cyclone4GX15 and Cyclone4CE22 + * Revision 1.124.1.199 2016/10/10 10:36:35Z thomas-b + * Added transfer protocol for ucap network receivers and added destination port + * Revision 1.124.1.198 2016/10/10 10:17:37 thomas-b + * Removed _PRELIMINARY_CODE_AUDIO restrictions + * Added new extended feature and structure definitions for ucap via network + * Revision 1.124.1.197 2016/10/07 11:24:50 thomas-b + * Fixed swab makro for addr settings + * Revision 1.124.1.196 2016/10/05 08:26:36 andre.hartmann + * Revision 1.124.1.195 2016/09/29 11:56:43Z philipp + * Added documentation for MBG_TRANSACTION_TYPE_NETWORK + * Revision 1.124.1.194 2016/09/29 10:43:41 thomas-b + * Added define for MBG_ARPHRD_ETHER + * Revision 1.124.1.193 2016/09/29 06:13:07 philipp + * Added support for beginning / ending typed transactions + * Revision 1.124.1.192 2016/09/28 13:35:00 philipp + * Renamed flag field + * Revision 1.124.1.191 2016/09/28 13:29:22 thomas-b + * Added feature flags for MBG_NET_GLB_CFG_INFO + * Revision 1.124.1.190 2016/09/26 13:04:54 udo + * added missing comma in MBG_TLV_FEAT_TYPE_NAMES + * Revision 1.124.1.189 2016/09/26 10:08:14 udo + * added TLV Feature MBG_TLV_FEAT_TYPE_FILE_REQUEST to request a generic file from HPS + * Revision 1.124.1.188 2016/09/23 08:29:09 martin + * Fixed missing comma in string table initializer. + * Revision 1.124.1.187 2016/09/22 12:12:29 philipp + * Split ::MBG_NET_INTF_LINK_OPTS::MBG_NET_INTF_LINK_OPT_CAN_SYNCE up into SyncE In and SyncE Out option + * Revision 1.124.1.186 2016/09/15 14:54:30 martin + * Support GRC181PEX. + * Revision 1.124.1.185 2016/09/12 09:16:49 martin + * Fixed cascaded comment characters. + * Revision 1.124.1.184 2016/09/08 10:25:03 martin + * Fixed build for 16 bit targets. + * Revision 1.124.1.183 2016/09/05 13:23:04 paul.kretz + * Added ENABLE_FLAGS to BUILTIN_FEAT_VSG180 + * Revision 1.124.1.182 2016/08/25 14:37:16Z paul.kretz + * added new gpio video type PAL_M + * Revision 1.124.1.181 2016/08/23 15:47:04Z martin + * Moved macros _setup_default_receiver_info_dcf() and + * _setup_default_receiver_info_gps() here. + * Revision 1.124.1.180 2016/08/16 13:01:13 martin + * Syntax fix. + * Revision 1.124.1.179 2016/08/12 11:05:14 paul.kretz + * Added digital audio output as new gpio type which is only included + * if symbol _PRELIMINARY_CODE_AUDIO is defined. + * Revision 1.124.1.178 2016/08/11 11:34:06Z martin + * Modified MBG_REF_OFFS_NOT_CFGD to avoid compiler warning. + * Revision 1.124.1.177 2016/08/11 11:30:16 martin + * Moved time monitoring stuff to new file time_mon.h. + * Revision 1.124.1.176 2016/08/11 10:28:09 udo + * prepare extended data set for time monitor + * Revision 1.124.1.175 2016/08/10 05:17:08 udo + * added domain number to Time Monitor Target Settings + * Revision 1.124.1.174 2016/08/09 14:48:06 martin + * Revision 1.124.1.173 2016/08/03 08:05:11Z thomas-b * Finished new network structures, definitions and relations * Revision 1.124.1.172 2016/07/29 09:36:21 paul.kretz * Added definitions for N2X180. @@ -952,7 +1041,7 @@ typedef uint16_t GPS_CMD; * Contains a software revision code, plus an optional * identifier for a customized version. * - * @see @ref group_ext_rev_info + * @see @ref group_ext_sys_info */ typedef struct { @@ -1214,6 +1303,9 @@ enum GPS_MODEL_CODES GPS_MODEL_GPS180CSM, GPS_MODEL_GRC181, GPS_MODEL_N2X180, + GPS_MODEL_GRC181PEX, + GPS_MODEL_MDU180, + GPS_MODEL_MDU312, N_GPS_MODEL /* If new model codes are added then care must be taken * to update the associated string initializers GPS_MODEL_NAMES @@ -1235,7 +1327,7 @@ enum GPS_MODEL_CODES * * @anchor GPS_MODEL_NAMES @{ */ -#define GPS_MODEL_NAME_UNKNOWN "(unknown)" +#define GPS_MODEL_NAME_UNKNOWN "Unknown" #define GPS_MODEL_NAME_GPS166 "GPS166" #define GPS_MODEL_NAME_GPS167 "GPS167" #define GPS_MODEL_NAME_GPS167SV "GPS167SV" @@ -1316,6 +1408,9 @@ enum GPS_MODEL_CODES #define GPS_MODEL_NAME_GPS180CSM "GPS180CSM" #define GPS_MODEL_NAME_GRC181 "GRC181" #define GPS_MODEL_NAME_N2X180 "N2X180" +#define GPS_MODEL_NAME_GRC181PEX "GRC181PEX" +#define GPS_MODEL_NAME_MDU180 "MDU180" +#define GPS_MODEL_NAME_MDU312 "MDU312" /** @} anchor GPS_MODEL_NAMES */ @@ -1415,7 +1510,10 @@ enum GPS_MODEL_CODES GPS_MODEL_NAME_GTS180, \ GPS_MODEL_NAME_GPS180CSM, \ GPS_MODEL_NAME_GRC181, \ - GPS_MODEL_NAME_N2X180 \ + GPS_MODEL_NAME_N2X180, \ + GPS_MODEL_NAME_GRC181PEX, \ + GPS_MODEL_NAME_MDU180, \ + GPS_MODEL_NAME_MDU312 \ } @@ -1447,12 +1545,7 @@ enum GPS_BUILTIN_FEATURE_BITS GPS_BIT_MODEL_IS_JJY, GPS_BIT_MODEL_IS_WWVB, -/** - TODO This has to be discussed - GPS_BIT_MODEL_IS_LNO, - GPS_BIT_MODEL_IS_SCU, -*/ - + GPS_BIT_MODEL_IS_BUS_LVL_DEV, GPS_BIT_MODEL_HAS_BVAR_STAT, GPS_BIT_MODEL_HAS_POS_XYZ, GPS_BIT_MODEL_HAS_POS_LLA, @@ -1460,14 +1553,21 @@ enum GPS_BUILTIN_FEATURE_BITS GPS_BIT_MODEL_HAS_TZDL, GPS_BIT_MODEL_HAS_TZCODE, GPS_BIT_MODEL_HAS_ANT_INFO, + GPS_BIT_MODEL_HAS_ENABLE_FLAGS, GPS_BIT_MODEL_HAS_STAT_INFO, GPS_BIT_MODEL_HAS_ANT_CABLE_LEN, GPS_BIT_MODEL_HAS_GPS_IGNORE_LOCK, -//### TODO + + GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV, - N_GPS_BIT_MODEL +#if 0 //### TODO This has to be discussed + GPS_BIT_MODEL_IS_LNO, + GPS_BIT_MODEL_IS_SCU, +#endif + + N_GPS_BUILTIN_FEATURE_BITS }; @@ -1489,12 +1589,7 @@ enum GPS_BUILTIN_FEATURE_BITS #define GPS_MODEL_IS_JJY ( 1UL << GPS_BIT_MODEL_IS_JJY ) ///< see ::GPS_BIT_MODEL_IS_JJY #define GPS_MODEL_IS_WWVB ( 1UL << GPS_BIT_MODEL_IS_WWVB ) ///< see ::GPS_BIT_MODEL_IS_WWVB -/** - TODO This has to be discussed -#define GPS_MODEL_IS_LNO ( 1UL << GPS_BIT_MODEL_IS_LNO ) ///< see ::GPS_BIT_MODEL_IS_LNO -#define GPS_MODEL_IS_SCU ( 1UL << GPS_BIT_MODEL_IS_SCU ) ///< see ::GPS_BIT_MODEL_IS_SCU -*/ - +#define GPS_MODEL_IS_BUS_LVL_DEV ( 1UL << GPS_BIT_MODEL_IS_BUS_LVL_DEV ) ///< see ::GPS_BIT_MODEL_IS_BUS_LVL_DEV #define GPS_MODEL_HAS_BVAR_STAT ( 1UL << GPS_BIT_MODEL_HAS_BVAR_STAT ) ///< see ::GPS_BIT_MODEL_HAS_BVAR_STAT #define GPS_MODEL_HAS_POS_XYZ ( 1UL << GPS_BIT_MODEL_HAS_POS_XYZ ) ///< see ::GPS_BIT_MODEL_HAS_POS_XYZ #define GPS_MODEL_HAS_POS_LLA ( 1UL << GPS_BIT_MODEL_HAS_POS_LLA ) ///< see ::GPS_BIT_MODEL_HAS_POS_LLA @@ -1502,15 +1597,21 @@ enum GPS_BUILTIN_FEATURE_BITS #define GPS_MODEL_HAS_TZDL ( 1UL << GPS_BIT_MODEL_HAS_TZDL ) ///< see ::GPS_BIT_MODEL_HAS_TZDL #define GPS_MODEL_HAS_TZCODE ( 1UL << GPS_BIT_MODEL_HAS_TZCODE ) ///< see ::GPS_BIT_MODEL_HAS_TZCODE #define GPS_MODEL_HAS_ANT_INFO ( 1UL << GPS_BIT_MODEL_HAS_ANT_INFO ) ///< see ::GPS_BIT_MODEL_HAS_ANT_INFO + #define GPS_MODEL_HAS_ENABLE_FLAGS ( 1UL << GPS_BIT_MODEL_HAS_ENABLE_FLAGS ) ///< see ::GPS_BIT_MODEL_HAS_ENABLE_FLAGS #define GPS_MODEL_HAS_STAT_INFO ( 1UL << GPS_BIT_MODEL_HAS_STAT_INFO ) ///< see ::GPS_BIT_MODEL_HAS_STAT_INFO #define GPS_MODEL_HAS_ANT_CABLE_LEN ( 1UL << GPS_BIT_MODEL_HAS_ANT_CABLE_LEN ) ///< see ::GPS_BIT_MODEL_HAS_ANT_CABLE_LEN #define GPS_MODEL_HAS_GPS_IGNORE_LOCK ( 1UL << GPS_BIT_MODEL_HAS_GPS_IGNORE_LOCK ) ///< see ::GPS_BIT_MODEL_HAS_GPS_IGNORE_LOCK +#if 0 // ### TODO This has to be discussed + #define GPS_MODEL_IS_LNO ( 1UL << GPS_BIT_MODEL_IS_LNO ) ///< see ::GPS_BIT_MODEL_IS_LNO + #define GPS_MODEL_IS_SCU ( 1UL << GPS_BIT_MODEL_IS_SCU ) ///< see ::GPS_BIT_MODEL_IS_SCU +#endif + // ### TODO do we need the next one? #define GPS_MODEL_HAS_XMR_HOLDOVER_INTV ( 1UL << GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV ) ///< see ::GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV -//##+++++ TODO: should we use an extra flag? +//### TODO: should we use an extra flag? #define GPS_MODEL_HAS_POS ( GPS_MODEL_HAS_POS_XYZ | GPS_MODEL_HAS_POS_LLA ) /** @} anchor GPS_BUILTIN_FEATURE_MASKS */ @@ -1635,6 +1736,9 @@ enum GPS_BUILTIN_FEATURE_BITS /** * @brief Common builtin features of all GPS receivers + * + * @see ::BUILTIN_FEAT_GPS_BUS_LVL + * @see ::BUILTIN_FEAT_GNSS */ #define BUILTIN_FEAT_GPS \ ( \ @@ -1656,6 +1760,9 @@ enum GPS_BUILTIN_FEATURE_BITS * * GNSS includes GPS but optionally other satellite systems, * and the associated API. + * + * @see ::BUILTIN_FEAT_GNSS_BUS_LVL + * @see ::BUILTIN_FEAT_GPS */ #define BUILTIN_FEAT_GNSS \ ( \ @@ -1664,6 +1771,185 @@ enum GPS_BUILTIN_FEATURE_BITS ) + +/** + * @brief Common builtin features of all simple TCR devices + */ +#define BUILTIN_FEAT_TCR_1 \ +( \ + GPS_MODEL_IS_TCR \ +) + + +/** + * @brief Common builtin features of all enhanced TCR devices + */ +#define BUILTIN_FEAT_TCR_2 \ +( \ + GPS_MODEL_IS_TCR | \ + GPS_MODEL_HAS_TIME_TTM | \ + GPS_MODEL_HAS_TZDL | \ + GPS_MODEL_HAS_ANT_INFO | \ + GPS_MODEL_HAS_ENABLE_FLAGS \ +) + + + +/** + * @brief Common builtin features of all simple DCF77 AM receivers + */ +#define BUILTIN_FEAT_DCF_1 \ +( \ + GPS_MODEL_IS_DCF_AM | \ + GPS_MODEL_HAS_TZCODE \ +) + + +/** + * @brief Common builtin features of all enhanced DCF77 AM receivers + */ +#define BUILTIN_FEAT_DCF_2 \ +( \ + GPS_MODEL_IS_DCF_AM | \ + GPS_MODEL_HAS_TIME_TTM | \ + GPS_MODEL_HAS_TZDL | \ + GPS_MODEL_HAS_ANT_INFO | \ + GPS_MODEL_HAS_ENABLE_FLAGS \ +) + + +/** + * @brief Common builtin features of all simple DCF77 PZF receivers + */ +#define BUILTIN_FEAT_DCF_PZF_1 \ +( \ + GPS_MODEL_IS_DCF_PZF | \ + GPS_MODEL_HAS_TZCODE \ +) + + +/** + * @brief Common builtin features of all enhanced DCF77 PZF receivers + */ +#define BUILTIN_FEAT_DCF_PZF_2 \ +( \ + GPS_MODEL_IS_DCF_PZF | \ + GPS_MODEL_HAS_TIME_TTM | \ + GPS_MODEL_HAS_TZDL | \ + GPS_MODEL_HAS_ANT_INFO | \ + GPS_MODEL_HAS_ENABLE_FLAGS \ +) + + + +/** + * @brief Common builtin features of all simple MSF receivers + */ +#define BUILTIN_FEAT_MSF_1 \ +( \ + GPS_MODEL_IS_MSF | \ + GPS_MODEL_HAS_TZCODE \ +) + + +/** + * @brief Common builtin features of all enhanced MSF receivers + */ +#define BUILTIN_FEAT_MSF_2 \ +( \ + GPS_MODEL_IS_MSF | \ + GPS_MODEL_HAS_TIME_TTM | \ + GPS_MODEL_HAS_TZDL | \ + GPS_MODEL_HAS_ANT_INFO | \ + GPS_MODEL_HAS_ENABLE_FLAGS \ +) + + + +/** + * @brief Common builtin features of all simple WWVB receivers + */ +#define BUILTIN_FEAT_WVB_1 \ +( \ + GPS_MODEL_IS_WWVB | \ + GPS_MODEL_HAS_TZCODE \ +) + + +/** + * @brief Common builtin features of all enhanced WWVB receivers + */ +#define BUILTIN_FEAT_WVB_2 \ +( \ + GPS_MODEL_IS_WWVB | \ + GPS_MODEL_HAS_TZDL \ +) + + + +/** + * @brief Common builtin features of all simple JJY receivers + */ +#define BUILTIN_FEAT_JJY_1 \ +( \ + GPS_MODEL_IS_JJY | \ + GPS_MODEL_HAS_TZCODE \ +) + + + +/** + * @brief Common builtin features of all N2X devices + */ +#define BUILTIN_FEAT_COMM_N2X \ +( \ + GPS_MODEL_HAS_TIME_TTM | \ + GPS_MODEL_HAS_TZDL | \ + GPS_MODEL_HAS_ENABLE_FLAGS \ +) + + + +/** + * @brief Common builtin features of all bus-level GPS receivers + */ +#define BUILTIN_FEAT_GPS_BUS_LVL ( BUILTIN_FEAT_GPS | GPS_MODEL_IS_BUS_LVL_DEV ) + + +/** + * @brief Common builtin features of all bus-level GNSS receivers + */ +#define BUILTIN_FEAT_GNSS_BUS_LVL ( BUILTIN_FEAT_GNSS | GPS_MODEL_IS_BUS_LVL_DEV ) + + +/** + * @brief Common builtin features of all simple, bus-level TCR devices + */ +#define BUILTIN_FEAT_TCR_1_BUS_LVL ( BUILTIN_FEAT_TCR_1 | GPS_MODEL_IS_BUS_LVL_DEV ) + +/** + * @brief Common builtin features of all enhanced, bus-level TCR devices + */ +#define BUILTIN_FEAT_TCR_2_BUS_LVL ( BUILTIN_FEAT_TCR_2 | GPS_MODEL_IS_BUS_LVL_DEV ) + + +/** + * @brief Common builtin features of all simple, bus-level DCF77 AM receivers + */ +#define BUILTIN_FEAT_DCF_1_BUS_LVL ( BUILTIN_FEAT_DCF_1 | GPS_MODEL_IS_BUS_LVL_DEV ) + +/** + * @brief Common builtin features of all enhanced, bus-level DCF77 AM receivers + */ +#define BUILTIN_FEAT_DCF_2_BUS_LVL ( BUILTIN_FEAT_DCF_2 | GPS_MODEL_IS_BUS_LVL_DEV ) + +/** + * @brief Common builtin features of all enhanced, bus-level DCF77 PZF receivers + */ +#define BUILTIN_FEAT_DCF_PZF_2_BUS_LVL ( BUILTIN_FEAT_DCF_PZF_2 | GPS_MODEL_IS_BUS_LVL_DEV ) + + + /** * @brief Definitions of builtin features per device type * @@ -1675,71 +1961,71 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_GPS166 ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_GPS167 ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_GPS167SV ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS167PC ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS167PCI ( BUILTIN_FEAT_GPS ) +#define BUILTIN_FEAT_GPS167PC ( BUILTIN_FEAT_GPS_BUS_LVL ) +#define BUILTIN_FEAT_GPS167PCI ( BUILTIN_FEAT_GPS_BUS_LVL ) #define BUILTIN_FEAT_GPS163 ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS168PCI ( BUILTIN_FEAT_GPS ) +#define BUILTIN_FEAT_GPS168PCI ( BUILTIN_FEAT_GPS_BUS_LVL ) #define BUILTIN_FEAT_GPS161 ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS169PCI ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_TCR167PCI ( GPS_MODEL_HAS_TIME_TTM ) +#define BUILTIN_FEAT_GPS169PCI ( BUILTIN_FEAT_GPS_BUS_LVL ) +#define BUILTIN_FEAT_TCR167PCI ( BUILTIN_FEAT_TCR_2_BUS_LVL ) #define BUILTIN_FEAT_GPS164 ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS170PCI ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_PZF511 ( GPS_MODEL_HAS_TZCODE ) +#define BUILTIN_FEAT_GPS170PCI ( BUILTIN_FEAT_GPS_BUS_LVL ) +#define BUILTIN_FEAT_PZF511 ( BUILTIN_FEAT_DCF_PZF_1 ) #define BUILTIN_FEAT_GPS170 ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_TCR511 ( GPS_MODEL_HAS_TIME_TTM ) -#define BUILTIN_FEAT_AM511 ( GPS_MODEL_HAS_TZCODE ) -#define BUILTIN_FEAT_MSF511 ( GPS_MODEL_HAS_TZCODE ) +#define BUILTIN_FEAT_TCR511 ( BUILTIN_FEAT_TCR_1_BUS_LVL | GPS_MODEL_HAS_TIME_TTM ) //### TODO Or full TCR_2? +#define BUILTIN_FEAT_AM511 ( BUILTIN_FEAT_DCF_1 ) +#define BUILTIN_FEAT_MSF511 ( BUILTIN_FEAT_MSF_1 ) #define BUILTIN_FEAT_GRC170 ( BUILTIN_FEAT_GNSS ) -#define BUILTIN_FEAT_GPS170PEX ( BUILTIN_FEAT_GPS ) +#define BUILTIN_FEAT_GPS170PEX ( BUILTIN_FEAT_GPS_BUS_LVL ) #define BUILTIN_FEAT_GPS162 ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_PTP270PEX ( 0 ) -#define BUILTIN_FEAT_FRC511PEX ( 0 ) +#define BUILTIN_FEAT_PTP270PEX ( GPS_MODEL_IS_BUS_LVL_DEV ) +#define BUILTIN_FEAT_FRC511PEX ( GPS_MODEL_IS_BUS_LVL_DEV ) #define BUILTIN_FEAT_GEN170 ( 0 ) -#define BUILTIN_FEAT_TCR170PEX ( GPS_MODEL_HAS_TIME_TTM ) -#define BUILTIN_FEAT_WWVB511 ( GPS_MODEL_HAS_TZCODE ) +#define BUILTIN_FEAT_TCR170PEX ( BUILTIN_FEAT_TCR_2_BUS_LVL ) +#define BUILTIN_FEAT_WWVB511 ( BUILTIN_FEAT_WVB_1 ) #define BUILTIN_FEAT_MGR170 ( 0 ) -#define BUILTIN_FEAT_JJY511 ( GPS_MODEL_HAS_TZCODE ) -#define BUILTIN_FEAT_PZF600 ( GPS_MODEL_HAS_TZCODE ) -#define BUILTIN_FEAT_TCR600 ( GPS_MODEL_HAS_TIME_TTM ) +#define BUILTIN_FEAT_JJY511 ( BUILTIN_FEAT_JJY_1 ) +#define BUILTIN_FEAT_PZF600 ( BUILTIN_FEAT_DCF_PZF_1 ) //### TODO Or full PZF_2? +#define BUILTIN_FEAT_TCR600 ( BUILTIN_FEAT_TCR_1 | GPS_MODEL_HAS_TIME_TTM ) //### TODO Or full TCR_2? #define BUILTIN_FEAT_GPS180 ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_GLN170 ( BUILTIN_FEAT_GNSS) -#define BUILTIN_FEAT_GPS180PEX ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_TCR180PEX ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL ) -#define BUILTIN_FEAT_PZF180PEX ( GPS_MODEL_HAS_TZDL ) +#define BUILTIN_FEAT_GPS180PEX ( BUILTIN_FEAT_GPS_BUS_LVL ) +#define BUILTIN_FEAT_TCR180PEX ( BUILTIN_FEAT_TCR_2_BUS_LVL ) +#define BUILTIN_FEAT_PZF180PEX ( BUILTIN_FEAT_DCF_PZF_2_BUS_LVL ) #define BUILTIN_FEAT_MGR180 ( 0 ) -#define BUILTIN_FEAT_MSF600 ( GPS_MODEL_HAS_TZCODE ) -#define BUILTIN_FEAT_WWVB600 ( GPS_MODEL_HAS_TZCODE ) -#define BUILTIN_FEAT_JJY600 ( GPS_MODEL_HAS_TZCODE ) +#define BUILTIN_FEAT_MSF600 ( BUILTIN_FEAT_MSF_1 ) //### TODO Or full MSF_2? +#define BUILTIN_FEAT_WWVB600 ( BUILTIN_FEAT_WVB_1 ) //### TODO Or full WVB_2? +#define BUILTIN_FEAT_JJY600 ( BUILTIN_FEAT_JJY_1 ) //### TODO Or full JJY_2? #define BUILTIN_FEAT_GPS180HS ( BUILTIN_FEAT_GPS ) -#define BUILTIN_FEAT_GPS180AMC ( BUILTIN_FEAT_GPS ) +#define BUILTIN_FEAT_GPS180AMC ( BUILTIN_FEAT_GPS_BUS_LVL ) #define BUILTIN_FEAT_ESI180 ( 0 ) #define BUILTIN_FEAT_CPE180 ( 0 ) #define BUILTIN_FEAT_LNO180 ( 0 ) #define BUILTIN_FEAT_GRC180 ( BUILTIN_FEAT_GNSS ) #define BUILTIN_FEAT_LIU ( 0 ) -#define BUILTIN_FEAT_DCF600HS ( GPS_MODEL_HAS_TZDL ) -#define BUILTIN_FEAT_DCF600RS ( GPS_MODEL_HAS_TZDL ) +#define BUILTIN_FEAT_DCF600HS ( BUILTIN_FEAT_DCF_2 ) //### TODO +#define BUILTIN_FEAT_DCF600RS ( BUILTIN_FEAT_DCF_2 ) //### TODO #define BUILTIN_FEAT_MRI ( 0 ) #define BUILTIN_FEAT_BPE ( 0 ) -#define BUILTIN_FEAT_GLN180PEX ( BUILTIN_FEAT_GNSS ) -#define BUILTIN_FEAT_N2X ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL | GPS_MODEL_HAS_ENABLE_FLAGS ) +#define BUILTIN_FEAT_GLN180PEX ( BUILTIN_FEAT_GNSS_BUS_LVL ) +#define BUILTIN_FEAT_N2X ( BUILTIN_FEAT_COMM_N2X ) #define BUILTIN_FEAT_RSC180 ( 0 ) #define BUILTIN_FEAT_LNE_GB ( 0 ) #define BUILTIN_FEAT_PPG180 ( 0 ) #define BUILTIN_FEAT_SCG ( 0 ) #define BUILTIN_FEAT_MDU300 ( 0 ) #define BUILTIN_FEAT_SDI ( 0 ) -#define BUILTIN_FEAT_FDM180 ( 0 ) +#define BUILTIN_FEAT_FDM180 ( GPS_MODEL_HAS_TZDL | GPS_MODEL_HAS_ENABLE_FLAGS ) #define BUILTIN_FEAT_SPT ( 0 ) -#define BUILTIN_FEAT_PZF180 ( GPS_MODEL_HAS_TZDL ) +#define BUILTIN_FEAT_PZF180 ( BUILTIN_FEAT_DCF_PZF_2 ) #define BUILTIN_FEAT_REL1000 ( 0 ) #define BUILTIN_FEAT_HPS100 ( 0 ) -#define BUILTIN_FEAT_VSG180 ( 0 ) -#define BUILTIN_FEAT_MSF180 ( GPS_MODEL_HAS_TZDL ) -#define BUILTIN_FEAT_WWVB180 ( GPS_MODEL_HAS_TZDL ) +#define BUILTIN_FEAT_VSG180 ( GPS_MODEL_HAS_ENABLE_FLAGS ) +#define BUILTIN_FEAT_MSF180 ( BUILTIN_FEAT_MSF_2 ) +#define BUILTIN_FEAT_WWVB180 ( BUILTIN_FEAT_WVB_2 ) #define BUILTIN_FEAT_CPC180 ( 0 ) #define BUILTIN_FEAT_CTC100 ( 0 ) -#define BUILTIN_FEAT_TCR180 ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL ) +#define BUILTIN_FEAT_TCR180 ( BUILTIN_FEAT_TCR_2 ) #define BUILTIN_FEAT_LUE180 ( 0 ) #define BUILTIN_FEAT_CPC_01 ( 0 ) #define BUILTIN_FEAT_TSU_01 ( 0 ) @@ -1751,7 +2037,10 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_GTS180 ( 0 ) #define BUILTIN_FEAT_GPS180CSM ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_GRC181 ( BUILTIN_FEAT_GNSS ) -#define BUILTIN_FEAT_N2X180 ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL | GPS_MODEL_HAS_ENABLE_FLAGS ) +#define BUILTIN_FEAT_N2X180 ( BUILTIN_FEAT_COMM_N2X ) +#define BUILTIN_FEAT_GRC181PEX ( BUILTIN_FEAT_GNSS_BUS_LVL ) +#define BUILTIN_FEAT_MDU180 ( 0 ) +#define BUILTIN_FEAT_MDU312 ( 0 ) /** @} anchor GPS_MODEL_BUILTIN_FEATURE_MASKS */ @@ -1847,6 +2136,10 @@ enum GPS_BUILTIN_FEATURE_BITS { GPS_MODEL_GPS180CSM, BUILTIN_FEAT_GPS180CSM }, \ { GPS_MODEL_GRC181, BUILTIN_FEAT_GRC181 }, \ { GPS_MODEL_N2X180, BUILTIN_FEAT_N2X180 }, \ + { GPS_MODEL_GRC181PEX, BUILTIN_FEAT_GRC181PEX }, \ + { GPS_MODEL_GRC181PEX, BUILTIN_FEAT_GRC181PEX }, \ + { GPS_MODEL_MDU180, BUILTIN_FEAT_MDU180 }, \ + { GPS_MODEL_MDU312, BUILTIN_FEAT_MDU312 }, \ { 0, 0 } \ } @@ -1854,6 +2147,56 @@ enum GPS_BUILTIN_FEATURE_BITS +/** + * @brief Initialize a ::RECEIVER_INFO structure for legacy DCF77 receivers + * + * Legacy DCF77 receivers may not provide a ::RECEIVER_INFO structure, + * but have well-known properties which can be used to set up a + * default ::RECEIVER_INFO. + * + * @param[in,out] _p Pointer to a ::RECEIVER_INFO STRUCTURE to be set up + * @param[in] _pdev Pointer to a ::PCPS_DEV structure read before + * + * @see ::_setup_default_receiver_info_gps + */ +#define _setup_default_receiver_info_dcf( _p, _pdev ) \ +do \ +{ \ + memset( (_p), 0, sizeof( *(_p) ) ); \ + \ + (_p)->ticks_per_sec = DEFAULT_GPS_TICKS_PER_SEC; \ + (_p)->n_ucaps = 0; \ + (_p)->n_com_ports = _pcps_has_serial( _pdev ) ? 1 : 0; \ + (_p)->n_str_type = ( (_p)->n_com_ports != 0 ) ? \ + DEFAULT_N_STR_TYPE_DCF : 0; \ +} while ( 0 ) + + + +/** + * @brief Initialize a ::RECEIVER_INFO structure for legacy GPS receivers + * + * Legacy GPS receivers may not provide a ::RECEIVER_INFO structure, + * but have well-known properties which can be used to set up a + * default ::RECEIVER_INFO. + * + * @param[in,out] _p Pointer to a ::RECEIVER_INFO STRUCTURE to be set up + * + * @see ::_setup_default_receiver_info_dcf + */ +#define _setup_default_receiver_info_gps( _p ) \ +do \ +{ \ + memset( (_p), 0, sizeof( *(_p) ) ); \ + \ + (_p)->ticks_per_sec = DEFAULT_GPS_TICKS_PER_SEC; \ + (_p)->n_ucaps = 2; \ + (_p)->n_com_ports = DEFAULT_N_COM; \ + (_p)->n_str_type = DEFAULT_N_STR_TYPE_GPS; \ +} while ( 0 ) + + + /* * The macros below can be used to classify a receiver, * e.g. depending on the time source and/or depending on @@ -2196,9 +2539,11 @@ enum MBG_XFEATURE_BITS MBG_XFEATURE_LNE_API, ///< Supports specific LNE API, see @ref group_lne_api MBG_XFEATURE_PWR_CTL_API, ///< Supports power control, see @ref group_pwr_ctl_api MBG_XFEATURE_EXT_SYS_INFO, ///< Supports extended revision information, see @ref group_ext_sys_info - MBG_XFEATURE_TRANSACTIONS, ///< Supports the ::GPS_BEGIN_TRANSACTION and ::GPS_END_TRANSACTION commands + MBG_XFEATURE_TRANSACTIONS, ///< Supports the ::GPS_BEGIN_TRANSACTION and ::GPS_END_TRANSACTION commands, see also ::MBG_TRANSACTION_TYPES MBG_XFEATURE_REBOOT, ///< Supports the ::GPS_REBOOT command - MBG_XFEATURE_CLK_RES_INFO, ///< Supports the GPS_CLK_RES_INFO command, see @ref group_clk_res_info + MBG_XFEATURE_CLK_RES_INFO, ///< Supports the ::GPS_CLK_RES_INFO command, see @ref group_clk_res_info + MBG_XFEATURE_UCAP_NET, ///< Supports the ::GPS_UCAP_NET_GLB_INFO and ::GPS_UCAP_NET_RECV_INFO_IDX commands, see @ref group_ucap_net + MBG_XFEATURE_REQ_TTM, ///< Supports TTM requests via GPS_TIME command N_MBG_XFEATURE ///< Number of defined extended features // NOTE If new features are appended here then an appropriate feature // name string has to be appended to ::MBG_XFEATURE_NAMES, and care must @@ -2225,7 +2570,9 @@ enum MBG_XFEATURE_BITS "Extended Revision Info", \ "Transaction commands", \ "Reboot command", \ - "Clock Resolution Info" \ + "Clock Resolution Info", \ + "Extended User Captures", \ + "Request TTM" \ } @@ -4003,7 +4350,7 @@ enum ICODE_TX_CODES /* C37118 */ "100 bps, DCLS or 1 kHz carrier, 2 digit year number, SBS, UTC offs. reverse to 1344, DST/Leap sec status", \ /* TXC101 */ "code from TV time sync device TXC-101 DTR-6", \ /* E002_E112 */ "10 bps, DCLS or 100 Hz carrier", \ - /* NASA36 */ "100 bps, DCLS or 1 kHz carrier" \ + /* NASA36 */ "100 bps, DCLS or 1 kHz carrier", \ /* A006_A136 */ "1000 bps, DCLS or 10 kHz carrier, 2 digit year number", \ /* A007_A137 */ "1000 bps, DCLS or 10 kHz carrier, 2 digit year number, SBS" \ } @@ -4600,33 +4947,60 @@ enum ICODE_RX_CODES ) /** - * @brief A mask of IRIG RX formats supporting a 2 digit year number + * @brief A mask of IRIG RX formats supporting a 2 digit year number after P5 + * + * Note: This macro specifies ONLY the codes where the year number + * is transmitted after position identifier P5. + * + * @see ::MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P6 + * @see ::MSK_ICODE_RX_HAS_ANY_SHORT_YEAR */ -#define MSK_ICODE_RX_HAS_SHORT_YEAR \ -( \ - 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_A136_A137 | \ - MSK_ICODE_RX_A006_A007 \ +#define MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P5 \ +( \ + 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_A136_A137 | \ + MSK_ICODE_RX_A006_A007 \ ) /** - * @brief A mask of IRIG RX formats supporting a 2 digit year number + * @brief A mask of IRIG RX formats supporting a 2 digit year number after P6 * - * This is after the P6 identifier. + * Note: This macro specifies ONLY the codes where the year number + * is transmitted after position identifier P6. + * + * @see ::MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P5 + * @see ::MSK_ICODE_RX_HAS_ANY_SHORT_YEAR */ #define MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P6 \ -( \ - MSK_ICODE_RX_G146 | \ - MSK_ICODE_RX_G006 \ +( \ + MSK_ICODE_RX_G146 | \ + MSK_ICODE_RX_G006 \ +) + +/** + * @brief A mask of IRIG RX formats providing any 2 digit year number + * + * Note: Different sets of code frames may provide a year number + * in different locations of the transmitted code. + * + * @see ::MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P5 + * @see ::MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P6 + */ +#define MSK_ICODE_RX_HAS_ANY_SHORT_YEAR \ +( \ + MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P5 | \ + MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P6 \ ) + + /** * @brief A mask of IRIG RX formats supporting TFOM time quality indicator */ @@ -5044,7 +5418,7 @@ typedef int16_t MBG_REF_OFFS; * (time offset from %UTC) has not yet been configured. This is usually * the case for IRIG receiver devices right after they have been shipped. */ -#define MBG_REF_OFFS_NOT_CFGD 0x8000 +#define MBG_REF_OFFS_NOT_CFGD ( (MBG_REF_OFFS) 0x8000 ) @@ -5359,14 +5733,10 @@ typedef struct /** * @brief A Generic data field for programmable output settings - * - * If the mode is set to ::POUT_TIME_SLOTS then ::POUT_SETTINGS::tm must be - * interpreted 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 { - POUT_TIME tm[N_POUT_TIMES]; ///< switching times, or other data, see ::POUT_DATA + POUT_TIME tm[N_POUT_TIMES]; ///< switching times uint8_t b[N_POUT_TIMES * sizeof( POUT_TIME )]; int32_t pulse_shift; @@ -5492,15 +5862,15 @@ enum POUT_MODES /// Output is normally always 'off', or always 'on', if flag ::POUT_INVERTED is set. POUT_IDLE, - /// Switch 'on' or 'off' at the times specified in ::POUT_SETTINGS::POUT_DATA::tm. + /// Switch 'on' or 'off' at the times specified in ::POUT_DATA::tm. POUT_TIMER, - /// Generate a pulse at the time specified in ::POUT_SETTINGS::POUT_DATA::tm[0].on. + /// Generate a pulse at the time specified in ::POUT_SETTINGS::POUT_DATA::tm[0]::on. /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_SINGLE_SHOT, - /// Generate a cyclic pulse at the interval specified in ::POUT_SETTINGS::POUT_DATA::tm[0].on.t. + /// Generate a cyclic pulse at the interval specified in ::POUT_SETTINGS::POUT_DATA::tm[0]:on::t. /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_CYCLIC_PULSE, @@ -5566,6 +5936,12 @@ enum POUT_MODES /// be in the range 0..::MBG_GPIO_CFG_LIMITS::num_io. POUT_GPIO, + /// A 1PPS signal with a fixed 20us pulse length + POUT_PTTI_PPS, + + /// A HaveQuick signal as configured in ::HAVEQUICK_SETTINGS::format + POUT_HAVEQUICK, + // New modes have to be added here at the end of the enumeration, and the // POUT_MODE_MASKS as well as string initializers (also in pcpslstr.h) // have to be updated accordingly. @@ -5601,6 +5977,8 @@ enum POUT_MODES #define MSK_POUT_SYNTH ( 1UL << POUT_SYNTH ) ///< see ::POUT_SYNTH #define MSK_POUT_TIME_SLOTS ( 1UL << POUT_TIME_SLOTS ) ///< see ::POUT_TIME_SLOTS #define MSK_POUT_GPIO ( 1UL << POUT_GPIO ) ///< see ::POUT_GPIO +#define MSK_POUT_PTTI_PPS ( 1UL << POUT_PTTI_PPS ) ///< see ::POUT_PTTI_PPS +#define MSK_POUT_HAVEQUICK ( 1UL << POUT_HAVEQUICK ) ///< see ::POUT_HAVEQUICK /** @} anchor POUT_MODE_MASKS */ @@ -5634,6 +6012,10 @@ enum POUT_MODES #define ENG_POUT_NAME_SYNTH "Synthesizer Frequency" #define ENG_POUT_NAME_TIME_SLOTS "Time Slots per Minute" #define ENG_POUT_NAME_GPIO "GPIO Signal" +#define ENG_POUT_PTTI_PPS "PTTI 1PPS" +#define ENG_POUT_HAVEQUICK "HaveQuick" + + /** @} anchor ENG_POUT_NAMES */ @@ -5663,7 +6045,9 @@ enum POUT_MODES ENG_POUT_NAME_DCF77_M59, \ ENG_POUT_NAME_SYNTH, \ ENG_POUT_NAME_TIME_SLOTS, \ - ENG_POUT_NAME_GPIO \ + ENG_POUT_NAME_GPIO, \ + ENG_POUT_PTTI_PPS, \ + ENG_POUT_HAVEQUICK \ } @@ -5696,6 +6080,8 @@ enum POUT_MODES #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 ENG_POUT_HINT_GPIO "Duplicated signal of the specified GPIO input or output" +#define ENG_POUT_HINT_PTTI_PPS "Generate 20us Pulse at beginning of the second" +#define ENG_POUT_HINT_HAVEQUICK "Duplicated HaveQuick Signal" /** @} anchor ENG_POUT_HINTS */ @@ -5724,7 +6110,9 @@ enum POUT_MODES ENG_POUT_HINT_DCF77_M59, \ ENG_POUT_HINT_SYNTH, \ ENG_POUT_HINT_TIME_SLOTS, \ - ENG_POUT_HINT_GPIO \ + ENG_POUT_HINT_GPIO, \ + ENG_POUT_HINT_PTTI_PPS, \ + ENG_POUT_HINT_HAVEQUICK \ } @@ -7016,10 +7404,12 @@ enum MBG_GPIO_TYPES MBG_GPIO_TYPE_VIDEO_OUT, ///< Video signal output (PAL, NTSC, ...) MBG_GPIO_TYPE_VIDEO_SYNC_OUT, ///< Video sync signal output (H-Sync, V-Sync, ...) MBG_GPIO_TYPE_STUDIO_CLOCK_OUT, ///< Studio clock output + MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT, ///< Digital Audio output (DARS, ...) N_MBG_GPIO_TYPES ///< Number of known types }; + #define DEFAULT_GPIO_TYPES_SHORT_STRS \ { \ "Freq. In", \ @@ -7029,7 +7419,8 @@ enum MBG_GPIO_TYPES "BITS Out", \ "Video Out", \ "Video Sync Out", \ - "Studio Clock Out" \ + "Studio Clock Out", \ + "Digital Audio Out" \ } @@ -7556,12 +7947,13 @@ typedef struct enum MBG_GPIO_VIDEO_FORMATS { MBG_GPIO_VIDEO_FORMAT_OFF, ///< OFF - MBG_GPIO_VIDEO_SD_FORMAT_NTSC, ///< NTSC - MBG_GPIO_VIDEO_SD_FORMAT_PAL, ///< PAL standard (Germany) + MBG_GPIO_VIDEO_SD_FORMAT_NTSC, ///< NTSC 525i + MBG_GPIO_VIDEO_SD_FORMAT_PAL, ///< PAL standard (Germany) 625i MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz, ///< SMPTE296M-3 720p at 50 Hz MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz, ///< SMPTE274M-6 1080i at 50 Hz MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz, ///< SMPTE296M-1 720p at 59.94 Hz MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz, ///< SMPTE274M-7 1080i at 59.94 Hz + MBG_GPIO_VIDEO_SD_FORMAT_PAL_M, ///< PAL M (Brazil) 525i N_MBG_GPIO_VIDEO_FORMATS ///< number of defined video formats }; @@ -7582,16 +7974,17 @@ enum MBG_GPIO_VIDEO_FORMAT_MASKS MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz - MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz ) ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz + MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz + MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL_M = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL_M ) ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_PAL_M }; - /** * @brief A combination of bit masks for SD video formats * @see ::MBG_GPIO_VIDEO_FORMAT_MASKS */ -#define MBG_GPIO_VIDEO_SD_FORMATS ( MSK_MBG_GPIO_VIDEO_FORMAT_OFF | MSK_MBG_GPIO_VIDEO_SD_FORMAT_NTSC | MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL ) +#define MBG_GPIO_VIDEO_SD_FORMATS ( MSK_MBG_GPIO_VIDEO_FORMAT_OFF | MSK_MBG_GPIO_VIDEO_SD_FORMAT_NTSC | MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL | \ + MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL_M ) /** * @brief A combination of bit masks for HD video formats @@ -7611,12 +8004,13 @@ enum MBG_GPIO_VIDEO_FORMAT_MASKS #define MBG_GPIO_VIDEO_OUT_STRS \ { \ "OFF", \ - "NTSC", \ - "PAL", \ + "NTSC (525i)", \ + "PAL (625i)", \ "720p 50 Hz", \ "1080i 50 Hz", \ "720p 59.94 Hz", \ - "1080i 59.94 Hz" \ + "1080i 59.94 Hz", \ + "PAL M (525i)" \ } @@ -8060,25 +8454,168 @@ typedef struct /** + * @brief Enumeration of types used with GPIO type digital audio outputs + * + * Used with ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT_SETTINGS::type, and used to + * define ::MBG_GPIO_DIGITAL_AUDIO_TYPE_MASKS + * + * @see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_MASKS + * @see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_STRS + */ +enum MBG_GPIO_DIGITAL_AUDIO_TYPES +{ + MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF, + MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS, ///< DARS + N_MBG_GPIO_DIGITAL_AUDIO_TYPES ///< number of known types +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_DIGITAL_AUDIO_TYPES + * + * Used with :: MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT_SUPP::supp_types + * + * @see ::MBG_GPIO_DIGITAL_AUDIO_TYPES + */ +enum MBG_GPIO_DIGITAL_AUDIO_TYPE_MASKS +{ + MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF ), ///< see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF + MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS ) ///< see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS +}; + + + +/** + * @brief Initializers for an array of video epoch strings + * + * @see ::MBG_GPIO_VIDEO_EPOCHS + */ +#define MBG_GPIO_DIGITAL_AUDIO_TYPE_STRS \ +{ \ + "OFF", \ + "DARS" \ +} + + + +/** + * @brief Enumeration of flags used with GPIO type digital audio outputs + */ +enum MBG_GPIO_DIGITAL_AUDIO_FLAGS +{ + MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG, ///< reserved + N_MBG_GPIO_DIGITAL_AUDIO_FLAGS ///< number of known flags +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_DIGITAL_AUDIO_FLAGS + * + * Used with ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT_SETTINGS::flags + * + * @see ::MBG_GPIO_DIGITAL_AUDIO_FLAGS + */ +enum MBG_GPIO_DIGITAL_AUDIO_FLAG_MASKS +{ + MSK_MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG ) ///< see ::MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG +}; + + + +/** + * @brief Configuration of a GPIO digital audio output + * + * Used as sub-structure of ::MBG_GPIO_SETTINGS. + * + * @see ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + * @see ::MBG_GPIO_SETTINGS + */ +typedef struct +{ + uint32_t type; ///< digital audio type, see ::MBG_GPIO_DIGITAL_AUDIO_TYPES + uint32_t flags; ///< reserved, currently always 0 + uint32_t reserved0; ///< reserved, currently always 0 + uint32_t reserved1; ///< reserved, currently always 0 + uint32_t reserved2; ///< reserved, currently always 0 + +} MBG_GPIO_DIGITAL_AUDIO_OUT_SETTINGS; + + + +/** + * @brief Supported options for digital audio output + * + * Used as sub-structure of ::MBG_GPIO_LIMITS. + * + * @see ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + * @see ::MBG_GPIO_LIMITS + */ +typedef struct +{ + uint32_t supp_types; ///< supported digital audio types, see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_MASKS + uint32_t supp_flags; ///< reserved, currently always 0 + uint32_t reserved0; ///< reserved, currently always 0 + uint32_t reserved1; ///< reserved, currently always 0 + uint32_t reserved2; ///< reserved, currently always 0 + +} MBG_GPIO_DIGITAL_AUDIO_OUT_SUPP; + + + +/** + * @brief Enumeration of general flags used with a GPIO + * + * @see ::MBG_GPIO_FLAG_MASKS + */ +enum MBG_GPIO_FLAGS +{ + MBG_GPIO_DEPENDS_ON_ASS_IO_IDX, ///< indicates that this output depends on GPIO with ::MBG_GPIO_SETTINGS::ass_io_idx and may not be configured independently + N_MBG_GPIO_FLAGS ///< number of known flags +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_FLAGS + * + * Used with ::MBG_GPIO_LIMITS::flags and ::MBG_GPIO_SETTINGS::flags + * + * @see ::MBG_GPIO_FLAGS + */ +enum MBG_GPIO_FLAG_MASKS +{ + MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX = ( 1UL << MBG_GPIO_DEPENDS_ON_ASS_IO_IDX ) ///< see ::MBG_GPIO_DEPENDS_ON_ASS_IO_IDX +}; + + + +/** * @brief A generic structure used to hold a GPIO port's settings */ typedef struct { - uint32_t type; ///< GPIO type, see ::MBG_GPIO_TYPES - uint32_t reserved; ///< reserved, currently always 0 - uint32_t flags; ///< reserved, currently always 0 + uint32_t type; ///< GPIO type, see ::MBG_GPIO_TYPES + + uint16_t reserved_1; ///< reserved, currently always 0 + uint8_t reserved_2; ///< reserved, currently always 0 + uint8_t ass_io_idx; ///< associated GPIO index, only valid if ::MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX is set in flags field + + uint32_t flags; ///< flags, see ::MBG_GPIO_FLAG_MASKS /// settings depending on the GPIO type, see ::MBG_GPIO_TYPES union { - MBG_GPIO_FREQ_IN_SETTINGS freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN - MBG_GPIO_FREQ_OUT_SETTINGS freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT - MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT - MBG_GPIO_BITS_IN_SETTINGS bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN - MBG_GPIO_BITS_OUT_SETTINGS bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT - MBG_GPIO_VIDEO_OUT_SETTINGS video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT - MBG_GPIO_VIDEO_SYNC_OUT_SETTINGS video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT - MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_FREQ_IN_SETTINGS freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN + MBG_GPIO_FREQ_OUT_SETTINGS freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT + MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT + MBG_GPIO_BITS_IN_SETTINGS bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN + MBG_GPIO_BITS_OUT_SETTINGS bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT + MBG_GPIO_VIDEO_OUT_SETTINGS video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT + MBG_GPIO_VIDEO_SYNC_OUT_SETTINGS video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT + MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_DIGITAL_AUDIO_OUT_SETTINGS digital_audio_out; ///< if ::MBG_GPIO_SETTINGS::type is ::;MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT } u; } MBG_GPIO_SETTINGS; @@ -8104,19 +8641,20 @@ typedef struct { uint32_t type; ///< GPIO type, see ::MBG_GPIO_TYPES uint32_t reserved; ///< reserved, currently always 0 - uint32_t supp_flags; ///< supported flags //##++++++++++++ which? + uint32_t supp_flags; ///< supported flags, see ::MBG_GPIO_FLAG_MASKS /// limits depending on the GPIO type, see ::MBG_GPIO_TYPES union { - MBG_GPIO_FREQ_IN_SUPP freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN - MBG_GPIO_FREQ_OUT_SUPP freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT - MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT - MBG_GPIO_BITS_IN_SUPP bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN - MBG_GPIO_BITS_OUT_SUPP bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT - MBG_GPIO_VIDEO_OUT_SUPP video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT - MBG_GPIO_VIDEO_SYNC_OUT_SUPP video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT - MBG_GPIO_STUDIO_CLOCK_OUT_SUPP studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_FREQ_IN_SUPP freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN + MBG_GPIO_FREQ_OUT_SUPP freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT + MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT + MBG_GPIO_BITS_IN_SUPP bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN + MBG_GPIO_BITS_OUT_SUPP bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT + MBG_GPIO_VIDEO_OUT_SUPP video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT + MBG_GPIO_VIDEO_SYNC_OUT_SUPP video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT + MBG_GPIO_STUDIO_CLOCK_OUT_SUPP studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_DIGITAL_AUDIO_OUT_SUPP digital_audio_out; ///< if ::MBG_GPIO_SETTINGS::type is ::;MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT } u; } MBG_GPIO_LIMITS; @@ -9683,6 +10221,15 @@ typedef char MBG_HOSTNAME[MBG_MAX_HOSTNAME_LEN]; ///< ASCIIZ format /** + * @brief Hardware type for identification of physical interfaces + * + * Use own definition for use under Windows, + * original ARPHRD_ETHER comes from linux/if_arp.h + */ +#define MBG_ARPHRD_ETHER 1 + + +/** * @defgroup group_vlan_cfg Definitions used with VLAN configuration * * @{ */ @@ -9880,11 +10427,35 @@ enum MBG_IP_ADDR_TYPES /** + * @brief Feature flag bits used to define ::MBG_NET_GLB_CFG_INFO_MASKS + * + * @see ::MBG_NET_GLB_CFG_INFO_MASKS + */ +enum MBG_NET_GLB_CFG_INFO_FLAGS +{ + MBG_NET_GLB_SUPP_STAGE_2, ///< Supports commands which have been added in stage 2 + N_MBG_NET_GLB_INFO_FLAGS +}; + + +/** + * @brief Flag masks used with ::MBG_NET_GLB_CFG_INFO::feat_flags + * + * @see ::MBG_NET_GLB_CFG_INFO_FLAGS + */ +enum MBG_NET_GLB_CFG_INFO_MASKS +{ + MBG_NET_GLB_SUPP_STAGE_2_MASK = (1UL << MBG_NET_GLB_SUPP_STAGE_2) ///< see ::MBG_NET_GLB_SUPP_STAGE_2 +}; + + + +/** * @brief Network interface link speed mode enumeration * * @see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS */ -enum MBG_NET_INTF_LINK_SPEED_MODE +enum MBG_NET_INTF_LINK_SPEED_MODES { MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN, ///< Unknown speed mode MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF, ///< 10baseT Half Duplex (10 MBit/s) @@ -9920,7 +10491,7 @@ enum MBG_NET_INTF_LINK_SPEED_MODE /** * @brief Network interface link speed mode masks * - * @see ::MBG_NET_INTF_LINK_SPEED_MODE + * @see ::MBG_NET_INTF_LINK_SPEED_MODES * * @anchor MBG_NET_INTF_LINK_SPEED_MODE_MASKS @{ */ @@ -9957,9 +10528,9 @@ enum MBG_NET_INTF_LINK_SPEED_MODE /** * @brief Network interface link speeds [Mb/s] * - * @see ::MBG_NET_INTF_LINK_SPEED_MODE_MASKS + * @see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS */ -enum MBG_NET_INTF_LINK_SPEED +enum MBG_NET_INTF_LINK_SPEEDS { MBG_NET_INTF_LINK_SPEED_UNKNOWN = 0UL, MBG_NET_INTF_LINK_SPEED_10 = 10UL, @@ -9979,7 +10550,7 @@ enum MBG_NET_INTF_LINK_SPEED * * @see ::MBG_NET_INTF_LINK_PORT_TYPE_MASKS */ -enum MBG_NET_INTF_LINK_PORT_TYPE +enum MBG_NET_INTF_LINK_PORT_TYPES { MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN, ///< Unknown port type MBG_NET_INTF_LINK_PORT_TYPE_TP, ///< Twisted Pair (TP) copper cable @@ -9996,7 +10567,7 @@ enum MBG_NET_INTF_LINK_PORT_TYPE /** * @brief Network interface link port masks * - * @see ::MBG_NET_INTF_LINK_PORT_TYPE + * @see ::MBG_NET_INTF_LINK_PORT_TYPES */ enum MBG_NET_INTF_LINK_PORT_TYPE_MASKS { @@ -10091,31 +10662,32 @@ enum MBG_NET_INTF_LINK_STATE_BITS * * @see ::MBG_NET_INTF_LINK_STATE_BITS (reclined to Linux' if.h, Windows is similiar) * - */ -enum MBG_NET_INTF_LINK_STATE_MASKS -{ - MBG_NET_INTF_LINK_STATE_MASK_UP = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_UP ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_UP - MBG_NET_INTF_LINK_STATE_MASK_RUNNING = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_RUNNING ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_RUNNING - MBG_NET_INTF_LINK_STATE_MASK_LOWER_UP = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP - MBG_NET_INTF_LINK_STATE_MASK_DORMANT = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DORMANT ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DORMANT - MBG_NET_INTF_LINK_STATE_MASK_BROADCAST = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_BROADCAST ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_BROADCAST - MBG_NET_INTF_LINK_STATE_MASK_MULTICAST = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MULTICAST ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MULTICAST - MBG_NET_INTF_LINK_STATE_MASK_ALL_MULTI = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI - MBG_NET_INTF_LINK_STATE_MASK_DEBUG = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DEBUG ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DEBUG - - MBG_NET_INTF_LINK_STATE_MASK_LOOPBACK = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK - MBG_NET_INTF_LINK_STATE_MASK_POINT_TO_POINT = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT - MBG_NET_INTF_LINK_STATE_MASK_NO_ARP = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_ARP ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_ARP - MBG_NET_INTF_LINK_STATE_MASK_PROMISC = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PROMISC ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PROMISC - MBG_NET_INTF_LINK_STATE_MASK_MASTER = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MASTER ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MASTER - MBG_NET_INTF_LINK_STATE_MASK_SLAVE = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_SLAVE ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_SLAVE - MBG_NET_INTF_LINK_STATE_MASK_PORT_SEL = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL - MBG_NET_INTF_LINK_STATE_MASK_AUTO_MEDIA = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA - - MBG_NET_INTF_LINK_STATE_MASK_ECHO = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ECHO ), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ECHO - MBG_NET_INTF_LINK_STATE_MASK_DYNAMIC = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC), ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC - MBG_NET_INTF_LINK_STATE_MASK_NO_TRAILERS = ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS -}; + * @anchor MBG_NET_INTF_LINK_STATE_MASKS @{ */ + +#define MBG_NET_INTF_LINK_STATE_MASK_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_UP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_UP +#define MBG_NET_INTF_LINK_STATE_MASK_RUNNING ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_RUNNING ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_RUNNING +#define MBG_NET_INTF_LINK_STATE_MASK_LOWER_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP +#define MBG_NET_INTF_LINK_STATE_MASK_DORMANT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DORMANT ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DORMANT +#define MBG_NET_INTF_LINK_STATE_MASK_BROADCAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_BROADCAST ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_BROADCAST +#define MBG_NET_INTF_LINK_STATE_MASK_MULTICAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MULTICAST ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MULTICAST +#define MBG_NET_INTF_LINK_STATE_MASK_ALL_MULTI ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI +#define MBG_NET_INTF_LINK_STATE_MASK_DEBUG ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DEBUG ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DEBUG + +#define MBG_NET_INTF_LINK_STATE_MASK_LOOPBACK ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK +#define MBG_NET_INTF_LINK_STATE_MASK_POINT_TO_POINT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT +#define MBG_NET_INTF_LINK_STATE_MASK_NO_ARP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_ARP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_ARP +#define MBG_NET_INTF_LINK_STATE_MASK_PROMISC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PROMISC ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PROMISC +#define MBG_NET_INTF_LINK_STATE_MASK_MASTER ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MASTER ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MASTER +#define MBG_NET_INTF_LINK_STATE_MASK_SLAVE ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_SLAVE ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_SLAVE +#define MBG_NET_INTF_LINK_STATE_MASK_PORT_SEL ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL +#define MBG_NET_INTF_LINK_STATE_MASK_AUTO_MEDIA ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA + +#define MBG_NET_INTF_LINK_STATE_MASK_ECHO ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ECHO ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ECHO +#define MBG_NET_INTF_LINK_STATE_MASK_DYNAMIC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC +#define MBG_NET_INTF_LINK_STATE_MASK_NO_TRAILERS ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS + +/** @} anchor MBG_NET_INTF_LINK_STATE_MASKS */ + /** @@ -10126,7 +10698,8 @@ enum MBG_NET_INTF_LINK_STATE_MASKS enum MBG_NET_INTF_LINK_OPTS { MBG_NET_INTF_LINK_OPT_CAN_SET_MAC, - MBG_NET_INTF_LINK_OPT_CAN_SYNCE, + MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN, + MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT, MBG_NET_INTF_LINK_OPT_CAN_AUTONEG, N_MBG_NET_INTF_LINK_OPTS }; @@ -10140,9 +10713,10 @@ enum MBG_NET_INTF_LINK_OPTS */ enum MBG_NET_INTF_LINK_OPT_MASKS { - MBG_NET_INTF_LINK_OPT_MASK_CAN_SET_MAC = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SET_MAC ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SET_MAC - MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE - MBG_NET_INTF_LINK_OPT_MASK_CAN_AUTONEG = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_AUTONEG ) ///< see ::MBG_NET_INTF_LINK_OPT_CAN_AUTONEG + MBG_NET_INTF_LINK_OPT_MASK_CAN_SET_MAC = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SET_MAC ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SET_MAC + MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_IN = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN + MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_OUT = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT + MBG_NET_INTF_LINK_OPT_MASK_CAN_AUTONEG = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_AUTONEG ) ///< see ::MBG_NET_INTF_LINK_OPT_CAN_AUTONEG }; @@ -10222,11 +10796,11 @@ enum MBG_NET_INTF_LINK_BOND_STATES /** * @brief Network interface link type bits * - * @see ::MBG_NET_INTF_LINK_TYPE_MASKS + * Used with ::MBG_NET_INTF_LINK_SETTINGS::type * - * Used with ::MBG_NET_INTF_LINK_INFO::type + * @see ::MBG_NET_INTF_LINK_TYPE_MASKS */ -enum MBG_NET_INTF_LINK_TYPE +enum MBG_NET_INTF_LINK_TYPES { MBG_NET_INTF_LINK_TYPE_PHYS, ///< Real physical network interface MBG_NET_INTF_LINK_TYPE_VLAN, ///< VLAN interface, assigned to physical interface @@ -10238,13 +10812,15 @@ enum MBG_NET_INTF_LINK_TYPE /** * @brief Network interface link type masks * - * @see ::MBG_NET_INTF_LINK_TYPE + * Used with ::MBG_NET_INTF_LINK_INFO::supp_types + * + * @see ::MBG_NET_INTF_LINK_TYPES */ enum MBG_NET_INTF_LINK_TYPE_MASKS { - MBG_NET_INTF_LINK_TYPE_MASK_PHYS = ( 1UL << MBG_NET_INTF_LINK_TYPE_PHYS ), ///< see ::MBG_NET_INTF_LINK_TYPE_BIT_STD - MBG_NET_INTF_LINK_TYPE_MASK_VLAN = ( 1UL << MBG_NET_INTF_LINK_TYPE_VLAN ), ///< see ::MBG_NET_INTF_LINK_TYPE_BIT_VLAN - MBG_NET_INTF_LINK_TYPE_MASK_BOND = ( 1UL << MBG_NET_INTF_LINK_TYPE_BOND ) ///< see ::MBG_NET_INTF_LINK_TYPE_BIT_BOND + MBG_NET_INTF_LINK_TYPE_MASK_PHYS = ( 1UL << MBG_NET_INTF_LINK_TYPE_PHYS ), ///< see ::MBG_NET_INTF_LINK_TYPE_PHYS + MBG_NET_INTF_LINK_TYPE_MASK_VLAN = ( 1UL << MBG_NET_INTF_LINK_TYPE_VLAN ), ///< see ::MBG_NET_INTF_LINK_TYPE_VLAN + MBG_NET_INTF_LINK_TYPE_MASK_BOND = ( 1UL << MBG_NET_INTF_LINK_TYPE_BOND ) ///< see ::MBG_NET_INTF_LINK_TYPE_BOND }; @@ -10308,7 +10884,7 @@ typedef struct uint8_t num_intf_addr; ///< number of configured interface addresses, see ::MBG_NET_INTF_ADDR_INFO_IDX uint8_t num_dns_srvr; ///< number of configured DNS servers, see ::MBG_IP_ADDR_IDX uint8_t num_dns_srch_dom; ///< number of configured DNS search domains, see ::MBG_NET_NAME_IDX - uint8_t num_intf_route; ///< number of configured interface routes, see ::MBG_NET_INTF_ROUTE_INFO_IFX + uint8_t num_intf_route; ///< number of configured interface routes, see ::MBG_NET_INTF_ROUTE_INFO_IDX uint8_t reserved; ///< currently reserved, always 0 uint16_t flags; ///< currently reserved, always 0 @@ -10335,7 +10911,7 @@ typedef struct uint16_t max_hostname_len; ///< max. length of hostname including trailing 0; if set to 0, max. length is 256 (see rfc1123) uint32_t reserved_1; ///< currently reserved, always 0 uint32_t reserved_2; ///< currently reserved, always 0 - uint32_t flags_1; ///< currently reserved, always 0 + uint32_t feat_flags; ///< Feature flags, see ::MBG_NET_GLB_CFG_INFO_MASKS uint32_t flags_2; ///< currently reserved, always 0 } MBG_NET_GLB_CFG_INFO; @@ -10351,7 +10927,7 @@ typedef struct _mbg_swab16( &(_p)->max_hostname_len ); \ _mbg_swab32( &(_p)->reserved_1 ); \ _mbg_swab32( &(_p)->reserved_2 ); \ - _mbg_swab32( &(_p)->flags_1 ); \ + _mbg_swab32( &(_p)->feat_flags ); \ _mbg_swab32( &(_p)->flags_2 ); \ } @@ -10457,32 +11033,32 @@ typedef struct uint32_t if_index; ///< Interface index assigned by the kernel uint32_t common_if_index; ///< Common interface index assigned by the lib (associated with the MAC address), - ///< Valid, if ::type is ::MBG_NET_INTF_LINK_TYPE_PHYS + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_PHYS uint32_t ass_if_index; ///< Interface index of the associated physical interface link, - ///< Valid, if ::type is ::MBG_NET_INTF_LINK_TYPE_VLAN + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN uint32_t flags; ///< Reserved, currently 0 - uint32_t states; ///< see ::MBG_NET_INTF_LINK_STATE_MASKS + uint32_t states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS - uint32_t hw_type; ///< Hardware type of interface (see linux/if_arp.h, i.e. ARPHRD_ETHER) + uint32_t hw_type; ///< Hardware type of interface (see linux/if_arp.h, i.e. ARPHRD_ETHER) ::TODO uint32_t mtu; ///< Max. packet size in bytes uint32_t txqlen; ///< Transmission queue length (number of packets) uint32_t speed; ///< Link speed in MBit/s - uint8_t type; ///< see ::MBG_NET_INTF_LINK_TYPE + uint8_t type; ///< see ::MBG_NET_INTF_LINK_TYPES uint8_t duplex; ///< Duplex mode, half (0) or full (1) uint8_t autoneg; ///< Indicates, whether autonegotiation is enabled or disabled - uint8_t port_type; ///< see ::MBG_NET_INTF_LINK_PORT_TYPE + uint8_t port_type; ///< see ::MBG_NET_INTF_LINK_PORT_TYPES uint8_t bond_mode; ///< Bonding mode, see ::MBG_NET_INTF_LINK_BOND_MODES - ///< Valid, if ::MBG_NET_INTF_LINK_STATE_MASK_MASTER is set in ::MBG_NET_INTF_LINK_SETTINGS::states + ///< Valid if ::MBG_NET_INTF_LINK_STATE_MASK_MASTER is set in ::MBG_NET_INTF_LINK_SETTINGS::states uint8_t bond_state; ///< Status of this interface in the bonding group, see ::MBG_NET_INTF_LINK_BOND_STATES - ///< Valid, if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in states + ///< Valid if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states uint16_t bond_idx; ///< Interface index of the bonding master link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index - ///< Valid, if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in states + ///< Valid, if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states uint16_t vlan_cfg; ///< VLAN configuration options, see ::MBG_VLAN_CFG - ///< Valid, if ::type is ::MBG_NET_INTF_LINK_TYPE_VLAN + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN uint16_t reserved_1; ///< Reserved, currently 0 uint32_t reserved_2; ///< Reserved, currently 0 @@ -10535,9 +11111,9 @@ typedef struct { MBG_NET_INTF_LINK_SETTINGS link_settings; ///< see ::MBG_NET_INTF_LINK_SETTINGS uint32_t supp_flags; ///< Reserved, currently 0 - uint32_t supp_states; ///< see ::MBG_NET_INTF_LINK_STATE_MASKS + uint32_t supp_states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS uint32_t supp_types; ///< see ::MBG_NET_INTF_LINK_TYPE_MASKS - uint32_t supp_speed_modes; ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_MASKS + uint32_t supp_speed_modes; ///< see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS uint32_t supp_port_types; ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_MASKS uint32_t supp_opts; ///< see ::MBG_NET_INTF_LINK_OPT_MASKS uint32_t supp_bond_modes; ///< see ::MBG_NET_INTF_LINK_BOND_MODE_MASKS @@ -10612,7 +11188,7 @@ typedef struct #define _mbg_swab_net_intf_addr_settings( _p ) \ { \ _mbg_swab32( &(_p)->addr_index ); \ - _mbg_swab32( &(_p)->if_index ); \ + _mbg_swab32( &(_p)->ass_if_index ); \ _mbg_swab32( &(_p)->flags ); \ _mbg_swab_ip_addr( &(_p)->ip ); \ _mbg_swab_ip_addr( &(_p)->broadcast ); \ @@ -10691,13 +11267,13 @@ typedef struct MBG_IP_ADDR gateway; ///< Gateway IP address, only used if type is ///< ::MBG_NET_INTF_ROUTE_TYPE_DEFAULT_GATEWAY or ::MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY - MBG_IP_ADDR dst; ///< Destination IP address, only used if type is - ///< ::MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY or ::MBG_NET_INTF_ROUTE_TYPE_DEST_ADDRESS + MBG_IP_ADDR dst; ///< Destination IP address, only used if ::MBG_NET_INTF_ROUTE_SETTINGS::type is + ///< ::MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY or ::MBG_NET_INTF_ROUTE_TYPE_DEST_ADDR uint8_t dst_prefix_bits; ///< Prefix Bits for the destination address uint32_t ass_if_index; ///< Index of the associated interface link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index uint32_t ass_addr_index; ///< Index of the associated interface address, see ::MBG_NET_INTF_ADDR_SETTINGS::addr_index, - ///< Vaid, if type is ::MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY or ::MBG_NET_INTF_ROUTE_TYPE_DEST_ADDRESS + ///< Valid if ::MBG_NET_INTF_ROUTE_SETTINGS::type is ::MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY or ::MBG_NET_INTF_ROUTE_TYPE_DEST_ADDR uint32_t reserved_3; ///< Reserved, currently 0 uint32_t reserved_4; ///< Reserved, currently 0 @@ -10780,6 +11356,267 @@ typedef struct + + +/** + * @defgroup group_ucap_net User Captures via Network + * + * @note Group for the user capture via network feature + * Only supported if ::MBG_XFEATURE_UCAP_NET is set in extended features + * Corresponding GPS commands are ::GPS_UCAP_NET_GLB_INFO and ::GPS_UCAP_NET_RECV_INFO_IDX + * + * @{ */ + + +#define MBG_UCAP_NET_DEFAULT_UDP_PORT 50815 + +/** + * @brief Transfer mode for user captures via network + * + * @see ::MBG_UCAP_NET_TRANSF_MODE_MASKS + * + * Used with ::MBG_UCAP_NET_RECV_SETTINGS::mode + */ +enum MBG_UCAP_NET_TRANSF_MODE +{ + MBG_UCAP_NET_TRANSF_MODE_UNKNOWN, ///< Unknown transfer mode + MBG_UCAP_NET_TRANSF_MODE_ON_REQ, ///< User captures will be transferred on request only + MBG_UCAP_NET_TRANSF_MODE_AUTO, ///< User captures are being transferred automatically + N_MBG_UCAP_NET_TRANSF_MODES +}; + + +/** + * @brief Masks for transfer mode used with ::MBG_UCAP_NET_GLB_INFO::supp_modes + * + * @see ::MBG_UCAP_NET_TRANSF_MODE + */ +enum MBG_UCAP_NET_TRANSF_MODE_MASKS +{ + MBG_UCAP_NET_TRANSF_MODE_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_UNKNOWN ), ///< see ::MBG_UCAP_NET_TRANSF_MODE_UNKNOWN + MBG_UCAP_NET_TRANSF_MODE_MASK_ON_REQ = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_ON_REQ ), ///< see ::MBG_UCAP_NET_TRANSF_MODE_ON_REQ + MBG_UCAP_NET_TRANSF_MODE_MASK_AUTO = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_AUTO ) ///< see ::MBG_UCAP_NET_TRANSF_MODE_AUTO +}; + + + +/** + * @brief Transfer protocol for user captures via network + * + * @see ::MBG_UCAP_NET_TRANSF_PROTO_MASKS + * + * Used with ::MBG_UCAP_NET_RECV_SETTINGS::proto + */ +enum MBG_UCAP_NET_TRANSF_PROTO +{ + MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN, ///< Unknown transfer mode + MBG_UCAP_NET_TRANSF_PROTO_UDP, ///< User captures are transferred via UDP + N_MBG_UCAP_NET_TRANSF_PROTOS +}; + + +/** + * @brief Masks for transfer protocol used with ::MBG_UCAP_NET_GLB_INFO::supp_protos + * + * @see ::MBG_UCAP_NET_TRANSF_PROTO + */ +enum MBG_UCAP_NET_TRANSF_PROTO_MASKS +{ + MBG_UCAP_NET_TRANSF_PROTO_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN ), ///< see ::MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN + MBG_UCAP_NET_TRANSF_PROTO_MASK_UDP = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UDP ) ///< see ::MBG_UCAP_NET_TRANSF_PROTO_UDP +}; + + + +/** + * @brief Supported flags for user captures via network + * + * @see ::MBG_UCAP_NET_SUPP_FLAG_MASKS + */ +enum MBG_UCAP_NET_SUPP_FLAGS +{ + MBG_UCAP_NET_SUPP_FLAG_IPV6, + N_MBG_UCAP_NET_SUPP_FLAGS +}; + + +/** + * @brief Masks for supported flags used with ::MBG_UCAP_NET_GLB_INFO::supp_flags + * + * @see ::MBG_UCAP_NET_TRANSF_PROTO + */ +enum MBG_UCAP_NET_SUPP_FLAG_MASKS +{ + MBG_UCAP_NET_SUPP_FLAG_MASK_IPV6 = ( 1UL << MBG_UCAP_NET_SUPP_FLAG_IPV6 ) ///< see ::MBG_UCAP_NET_SUPP_FLAG_IPV6 +}; + + +/** + * @brief Global settings for user captures via network + * + * @note This structure shall be used to set the current global settings of a device + * with GPS command ::GPS_UCAP_NET_GLB_INFO. + */ +typedef struct +{ + uint32_t num_recvs; ///< Number of configured network receivers, see ::MBG_UCAP_NET_RECV_INFO_IDX + uint32_t reserved_0; ///< Reserved, currently always 0 + uint32_t reserved_1; ///< Reserved, currently always 0 + uint32_t reserved_2; ///< Reserved, currently always 0 + +} MBG_UCAP_NET_GLB_SETTINGS; + + +#define _mbg_swab_ucap_net_glb_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->num_recvs ); \ + _mbg_swab32( &(_p)->reserved_0 ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ +} + + + +/** + * @brief Global settings, features and flags for user captures via network + * + * @note This structure shall be used to read the current global settings from a device + * with GPS command ::GPS_UCAP_NET_GLB_INFO. + */ +typedef struct +{ + MBG_UCAP_NET_GLB_SETTINGS settings; ///< see ::MBG_UCAP_NET_GLB_SETTINGS + + uint32_t n_supp_recvs; ///< Number of supported network receivers, see ::MBG_UCAP_NET_RECV_INFO_IDX + uint32_t supp_modes; ///< Supported transfer modes, see ::MBG_UCAP_NET_TRANSF_MODE_MASKS + uint32_t supp_protos; ///< Supported transfer protocols, see ::MBG_UCAP_NET_TRANSF_PROTO_MASKS + uint32_t reserved_0; ///< Reserved, currently always 0 + uint32_t reserved_1; ///< Reserved, currently always 0 + uint32_t supp_flags; ///< Supported flags, see ::MBG_UCAP_NET_SUPP_FLAG_MASKS + +} MBG_UCAP_NET_GLB_INFO; + + +#define _mbg_swab_ucap_net_glb_info( _p ) \ +{ \ + _mbg_swab_ucap_net_glb_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->n_supp_recvs ); \ + _mbg_swab32( &(_p)->supp_modes ); \ + _mbg_swab32( &(_p)->supp_protos ); \ + _mbg_swab32( &(_p)->reserved_0 ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ +} + + + +/** + * @brief Settings for receivers of user captures via network + */ +typedef struct +{ + uint8_t mode; ///< Transfer mode, see ::MBG_UCAP_NET_TRANSF_MODE + uint8_t proto; ///< Transfer protocol, see ::MBG_UCAP_NET_TRANSF_PROTO + uint16_t reserved_1; ///< Reserved, currently always 0 + + uint32_t reserved_2; ///< Reserved, currently always 0 + uint32_t reserved_3; ///< Reserved, currently always 0 + uint32_t ucaps; ///< Bit mask for active user captures + + MBG_IP_ADDR_PORT addr; ///< Destination IP and port address of the network receiver, see ::MBG_IP_ADDR_PORT + +} MBG_UCAP_NET_RECV_SETTINGS; + + +#define _mbg_swab_ucap_net_recv_settings( _p ) \ +{ \ + _mbg_swab16( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ + _mbg_swab32( &(_p)->reserved_3 ); \ + _mbg_swab32( &(_p)->ucaps ); \ + _mbg_swab_ip_addr_port( &(_p)->addr ); \ +} + + + +/** + * @brief Settings for receivers of user captures via network + * + * @note This structure shall be used to write the settings to the device + * with GPS command ::GPS_UCAP_NET_RECV_INFO_IDX. + * This can be done for index 0 to ::MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1. + * + * @see ::MBG_UCAP_NET_RECV_SETTINGS + */ +typedef struct +{ + uint16_t idx; ///< 0..::MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1 + MBG_UCAP_NET_RECV_SETTINGS settings; ///< see ::MBG_UCAP_NET_RECV_SETTINGS + +} MBG_UCAP_NET_RECV_SETTINGS_IDX; + + +#define _mbg_swab_ucap_net_recv_settings_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_ucap_net_recv_settings( &(_p)->settings ); \ +} + + + +/** + * @brief Settings, features and flags for receivers of user captures via network + */ +typedef struct +{ + MBG_UCAP_NET_RECV_SETTINGS settings; ///< see ::MBG_UCAP_NET_RECV_SETTINGS + + uint32_t reserved_0; ///< Reserved, currently always 0 + uint32_t reserved_1; ///< Reserved, currently always 0 + uint32_t reserved_2; ///< Reserved, currently always 0 + uint32_t reserved_3; ///< Reserved, currently always 0 + +} MBG_UCAP_NET_RECV_INFO; + + +#define _mbg_swab_ucap_net_recv_info( _p ) \ +{ \ + _mbg_swab_ucap_net_recv_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->reserved_0 ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ + _mbg_swab32( &(_p)->reserved_3 ); \ +} + + + +/** + * @brief Settings, features and flags for receivers of user captures via network + * + * @note This structure shall be used to read the current settings from the device + * with GPS command ::GPS_UCAP_NET_RECV_INFO_IDX. + * This can be done for index 0 to ::MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1. + * + * @see ::MBG_UCAP_NET_RECV_INFO + */ +typedef struct +{ + uint16_t idx; ///< 0..::MBG_UCAP_NET_GLB_INFO::n_supp_recvs-1 + MBG_UCAP_NET_RECV_INFO info; ///< see ::MBG_UCAP_NET_RECV_INFO + +} MBG_UCAP_NET_RECV_INFO_IDX; + + +#define _mbg_swab_ucap_net_recv_info_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_ucap_net_recv_info( &(_p)->info ); \ +} + +/** @} defgroup ext_ucap */ + + + /** * @defgroup group_ptp Definitions used with PTP/IEEE1588 * @@ -11879,13 +12716,13 @@ typedef struct } PTP_TELECOMG8275_PROFILE_CFG; -#define _mbg_swab_ptp_telecom8275_profile_cfg( _p ) \ -{ \ - _mbg_swab8( &(_p)->use_alternate_multicast_mac_address ); \ - _mbg_swab8( &(_p)->reserved_1 ); \ - _mbg_swab8( &(_p)->reserved_2 ); \ - _mbg_swab8( &(_p)->reserved_3 ); \ - _mbg_swab32( &(_p)->reserved_4 ); \ +#define _mbg_swab_ptp_telecom8275_profile_cfg( _p ) \ +{ \ + _mbg_swab8( &(_p)->use_alternate_multicast_mac_address ); \ + _mbg_swab8( &(_p)->reserved_1 ); \ + _mbg_swab8( &(_p)->reserved_2 ); \ + _mbg_swab8( &(_p)->reserved_3 ); \ + _mbg_swab32( &(_p)->reserved_4 ); \ } @@ -12090,7 +12927,7 @@ enum T1_SSM_QLVL * * @see ::SDH_NETWORK_OPTION_MASKS */ -enum SDH_NETWORK_OPTION +enum SDH_NETWORK_OPTIONS { SDH_NETWORK_OPTION_1, SDH_NETWORK_OPTION_2, @@ -12103,12 +12940,12 @@ enum SDH_NETWORK_OPTION /** * @brief Flag masks used with ::MBG_SYNC_E_INFO::supp_sdh_network_opts * - * @see ::SDH_NETWORK_OPTION + * @see ::SDH_NETWORK_OPTIONS */ enum SDH_NETWORK_OPTION_MASKS { - SDH_NETWORK_OPTION_1_MSK = ( 1UL << SDH_NETWORK_OPTION_1 ), ///< see ::SDH_NETWORK_OPTION_1_MSK - SDH_NETWORK_OPTION_2_MSK = ( 1UL << SDH_NETWORK_OPTION_2 ), ///< see ::SDH_NETWORK_OPTION_2_MSK + SDH_NETWORK_OPTION_1_MSK = ( 1UL << SDH_NETWORK_OPTION_1 ), ///< see ::SDH_NETWORK_OPTION_1 + SDH_NETWORK_OPTION_2_MSK = ( 1UL << SDH_NETWORK_OPTION_2 ), ///< see ::SDH_NETWORK_OPTION_2 }; @@ -12132,7 +12969,7 @@ enum SDH_NETWORK_OPTION_MASKS * * @see ::GBIT_LINK_COPPER_MODE_MASKS */ -enum GBIT_LINK_COPPER_MODE +enum GBIT_LINK_COPPER_MODES { GBIT_LINK_COPPER_AUTO, // valid if synce is disabled GBIT_LINK_COPPER_FORCE_SYNCE_AUTO, @@ -12148,7 +12985,7 @@ enum GBIT_LINK_COPPER_MODE /** * @brief Flag masks used with ::MBG_SYNC_E_INFO::supp_gbit_link_copper_modes * - * @see ::GBIT_LINK_COPPER_MODE + * @see ::GBIT_LINK_COPPER_MODES */ enum GBIT_LINK_COPPER_MODE_MASKS { @@ -12190,266 +13027,7 @@ enum GBIT_LINK_STATUS "AUTO (SFP LINK UP)", \ } - - -/** - * @brief Enumeration of supported time protocol types for Time Monitor - */ -enum MBG_TIME_MON_PROTOCOL_TYPES -{ - MBG_TIME_MON_PROT_PTP_HW, ///< PTP protocol with hardware time stamping - MBG_TIME_MON_PROT_PTP_SW, ///< PTP protocol software only - MBG_TIME_MON_PROT_NTP_HW, ///< NTP protocol with hardware time stamping - MBG_TIME_MON_PROT_NTP_SW, ///< NTP protocol software only - N_MBG_TIME_MON_PROTOCOL_TYPES -}; - - - -#define MBG_TIME_MON_TOTAL_MAX_NUM_TARGETS 100 - -/** - * @brief Limits to be considered when specifying Time Monitor - */ -typedef struct -{ - uint16_t max_supp_inst; ///< maximum number of instances (e.g. HPS100) which can be specified for Time Monitoring - uint16_t n_inst; ///< number of configured instances for Time Monitoring - uint8_t supp_prot_types; ///< supported time protocol types (see ::MBG_TIME_MON_PROTOCOL_TYPES) - uint8_t reserved_1; ///< reserved, currently always 0 - uint16_t reserved_2; ///< reserved, currently always 0 - -} MBG_TIME_MON_LIMITS; - -#define _mbg_swab_mbg_time_mon_limits( _p ) \ -{ \ - _mbg_swab16( &(_p)->max_supp_inst ); \ - _mbg_swab16( &(_p)->n_inst ); \ - _mbg_swab16( &(_p)->reserved_2 ); \ -} - - - -/** - * @brief Bits used to define ::MBG_TIME_MON_INST_FLAG_MASKS - */ -enum MBG_TIME_MON_INST_FLAGS -{ - MBG_TIME_MON_INST_IS_AVAILABLE, ///< Time Monitor on Instance is available - MBG_TIME_MON_INST_ENABLED, ///< Time Monitor on Instance enabled - N_TIME_MON_INST_FLAGS ///< number of defined bits -}; - - - -/** - * @brief Flag masks used with ::MBG_TIME_MON_INST_SETTINGS::flags - * - * @see ::MBG_TIME_MON_INST_FLAG_MASKS - */ -enum MBG_TIME_MON_INST_FLAG_MASKS -{ - MBG_TIME_MON_MASK_INST_IS_AVAILABLE = ( 1UL << MBG_TIME_MON_INST_IS_AVAILABLE ), ///< see ::MBG_TIME_MON_INST_IS_AVAILABLE - MBG_TIME_MON_MASK_INST_ENABLED = ( 1UL << MBG_TIME_MON_INST_ENABLED ), ///< see ::MBG_TIME_MON_INST_ENABLED -}; - - -/** - * @brief Settings for a Time Monitoring interface - */ -typedef struct -{ - uint32_t flags; ///< see ::MBG_TIME_MON_INST_FLAG_MASKS - uint8_t slot_id; ///< Slot_id of instance - uint8_t reserved_1; ///< reserved, currently always 0 - uint16_t num_targets; ///< number of targets (target is the client to monitor) - uint32_t reserved_2; ///< reserved, currently always 0 - -} MBG_TIME_MON_INST_SETTINGS; - -#define _mbg_swab_time_mon_inst_settings( _p ) \ -{ \ - _mbg_swab32( &(_p)->flags ); \ - _mbg_swab16( &(_p)->num_targets ); \ - _mbg_swab32( &(_p)->reserved_2 ); \ -} - - -/** - * @brief Configuration settings for a specific Time Monitor interface - */ -typedef struct -{ - uint32_t idx; ///< index, 0..MBG_TIME_MON_LIMITS::max_supp_inst-1 - MBG_TIME_MON_INST_SETTINGS settings; ///< specification for a Time Monitor instance with that index - -} MBG_TIME_MON_INST_SETTINGS_IDX; - -#define _mbg_swab_time_mon_inst_settings_idx( _p ) \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_time_mon_inst_settings( &(_p)->settings ); \ -} - -/** - * @brief Current settings and general capabilities of a Time Monitor interface - */ -typedef struct -{ - MBG_TIME_MON_INST_SETTINGS settings; - uint32_t reserved; ///< reserved, currently always 0 - uint32_t flags; ///< reserved, currently always 0 - -} MBG_TIME_MON_INST_INFO; - -#define _mbg_swab_time_mon_inst_info( _p ) \ -{ \ - _mbg_swab_time_mon_inst_settings( &(_p)->settings ); \ - _mbg_swab32( &(_p)->supp_flags ); \ - _mbg_swab32( &(_p)->reserved ); \ -} - -/** - * @brief Current settings and general capabilities of a specific Time Monitor interface - * - * @note The ::MBG_TIME_MON_INST_SETTINGS_IDX structure should be send back - * to the device to save the configuration. - */ -typedef struct -{ - uint32_t idx; ///< index, 0..MBG_TIME_MON_LIMITS::max_supp_inst-1 - MBG_TIME_MON_INST_INFO info; ///< capabilities and current settings - -} MBG_TIME_MON_INST_INFO_IDX; - -#define _mbg_swab_time_mon_inst_info_idx( _p ) \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_time_mon_inst_info( &(_p)->info ); \ -} - - -/** - * @brief Settings of a target on an interface for Time Monitoring - */ -typedef struct -{ - uint8_t slot_id; ///< Slot_id of instance - uint8_t prot_type; ///< see ::MBG_TIME_MON_PROTOCOL_TYPES - uint16_t target_id; ///< Index of target on that HPS100 (target is a client to monitor timing) - uint32_t reserved_2; ///< reserved, currently always 0 - MBG_HOSTNAME addr; ///< Hostname address of target to monitor - -} MBG_TIME_MON_TARGET_SETTINGS; - -#define _mbg_swab_time_mon_target_settings( _p ) \ -{ \ - _mbg_swab16( &(_p)->target_id ); \ - _mbg_swab32( &(_p)->reserved_2 ); \ -} - - -/** - * @brief Settings of a specific target on a specific interface for Time Monitoring - */ -typedef struct -{ - uint32_t idx; ///< index, 0..MBG_TIME_MON_LIMITS::max_supp_inst-1, this is the hps_id - MBG_TIME_MON_TARGET_SETTINGS settings; ///< specification for target on instance for Time Monitor - -} MBG_TIME_MON_TARGET_SETTINGS_IDX; - -#define _mbg_swab_time_mon_target_settings_idx( _p ) \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_time_mon_target_settings( &(_p)->settings ); \ -} - - -/** - * @brief Bits used to define ::MBG_TIME_MON_STATUS_FLAG_MASKS - */ -enum MBG_TIME_MON_STATUS_FLAGS -{ - MBG_TIME_MON_STATUS_MONITORING_ENABLED, ///< Time Monitor is enabled - MBG_TIME_MON_STATUS_TARGET_REACHABLE, ///< Target is reachable - MBG_TIME_MON_STATUS_TARGET_SYNC, ///< Target is synchronized - MBG_TIME_MON_STATUS_TARGET_LOCKED, ///< Target is locked (warmed up) - N_TIME_MON_STATUS_FLAGS ///< number of defined bits -}; - - -/** - * @brief Flag masks used with ::MBG_TIME_MON_STATUS_INFO::flags - * - * @see ::MBG_TIME_MON_INST_FLAG_MASKS - */ -enum MBG_TIME_MON_STATUS_FLAGS_MASKS -{ - MBG_TIME_MON_STATUS_MASK_MONITORING_ENABLED = ( 1UL << MBG_TIME_MON_STATUS_MONITORING_ENABLED ), ///< see ::MBG_TIME_MON_STATUS_MONITORING_ENABLED - MBG_TIME_MON_STATUS_MASK_TARGET_REACHABLE = ( 1UL << MBG_TIME_MON_STATUS_TARGET_REACHABLE ), ///< see ::MBG_TIME_MON_STATUS_TARGET_REACHABLE - MBG_TIME_MON_STATUS_MASK_TARGET_SYNC = ( 1UL << MBG_TIME_MON_STATUS_TARGET_SYNC ), ///< see ::MBG_TIME_MON_STATUS_TARGET_SYNC - MBG_TIME_MON_STATUS_MASK_TARGET_LOCKED = ( 1UL << MBG_TIME_MON_STATUS_TARGET_LOCKED ), ///< see ::MBG_TIME_MON_STATUS_TARGET_LOCKED -}; - - -/** - * @brief Current status of a target of an interface for Time Monitor - */ -typedef struct -{ - uint8_t flags; ///< see ::MBG_TIME_MON_STATUS_FLAGS_MASKS - uint8_t slot_id; ///< Slot_id of instance - uint16_t target_id; ///< Index of target on that HPS100 (target is the client to monitor) - NANO_TIME offset; ///< current time offset from target - NANO_TIME meas_offset; ///< measured time offset to target - NANO_TIME meas_path_delay; ///< measured mean path delay to target - uint8_t port_state; ///< current port state of target , see ::PTP_PORT_STATES - uint8_t reserved_1; ///< reserved, currently always 0 - uint16_t reserved_2; ///< reserved, currently always 0 - MBG_HOSTNAME addr; ///< Hostname address of target - -} MBG_TIME_MON_TARGET_STATUS; - -#define _mbg_swab_time_mon_target_status( _p ) \ -{ \ - _mbg_swab16( &(_p)->target_id ); \ - _mbg_swab_nano_time( &(_p)->offset ); \ - _mbg_swab_nano_time( &(_p)->meas_offset ); \ - _mbg_swab_nano_time( &(_p)->meas_path_delay );\ -} - -/** - * @brief Current status of a specific target of a specific interface for Time Monitor - */ -typedef struct -{ - uint32_t idx; ///< index, 0..MBG_TIME_MON_LIMITS::max_supp_inst-1 - MBG_TIME_MON_TARGET_STATUS status; ///< current status - -} MBG_TIME_MON_TARGET_STATUS_IDX; - -#define _mbg_swab_time_mon_target_status_idx( _p ) \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_time_mon_target_status( &(_p)->status ); \ -} - - - -#else // !defined( _PRELIMINARY_CODE ), dummy declarations to avoid compiler errors with function prototypes - - typedef int MBG_TIME_MON_LIMITS; - typedef int MBG_TIME_MON_INST_SETTINGS; - typedef int MBG_TIME_MON_INST_SETTINGS_IDX; - typedef int MBG_TIME_MON_INST_INFO; - typedef int MBG_TIME_MON_INST_INFO_IDX; - typedef int MBG_TIME_MON_TARGET_SETTINGS; - typedef int MBG_TIME_MON_TARGET_SETTINGS_IDX; - typedef int MBG_TIME_MON_TARGET_STATUS; - typedef int MBG_TIME_MON_TARGET_STATUS_IDX; - -#endif // !defined( _PRELIMINARY_CODE ) +#endif // defined( _PRELIMINARY_CODE ) @@ -12703,6 +13281,10 @@ typedef struct } MBG_PTP_STATISTICS_STATUS; +#else // !defined( _PRELIMINARY_CODE ) + + typedef int MBG_PTP_STATISTICS_STATUS; + #endif // !defined( _PRELIMINARY_CODE ) @@ -12842,7 +13424,7 @@ typedef struct uint32_t reserved_3; ///< reserved, currently 0 uint32_t reserved_4; ///< reserved, currently 0 - uint32_t flags; ///< NTP flags, see ::NTP_FLAG_MASKS + uint32_t flags; ///< NTP flags, see @ref NTP_FLAG_MASKS } NTP_GLB_SETTINGS; @@ -13126,7 +13708,7 @@ typedef struct { uint16_t max_refclks; ///< Number of maximum refclocks in ntp.conf uint16_t cur_refclks; ///< Number of currently configured refclocks - uint32_t feat_flags; ///< Supported refclock specific feature flags, see ::NTP_FLAG_MASKS + uint32_t feat_flags; ///< Supported refclock specific feature flags, see @ref NTP_FLAG_MASKS uint32_t reserved; ///< Future use } NTP_REFCLK_CFG_LIMITS; @@ -13190,23 +13772,23 @@ typedef struct { uint8_t type; ///< See ::NTP_REFCLK_TYPES uint8_t instance; ///< Refclock instance of the specified type. Usually up to 4 instances of the same type are supported by ntpd. - uint8_t mode; ///< Driver specific "mode" //### Flag to enable "mode"? + uint8_t mode; ///< Driver specific "mode" //### TODO Flag to enable "mode"? int8_t stratum; ///< Stratum number to be fudged; -1 if unspecified and thus default is to be used - int8_t refid[4]; ///< Reference id used by driver //### Flag to enable "refid"? + int8_t refid[4]; ///< Reference id used by driver //### TODO Flag to enable "refid"? uint8_t minpoll; ///< Minimum polling interval, [log2 seconds], 0 if unused/unspecified uint8_t maxpoll; ///< Maximum polling interval, [log2 seconds], 0 if unused/unspecified uint8_t reserved_1; ///< Reserved for future use uint8_t reserved_2; ///< Future use - NANO_TIME_64 time1; ///< Driver specific //### TODO This can be a signed floating point number. Is (u)int32_t appropriate? - NANO_TIME_64 time2; ///< Driver specific //### TODO This can be a signed floating point number. Is (u)int32_t appropriate? + NANO_TIME_64 time1; ///< Driver specific + NANO_TIME_64 time2; ///< Driver specific uint16_t drv_flags_enable; ///< Enable/disable driver specific flags, see @ref NTP_FUDGE_FLAG_NUMBERS uint16_t drv_flags_value; ///< 0 or 1, if (drv_flags_enable & x) == 1, see @ref NTP_FUDGE_FLAG_NUMBERS - uint32_t flags; ///< See ::NTP_FLAG_MASKS. Only flags specified in ::TODO can be used here. + uint32_t flags; ///< See @ref NTP_FLAG_MASKS. Only flags specified in ::TODO can be used here. uint32_t reserved_3; ///< Future use @@ -13721,7 +14303,7 @@ typedef struct _mbg_swab16( &(_p)->reserved_2 ); \ } -#endif // defined( _PRELIMINARY_CODE ) +#endif // defined( _PRELIMINARY_CODE ) @@ -13738,7 +14320,7 @@ typedef struct uint32_t reserved_2; ///< reserved, currently 0 uint32_t supp_ntp_roles; ///< supported NTP roles, see ::NTP_ROLE_MASKS - uint32_t supp_flags; ///< supported NTP flags, see ::NTP_FLAG_MASKS + uint32_t supp_flags; ///< supported NTP flags, see @ref NTP_FLAG_MASKS } NTP_GLB_INFO; @@ -13763,7 +14345,7 @@ typedef struct uint32_t reserved_1; ///< reserved, currently 0 uint32_t reserved_2; ///< reserved, currently 0 - uint32_t flags; ///< NTP flags, see ::NTP_FLAG_MASKS + uint32_t flags; ///< NTP flags, see @ref NTP_FLAG_MASKS } NTP_CLNT_MODE_SETTINGS; @@ -13793,8 +14375,8 @@ typedef struct uint32_t reserved_1; ///< reserved, currently 0 uint32_t reserved_2; ///< reserved, currently 0 - uint32_t supp_flags; ///< supported NTP flags, see ::NTP_FLAG_MASKS - uint32_t supp_peer_flags; ///< supported NTP flags for peers, see ::NTP_FLAG_MASKS + uint32_t supp_flags; ///< supported NTP flags, see @ref NTP_FLAG_MASKS + uint32_t supp_peer_flags; ///< supported NTP flags for peers, see @ref NTP_FLAG_MASKS } NTP_CLNT_MODE_INFO; @@ -13892,7 +14474,7 @@ typedef struct uint32_t reserved_3; ///< reserved, currently 0 uint32_t reserved_4; ///< reserved, currently 0 - uint32_t flags; ///< additional options configured, see ::NTP_FLAG_MASKS + uint32_t flags; ///< additional options configured, see @ref NTP_FLAG_MASKS } NTP_PEER_SETTINGS; @@ -13936,7 +14518,7 @@ typedef struct uint32_t reserved_1; ///< reserved, currently 0 uint32_t reserved_2; ///< reserved, currently 0 - uint32_t flags; ///< NTP flags, see ::NTP_FLAG_MASKS + uint32_t flags; ///< NTP flags, see @ref NTP_FLAG_MASKS } NTP_SRV_MODE_SETTINGS; @@ -13958,7 +14540,7 @@ typedef struct uint32_t reserved_1; ///< reserved, currently 0 uint32_t reserved_2; ///< reserved, currently 0 - uint32_t supp_flags; ///< supported NTP flags, see ::NTP_FLAG_MASKS + uint32_t supp_flags; ///< supported NTP flags, see @ref NTP_FLAG_MASKS } NTP_SRV_MODE_INFO; @@ -15336,11 +15918,36 @@ typedef struct * * @{ */ + +/** + * @brief A data type used to hold a unique ID (UID) for a TLV transaction + */ +typedef uint32_t MBG_TLV_UID; + +#define _mbg_swab_tlv_uid( _p ) \ + _mbg_swab32( _p ) + + + +/** + * @brief A data type to hold one of the ::MBG_TLV_TYPES or ::MBG_TLV_FEAT_TYPES + * + * @see ::MBG_TLV_TYPES + * @see ::MBG_TLV_FEAT_TYPES + */ +typedef uint32_t MBG_TLV_TYPE; + +#define _mbg_swab_tlv_type( _p ) \ + _mbg_swab32( _p ) + + + /** * @defgroup group_tlv_feat Meinberg TLV feature definitions * * @{ */ + /** * @brief The maximum number of TLV feature types. * @@ -15352,13 +15959,17 @@ typedef struct /** - * @brief An enumeration of known TLV feature types. + * @brief Enumeration of known TLV feature types. * * TLV feature types are used to specify the content of a binary TLV message * so that the receiver knows how to interpret the content. * + * Used with ::MBG_TLV_INFO::supp_tlv_feat and ::MBG_TLV_DATA::type. ### TODO + * * @see ::MBG_TLV_FEAT_BUFFER * @see ::MBG_TLV_FEAT_TYPE_NAMES + * @see ::MBG_TLV_TYPES + * @see ::MBG_TLV_TYPE */ enum MBG_TLV_FEAT_TYPES { @@ -15395,6 +16006,10 @@ enum MBG_TLV_FEAT_TYPES /// 1) ::MBG_TLV_TYPE_BLOB => ::MBG_LICENSE_NTP_IDX, see @ref group_license_limits MBG_TLV_FEAT_TYPE_LICENSE_NTP_IDX, + /// Expects two TLV types in order: + /// 1) ::MBG_TLV_TYPE_STR => Full qualified path including filename on target system + MBG_TLV_FEAT_TYPE_FILE_REQUEST, + N_MBG_TLV_FEAT_TYPES // NOTE If new TLV feature types are appended here then an appropriate // name string has to be appended to ::MBG_TLV_FEAT_TYPE_NAMES, and care must @@ -15402,7 +16017,6 @@ enum MBG_TLV_FEAT_TYPES }; - /** * @brief Names of TLV API features * @@ -15418,7 +16032,11 @@ enum MBG_TLV_FEAT_TYPES "TLV Firmware Rollback", \ "TLV File Transfer", \ "TLV Execute Command", \ - "TLV License Upgrade" \ + "TLV License Upgrade", \ + "TLV License Limits", \ + "TLV License PTPV2 IDX", \ + "TLV License NTP IDX", \ + "TLV File Request" \ } @@ -15459,11 +16077,11 @@ typedef struct * Should be used by the firmware only to set one of the ::MBG_TLV_FEAT_TYPES * bits in an ::MBG_TLV_FEAT_BUFFER after power-up. * - * @param[in] _tlv_feat_bit One of the ::MBG_TLV_FEAT_TYPES + * @param[in] _tlv_feat_type One of the ::MBG_TLV_FEAT_TYPES * @param[in] _tlv_feat_buffp Pointer to a ::MBG_TLV_FEAT_BUFFER */ -#define _set_tlv_feat_bit( _tlv_feat_bit, _tlv_feat_buffp ) \ - _set_array_bit( _tlv_feat_bit, (_tlv_feat_buffp)->b, MAX_MBG_TLV_FEAT_BYTES ) +#define _set_tlv_feat_bit( _tlv_feat_type, _tlv_feat_buffp ) \ + _set_array_bit( _tlv_feat_type, (_tlv_feat_buffp)->b, MAX_MBG_TLV_FEAT_BYTES ) /** @} defgroup group_tlv_feat */ @@ -15480,7 +16098,7 @@ typedef struct { uint32_t reserved; ///< Future use uint32_t flags; ///< Future use - MBG_TLV_FEAT_BUFFER supp_tlv_feat; ///< Bit mask of supported TLV features, see ::MBG_TLV_FEAT_TYPES + MBG_TLV_FEAT_BUFFER supp_tlv_feat; ///< A byte array of supported TLV feature bits, see ::MBG_TLV_FEAT_TYPES } MBG_TLV_INFO; @@ -15493,7 +16111,13 @@ typedef struct /** - * @brief Enum specifying TLV type in ::MBG_TLV_HDR::type + * @brief Enumeration of known TLV types + * + * Used with ::MBG_TLV_TYPE types, e.g. in ::MBG_TLV_HDR::tlv_type + * or ::MBG_TLV_DATA::type. + * + * @see ::MBG_TLV_FEAT_TYPES + * @see ::MBG_TLV_TYPE */ enum MBG_TLV_TYPES { @@ -15515,21 +16139,19 @@ enum MBG_TLV_TYPES */ typedef struct { - uint32_t uid; ///< Unique ID identifying following TLVs, 0 if empty/not set. - uint32_t type; ///< In a ::MBG_TLV_ANNOUNCE message this is one of the ::MBG_TLV_FEAT_TYPES, - ///< in a ::MBG_TLV_RCV_STATE message one of the ::MBG_TLV_TYPES. - uint32_t total_bytes; ///< Contains all bytes including header size(s) that - ///< are related to a TLV block transaction. - uint32_t reserved_1; ///< Future use + MBG_TLV_UID uid; ///< Unique ID identifying following TLVs, 0 if empty/not set. + MBG_TLV_TYPE type; ///< One of the ::MBG_TLV_TYPES or ::MBG_TLV_FEAT_TYPES depending on the type of message. + uint32_t total_bytes; ///< Number of all bytes including header(s) that are related to a TLV block transaction. + uint32_t reserved_1; ///< Reserved for future use } MBG_TLV_DATA; -#define _mbg_swab_tlv_data( _p ) \ -{ \ - _mbg_swab32( &(_p)->uid ); \ - _mbg_swab32( &(_p)->type ); \ - _mbg_swab32( &(_p)->total_bytes ); \ - _mbg_swab32( &(_p)->reserved_1 ); \ +#define _mbg_swab_tlv_data( _p ) \ +{ \ + _mbg_swab_tlv_uid( &(_p)->uid ); \ + _mbg_swab_tlv_type( &(_p)->type ); \ + _mbg_swab32( &(_p)->total_bytes ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ } @@ -15539,9 +16161,9 @@ typedef struct */ typedef struct { - MBG_TLV_DATA data; ///< See ::MBG_TLV_DATA - uint32_t read_bytes; ///< Number of read bytes - uint32_t reserved_1; ///< Future use + MBG_TLV_DATA data; ///< See ::MBG_TLV_DATA + uint32_t read_bytes; ///< Number of bytes read + uint32_t reserved_1; ///< Future use } MBG_TLV_RCV_STATE; @@ -15557,15 +16179,17 @@ typedef struct */ typedef struct { - MBG_TLV_DATA data; ///< See ::MBG_TLV_DATA - uint32_t reserved_1; ///< Future use - uint32_t reserved_2; ///< Future use + MBG_TLV_DATA data; ///< See ::MBG_TLV_DATA + uint32_t reserved_1; ///< Future use + uint32_t reserved_2; ///< Future use } MBG_TLV_ANNOUNCE; -#define _mbg_swab_tlv_announce( _p ) \ -{ \ - _mbg_swab_tlv_data( &(_p)->data ); \ +#define _mbg_swab_tlv_announce( _p ) \ +{ \ + _mbg_swab_tlv_data( &(_p)->data ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ } @@ -15577,8 +16201,8 @@ typedef struct */ typedef struct { - uint32_t uid; ///< Unique source ID. See ::MBG_TLV_DATA::uid - uint32_t type; ///< "Subtype" identifying current TLV, see ::MBG_TLV_TYPES + MBG_TLV_UID uid; ///< Unique source ID. See ::MBG_TLV_DATA::uid + MBG_TLV_UID tlv_type; ///< "Subtype" identifying current TLV, see ::MBG_TLV_TYPES uint32_t cur_bytes; ///< Number of bytes in ::MBG_TLV::value uint32_t trans_bytes; ///< Number of bytes transferred so far related to this TLV type. uint32_t total_bytes; ///< Number of total bytes (size) of this TLV type without header. @@ -15609,7 +16233,7 @@ typedef struct typedef struct { MBG_TLV_HDR hdr; ///< See ::MBG_TLV_HDR - uint8_t value[MSG_TLV_MAX_VALUE_SIZE]; ///< See ::MSG_TLV_MAX_VALUE_SIZE + uint8_t value[MSG_TLV_MAX_VALUE_SIZE]; ///< See ::MSG_TLV_MAX_VALUE_SIZE } MBG_TLV; @@ -16423,6 +17047,7 @@ enum MBG_EXT_SYS_INFO_BITS MBG_EXT_SYS_INFO_BIT_HW_REV, MBG_EXT_SYS_INFO_BIT_OS_REV, MBG_EXT_SYS_INFO_BIT_FPGA_REV, + MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV, N_MBG_EXT_SYS_INFO_BITS }; @@ -16437,10 +17062,11 @@ enum MBG_EXT_SYS_INFO_BITS */ enum MBG_EXT_SYS_INFO_MSKS { - MBG_EXT_SYS_INFO_MSK_SW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_SW_REV ), ///< see ::MBG_SYS_REV_INFO_BIT_SW_REV - MBG_EXT_SYS_INFO_MSK_HW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_HW_REV ), ///< see ::MBG_SYS_REV_INFO_BIT_HW_REV - MBG_EXT_SYS_INFO_MSK_OS_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_REV ), ///< see ::MBG_SYS_REV_INFO_BIT_OS_REV - MBG_EXT_SYS_INFO_MSK_FPGA_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_FPGA_REV ) ///< see ::MBG_SYS_REV_INFO_BIT_FPGA_REV + MBG_EXT_SYS_INFO_MSK_SW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_SW_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_SW_REV + MBG_EXT_SYS_INFO_MSK_HW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_HW_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_HW_REV + MBG_EXT_SYS_INFO_MSK_OS_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_OS_REV + MBG_EXT_SYS_INFO_MSK_FPGA_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_FPGA_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_FPGA_REV + MBG_EXT_SYS_INFO_MSK_CORE_MOD_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV ) ///< see ::MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV }; @@ -16449,6 +17075,8 @@ enum MBG_EXT_SYS_INFO_PROC_TYPES MBG_EXT_SYS_INFO_PROC_TYPE_NONE, MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_A9, MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_SAM3u, + MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_SAM3s, + MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_STM32F4, N_MBG_EXT_SYS_INFO_PROC_TYPES }; @@ -16456,7 +17084,9 @@ enum MBG_EXT_SYS_INFO_PROC_TYPES { \ "None", \ "Cortex A9", \ - "Cortex SAM3u" \ + "Cortex SAM3u", \ + "Cortex SAM3s", \ + "Cortex STM32F4" \ } enum MBG_EXT_SYS_INFO_FPGA_TYPES @@ -16464,6 +17094,8 @@ enum MBG_EXT_SYS_INFO_FPGA_TYPES MBG_EXT_SYS_INFO_FPGA_TYPE_NONE, MBG_EXT_SYS_INFO_FPGA_TYPE_CYCLONE5_SOC, ///< System on chip MBG_EXT_SYS_INFO_FPGA_TYPE_CYCLONE5, ///< Stand alone FPGA + MBG_EXT_SYS_INFO_FPGA_TYPE_CYCLONE4GX15, + MBG_EXT_SYS_INFO_FPGA_TYPE_CYLCONE4CE22, N_MBG_EXT_SYS_INFO_FPGA_TYPES }; @@ -16471,7 +17103,24 @@ enum MBG_EXT_SYS_INFO_FPGA_TYPES { \ "None", \ "Cyclone5 SoC", \ - "Cyclone5" \ + "Cyclone5", \ + "Cyclone4GX15", \ + "Cyclone4CE22" \ +} + +enum MBG_EXT_SYS_INFO_CORE_MOD_TYPES +{ + MBG_EXT_SYS_INFO_CORE_MOD_TYPE_NONE, + MBG_EXT_SYS_INFO_CORE_MOD_TYPE_UBX_LEA_M8F, ///< u-blox GNSS module without Galileo support + MBG_EXT_SYS_INFO_CORE_MOD_TYPE_UBX_LEA_M8T, ///< u-blox GNSS module with Galileo support + N_MBG_EXT_SYS_INFO_CORE_MOD_TYPES +}; + +#define MBG_EXT_SYS_INFO_CORE_MOD_STRS \ +{ \ + "None", \ + "u-blox LEA-M8F", \ + "u-blox LEA-M8T" \ } typedef struct @@ -16482,12 +17131,15 @@ typedef struct uint32_t hw_rev; uint32_t os_rev; uint32_t fpga_rev; + uint16_t proc_type; ///< See ::MBG_EXT_SYS_INFO_PROC_TYPES uint16_t fpga_type; ///< See ::MBG_EXT_SYS_INFO_FPGA_TYPES + uint16_t core_mod_type; ///< See ::MBG_EXT_SYS_INFO_CORE_MOD_TYPES + uint16_t reserved; + + uint32_t core_mod_rev; /* Reserved for future use, currently 0 */ - uint32_t reserved_rev_1; - uint32_t reserved_rev_2; uint32_t reserved_rev_3; uint32_t reserved_rev_4; uint32_t reserved_rev_5; @@ -16509,6 +17161,9 @@ typedef struct _mbg_swab32( &(_p)->fpga_rev ); \ _mbg_swab16( &(_p)->proc_type ); \ _mbg_swab16( &(_p)->fpga_type ); \ + _mbg_swab16( &(_p)->core_mod_type ); \ + _mbg_swab16( &(_p)->reserved ); \ + _mbg_swab32( &(_p)->core_mod_rev ); \ } @@ -16553,7 +17208,6 @@ typedef struct uint8_t licenses[MBG_MAX_LICENSES]; ///< To get the number of supported licenses ///< of a specific type you need to access the array ///< with the specififc license index defined at ::MBG_LICENSE_BASE_TYPES. - } MBG_LICENSE_LIMITS; @@ -16582,7 +17236,7 @@ enum MBG_LICENSE_BASE_FLAGS * * Used with ::MBG_LICENSE_BASE::supp_flags * - * @see ::MBG_LICENSE_COMM_BITS + * @see ::MBG_LICENSE_BASE_FLAGS */ enum MBG_LICENSE_BASE_MSKS { @@ -16591,9 +17245,9 @@ enum MBG_LICENSE_BASE_MSKS /** - * @brief Common license information that should be part of each individual - * license type. Can be seen as a base / parent class in C++. + * @brief Common license information * + * Should be part of each individual license type. */ typedef struct { @@ -16634,8 +17288,8 @@ enum MBG_LICENSE_PTPV2_MEMBERS */ enum MBG_LICENSE_PTPV2_MEMBER_MSKS { - MBG_LICENSE_PTPV2_MEMBER_MSK_MAX_UCLIENTS = ( 1UL << MBG_LICENSE_PTPV2_MEMBER_MAX_UCLIENTS ), ///< See ::MBG_LICENSE_PTPV2_MEMBER_MAX_UCLIENTS - MBG_LICENSE_PTPV2_MEMBER_MSK_MAX_MTRANS = ( 1UL << MBG_LICENSE_PTPV2_MEMBER_MAX_MTRANS ) ///< See ::MBG_LICENSE_PTPV2_MEMBER_MAX_MCLIENTS + MBG_LICENSE_PTPV2_MEMBER_MSK_MAX_UCLIENTS = ( 1UL << MBG_LICENSE_PTPV2_MEMBER_MAX_UCLIENTS ), ///< See ::MBG_LICENSE_PTPV2_MEMBER_MAX_UCLIENTS + MBG_LICENSE_PTPV2_MEMBER_MSK_MAX_MTRANS = ( 1UL << MBG_LICENSE_PTPV2_MEMBER_MAX_MTRANS ) ///< See ::MBG_LICENSE_PTPV2_MEMBER_MAX_MTRANS }; @@ -16744,7 +17398,6 @@ typedef struct _mbg_swab32( &(_p)->idx ); \ } - /** @} defgroup group_license_limits */ @@ -16782,7 +17435,7 @@ typedef struct #define _mbg_swab_mbg_clk_res_info( _p) \ { \ _mbg_swab32( &(_p)->base_clk ); \ - _mbg_swab32( &(_p)->base_clk ); \ + _mbg_swab32( &(_p)->num_clk_phase ); \ _mbg_swab32( &(_p)->reserved_9 ); \ _mbg_swab32( &(_p)->reserved_8 ); \ _mbg_swab32( &(_p)->reserved_7 ); \ @@ -16799,6 +17452,32 @@ typedef struct +/** + * @brief Type of upcoming transaction sequence + * + * Used in combination with ::GPS_BEGIN_TRANSACTION and ::GPS_END_TRANSACTION + * to announce which type of transaction is going to be started. Thus the receiver + * can prepare for following actions. + */ +enum MBG_TRANSACTION_TYPES +{ + MBG_TRANSACTION_TYPE_NONE, + /* ### TODO FIXME + * Network transaction requires at least and as first command: + * - ::GPS_NET_GLB_CFG (::MBG_NET_GLB_CFG_INFO) + * Depending on ::MBG_NET_GLB_CFG_INFO::glb_settings and its num_[...] + * members there are a couple of index commands which should be handled in any order: + * - ::GPS_NET_DNS_SRVR (::MBG_IP_ADDR_IDX) + * - ::GPS_NET_DNS_SRCH_DOM (::MBG_NET_NAME_IDX) + * - ::GPS_NET_INTF_LINK_IDX (::MBG_NET_INTF_LINK_INFO_IDX) + * - ::GPS_NET_INTF_ADDR_IDX (::MBG_NET_INTF_ADDR_INFO_IDX) + * - ::GPS_NET_INTF_ROUTE_IDX (::MBG_NET_INTF_ROUTE_INFO_IDX) + */ + MBG_TRANSACTION_TYPE_NETWORK, + MBG_TRANSACTION_TYPE_PTP, + MAX_MBG_TRANSACTION_TYPES +}; + #if defined( _USING_BYTE_ALIGNMENT ) #pragma pack() // set default alignment #undef _USING_BYTE_ALIGNMENT diff --git a/mbglib/common/mbg_ntp_test_util.c b/mbglib/common/mbg_ntp_test_util.c index dd9630b..163c906 100755 --- a/mbglib/common/mbg_ntp_test_util.c +++ b/mbglib/common/mbg_ntp_test_util.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_ntp_test_util.c 1.5 2016/08/05 12:35:43 martin REL_M $ + * $Id: mbg_ntp_test_util.c 1.6 2016/11/21 17:22:49 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbg_ntp_test_util.c $ + * Revision 1.6 2016/11/21 17:22:49 martin + * Adjustable client poll value sent to server, defaults to 6. * Revision 1.5 2016/08/05 12:35:43 martin * Proper evaluation of precision field. * Use safe str_util functions. @@ -370,7 +372,7 @@ void init_ntp_req_packet( NTP_PACKET *p, int req_mode, int prot_version ) pbp->flags.version = prot_version; pbp->flags.leap_ind = 3; pbp->flags.stratum = 0; - pbp->flags.poll = 6; + pbp->flags.poll = client_poll_value; pbp->flags.precision = client_precision; } // init_ntp_req_packet diff --git a/mbglib/common/mbg_ntp_test_util.h b/mbglib/common/mbg_ntp_test_util.h index 5ee050d..fb2a5d4 100755 --- a/mbglib/common/mbg_ntp_test_util.h +++ b/mbglib/common/mbg_ntp_test_util.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_ntp_test_util.h 1.4 2016/08/05 12:37:31 martin REL_M $ + * $Id: mbg_ntp_test_util.h 1.5 2016/11/21 17:22:50 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbg_ntp_test_util.h $ + * Revision 1.5 2016/11/21 17:22:50 martin + * Adjustable client poll value sent to server, defaults to 6. * Revision 1.4 2016/08/05 12:37:31 martin * New variable client_precision. * Updated function prototypes. @@ -92,6 +94,15 @@ _ext int8_t client_precision ; +#define DEFAULT_CLIENT_POLL_VALUE 6 + +_ext uint8_t client_poll_value +#ifdef _DO_INIT + = DEFAULT_CLIENT_POLL_VALUE +#endif +; + + typedef struct { double min; diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h index a3511d6..f5b3538 100755 --- a/mbglib/common/mbg_tgt.h +++ b/mbglib/common/mbg_tgt.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_tgt.h 1.35 2016/08/05 12:21:34 martin REL_M $ + * $Id: mbg_tgt.h 1.35.1.6 2016/09/27 15:33:30 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,18 @@ * * ----------------------------------------------------------------------- * $Log: mbg_tgt.h $ + * Revision 1.35.1.6 2016/09/27 15:33:30 martin + * Added definition for _NO_MBG_API. + * Revision 1.35.1.5 2016/09/26 16:17:36 martin + * Fixed definitions for Windows kernel mode build. + * Revision 1.35.1.4 2016/08/31 08:17:51Z thomas-b + * Do not typedef ssize_t if HAVE_SSIZE_T is defined already + * Revision 1.35.1.3 2016/08/11 08:27:17 martin + * Fixed build for Windows kernel space. + * Revision 1.35.1.2 2016/08/10 12:26:49Z martin + * *** empty log message *** + * Revision 1.35.1.1 2016/08/09 15:59:25 martin + * *** empty log message *** * Revision 1.35 2016/08/05 12:21:34 martin * Conditionally define a macro _DEPRECATED_BY which can be used to * tag functions as deprecated, so compilers can emit appropriate warnings. @@ -323,7 +335,7 @@ #if defined( MBG_TGT_FREEBSD ) \ - || defined( MBG_TGT_NETBSD ) \ + || defined( MBG_TGT_NETBSD ) \ || defined( MBG_TGT_OPENBSD ) #define MBG_TGT_BSD @@ -333,9 +345,11 @@ #endif -#if defined( MBG_TGT_LINUX ) \ - || defined( MBG_TGT_BSD ) \ +#if defined( MBG_TGT_LINUX ) \ + || defined( MBG_TGT_BSD ) \ + || defined( MBG_TGT_QNX_NTO ) \ || defined( MBG_TGT_SUNOS ) + #define MBG_TGT_POSIX #define MBG_TGT_UNIX #endif @@ -344,7 +358,13 @@ // Some definitions depending on the build environment ... -#if defined( __GNUC__ ) +#if defined( __GNUC__ ) || defined( __clang__ ) + + #if defined( __clang__ ) + #define _CLANG_VERSION ( __clang_major__ * 10000 \ + + __clang_minor__ * 100 \ + + __clang_patchlevel__ ) + #endif // defined( __clang__ ) #define _GCC_VERSION ( __GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ @@ -419,6 +439,7 @@ #elif defined( MBG_TGT_QNX_NTO ) // QNX 6.x (Neutrino) + #include <unistd.h> #include <stdint.h> #include <inttypes.h> #include <stdbool.h> @@ -435,13 +456,22 @@ #define MBG_TGT_HAS_WCHAR_T 1 - #define __mbg_inline __inline__ - - #if ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer support this + #if defined( __clang__ ) + #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) // works with clang 3.4.1 + #elif ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) - #else + #elif ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer #define _DEPRECATED_BY( _s ) __attribute__((deprecated)) + #else + // Not supported at all, use empty default definiton below. + #endif + + #if ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer + #define __mbg_inline __inline__ __attribute__((always_inline)) + #else + // Not supported at all, use empty default definiton below. + #define __mbg_inline __inline__ #endif #elif defined( _MSC_VER ) @@ -452,9 +482,9 @@ // 1700: MSVC++ 11.0 (Visual Studio 2012) // 1600: MSVC++ 10.0 (Visual Studio 2010) // 1500: MSVC++ 9.0 (Visual Studio 2008) - // 1400: MSVC++ 8.0 (Visual Studio 2005) - // 1310: MSVC++ 7.1 (Visual Studio 2003) - // 1300: MSVC++ 7.0 + // 1400: MSVC++ 8.0 (Visual Studio 2005, Windows Server 2003 SP1 DDK - AMD64) + // 1310: MSVC++ 7.1 (Visual Studio .NET 2003, Windows Server 2003 DDK) + // 1300: MSVC++ 7.0 (Visual Studio .NET 2002, Windows XP SP1 DDK) // 1200: MSVC++ 6.0 // 1100: MSVC++ 5.0 @@ -514,21 +544,28 @@ #endif // availability of _abs64() - #if ( _MSC_VER >= 1500 ) + #if ( _MSC_VER >= 1310 ) // This is supported at least since Visual Studio 2008 + // and Windows Server 2003 SP1 DDK. #define MBG_TGT_HAS_ABS64 1 #endif - // ssize_t support - #if ( _MSC_VER >= 1500 ) - // ssize_t may not be defined, but SSIZE_T is - #include <basetsd.h> - typedef SSIZE_T ssize_t; - #else - // At least VC6 hasn't SIZE_T, either, but size_t - // is typedef'ed as unsigned int, so we just typedef - // the signed variant here. - typedef int ssize_t; + #if !defined ( HAVE_SSIZE_T ) + + // ssize_t support + #if ( _MSC_VER >= 1500 ) + // ssize_t may not be defined, but SSIZE_T is + #include <basetsd.h> + typedef SSIZE_T ssize_t; + #else + // At least VC6 hasn't SIZE_T, either, but size_t + // is typedef'ed as unsigned int, so we just typedef + // the signed variant here. + typedef int ssize_t; + #endif + + #define HAVE_SSIZE_T 1 + #endif #elif defined( _CVI_ ) @@ -691,6 +728,8 @@ #if defined( _KDD_ ) #define MBG_TGT_KERNEL #include <ntddk.h> + + #define _MBG_API #else // This must not be used for kernel drivers. @@ -732,9 +771,9 @@ typedef int socklen_t; #endif - #endif + #define _MBG_API WINAPI - #define _MBG_API WINAPI + #endif #if defined( MBG_LIB_EXPORT ) #define _MBG_API_ATTR __declspec( dllexport ) @@ -767,9 +806,11 @@ * @brief A socket file descriptor type */ #if defined( MBG_TGT_WIN32 ) - // usually evaluates to UINT_PTR, which in turn evaluates - // to (unsigned int), or (unsigned __int64). - typedef SOCKET MBG_SOCK_FD; + #if !defined( MBG_TGT_KERNEL ) // we don't need this in kernel space + // usually evaluates to UINT_PTR, which in turn evaluates + // to (unsigned int), or (unsigned __int64). + typedef SOCKET MBG_SOCK_FD; + #endif #elif defined( MBG_TGT_POSIX ) typedef int MBG_SOCK_FD; //### TODO //### TODO typedef int SOCKET; @@ -807,6 +848,10 @@ #define _MBG_API_ATTR #endif +#if !defined( _NO_MBG_API ) + #define _NO_MBG_API +#endif + #if !defined( _NO_MBG_API_ATTR ) #define _NO_MBG_API_ATTR #endif diff --git a/mbglib/common/mbgerror.c b/mbglib/common/mbgerror.c index faf7e98..c2e089d 100755 --- a/mbglib/common/mbgerror.c +++ b/mbglib/common/mbgerror.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgerror.c 1.2 2016/08/05 12:25:44 martin REL_M $ + * $Id: mbgerror.c 1.2.1.3 2016/09/13 10:24:02 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,13 @@ * * ----------------------------------------------------------------------- * $Log: mbgerror.c $ - * Revision 1.2 2016/08/05 12:25:44 martin + * Revision 1.2.1.3 2016/09/13 10:24:02 martin + * Fixed some compiler warnings. + * Revision 1.2.1.2 2016/08/16 12:48:30Z gregoire.diehl + * CVI fixes + * Revision 1.2.1.1 2016/08/11 07:58:15 martin + * Fixed a compiler warning. + * Revision 1.2 2016/08/05 12:25:44Z martin * Added some functions. * Revision 1.1 2014/03/07 12:08:14 martin * Initial revision. @@ -136,7 +142,8 @@ static ERRNO_CNV_ENTRY posix_h_errno_table[] = #if defined( MBG_TGT_CVI ) -static ERRNO_CNV_ENTRY cvi_rs232_error_table[] = +static ERRNO_CNV_ENTRY cvi_rs232_error_table[] = +{ // { kRS_UnknownSysError, }, // Unknown system error. // { kRS_InvalidPortNum, }, // In valid port number. // { kRS_PortNotOpen, }, // Port is not open. @@ -336,7 +343,7 @@ const char *mbg_strerror( int mbg_errno ) for ( p = tbl; p->name; p++ ) { - if ( p->code == mbg_errno ) + if ( (ulong) mbg_errno == p->code ) return p->name; } @@ -382,9 +389,11 @@ int mbg_cvi_rs232_error_to_mbg( int cvi_rc, const char *info ) #if DEBUG if ( info ) fprintf( stderr, "%s, CVI RS-232 rc: %i\n", info, cvi_rc ); + #else + (void) info; // avoid compiler warning #endif - return ( cvi_rc < 0 ) ? lookup_mbg_errno( cvi_error, cvi_rs232_error_table ) : MBG_SUCCESS; + return ( cvi_rc < 0 ) ? lookup_mbg_errno( cvi_rc, cvi_rs232_error_table ) : MBG_SUCCESS; } // mbg_cvi_rs232_error_to_mbg @@ -408,6 +417,8 @@ int mbg_win32_last_err_to_mbg( DWORD last_err, const char *info ) #if DEBUG if ( info ) fprintf( stderr, "%s, wsa_err: 0x%08lX\n", info, (long) last_err ); + #else + (void) info; // avoid compiler warning #endif return ( last_err == ERROR_SUCCESS ) ? MBG_SUCCESS : lookup_mbg_errno( last_err, win32_error_table ); @@ -430,6 +441,8 @@ int mbg_win32_wsa_err_to_mbg( DWORD wsa_err, const char *info ) #if DEBUG if ( info ) fprintf( stderr, "%s, wsa_err: 0x%08lX\n", info, (long) wsa_err ); + #else + (void) info; // avoid compiler warning #endif // The WSA error code is only retrieved after an error has occurred, so @@ -459,6 +472,8 @@ int mbg_posix_errno_to_mbg( int posix_errno, const char *info ) if ( info ) fprintf( stderr, "%s: %s (errno: %i)\n", info, strerror( posix_errno ), posix_errno ); + #else + (void) info; // avoid compiler warning #endif return lookup_mbg_errno( posix_errno, posix_errno_table ); @@ -493,6 +508,8 @@ int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info ) if ( info ) fprintf( stderr, "%s: %s (h_errno: %i)\n", info, hstrerror( posix_h_errno ), posix_h_errno ); + #else + (void) info; // avoid compiler warning #endif return lookup_mbg_errno( posix_h_errno, posix_h_errno_table ); diff --git a/mbglib/common/mbgerror.h b/mbglib/common/mbgerror.h index 1e2b93a..5727f96 100755 --- a/mbglib/common/mbgerror.h +++ b/mbglib/common/mbgerror.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgerror.h 1.8 2016/08/05 12:29:20 martin REL_M $ + * $Id: mbgerror.h 1.9 2016/10/31 17:41:55 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgerror.h $ + * Revision 1.9 2016/10/31 17:41:55 martin + * New error code MBG_ERR_DATA_FMT. * Revision 1.8 2016/08/05 12:29:20 martin * Re-enabled some symbols which have been commented out. * Added new codes, and initializers for code/string conversion tables. @@ -147,7 +149,7 @@ #define MBG_ERR_HDR_CSUM -61 ///< binary protocol header checksum error #define MBG_ERR_DATA_CSUM -62 ///< binary protocol data checksum error #define MBG_ERR_RCVD_NACK -63 ///< binary protocol received reply msg with a NACK code -#define MBG_ERR_RCVD_NO_ACK -64 ///< binary protocol received reply msg without expected ACK code +#define MBG_ERR_RCVD_NO_ACK -64 ///< binary protocol received reply msg without expected ACK code //### TODO #define MBG_ERR_CONN_TYPE -65 ///< binary protocol no valid/supported connection type specified #define MBG_ERR_BYTES_WRITTEN -66 ///< binary protocol failed to write all bytes #define MBG_ERR_AUTH -67 ///< binary protocol failed authentication @@ -189,6 +191,7 @@ #define MBG_ERR_ALREADY_ALLOC -96 ///< pointer already allocated when trying to allocate memory #define MBG_ERR_HOST_NOT_FOUND -97 ///< host not found #define MBG_ERR_CONN_RESET -98 ///< connection reset by peer +#define MBG_ERR_DATA_FMT -99 ///< invalid data format // NOTE: New codes have to be appended to this list, and the sequence of codes must not // be changed. Whenever new codes have been defined, appropriate entries have to be added @@ -215,7 +218,7 @@ { MBG_ERR_TIMEOUT, "Timeout" }, \ { MBG_ERR_FW_ID, "Invalid firmware ID" }, \ { MBG_ERR_NBYTES, "Unexpected number of data bytes for this API" }, \ - { MBG_ERR_INV_TIME, "Clock has invalid time" }, /* ### TODO or tried to pass invalid time to the device? */ \ + { MBG_ERR_INV_TIME, "Invalid time passed to device" }, \ { MBG_ERR_FIFO, "FIFO unexpectedly empty" }, \ { MBG_ERR_NOT_READY, "Device not ready" }, \ { MBG_ERR_INV_TYPE, "Unsupported data type" }, \ @@ -271,7 +274,7 @@ { MBG_ERR_DISCONN, "Connection closed by remote site/host" }, \ { MBG_ERR_INV_CFG, "Invalid/inconsistent configuration read from device" }, \ { MBG_ERR_RANGE, "Input parameter was out of range" }, \ - { MBG_ERR_INV_TLV_ANN_BYTES, "Number of announced TLV bytes doesn't match number of transferred bytes" }, \ + { MBG_ERR_INV_TLV_ANN_BYTES, "TLV num of transferred bytes differs from num of announced bytes" }, \ { MBG_ERR_INV_TLV_SIZE, "MBG_ERR_INV_TLV_SIZE" }, /* ### TODO */ \ { MBG_ERR_INV_TLV_UID, "MBG_ERR_INV_TLV_UID" }, /* ### TODO */ \ { MBG_ERR_EXIST, "File exists" }, \ @@ -280,6 +283,7 @@ { MBG_ERR_ALREADY_ALLOC, "Memory already allocated" }, \ { MBG_ERR_HOST_NOT_FOUND, "Host not found" }, \ { MBG_ERR_CONN_RESET, "Connection reset by peer" }, \ + { MBG_ERR_DATA_FMT, "Invalid data format" }, \ { 0, NULL } /* end of table */ \ } diff --git a/mbglib/common/str_util.c b/mbglib/common/str_util.c index c5c40b5..c3c89cb 100755 --- a/mbglib/common/str_util.c +++ b/mbglib/common/str_util.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: str_util.c 1.2 2016/08/05 12:31:04 martin REL_M $ + * $Id: str_util.c 1.3 2016/10/24 08:10:04 thomas-b REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: str_util.c $ + * Revision 1.3 2016/10/24 08:10:04 thomas-b + * Fixed counter var check in mbg_memcpy_reversed * Revision 1.2 2016/08/05 12:31:04 martin * New functions mbg_memcpy() and mbg_memcpy_reversed(). * Moved string trim functions from cfg_util module here. @@ -437,7 +439,7 @@ void mbg_memcpy_reversed( void *dst, const void *src, size_t n_bytes ) uint8_t *dstp = ( (uint8_t *) dst ) + n_bytes; uint8_t *srcp = ( (uint8_t *) src ) + n_bytes; - while ( --n_bytes ) + while ( n_bytes-- ) *(--dstp) = *(--srcp); } diff --git a/mbglib/common/timeutil.c b/mbglib/common/timeutil.c index 83d442e..026570f 100755 --- a/mbglib/common/timeutil.c +++ b/mbglib/common/timeutil.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: timeutil.c 1.1 2016/07/15 14:14:19 martin REL_M $ + * $Id: timeutil.c 1.1.1.3 2016/11/21 15:22:37 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,12 @@ * * ----------------------------------------------------------------------- * $Log: timeutil.c $ - * Revision 1.1 2016/07/15 14:14:19 martin + * Revision 1.1.1.3 2016/11/21 15:22:37 martin + * Revision 1.1.1.2 2016/08/11 15:09:46Z martin + * *** empty log message *** + * Revision 1.1.1.1 2016/08/11 07:54:40 martin + * Fixed build with old Visual Studio. + * Revision 1.1 2016/07/15 14:14:19Z martin * Initial revision * **************************************************************************/ @@ -22,6 +27,10 @@ #include <str_util.h> #include <mbgerror.h> +#if defined( MBG_TGT_WIN32 ) + #include <stdio.h> +#endif + /*HDR*/ @@ -32,11 +41,91 @@ int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, cons if ( calling_fnc ) n += snprintf_safe( &s[n], max_len - n, " in %s", calling_fnc ); - n += snprintf_safe( &s[n], max_len - n, " for time_t %llu: %s", - (unsigned long long) t, mbg_strerror( mbg_errno ) ); + #if defined( _MSC_VER ) && ( _MSC_VER < 1500 ) + //### TODO E.g. in VC6 time_t is only 32 bit anyway. + n += snprintf_safe( &s[n], max_len - n, " for time_t %lu: %s", + (unsigned long) t, mbg_strerror( mbg_errno ) ); + #else + n += snprintf_safe( &s[n], max_len - n, " for time_t %llu: %s", + (unsigned long long) t, mbg_strerror( mbg_errno ) ); + #endif return n; } // snprint_gmtime_error + +#if defined( MBG_TGT_WIN32 ) + +#define CLOCK_REALTIME 0 + +/*HDR*/ +int mbg_clock_gettime( int clock_id, struct timespec *res ) +{ + if ( clock_id == CLOCK_REALTIME ) + { + #if defined( TIME_UTC ) // C11 / VS2015+ + int rc = timespec_get( res, TIME_UTC ); // TODO Check this code + return ( rc == 0 ) ? -1 : 0 // rc == 0 means error + #else + #define EPOCH_HNS 116444736000000000i64 + #define NSEC_PER_SEC 1000000000i64 + FILETIME ft; + unsigned __int64 tmp; + gstaft_fnc( &ft ); + tmp = ( (__int64) ft.dwHighDateTime << 32 ) | ft.dwLowDateTime; + tmp -= EPOCH_HNS; // convert to Unix epoch + tmp *= 100; // convert to nanoseconds + res->tv_sec = ( tmp / NSEC_PER_SEC ); + res->tv_nsec = ( tmp % NSEC_PER_SEC ); + return 0; + #endif + } + else + return -1; // TODO this is e.g. in case of CLOCK_MONOTONIC, we could use QPC then. + +} // mbg_clock_gettime + + + +bool force_legacy_gstaft; + + +/*HDR*/ +void check_precise_time_api( void ) +{ + const char *info =""; + GSTAFT_FNC tmp_fnc; + HINSTANCE h = LoadLibrary( "kernel32.dll" ); + + if ( h == NULL ) + { + info = "Precise system time may not be supported; failed to get handle for kernel32.dll."; + goto out; + } + + tmp_fnc = (GSTAFT_FNC) GetProcAddress( h, "GetSystemTimePreciseAsFileTime" ); + + if ( tmp_fnc == NULL ) + { + info = "Precise system time NOT supported"; + goto out; + } + + if ( force_legacy_gstaft ) + { + info = "Precise system time is supported, but legacy function used by request"; + goto out; + } + + gstaft_fnc = tmp_fnc; + info = "Precise system time is supported and used"; + +out: + printf( "%s\n", info ); + +} // check_precise_time_api + +#endif + diff --git a/mbglib/common/timeutil.h b/mbglib/common/timeutil.h index 33a744f..d5f7e02 100755 --- a/mbglib/common/timeutil.h +++ b/mbglib/common/timeutil.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: timeutil.h 1.1 2016/07/15 14:14:20 martin REL_M $ + * $Id: timeutil.h 1.2.1.1 2016/08/11 15:09:51 martin TRASH $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,11 @@ * * ----------------------------------------------------------------------- * $Log: timeutil.h $ - * Revision 1.1 2016/07/15 14:14:20 martin + * Revision 1.2.1.1 2016/08/11 15:09:51 martin + * *** empty log message *** + * Revision 1.2 2016/08/11 13:44:00 martin + * Include stddef.h. + * Revision 1.1 2016/07/15 14:14:20Z martin * Initial revision * **************************************************************************/ @@ -24,6 +28,7 @@ #include <mbgerror.h> #include <time.h> +#include <stddef.h> #ifdef _TIMEUTIL @@ -41,6 +46,27 @@ extern "C" { #endif +#if defined( MBG_TGT_WIN32 ) + +#define __const__ const + +/** + * @brief A pointer to a function returning the system time as FILETIME + * + * This can be e.g. the standard Windows API call GetSystemTimeAsFileTime() + * or the GetSystemTimeAsPreciseFileTime() API call introduced with Windows 8. + */ +typedef VOID (WINAPI *GSTAFT_FNC)(LPFILETIME lpSystemTimeAsFileTime); + +_ext GSTAFT_FNC gstaft_fnc +#ifdef _DO_INIT + = GetSystemTimeAsFileTime +#endif +; + +#endif + + /* function prototypes: */ static __mbg_inline @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: ntptest.c 1.6 2016/08/05 12:42:48 martin REL_M $ + * $Id: ntptest.c 1.7 2016/11/21 17:32:54 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -12,6 +12,9 @@ * * ----------------------------------------------------------------------- * $Log: ntptest.c $ + * Revision 1.7 2016/11/21 17:32:54 martin + * New parameter -P to set client poll value sent to server. + * Moved some Windows-specific code elsewhere. * Revision 1.6 2016/08/05 12:42:48 martin * Support build build under Windows. * Use precise time API under Windows, if supported. @@ -56,25 +59,13 @@ static const char program_name[] = "ntptest"; -static const char program_version[] = "v1.3"; +static const char program_version[] = "v1.4"; static const char program_copyright[] = "(c) Meinberg 2014-2016"; static const char program_contact[] = "contact: <martin.burnicki@meinberg.de>"; #if defined( MBG_TGT_WIN32 ) - -#define __const__ const - -/** - * @brief A pointer to a function returning the system time as FILETIME - * - * This can be e.g. the standard Windows API call GetSystemTimeAsFileTime() - * or the GetSystemTimeAsPreciseFileTime() API call introduced with Windows 8. - */ -typedef VOID (WINAPI *GSTAFT_FNC)(LPFILETIME lpSystemTimeAsFileTime); - -static GSTAFT_FNC gstaft_fnc = GetSystemTimeAsFileTime; - + #define __const__ const #endif @@ -117,74 +108,6 @@ static NTP_PACKET default_ntp_req_packet; // template of request packet static QUERY_STATS glb_query_stats; -#if defined( MBG_TGT_WIN32 ) - -#define CLOCK_REALTIME 0 - -int clock_gettime( int clock_id, struct timespec *res ) -{ - if ( clock_id == CLOCK_REALTIME ) - { - #if defined( TIME_UTC ) // VS2015+ - int rc = timespec_get( res, TIME_UTC ); // TODO Check this code - return ( rc == 0 ) ? -1 : 0 // rc == 0 means error - #else - #define EPOCH_HNS 116444736000000000i64 - #define NSEC_PER_SEC 1000000000i64 - FILETIME ft; - unsigned __int64 tmp; - gstaft_fnc( &ft ); - tmp = ( (__int64) ft.dwHighDateTime << 32 ) | ft.dwLowDateTime; - tmp -= EPOCH_HNS; // convert to Unix epoch - tmp *= 100; // convert to nanoseconds - res->tv_sec = ( tmp / NSEC_PER_SEC ); - res->tv_nsec = ( tmp % NSEC_PER_SEC ); - return 0; - #endif - } - else - return -1; // TODO this is e.g. in case of CLOCK_MONOTONIC, we could use QPC then. - -} // clock_gettime - - -void check_precise_time_api( void ) -{ - const char *info =""; - GSTAFT_FNC tmp_fnc; - HINSTANCE h = LoadLibrary( "kernel32.dll" ); - - if ( h == NULL ) - { - info = "Precise system time may not be supported; failed to get handle for kernel32.dll."; - goto out; - } - - tmp_fnc = (GSTAFT_FNC) GetProcAddress( h, "GetSystemTimePreciseAsFileTime" ); - - if ( tmp_fnc == NULL ) - { - info = "Precise system time NOT supported"; - goto out; - } - - if ( force_legacy_gstaft ) - { - info = "Precise system time is supported, but legacy function used by request"; - goto out; - } - - gstaft_fnc = tmp_fnc; - info = "Precise system time is supported and used"; - -out: - printf( "%s\n", info ); - -} // check_precise_time_api - -#endif - - /*HDR*/ void mbglog( int priority, const char *fmt, ... ) @@ -372,6 +295,7 @@ void usage( void ) printf( " -v verbose, print full packets even in continuous mode\n" ); printf( " -V n NTP protocol version, %i..%i, default: %i\n", MIN_REQ_NTP_VERSION, MAX_REQ_NTP_VERSION, DEFAULT_REQ_NTP_VERSION ); + printf( " -P n NTP client poll value sent to server, default: %i\n", DEFAULT_CLIENT_POLL_VALUE ); printf( " -T n packet receive timeout [ms], default: %u\n", RCV_TIMEOUT ); printf( " -Z send 4 req/s to server, print time, offset changes and status summary\n" ); printf( " e.g. for leap second tests\n" ); @@ -398,7 +322,7 @@ void check_options( int argc, char *argv[] ) #define WIN32_OPTS #endif - while ( ( c = getopt( argc, argv, "cs:vV:T:Zh?" WIN32_OPTS ) ) != -1 ) + while ( ( c = getopt( argc, argv, "cs:vV:P:T:Zh?" WIN32_OPTS ) ) != -1 ) { switch ( c ) { @@ -432,6 +356,11 @@ void check_options( int argc, char *argv[] ) break; + case 'P': + client_poll_value = strtol( optarg, NULL, 10 ); + break; + + case 'Z': // quick settings for leap second test run_continuously = 1; #if defined( MBG_TGT_WIN32 ) |