summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2016-08-05 12:00:00 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2016-08-05 12:00:00 +0200
commitdafaea82601c0ba768bb74f5ba3876e809ef3995 (patch)
tree5a2033c0202ab59ef9a62a33ab7c96bcd05bf3e0
parentb4987393ee0d42a1266b8f574f41a7230fc4aa87 (diff)
downloadntptest-dafaea82601c0ba768bb74f5ba3876e809ef3995.tar.gz
ntptest-dafaea82601c0ba768bb74f5ba3876e809ef3995.zip
Source code can be built on Windows1.3
Yet no Windows project files included. Use precise time API under Windows, if supported. Move Makefile to new subdirectory 'unix'. Make stdout unbuffered on POSIX, so output is shown immediately even if piped e.g. via the tee command. Use safe string functions. Use compatible Meinberg error codes.
-rwxr-xr-xREADME54
-rwxr-xr-xmbglib/common/gpsdefs.h7691
-rwxr-xr-xmbglib/common/mbg_ntp_test_util.c116
-rwxr-xr-xmbglib/common/mbg_ntp_test_util.h31
-rwxr-xr-xmbglib/common/mbg_tgt.h278
-rwxr-xr-xmbglib/common/mbgerror.c711
-rwxr-xr-xmbglib/common/mbgerror.h511
-rwxr-xr-xmbglib/common/mbgntp.h10
-rwxr-xr-xmbglib/common/str_util.c447
-rwxr-xr-xmbglib/common/str_util.h265
-rwxr-xr-xmbglib/common/timeutil.c42
-rwxr-xr-xmbglib/common/timeutil.h91
-rwxr-xr-xmbglib/common/words.h209
-rwxr-xr-xntptest.c320
-rwxr-xr-xunix/Makefile (renamed from Makefile)12
15 files changed, 9742 insertions, 1046 deletions
diff --git a/README b/README
index 6940ea3..3dfb116 100755
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Id: README 1.2 2015/05/11 12:38:59 martin REL_M $
+$Id: README 1.3 2016/08/05 12:54:04 martin REL_M $
This is the README file for the ntptest tool which is similar to ntpdate
which comes with the NTP software package. It sends an NTP request packet
@@ -11,8 +11,11 @@ the status as well as offset *changes* from the initial offset are printed
in 1 line. This is useful e.g. for leap second monitoring of remote devices.
-To build the executable just unpack the tar.gz source code archive, cd into
-the extracted directory, and run "make".
+To build the executable under Linux just unpack the tar.gz source code archive,
+cd into the unix/ directory below the extracted directory, and run "make".
+
+For Windows there is a project file for Visual Studion 2008 in the windows\vs2008
+directory.
Then type "./ntptest -?" to get some usage information.
@@ -22,35 +25,37 @@ specified on the command line, e.g.:
------------------------------------------------------------------------------
#ntptest> ./ntptest 172.16.100.43
-ntptest v1.1, (c) Meinberg 2014-2015, contact: <martin.burnicki@meinberg.de>
+ntptest v1.3, (c) Meinberg 2014-2016, contact: <martin.burnicki@meinberg.de>
Host 172.16.100.43
Request packet:
- mode 3, version 4, leap_ind 3, stratum 0, poll 6, prec 238
+ mode 3, version 4, leap_ind 3, stratum 0, poll 6, prec -18 (3.81 us)
root delay: 00000000 (0.0000 s)
root dispersion: 00000000 (0.0000 s/s)
reference id: 00000000 ()
Ref time: 00000000.00000000 1900-01-01 00:00:00.000000000
Org time (T1): 00000000.00000000 1900-01-01 00:00:00.000000000
Rcv time (T2): 00000000.00000000 1900-01-01 00:00:00.000000000
- Xmt time (T3): D8FB20A9.28DD1D49 2015-05-11 12:35:53.159623937
- Curr time (T4): D8FB20A9.28DD1D49 2015-05-11 12:35:53.159623937
+ Xmt time (T3): DB4F094D.CBB95E8A 2016-08-05 12:47:09.795797260
+ Curr time (T4): DB4F094D.CBB95E8A 2016-08-05 12:47:09.795797260
Response packet:
- mode 4, version 4, leap_ind 0, stratum 1, poll 6, prec 237
+ mode 4, version 4, leap_ind 0, stratum 1, poll 6, prec -18 (3.81 us)
root delay: 00000000 (0.0000 s)
- root dispersion: 0000001B (0.0004 s/s)
- reference id: 00535050 (PPS)
- Ref time: D8FB209C.5420AD42 2015-05-11 12:35:40.328623608
- Org time (T1): D8FB20A9.28DD1D49 2015-05-11 12:35:53.159623937
- Rcv time (T2): D8FB20A9.28E01E8F 2015-05-11 12:35:53.159669790
- Xmt time (T3): D8FB20A9.28E213DE 2015-05-11 12:35:53.159699670
- Curr time (T4): D8FB20A9.28EF8182 2015-05-11 12:35:53.159904569
-
-turnaround: 280.632 (280.632..280.632) us (T4 - T1)
-server latency: 29.880 (29.880..29.880) us (T3 - T2)
-computed delay: 250.752 (250.752..250.752) us ((T4 - T1) - (T3 - T2))
-computed offset: -79.524 (-79.524..-79.524) us (((T2 - T1) + (T3 - T4)) / 2)
+ root dispersion: 00000046 (0.0011 s/s)
+ reference id: 0053524D (MRS)
+ Ref time: DB4F0949.096E2ED8 2016-08-05 12:47:05.036837508
+ Org time (T1): DB4F094D.CBB95E8A 2016-08-05 12:47:09.795797260
+ Rcv time (T2): DB4F094D.CBA1359C 2016-08-05 12:47:09.795428610
+ Xmt time (T3): DB4F094D.CBB5D7CF 2016-08-05 12:47:09.795743454
+ Curr time (T4): DB4F094D.CBD81EA0 2016-08-05 12:47:09.796266473
+
+Authentication: not used
+
+turnaround: 469.213 (469.213..469.213) us (T4 - T1)
+server latency: 314.844 (314.844..314.844) us (T3 - T2)
+computed delay: 154.369 (154.369..154.369) us ((T4 - T1) - (T3 - T2))
+computed offset: -445.835 (-445.835..-445.835) us (((T2 - T1) + (T3 - T4)) / 2)
------------------------------------------------------------------------------
The output shows the contents of the request packet sent to the NTP server,
@@ -101,6 +106,11 @@ Please note:
based on weighted avarages from subsequent poll, so the results displayed
by this program will vary more than those displayed by "ntpq -p".
+- Under Windows the "precise" time API is used, if available. This is the
+ case in Windows 8 / Windows Server 2012 and newer. Under older Windows
+ versions the precision of the system time is limited to 1 ms or even worse,
+ so the calculated time offsets are not very precise.
+
- Don't run this program only with parameter -c against public NTP server.
Polling at 1 request per second can be considered as abusive.
Use the -s parameter to increase the sleep interval betweent to pollings
@@ -119,9 +129,9 @@ at the beginning of the leap second, so the displayed offset step from ~0 ms
to ~-1000 ms.
-----------------------------------------------------------------------------------
-#ntptest> ./ntptest 172.16.100.44
+#ntptest> ./ntptest -Z 172.16.100.44
-ntptest v1.1, (c) Meinberg 2014-2015, contact: <martin.burnicki@meinberg.de>
+ntptest v1.3, (c) Meinberg 2014-2016, contact: <martin.burnicki@meinberg.de>
Host 172.16.100.44, running continuously
...
diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h
index 9a3e1e1..d9c6258 100755
--- a/mbglib/common/gpsdefs.h
+++ b/mbglib/common/gpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.122 2014/07/29 08:57:44 martin REL_M $
+ * $Id: gpsdefs.h 1.124.1.173 2016/08/03 08:05:11 thomas-b TEST $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -13,7 +13,377 @@
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
- * Revision 1.122 2014/07/29 08:57:44 martin
+ * Revision 1.124.1.173 2016/08/03 08:05:11 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.
+ * Revision 1.124.1.171 2016/07/15 14:08:09Z martin
+ * Fixed a typo.
+ * Revision 1.124.1.170 2016/07/07 14:17:02 martin
+ * Cleaned up POUT API.
+ * Doxygen fixes.
+ * Revision 1.124.1.169 2016/07/07 09:57:10 andre.hartmann
+ * added mbg_clk_res_info
+ * Revision 1.124.1.168 2016/06/28 15:42:16Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.167 2016/06/28 15:04:40 martin
+ * Added definitions for GRC181.
+ * Added missing definitions for GPS180CSM.
+ * Revision 1.124.1.166 2016/06/23 09:23:24 thomas-b
+ * Added num_dns_srvr and num_dns_srch_dom to MBG_NET_GLB_CFG_SETTINGS
+ * Revision 1.124.1.165 2016/06/22 06:58:37 udo
+ * added new parameters to MBG_TIME_MON_TARGET_STATUS
+ * Revision 1.124.1.164 2016/06/21 06:34:54 andre
+ * QL alarms now separated for TDEV and MTIE
+ * comment for QL hysteresis added
+ * Revision 1.124.1.163 2016/06/10 07:59:09Z philipp
+ * Extended sysinfo proc and fpga types by SAM3u and Cyclone5
+ * Revision 1.124.1.162 2016/06/09 09:17:08 thomas-b
+ * Added builtin features TIME and TZDL for TCR cards
+ * Revision 1.124.1.161 2016/06/06 08:59:45 andre
+ * Revision 1.124.1.160 2016/06/02 13:36:11Z philipp
+ * Extended MBG_EXT_SYS_INFO proc and fpga types
+ * Revision 1.124.1.159 2016/06/02 10:57:51 philipp
+ * Added string initializers for MBG_EXT_SYS_INFO's proc and FPGA types
+ * Revision 1.124.1.158 2016/06/02 10:24:22 philipp
+ * Renaming all revision macros and helper functions
+ * Revision 1.124.1.157 2016/06/02 10:15:35 philipp
+ * Renaming all MBG_EXT_REV_INFO related stuff to MBG_EXT_SYS_INFO.
+ * Revision 1.124.1.156 2016/06/01 10:49:49 andre
+ * Revision 1.124.1.155 2016/06/01 09:51:26Z philipp
+ * Added structures and definitions for new type MBG_LICENSE to be queried via TLV_API.
+ * Revision 1.124.1.154 2016/06/01 06:59:00 andre
+ * Revision 1.124.1.153 2016/05/31 14:32:27Z andre
+ * Revision 1.124.1.152 2016/05/31 14:32:02Z andre
+ * Revision 1.124.1.151 2016/05/30 08:14:09Z thomas-b
+ * Added builtin feature GPS_MODEL_HAS_TIME to GPS receivers and N2x
+ * Revision 1.124.1.150 2016/05/27 06:32:12 philipp
+ * Changed XMR_HOLDOVER_STATUS_MODE_NAMES
+ * Revision 1.124.1.149 2016/05/26 08:01:16 andre
+ * Revision 1.124.1.148 2016/05/24 14:43:10Z andre
+ * Revision 1.124.1.147 2016/05/24 13:32:24Z philipp
+ * Added PTP Statistics
+ * Revision 1.124.1.146 2016/05/20 08:58:52 thomas-b
+ * New BUILTIN_FEATURE GPS_HAS_TZCODE for older PZF cards
+ * Revision 1.124.1.145 2016/05/20 06:41:42 thomas-b
+ * Added TZDL and ENABLE_FLAGS to BUILTIN_FEAT_N2X
+ * Revision 1.124.1.144 2016/05/19 13:12:32 paul
+ * renamed two video HD formats:
+ * 1080i29.97Hz to 1080i59.94Hz and 1080i25Hz to 1080i50Hz
+ * Revision 1.124.1.143 2016/05/11 13:20:20Z thomas-b
+ * Changed several fields and flags in NET_CFG structures
+ * Revision 1.124.1.142 2016/05/09 08:06:53 philipp
+ * New array string initializers for LED modes and colors
+ * Revision 1.124.1.141 2016/05/04 09:57:27 thomas-b
+ * Comment changed
+ * Revision 1.124.1.140 2016/04/26 09:17:41 thomas-b
+ * Changed structure MBG_NET_GLB_CFG_SETTINGS
+ * Revision 1.124.1.139 2016/04/26 08:51:47 philipp
+ * New multi reference input type SyncE
+ * Revision 1.124.1.138 2016/04/26 08:18:58 thomas-b
+ * Added typedefs for interface route structures if _PRELIMINARY_CODE is not defined
+ * Revision 1.124.1.137 2016/04/26 07:39:45 thomas-b
+ * Changed names and descriptions in net_cfg structures
+ * Relocated preliminary code areas in net_cfg and ntp definitions
+ * Revision 1.124.1.136 2016/04/26 06:05:44 philipp
+ * Removed space to fix compiler error on ARM GCC 4.9.3
+ * Revision 1.124.1.135 2016/04/25 15:13:58 martin
+ * *** empty log message ***
+ * Revision 1.124.1.134 2016/04/25 14:34:46 martin
+ * *** empty log message ***
+ * Revision 1.124.1.133 2016/04/25 10:23:22Z martin
+ * TLV code isn't preliminary anymore.
+ * Enums with more than 16 entries are not supported by 16 bit compilers.
+ * Revision 1.124.1.132 2016/04/22 08:36:27 philipp
+ * Added String initializers for GPIO bit out flags
+ * Revision 1.124.1.131 2016/04/21 10:53:29 philipp
+ * Added GPIO bits format strings.
+ * Added T1 SSM quality levels.
+ * Revision 1.124.1.130 2016/04/20 14:43:29 udo
+ * use NANO_TIME instead of double
+ * Revision 1.124.1.129 2016/04/20 13:16:58 thomas-b
+ * Added typedefs for NTP_SRV_MODE_INFO and NTP_SRV_MODE_SETTINGS
+ * Revision 1.124.1.128 2016/04/20 09:26:05 philipp
+ * Moved all HPS-PTP related structures to gpspriv.h and removed related extended feature bit from gpsdefs.h.
+ * Also removed functions from mbgextio and xdevfeat since HPS-PTP handling needs a redesign concerning structures.
+ * Thus, handle everything explicitly for now!
+ * -> Redesing this A.S.A.P.!!!
+ * Revision 1.124.1.127 2016/04/18 12:37:02 thomas-b
+ * New network structures and definitions for bonding and routing
+ * Revision 1.124.1.126 2016/04/15 13:14:08 daniel
+ * Added PTP profile ITU-T. G. 8275.2
+ * Revision 1.124.1.125 2016/04/15 09:22:16 udo
+ * fixed alignment problem in PTP_DEV_CFG_GLB
+ * Revision 1.124.1.124 2016/04/15 08:17:28 philipp
+ * New feature MBG_XFEATURE_EXT_PTP
+ * Revision 1.124.1.123 2016/04/15 07:31:46 andre
+ * Revision 1.124.1.122 2016/04/08 10:18:02Z daniel
+ * Fixed MBG_ENCODE_EXT_REV macro
+ * Revision 1.124.1.121 2016/04/08 10:16:29 martin
+ * *** empty log message ***
+ * Revision 1.124.1.120 2016/04/07 13:20:23 philipp
+ * Extended NTP definitions and added new structure MBG_EXT_REV_INFO including enums, masks, etc..
+ * Revision 1.124.1.119 2016/04/05 13:29:25 daniel
+ * Adjust ptp cfg and state structures to take care of unified data type sizes and alignment
+ * Revision 1.124.1.118 2016/04/04 14:46:13 martin
+ * Added TLV feature type names.
+ * Revision 1.124.1.117 2016/03/24 14:08:47 martin
+ * *** empty log message ***
+ * Revision 1.124.1.116 2016/03/24 09:14:52 martin
+ * New extended feature MBG_XFEATURE_PWR_CTL_API.
+ * Revision 1.124.1.115 2016/03/18 11:21:52 martin
+ * *** empty log message ***
+ * Revision 1.124.1.114 2016/03/18 10:32:25 martin
+ * *** empty log message ***
+ * Revision 1.124.1.113 2016/03/17 09:21:01 martin
+ * *** empty log message ***
+ * Revision 1.124.1.112 2016/03/16 15:13:37 martin
+ * *** empty log message ***
+ * Revision 1.124.1.111 2016/03/16 08:29:13 martin
+ * Removed ..._MODEL_HAS_GNSS_MODE definitions, use ..._MODEL_IS_GNSS
+ * instead.
+ * Revision 1.124.1.110 2016/03/15 14:55:04 martin
+ * Modified LNE and LED API.
+ * Revision 1.124.1.109 2016/03/14 11:54:06 martin
+ * Fixed duplicate macro name.
+ * Revision 1.124.1.108 2016/03/11 15:12:08 martin
+ * Started to refactor LED and LNE API.
+ * Revision 1.124.1.107 2016/03/11 11:25:26 martin
+ * Made XMR_STATS::step_det_val a reserved, unused field.
+ * Cleanup.
+ * Revision 1.124.1.106 2016/03/11 10:09:44 andre
+ * Revision 1.124.1.105 2016/03/02 15:03:42Z daniel
+ * Updates for new PTP Utility profile and PTP statistics
+ * Revision 1.124.1.104 2016/02/29 15:51:31 andre
+ * added estimated holdover var to XMR_HOLDOVER_STATUS
+ * Revision 1.124.1.103 2016/02/25 08:47:32Z paul
+ * Added definitions for GTS180.
+ * Revision 1.124.1.102 2016/02/24 09:23:55Z gregoire
+ * change PTP_ANN_RCPT_TIMEOUT_MAX from 255 to 8
+ * Revision 1.124.1.101 2016/02/19 12:11:21Z udo
+ * added MBG_LNE_INFO_EXT
+ * Revision 1.124.1.100 2016/02/18 14:56:37 daniel
+ * Added TLV FEAT_TYPE LICENSE UPGRADE
+ * Revision 1.124.1.99 2016/02/18 11:27:27 udo
+ * added MBG_LNE_LED_STATUS
+ * Revision 1.124.1.98 2016/02/16 08:38:50 gregoire
+ * added new initializer to MBG_XFEATURE_NAMES
+ * Revision 1.124.1.97 2016/02/11 12:02:39Z daniel
+ * Added two TLV_FEAT_TYPES
+ * Revision 1.124.1.96 2016/02/10 15:52:36 thomas-b
+ * Added enum MBG_IMS_FDM_FLAGS and appropriate masks enum
+ * Revision 1.124.1.95 2016/02/03 13:27:44 martin
+ * Added definitions for LNE180SFP.
+ * Revision 1.124.1.94 2016/02/03 09:41:32 martin
+ * Fixed build without _PRELIMINARY_CODE.
+ * Revision 1.124.1.93 2016/02/02 15:53:46Z martin
+ * Added definitions for CSM100.
+ * Revision 1.124.1.92 2016/01/29 09:06:32 udo
+ * Added time-protocol type to Time Monitor Target settings.
+ * Revision 1.124.1.91 2016/01/22 11:34:39 gregoire
+ * Added string initializers for XMR_STATS_FLAGS_BITS.
+ * Revision 1.124.1.90 2016/01/22 08:16:07Z gregoire
+ * Renamed DEFAULT_MULTI_REF_NAMES_SHORT strings.
+ * Revision 1.124.1.89 2016/01/21 08:59:03Z andre
+ * Added auto_bis field in XMR_STATS.
+ * Revision 1.124.1.88 2016/01/19 14:11:47Z udo
+ * Modified time monitor structures.
+ * Revision 1.124.1.87 2016/01/18 08:37:03 udo
+ * Added support for PTP Time Monitoring on TSU/HPS100.
+ * Revision 1.124.1.86 2016/01/15 11:30:14 martin
+ * New field 'timestamp' in XMR_STATS.
+ * Revision 1.124.1.85 2016/01/15 08:52:51 martin
+ * Some flag masks for XMR_STATS.
+ * Revision 1.124.1.84 2016/01/13 15:26:00 martin
+ * Removed obsolete code added in the previous version.
+ * Revision 1.124.1.83 2016/01/13 15:09:17 martin
+ * Support XMR_STATS.
+ * Revision 1.124.1.82 2015/12/14 13:03:09 lars
+ * Fixes / changes in IRIG TX / RX masks.
+ * Revision 1.124.1.81 2015/12/14 11:09:01Z lars
+ * *** preliminary ***
+ * Revision 1.124.1.80 2015/12/09 17:34:56Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.79 2015/12/09 10:21:18 martin
+ * *** empty log message ***
+ * Revision 1.124.1.78 2015/12/09 08:28:36 martin
+ * New legacy model codes.
+ * Changed/Added some IRIG enums.
+ * Revision 1.124.1.77 2015/12/07 14:43:04 martin
+ * Doxygen fixes.
+ * Revision 1.124.1.76 2015/12/04 14:20:18 paul
+ * Fixed a typo in comment of video string initialzier.
+ * Added support for configurable epochs for video outputs.
+ * Revision 1.124.1.75 2015/12/02 16:51:19Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.74 2015/12/02 16:35:32 martin
+ * *** empty log message ***
+ * Revision 1.124.1.73 2015/12/01 11:34:33 martin
+ * *** empty log message ***
+ * Revision 1.124.1.72 2015/11/30 16:51:12 martin
+ * *** empty log message ***
+ * Revision 1.124.1.71 2015/11/30 16:22:30 martin
+ * *** empty log message ***
+ * Revision 1.124.1.70 2015/11/30 09:02:47 philipp
+ * Added TLV feature MBG_TLV_CTX_FLAG_FW_ROLLBACK.
+ * Revision 1.124.1.69 2015/11/30 08:16:57 philipp
+ * Added MBG_TLV_INFO feature macros.
+ * Revision 1.124.1.68 2015/11/26 17:01:08 martin
+ * *** empty log message ***
+ * Revision 1.124.1.67 2015/11/26 08:32:54 martin
+ * *** empty log message ***
+ * Revision 1.124.1.66 2015/11/25 16:55:08 martin
+ * Started to implement extended features.
+ * Revision 1.124.1.65 2015/11/24 13:10:54 philipp
+ * TLV additions / partly redesign and feature inline functions.
+ * Revision 1.124.1.64 2015/11/23 10:23:47 philipp
+ * Added Doxygen documentation for TLV structures, flags and masks.
+ * Revision 1.124.1.63 2015/11/23 10:11:28 martin
+ * *** empty log message ***
+ * Revision 1.124.1.62 2015/11/23 08:27:32 gregoire
+ * Added initializers for MBG_IMS_FDM_LINE_FREQS.
+ * Revision 1.124.1.61 2015/11/20 09:16:39Z philipp
+ * Fixed macro _mbg_swab_tlv_announce.
+ * Revision 1.124.1.60 2015/11/20 08:14:29 philipp
+ * Added id member to struct MBG_TLV_ANNOUNCE.
+ * Revision 1.124.1.59 2015/11/20 07:26:29 philipp
+ * Moved TLV structures here.
+ * Revision 1.124.1.58 2015/11/18 13:51:50 philipp
+ * Added leapfile to NTP miscellaneous structures.
+ * Revision 1.124.1.57 2015/11/18 13:39:22 philipp
+ * Added NTP miscellaneous structures.
+ * Revision 1.124.1.56 2015/11/06 12:42:08 philipp
+ * Added NTP statistics structures.
+ * Revision 1.124.1.55 2015/11/06 11:25:22 philipp
+ * Removed member symlink in NTP_REFCLK_CFG_SPEC since it is implementation defined.
+ * Revision 1.124.1.54 2015/11/06 11:16:35 philipp
+ * Added NTP symmetric key structures.
+ * Revision 1.124.1.53 2015/11/06 09:17:40 philipp
+ * Added byte swap macros to NTP restriction and NTP refclock configuration structures.
+ * Revision 1.124.1.52 2015/11/05 12:20:12 martin
+ * New define MBG_MAX_HOSTNAME_LEN.
+ * Preliminary fix for TZDL initializers.
+ * Updated some comments.
+ * Revision 1.124.1.51 2015/11/05 09:07:56 philipp
+ * Added structures for NTP restriction and refclock configuration (preliminary code).
+ * Revision 1.124.1.50 2015/10/28 12:09:26 martin
+ * GPIO types for SCG not preliminary anymore.
+ * Added definitions for LUE180.
+ * Revision 1.124.1.49 2015/10/26 11:55:19 daniel
+ * Merged aligned PTP SMPTE and TELECOM PHASE profile structures from previous branch here.
+ * Revision 1.124.1.48 2015/10/26 11:24:04 daniel
+ * Support for PTP Preset 802.1AS
+ * Revision 1.124.1.47 2015/10/26 10:56:42 paul
+ * added a new flag for GPIO studio clock out
+ * Revision 1.124.1.46 2015/10/26 09:47:53Z paul
+ * added a missing GPIO studio clock scale string initializer
+ * Revision 1.124.1.45 2015/10/23 11:00:27Z paul
+ * Revision 1.124.1.44 2015/10/22 14:35:51Z paul
+ * fixed a typo
+ * Revision 1.124.1.43 2015/10/22 14:17:34Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.42 2015/10/22 14:15:02 paul
+ * some changes in GPIO structs
+ * Revision 1.124.1.41 2015/10/21 14:36:32Z paul
+ * renamed stud_clk_out in studio_clk_out and vid_sync_out in video_sync_out
+ * Revision 1.124.1.40 2015/10/20 13:38:57Z paul
+ * renamed HD format in GPIO video type
+ * Revision 1.124.1.39 2015/10/20 12:11:36Z paul
+ * Revision 1.124.1.38 2015/10/20 10:58:01Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.37 2015/10/20 10:43:39 paul
+ * Revision 1.124.1.36 2015/10/20 10:15:57Z paul
+ * added preliminary studio clock structs and defines
+ * Revision 1.124.1.35 2015/10/19 10:48:00Z gregoire
+ * Revision 1.124.1.34 2015/10/19 10:08:47Z gregoire
+ * Revision 1.124.1.33 2015/10/16 11:03:06Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.32 2015/10/15 14:17:22 martin
+ * *** empty log message ***
+ * Revision 1.124.1.31 2015/10/15 08:40:37 paul
+ * added two new HD video formats
+ * Revision 1.124.1.30 2015/10/15 07:38:14Z gregoire
+ * AES67 Media Profile added
+ * Revision 1.124.1.29 2015/10/13 08:44:08Z gregoire
+ * smpte_jam_event added to PTP_DEV_CFG_GLB
+ * Revision 1.124.1.28 2015/10/12 10:01:59Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.27 2015/10/09 11:09:13 martin
+ * *** empty log message ***
+ * Revision 1.124.1.26 2015/10/09 09:03:50 gregoire
+ * Revision 1.124.1.25 2015/10/09 07:18:49Z gregoire
+ * Builtin feature BUILTIN_FEAT_GNSS set for GRC models.
+ * Revision 1.124.1.24 2015/10/08 13:27:37Z martin
+ * *** empty log message ***
+ * Revision 1.124.1.23 2015/10/06 10:33:39 paul
+ * Changed GPIO names.
+ * Added two defines for GPIO_TYPE_VIDEO_SYNC.
+ * Revision 1.124.1.22 2015/10/06 07:55:11Z paul
+ * Changed names of GPIO types and structs.
+ * Revision 1.124.1.21 2015/10/02 13:07:11Z martin
+ * Doxygen fixes.
+ * Revision 1.124.1.20 2015/10/02 10:33:00 martin
+ * *** empty log message ***
+ * Revision 1.124.1.19 2015/10/01 10:51:32 martin
+ * *** empty log message ***
+ * Revision 1.124.1.18 2015/09/30 08:03:45 paul
+ * Bug fix in some GPIO structs.
+ * Added comments.
+ * Revision 1.124.1.17 2015/09/29 09:55:22Z paul
+ * added video output and sync output as two new GPIO types
+ * Revision 1.124.1.16 2015/09/28 09:34:56Z thomas-b
+ * Renamed td_max_limit in MBG_IMS_FDM_LIMITS to td_pos_limit
+ * Revision 1.124.1.15 2015/09/18 13:58:44 martin
+ * *** empty log message ***
+ * Revision 1.124.1.14 2015/09/17 14:56:57 thomas-b
+ * Renamed several variables in MBG_FDM_SETTINGS and MBG_FDM_LIMITS
+ * Revision 1.124.1.13 2015/09/15 13:15:01 martin
+ * Moved definitions for NANO_TIME and NANO_TIME_64 to words.h.
+ * Revision 1.124.1.12 2015/09/15 11:08:22 martin
+ * Support new model TCR180.
+ * Added missing comma in DEFAULT_GPS_MODEL_NAMES.
+ * Revision 1.124.1.11 2015/09/07 09:19:21 martin
+ * Revision 1.124.1.10 2015/09/04 09:19:17 daniel
+ * Moved 2 additional TSU strcutures to PREMINARY_CODE block
+ * Revision 1.124.1.9 2015/09/03 09:17:41 martin
+ * Doxygen fixes.
+ * Revision 1.124.1.8 2015/09/02 16:42:17 martin
+ * Preliminary code which is only included if a preprocessor symbol
+ * _PRELIMINARY_CODE is defined in the project Makefile.
+ * Revision 1.124.1.7 2015/08/25 10:30:13 daniel
+ * Revision 1.124.1.6 2015/08/25 10:02:37 daniel
+ * Revision 1.124.1.5 2015/08/25 09:16:39 daniel
+ * Changed reserved member in PTP_STATE to include tsu_secs
+ * Revision 1.124.1.4 2015/08/10 07:37:09 daniel
+ * Added sync_e byte swab macros
+ * Revision 1.124.1.3 2015/08/07 10:51:10 daniel
+ * Fixed typo in CTC100 declaration
+ * Revision 1.124.1.2 2015/08/07 10:49:40 daniel
+ * RE-added temp. PTP structures PTP_DEV_CFG_GLB and PTP_DEV_CFG_NET
+ * Added new model CTC100
+ * Revision 1.124.1.1 2015/07/29 07:40:55 daniel
+ * Revision 1.124 2015/07/14 14:22:46 martin
+ * Doxygen fix.
+ * Revision 1.123 2015/07/06 13:00:10 martin
+ * Added definitions for VSG180, MSF180, WWVB180, and CPC180.
+ * Added definitions for PZF180.
+ * Definitions for SDI and MDU300 added by stephan.
+ * Definitions for HPS100 added by daniel.
+ * FDM180 and associated definitions added by paul.
+ * Started to support eXtended Binary Protocol (XBP).
+ * Merged daniel and gregoire's changes from the 1.120.2.x branch.
+ * Defines for IPv6 multicast scopes added by gregoire.
+ * XMR_EXT_SRC_INFO and associated XMR_SETTINGS_FLAG_MSKS flags
+ * defined by andre.
+ * Support XMULTI_REF_INFO::n_prio field again.
+ * Fixed _mbg_swab_gpio_cfg_limits() macro.
+ * Added MBG_NET_LINK_OPT_MASK_CAN_SYNCE to MBG_NET_LINK_OPT_MASKS.
+ * New PTP_ROLE_MASKS PTP_ROLE_NTP_SERVER and PTP_ROLE_NTP_CLIENT.
+ * Some PTP profile extensions added by daniel.
+ * Added missing defines for SPT.
+ * Added definitions for REL1000.
+ * Moved structure NANO_TIME_64 here.
+ * Revision 1.122 2014/07/29 08:57:44Z martin
* Updated doxygen comments.
* Revision 1.121 2014/07/17 09:41:50 martin
* Introduced XMR_HOLDOVER_STATUS, MBG_GPIO_STATUS,
@@ -487,6 +857,7 @@
#endif
+
/* Start of header body */
#if defined( _USE_PACK )
@@ -549,8 +920,8 @@ enum GNSS_SVNOS
typedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite)
-typedef uint16_t HEALTH; ///< an SV's health code
-typedef uint16_t CFG; ///< an SV's configuration code
+typedef uint16_t HEALTH; ///< an SV's 6 bit health code
+typedef uint16_t CFG; ///< an SV's 4 bit configuration code
typedef uint16_t IOD; ///< Issue-Of-Data code
@@ -580,11 +951,13 @@ typedef uint16_t GPS_CMD;
*
* Contains a software revision code, plus an optional
* identifier for a customized version.
+ *
+ * @see @ref group_ext_rev_info
*/
typedef struct
{
uint16_t code; ///< Version number, e.g. 0x0120 means v1.20
- char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized version
+ char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized firmware version, should be empty in standard versions
uint8_t reserved; ///< Reserved field to yield even structure size
} SW_REV;
@@ -737,7 +1110,7 @@ typedef struct
uint8_t n_com_ports; ///< number of on-board serial ports
uint8_t n_str_type; ///< max num of string types supported by any port
uint8_t n_prg_out; ///< number of programmable pulse outputs
- uint16_t flags; ///< additional information, see ::RECEIVER_INFO_FLAG_BITS
+ uint16_t flags; ///< additional information, see ::RECEIVER_INFO_FLAG_MASKS
} RECEIVER_INFO;
@@ -816,6 +1189,31 @@ enum GPS_MODEL_CODES
GPS_MODEL_LNE_GB,
GPS_MODEL_PPG180,
GPS_MODEL_SCG,
+ GPS_MODEL_MDU300,
+ GPS_MODEL_SDI,
+ GPS_MODEL_FDM180,
+ GPS_MODEL_SPT,
+ GPS_MODEL_PZF180,
+ GPS_MODEL_REL1000,
+ GPS_MODEL_HPS100,
+ GPS_MODEL_VSG180,
+ GPS_MODEL_MSF180,
+ GPS_MODEL_WWVB180,
+ GPS_MODEL_CPC180,
+ GPS_MODEL_CTC100,
+ GPS_MODEL_TCR180,
+ GPS_MODEL_LUE180,
+ GPS_MODEL_CPC_01,
+ GPS_MODEL_TSU_01,
+ GPS_MODEL_CMC_01,
+ GPS_MODEL_SCU_01,
+ GPS_MODEL_FCU_01,
+ GPS_MODEL_CSM100,
+ GPS_MODEL_LNE180SFP,
+ GPS_MODEL_GTS180,
+ GPS_MODEL_GPS180CSM,
+ GPS_MODEL_GRC181,
+ GPS_MODEL_N2X180,
N_GPS_MODEL
/* If new model codes are added then care must be taken
* to update the associated string initializers GPS_MODEL_NAMES
@@ -893,6 +1291,31 @@ enum GPS_MODEL_CODES
#define GPS_MODEL_NAME_LNE_GB "LNE_GB"
#define GPS_MODEL_NAME_PPG180 "PPG180"
#define GPS_MODEL_NAME_SCG "SCG"
+#define GPS_MODEL_NAME_MDU300 "MDU300"
+#define GPS_MODEL_NAME_SDI "SDI"
+#define GPS_MODEL_NAME_FDM180 "FDM180"
+#define GPS_MODEL_NAME_SPT "SPT"
+#define GPS_MODEL_NAME_PZF180 "PZF180"
+#define GPS_MODEL_NAME_REL1000 "REL1000"
+#define GPS_MODEL_NAME_HPS100 "HPS100"
+#define GPS_MODEL_NAME_VSG180 "VSG180"
+#define GPS_MODEL_NAME_MSF180 "MSF180"
+#define GPS_MODEL_NAME_WWVB180 "WWVB180"
+#define GPS_MODEL_NAME_CPC180 "CPC180"
+#define GPS_MODEL_NAME_CTC100 "CTC100"
+#define GPS_MODEL_NAME_TCR180 "TCR180"
+#define GPS_MODEL_NAME_LUE180 "LUE180"
+#define GPS_MODEL_NAME_CPC_01 "CPC_01"
+#define GPS_MODEL_NAME_TSU_01 "TSU_01"
+#define GPS_MODEL_NAME_CMC_01 "CMC_01"
+#define GPS_MODEL_NAME_SCU_01 "SCU_01"
+#define GPS_MODEL_NAME_FCU_01 "FCU_01"
+#define GPS_MODEL_NAME_CSM100 "CSM100"
+#define GPS_MODEL_NAME_LNE180SFP "LNE180SFP"
+#define GPS_MODEL_NAME_GTS180 "GTS180"
+#define GPS_MODEL_NAME_GPS180CSM "GPS180CSM"
+#define GPS_MODEL_NAME_GRC181 "GRC181"
+#define GPS_MODEL_NAME_N2X180 "N2X180"
/** @} anchor GPS_MODEL_NAMES */
@@ -967,7 +1390,32 @@ enum GPS_MODEL_CODES
GPS_MODEL_NAME_RSC180, \
GPS_MODEL_NAME_LNE_GB, \
GPS_MODEL_NAME_PPG180, \
- GPS_MODEL_NAME_SCG \
+ GPS_MODEL_NAME_SCG, \
+ GPS_MODEL_NAME_MDU300, \
+ GPS_MODEL_NAME_SDI, \
+ GPS_MODEL_NAME_FDM180, \
+ GPS_MODEL_NAME_SPT, \
+ GPS_MODEL_NAME_PZF180, \
+ GPS_MODEL_NAME_REL1000, \
+ GPS_MODEL_NAME_HPS100, \
+ GPS_MODEL_NAME_VSG180, \
+ GPS_MODEL_NAME_MSF180, \
+ GPS_MODEL_NAME_WWVB180, \
+ GPS_MODEL_NAME_CPC180, \
+ GPS_MODEL_NAME_CTC100, \
+ GPS_MODEL_NAME_TCR180, \
+ GPS_MODEL_NAME_LUE180, \
+ GPS_MODEL_NAME_CPC_01, \
+ GPS_MODEL_NAME_TSU_01, \
+ GPS_MODEL_NAME_CMC_01, \
+ GPS_MODEL_NAME_SCU_01, \
+ GPS_MODEL_NAME_FCU_01, \
+ GPS_MODEL_NAME_CSM100, \
+ GPS_MODEL_NAME_LNE180SFP, \
+ GPS_MODEL_NAME_GTS180, \
+ GPS_MODEL_NAME_GPS180CSM, \
+ GPS_MODEL_NAME_GRC181, \
+ GPS_MODEL_NAME_N2X180 \
}
@@ -997,22 +1445,27 @@ enum GPS_BUILTIN_FEATURE_BITS
GPS_BIT_MODEL_IS_DCF_PZF,
GPS_BIT_MODEL_IS_MSF,
GPS_BIT_MODEL_IS_JJY,
- GPS_BIT_MODEL_IS_WWV,
+ GPS_BIT_MODEL_IS_WWVB,
+/**
+ TODO This has to be discussed
GPS_BIT_MODEL_IS_LNO,
GPS_BIT_MODEL_IS_SCU,
+*/
GPS_BIT_MODEL_HAS_BVAR_STAT,
GPS_BIT_MODEL_HAS_POS_XYZ,
GPS_BIT_MODEL_HAS_POS_LLA,
+ GPS_BIT_MODEL_HAS_TIME_TTM,
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_LENGTH,
+ GPS_BIT_MODEL_HAS_ANT_CABLE_LEN,
GPS_BIT_MODEL_HAS_GPS_IGNORE_LOCK,
+//### TODO
GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV,
- GPS_BIT_MODEL_HAS_GNSS_MODE,
N_GPS_BIT_MODEL
};
@@ -1034,23 +1487,28 @@ enum GPS_BUILTIN_FEATURE_BITS
#define GPS_MODEL_IS_DCF_PZF ( 1UL << GPS_BIT_MODEL_IS_DCF_PZF ) ///< see ::GPS_BIT_MODEL_IS_DCF_PZF
#define GPS_MODEL_IS_MSF ( 1UL << GPS_BIT_MODEL_IS_MSF ) ///< see ::GPS_BIT_MODEL_IS_MSF
#define GPS_MODEL_IS_JJY ( 1UL << GPS_BIT_MODEL_IS_JJY ) ///< see ::GPS_BIT_MODEL_IS_JJY
-#define GPS_MODEL_IS_WWV ( 1UL << GPS_BIT_MODEL_IS_WWV ) ///< see ::GPS_BIT_MODEL_IS_WWV
+#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_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
+#define GPS_MODEL_HAS_TIME_TTM ( 1UL << GPS_BIT_MODEL_HAS_TIME_TTM ) ///< see ::GPS_BIT_MODEL_HAS_TIME_TTM
#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_LENGTH ( 1UL << GPS_BIT_MODEL_HAS_ANT_CABLE_LENGTH ) ///< see ::GPS_BIT_MODEL_HAS_ANT_CABLE_LENGTH
+#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
-#define GPS_MODEL_HAS_XMR_HOLDOVER_INTV ( 1UL << GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV ) ///< see ::GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV
-#define GPS_MODEL_HAS_GNSS_MODE ( 1UL << GPS_BIT_MODEL_HAS_GNSS_MODE ) ///< see ::GPS_BIT_MODEL_HAS_GNSS_MODE
+// ### 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?
#define GPS_MODEL_HAS_POS ( GPS_MODEL_HAS_POS_XYZ | GPS_MODEL_HAS_POS_LLA )
@@ -1070,7 +1528,6 @@ enum GPS_BUILTIN_FEATURE_BITS
#define GPS_MODEL_HAS_AUTO_OFF // --
#define GPS_MODEL_HAS_SW_REV // deprecated, use only if ri not supported
#define GPS_MODEL_HAS_BVAR_STAT // req
-#define GPS_MODEL_HAS_TIME // ?
#define GPS_MODEL_HAS_POS_XYZ // GPS_MODEL_IS_GPS, GPS_MODEL_HAS_POS, GPS_MODEL_HAS_POS_XYZ ?
#define GPS_MODEL_HAS_POS_LLA // GPS_MODEL_IS_GPS, GPS_MODEL_HAS_POS, GPS_MODEL_HAS_POS_LLA ?
#define GPS_MODEL_HAS_TZDL // req
@@ -1082,7 +1539,7 @@ enum GPS_BUILTIN_FEATURE_BITS
#define GPS_MODEL_HAS_STAT_INFO // req
#define GPS_MODEL_HAS_SWITCH_PARMS // deprecated, use ...
#define GPS_MODEL_HAS_STRING_PARMS // deprecated, use ...
-#define GPS_MODEL_HAS_ANT_CABLE_LENGTH // GPS_MODEL_IS_GPS, also GNSS, or req?
+#define GPS_MODEL_HAS_ANT_CABLE_LEN // GPS_MODEL_IS_GPS, also GNSS, or req?
#define GPS_MODEL_HAS_SYNC_OUTAGE_DELAY // custom
#define GPS_MODEL_HAS_PULSE_INFO // custom
#define GPS_MODEL_HAS_OPT_FEATURES // deprecated, use ri
@@ -1103,74 +1560,74 @@ enum GPS_BUILTIN_FEATURE_BITS
#define GPS_MODEL_HAS_IRIG_RX_SETTINGS // ri ...
#define GPS_MODEL_HAS_IRIG_RX_INFO // ri ...
#define GPS_MODEL_HAS_REF_OFFS // ri ...
-#define GPS_MODEL_HAS_DEBUG_STATUS //
-#define GPS_MODEL_HAS_XMR_SETTINGS_IDX //
-#define GPS_MODEL_HAS_XMR_INFO_IDX //
-#define GPS_MODEL_HAS_XMR_STATUS_IDX //
-#define GPS_MODEL_HAS_OPT_SETTINGS //
-#define GPS_MODEL_HAS_OPT_INFO //
-#define GPS_MODEL_HAS_CLR_UCAP_BUFF //
-#define GPS_MODEL_HAS_TIME_SCALE //
-#define GPS_MODEL_HAS_NAV_ENG_SETTINGS //
-#define GPS_MODEL_HAS_RAW_IRIG_DATA //
-#define GPS_MODEL_HAS_GPIO_CFG_LIMITS //
-#define GPS_MODEL_HAS_GPIO_INFO_IDX //
-#define GPS_MODEL_HAS_GPIO_SETTINGS_IDX //
-#define GPS_MODEL_HAS_XMR_INSTANCES //
-#define GPS_MODEL_HAS_CLR_EVT_LOG //
-#define GPS_MODEL_HAS_NUM_EVT_LOG_ENTRIES //
-#define GPS_MODEL_HAS_FIRST_EVT_LOG_ENTRY //
-#define GPS_MODEL_HAS_NEXT_EVT_LOG_ENTRY //
-#define GPS_MODEL_HAS_LNO_STATUS //
-#define GPS_MODEL_HAS_IMS_STATE //
-#define GPS_MODEL_HAS_IMS_SENSOR_STATE_IDX //
-#define GPS_MODEL_HAS_XMR_HOLDOVER_INTV //
-#define GPS_MODEL_HAS_HAVEQUICK_RX_SETTINGS //
-#define GPS_MODEL_HAS_HAVEQUICK_RX_INFO //
-#define GPS_MODEL_HAS_HAVEQUICK_TX_SETTINGS //
-#define GPS_MODEL_HAS_HAVEQUICK_TX_INFO //
-#define GPS_MODEL_HAS_PTP_CFG //
-#define GPS_MODEL_HAS_PTP_STATE //
-#define GPS_MODEL_HAS_PTP_UC_MASTER_CFG_LIMITS //
-#define GPS_MODEL_HAS_PTP_UC_MASTER_CFG //
-#define GPS_MODEL_HAS_NTP_GLB_CFG //
-#define GPS_MODEL_HAS_NTP_CLNT_MODE_CFG //
-#define GPS_MODEL_HAS_NTP_SRV_MODE_CFG //
-#define GPS_MODEL_HAS_NTP_PEER_SETTINGS_IDX //
-#define GPS_MODEL_HAS_NTP_SYS_STATE //
-#define GPS_MODEL_HAS_NTP_PEER_STATE_IDX //
-#define GPS_MODEL_HAS_SHS //
-#define GPS_MODEL_HAS_SHS_STATUS //
-#define GPS_MODEL_HAS_NET_GLB_CFG //
-#define GPS_MODEL_HAS_NET_DNS_SRVR //
-#define GPS_MODEL_HAS_NET_DNS_SRC_DOM //
-#define GPS_MODEL_HAS_NET_STAT_DNS_SRVR //
-#define GPS_MODEL_HAS_NET_STAT_DNS_SRC_DOM //
-#define GPS_MODEL_HAS_GNSS_SAT_INFO_IDX //
-
-#define GPS_MODEL_HAS_CFGH //
-#define GPS_MODEL_HAS_ALM //
-#define GPS_MODEL_HAS_EPH //
-#define GPS_MODEL_HAS_UTC //
-#define GPS_MODEL_HAS_IONO //
-#define GPS_MODEL_HAS_ASCII_MSG //
-
-#define GPS_MODEL_HAS_GLNS_ALM //
-#define GPS_MODEL_HAS_GNSS_SAT_INFO //
-#define GPS_MODEL_HAS_GNSS_MODE //
-
-#define GPS_MODEL_HAS_IP4_SETTINGS //
-#define GPS_MODEL_HAS_LAN_IF_INFO //
-#define GPS_MODEL_HAS_IP4_STATE //
-
-#define GPS_MODEL_HAS_SCU_STAT //
-
-#define GPS_MODEL_HAS_CRYPTED_PACKET //
-#define GPS_MODEL_HAS_CRYPTED_RAW_PACKET //
-
-#define GPS_MODEL_HAS_SECU_INFO //
-#define GPS_MODEL_HAS_SECU_SETTINGS //
-#define GPS_MODEL_HAS_SECU_PUBLIC_KEY //
+#define GPS_MODEL_HAS_DEBUG_STATUS //
+#define GPS_MODEL_HAS_XMR_SETTINGS_IDX //
+#define GPS_MODEL_HAS_XMR_INFO_IDX //
+#define GPS_MODEL_HAS_XMR_STATUS_IDX //
+#define GPS_MODEL_HAS_OPT_SETTINGS //
+#define GPS_MODEL_HAS_OPT_INFO //
+#define GPS_MODEL_HAS_CLR_UCAP_BUFF //
+#define GPS_MODEL_HAS_TIME_SCALE //
+#define GPS_MODEL_HAS_NAV_ENG_SETTINGS //
+#define GPS_MODEL_HAS_RAW_IRIG_DATA //
+#define GPS_MODEL_HAS_GPIO_CFG_LIMITS //
+#define GPS_MODEL_HAS_GPIO_INFO_IDX //
+#define GPS_MODEL_HAS_GPIO_SETTINGS_IDX //
+#define GPS_MODEL_HAS_XMR_INSTANCES //
+#define GPS_MODEL_HAS_CLR_EVT_LOG //
+#define GPS_MODEL_HAS_NUM_EVT_LOG_ENTRIES //
+#define GPS_MODEL_HAS_FIRST_EVT_LOG_ENTRY //
+#define GPS_MODEL_HAS_NEXT_EVT_LOG_ENTRY //
+#define GPS_MODEL_HAS_LNO_STATUS //
+#define GPS_MODEL_HAS_IMS_STATE //
+#define GPS_MODEL_HAS_IMS_SENSOR_STATE_IDX //
+#define GPS_MODEL_HAS_XMR_HOLDOVER_INTV //
+#define GPS_MODEL_HAS_HAVEQUICK_RX_SETTINGS //
+#define GPS_MODEL_HAS_HAVEQUICK_RX_INFO //
+#define GPS_MODEL_HAS_HAVEQUICK_TX_SETTINGS //
+#define GPS_MODEL_HAS_HAVEQUICK_TX_INFO //
+#define GPS_MODEL_HAS_PTP_CFG //
+#define GPS_MODEL_HAS_PTP_STATE //
+#define GPS_MODEL_HAS_PTP_UC_MASTER_CFG_LIMITS //
+#define GPS_MODEL_HAS_PTP_UC_MASTER_CFG //
+#define GPS_MODEL_HAS_NTP_GLB_CFG //
+#define GPS_MODEL_HAS_NTP_CLNT_MODE_CFG //
+#define GPS_MODEL_HAS_NTP_SRV_MODE_CFG //
+#define GPS_MODEL_HAS_NTP_PEER_SETTINGS_IDX //
+#define GPS_MODEL_HAS_NTP_SYS_STATE //
+#define GPS_MODEL_HAS_NTP_PEER_STATE_IDX //
+#define GPS_MODEL_HAS_SHS //
+#define GPS_MODEL_HAS_SHS_STATUS //
+#define GPS_MODEL_HAS_NET_GLB_CFG //
+#define GPS_MODEL_HAS_NET_DNS_SRVR //
+#define GPS_MODEL_HAS_NET_DNS_SRCH_DOM //
+#define GPS_MODEL_HAS_NET_STAT_DNS_SRVR //
+#define GPS_MODEL_HAS_NET_STAT_DNS_SRCH_DOM //
+#define GPS_MODEL_HAS_GNSS_SAT_INFO_IDX //
+
+#define GPS_MODEL_HAS_CFGH //
+#define GPS_MODEL_HAS_ALM //
+#define GPS_MODEL_HAS_EPH //
+#define GPS_MODEL_HAS_UTC //
+#define GPS_MODEL_HAS_IONO //
+#define GPS_MODEL_HAS_ASCII_MSG //
+
+#define GPS_MODEL_HAS_GLNS_ALM //
+#define GPS_MODEL_HAS_GNSS_SAT_INFO //
+//#define GPS_MODEL_HAS_GNSS_MODE //
+
+#define GPS_MODEL_HAS_IP4_SETTINGS //
+#define GPS_MODEL_HAS_LAN_IF_INFO //
+#define GPS_MODEL_HAS_IP4_STATE //
+
+#define GPS_MODEL_HAS_SCU_STAT //
+
+#define GPS_MODEL_HAS_CRYPTED_PACKET //
+#define GPS_MODEL_HAS_CRYPTED_RAW_PACKET //
+
+#define GPS_MODEL_HAS_SECU_INFO //
+#define GPS_MODEL_HAS_SECU_SETTINGS //
+#define GPS_MODEL_HAS_SECU_PUBLIC_KEY //
#endif //##++ more potential builtin features and classifiers
@@ -1185,11 +1642,12 @@ enum GPS_BUILTIN_FEATURE_BITS
GPS_MODEL_HAS_BVAR_STAT | \
GPS_MODEL_HAS_POS_XYZ | \
GPS_MODEL_HAS_POS_LLA | \
+ GPS_MODEL_HAS_TIME_TTM | \
GPS_MODEL_HAS_TZDL | \
GPS_MODEL_HAS_ANT_INFO | \
GPS_MODEL_HAS_ENABLE_FLAGS | \
GPS_MODEL_HAS_STAT_INFO | \
- GPS_MODEL_HAS_ANT_CABLE_LENGTH \
+ GPS_MODEL_HAS_ANT_CABLE_LEN \
)
@@ -1202,12 +1660,10 @@ enum GPS_BUILTIN_FEATURE_BITS
#define BUILTIN_FEAT_GNSS \
( \
BUILTIN_FEAT_GPS | \
- GPS_MODEL_IS_GNSS | \
- GPS_MODEL_HAS_GNSS_MODE \
+ GPS_MODEL_IS_GNSS \
)
-
/**
* @brief Definitions of builtin features per device type
*
@@ -1225,52 +1681,77 @@ enum GPS_BUILTIN_FEATURE_BITS
#define BUILTIN_FEAT_GPS168PCI ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_GPS161 ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_GPS169PCI ( BUILTIN_FEAT_GPS )
-#define BUILTIN_FEAT_TCR167PCI ( 0 )
+#define BUILTIN_FEAT_TCR167PCI ( GPS_MODEL_HAS_TIME_TTM )
#define BUILTIN_FEAT_GPS164 ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_GPS170PCI ( BUILTIN_FEAT_GPS )
-#define BUILTIN_FEAT_PZF511 ( 0 )
+#define BUILTIN_FEAT_PZF511 ( GPS_MODEL_HAS_TZCODE )
#define BUILTIN_FEAT_GPS170 ( BUILTIN_FEAT_GPS )
-#define BUILTIN_FEAT_TCR511 ( 0 )
-#define BUILTIN_FEAT_AM511 ( 0 )
-#define BUILTIN_FEAT_MSF511 ( 0 )
-#define BUILTIN_FEAT_GRC170 ( 0 )
+#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_GRC170 ( BUILTIN_FEAT_GNSS )
#define BUILTIN_FEAT_GPS170PEX ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_GPS162 ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_PTP270PEX ( 0 )
#define BUILTIN_FEAT_FRC511PEX ( 0 )
#define BUILTIN_FEAT_GEN170 ( 0 )
-#define BUILTIN_FEAT_TCR170PEX ( 0 )
-#define BUILTIN_FEAT_WWVB511 ( 0 )
+#define BUILTIN_FEAT_TCR170PEX ( GPS_MODEL_HAS_TIME_TTM )
+#define BUILTIN_FEAT_WWVB511 ( GPS_MODEL_HAS_TZCODE )
#define BUILTIN_FEAT_MGR170 ( 0 )
-#define BUILTIN_FEAT_JJY511 ( 0 )
-#define BUILTIN_FEAT_PZF600 ( 0 )
-#define BUILTIN_FEAT_TCR600 ( 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_GPS180 ( BUILTIN_FEAT_GPS )
-#define BUILTIN_FEAT_GLN170 ( 0 )
+#define BUILTIN_FEAT_GLN170 ( BUILTIN_FEAT_GNSS)
#define BUILTIN_FEAT_GPS180PEX ( BUILTIN_FEAT_GPS )
-#define BUILTIN_FEAT_TCR180PEX ( 0 )
-#define BUILTIN_FEAT_PZF180PEX ( 0 )
+#define BUILTIN_FEAT_TCR180PEX ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL )
+#define BUILTIN_FEAT_PZF180PEX ( GPS_MODEL_HAS_TZDL )
#define BUILTIN_FEAT_MGR180 ( 0 )
-#define BUILTIN_FEAT_MSF600 ( 0 )
-#define BUILTIN_FEAT_WWVB600 ( 0 )
-#define BUILTIN_FEAT_JJY600 ( 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_GPS180HS ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_GPS180AMC ( BUILTIN_FEAT_GPS )
#define BUILTIN_FEAT_ESI180 ( 0 )
#define BUILTIN_FEAT_CPE180 ( 0 )
#define BUILTIN_FEAT_LNO180 ( 0 )
-#define BUILTIN_FEAT_GRC180 ( 0 )
+#define BUILTIN_FEAT_GRC180 ( BUILTIN_FEAT_GNSS )
#define BUILTIN_FEAT_LIU ( 0 )
-#define BUILTIN_FEAT_DCF600HS ( 0 )
-#define BUILTIN_FEAT_DCF600RS ( 0 )
+#define BUILTIN_FEAT_DCF600HS ( GPS_MODEL_HAS_TZDL )
+#define BUILTIN_FEAT_DCF600RS ( GPS_MODEL_HAS_TZDL )
#define BUILTIN_FEAT_MRI ( 0 )
#define BUILTIN_FEAT_BPE ( 0 )
#define BUILTIN_FEAT_GLN180PEX ( BUILTIN_FEAT_GNSS )
-#define BUILTIN_FEAT_N2X ( 0 )
+#define BUILTIN_FEAT_N2X ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL | GPS_MODEL_HAS_ENABLE_FLAGS )
#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_SPT ( 0 )
+#define BUILTIN_FEAT_PZF180 ( GPS_MODEL_HAS_TZDL )
+#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_CPC180 ( 0 )
+#define BUILTIN_FEAT_CTC100 ( 0 )
+#define BUILTIN_FEAT_TCR180 ( GPS_MODEL_HAS_TIME_TTM | GPS_MODEL_HAS_TZDL )
+#define BUILTIN_FEAT_LUE180 ( 0 )
+#define BUILTIN_FEAT_CPC_01 ( 0 )
+#define BUILTIN_FEAT_TSU_01 ( 0 )
+#define BUILTIN_FEAT_CMC_01 ( 0 )
+#define BUILTIN_FEAT_SCU_01 ( 0 )
+#define BUILTIN_FEAT_FCU_01 ( 0 )
+#define BUILTIN_FEAT_CSM100 ( 0 )
+#define BUILTIN_FEAT_LNE180SFP ( 0 )
+#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 )
/** @} anchor GPS_MODEL_BUILTIN_FEATURE_MASKS */
@@ -1341,6 +1822,31 @@ enum GPS_BUILTIN_FEATURE_BITS
{ GPS_MODEL_LNE_GB, BUILTIN_FEAT_LNE_GB }, \
{ GPS_MODEL_PPG180, BUILTIN_FEAT_PPG180 }, \
{ GPS_MODEL_SCG, BUILTIN_FEAT_SCG }, \
+ { GPS_MODEL_MDU300, BUILTIN_FEAT_MDU300 }, \
+ { GPS_MODEL_SDI, BUILTIN_FEAT_SDI }, \
+ { GPS_MODEL_FDM180, BUILTIN_FEAT_FDM180 }, \
+ { GPS_MODEL_SPT, BUILTIN_FEAT_SPT }, \
+ { GPS_MODEL_PZF180, BUILTIN_FEAT_PZF180 }, \
+ { GPS_MODEL_REL1000, BUILTIN_FEAT_REL1000 }, \
+ { GPS_MODEL_HPS100, BUILTIN_FEAT_HPS100 }, \
+ { GPS_MODEL_VSG180, BUILTIN_FEAT_VSG180 }, \
+ { GPS_MODEL_MSF180, BUILTIN_FEAT_MSF180 }, \
+ { GPS_MODEL_WWVB180, BUILTIN_FEAT_WWVB180 }, \
+ { GPS_MODEL_CPC180, BUILTIN_FEAT_CPC180 }, \
+ { GPS_MODEL_CTC100, BUILTIN_FEAT_CTC100 }, \
+ { GPS_MODEL_TCR180, BUILTIN_FEAT_TCR180 }, \
+ { GPS_MODEL_LUE180, BUILTIN_FEAT_LUE180 }, \
+ { GPS_MODEL_CPC_01, BUILTIN_FEAT_CPC_01 }, \
+ { GPS_MODEL_TSU_01, BUILTIN_FEAT_TSU_01 }, \
+ { GPS_MODEL_CMC_01, BUILTIN_FEAT_CMC_01 }, \
+ { GPS_MODEL_SCU_01, BUILTIN_FEAT_SCU_01 }, \
+ { GPS_MODEL_FCU_01, BUILTIN_FEAT_FCU_01 }, \
+ { GPS_MODEL_CSM100, BUILTIN_FEAT_CSM100 }, \
+ { GPS_MODEL_LNE180SFP, BUILTIN_FEAT_LNE180SFP }, \
+ { GPS_MODEL_GTS180, BUILTIN_FEAT_GTS180 }, \
+ { GPS_MODEL_GPS180CSM, BUILTIN_FEAT_GPS180CSM }, \
+ { GPS_MODEL_GRC181, BUILTIN_FEAT_GRC181 }, \
+ { GPS_MODEL_N2X180, BUILTIN_FEAT_N2X180 }, \
{ 0, 0 } \
}
@@ -1505,9 +2011,20 @@ enum GPS_OSC_TYPES
/**
- * @brief Enumeration of device features flags reported in ::RECEIVER_INFO::features
+ * @brief Enumeration of device features flags reported in ::RI_FEATURES
*
- * Each flags indicates if a device supports the associated feature.
+ * Used with ::RECEIVER_INFO::features. Each flags indicates if a device
+ * supports the associated feature, but due to the limited bit size of
+ * the ::RI_FEATURES type the number of these features is limited to 32.
+ *
+ * To extend the number of possible features the ::MBG_XFEATURE_BITS, the
+ * ::MBG_XFEATURE_BUFFER structure and associated definitions have been
+ * introduced, which are supported by devices which have ::GPS_HAS_XFEATURE
+ * set in ::RI_FEATURES.
+ *
+ * @see ::RI_FEATURES
+ * @see ::MBG_XFEATURE_BITS
+ * @see ::MBG_XFEATURE_BUFFER
*/
enum GPS_FEATURE_BITS
{
@@ -1544,12 +2061,12 @@ enum GPS_FEATURE_BITS
GPS_FEAT_NET_CFG, ///< supports extended network interface configuration, supersedes ::GPS_FEAT_LAN_IP4
GPS_FEAT_VST, ///< supports VST (Versatile Storage) API and structures
GPS_FEAT_SHS, ///< supports SHS (Secure Hybrid System) API and structures
+ GPS_FEAT_XBP, ///< supports XBP (eXtended Binary Protocol) API and structures, see @ref group_xbp
+ GPS_FEAT_XFEATURE, ///< support eXtended features, see @ref group_xfeature
+ N_GPS_FEATURE ///< the number of known ::GPS_FEATURE_BITS, should now be at its limit, i.e. 32.
- N_GPS_FEATURE ///< the number of valid features
- /*
- * If new features are added then care must be taken to update the associated
- * definitions below accordingly, e.g. string initializers and bit masks.
- */
+ // WARNING: There are no more unassigned feature bits available here.
+ // New features have to be defined using the ::MBG_XFEATURE_BITS
};
@@ -1589,7 +2106,9 @@ enum GPS_FEATURE_BITS
"NTP", \
"Ext. Network Config", \
"Versatile Storage", \
- "SHS" \
+ "SHS", \
+ "Extended Binary Protocol", \
+ "Extended Features" \
}
@@ -1633,7 +2152,8 @@ enum GPS_FEATURE_BITS
#define GPS_HAS_NET_CFG ( 1UL << GPS_FEAT_NET_CFG ) ///< see ::GPS_FEAT_NET_CFG
#define GPS_HAS_VST ( 1UL << GPS_FEAT_VST ) ///< see ::GPS_FEAT_VST
#define GPS_HAS_SHS ( 1UL << GPS_FEAT_SHS ) ///< see ::GPS_FEAT_SHS
-
+#define GPS_HAS_XBP ( 1UL << GPS_FEAT_XBP ) ///< see ::GPS_FEAT_XBP
+#define GPS_HAS_XFEATURE ( 1UL << GPS_FEAT_XFEATURE ) ///< see ::GPS_FEAT_XFEATURE
// the next ones are special since they just shadow another flag:
#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX ///< always supported with IRIG inputs, see ::GPS_HAS_IRIG_RX
@@ -1642,6 +2162,122 @@ enum GPS_FEATURE_BITS
/** @} anchor GPS_FEATURE_MASKS */
+/**
+ * @defgroup group_xfeature Extended feature definitions
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::GPS_HAS_XFEATURE is set in ::RECEIVER_INFO::features.
+ *
+ * @{ */
+
+
+/**
+ * @brief The maximum number of feature bits supported by the MBG_XFEATURE API.
+ *
+ * Warning: Changing this number breaks API compatibility!
+ *
+ * @see ::MBG_XFEATURE_BITS
+ */
+#define MAX_XFEATURE_BITS 1024
+
+
+
+/**
+ * @brief Enumeration of defined extended features.
+ *
+ * @see ::MBG_XFEATURE_NAMES
+ * @see ::MBG_XFEATURE_BUFFER
+ */
+enum MBG_XFEATURE_BITS
+{
+ MBG_XFEATURE_TLV_API, ///< Supports generic TLV API, see @ref group_tlv_api
+ MBG_XFEATURE_SAVE_CFG, ///< Supports the ::GPS_SAVE_CFG command
+ MBG_XFEATURE_LED_API, ///< Supports programmable LED API, see @ref group_led_api
+ 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_REBOOT, ///< Supports the ::GPS_REBOOT command
+ MBG_XFEATURE_CLK_RES_INFO, ///< Supports the GPS_CLK_RES_INFO command, see @ref group_clk_res_info
+ 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
+ // be taken that ::N_MBG_XFEATURE doesn't exceed ::MAX_XFEATURE_BITS.
+};
+
+
+
+/**
+ * @brief Names of extended device features
+ *
+ * Can be used to initialize a string array of ::N_MBG_XFEATURE entries,
+ * so the number of strings must correspond to ::N_MBG_XFEATURE.
+ *
+ * @see ::MBG_XFEATURE_BITS
+ */
+#define MBG_XFEATURE_NAMES \
+{ \
+ "Generic TLV API", \
+ "Save Config On Card", \
+ "Programmable LED API", \
+ "LNE API", \
+ "Power Control API", \
+ "Extended Revision Info", \
+ "Transaction commands", \
+ "Reboot command", \
+ "Clock Resolution Info" \
+}
+
+
+
+/**
+ * @brief Array size required to store all extended features
+ *
+ * The number of bytes required to store up to ::MAX_XFEATURE_BITS
+ * feature bits in a byte array.
+ */
+#define MAX_XFEATURE_BYTES ( MAX_XFEATURE_BITS / 8 )
+
+
+
+/**
+ * @brief A structure used to store extended device features.
+ *
+ * Up to ::MAX_XFEATURE_BITS totally can be stored, but only
+ * ::N_MBG_XFEATURE extended features are currently defined.
+ * The ::_set_xfeature_bit macro should be used by the firmware
+ * to set a feature bit in the buffer, and the ::check_xfeature
+ * function should be used to implement API calls which test if an
+ * extended feature is supported.
+ *
+ * @see ::_set_xfeature_bit
+ * @see ::check_xfeature
+ */
+typedef struct
+{
+ uint8_t b[MAX_XFEATURE_BYTES];
+
+} MBG_XFEATURE_BUFFER;
+
+
+
+/**
+ * @brief Set an extended feature bit in a ::MBG_XFEATURE_BUFFER
+ *
+ * Should be used by the firmware only to set one of the ::MBG_XFEATURE_BITS
+ * in an ::MBG_XFEATURE_BUFFER after power-up.
+ *
+ * @param[in] _xf_bit One of the ::MBG_XFEATURE_BITS
+ * @param[in] _xf_buffp Pointer to an ::MBG_XFEATURE_BUFFER
+ */
+#define _set_xfeature_bit( _xf_bit, _xf_buffp ) \
+ _set_array_bit( _xf_bit, (_xf_buffp)->b, MAX_XFEATURE_BYTES )
+
+
+/** @} defgroup group_xfeature */
+
+
+
/*
* The features below are supported by default by older
* C166 based GPS receivers:
@@ -1742,13 +2378,13 @@ typedef struct
* the receiver's internal time.
*
* %UTC time differs from GPS time since a number of leap seconds have
- * been inserted in the %UTC time scale after the GPS epoche. The number
+ * been inserted in the %UTC time scale after the GPS epoch. The number
* of leap seconds is disseminated by the satellites using the ::UTC
* parameter set, which also provides info on pending leap seconds.
*/
typedef struct
{
- uint16_t wn; ///< the week number since GPS has been installed
+ uint16_t wn; ///< the week number since the GPS system has been put into operation
uint32_t sec; ///< the second of that week
uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
@@ -1786,7 +2422,7 @@ typedef struct
int8_t min; ///< minutes, 0..59
int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second
int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
- int32_t offs_from_utc; ///< local time's offset from %UTC
+ int32_t offs_from_utc; ///< local time offset from %UTC [sec]
uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS
} TM_GPS;
@@ -1823,9 +2459,9 @@ enum TM_GPS_STATUS_BITS
TM_BIT_EXT_SYNC, ///< synchronized externally
TM_BIT_HOLDOVER, ///< in holdover mode after previous synchronization
TM_BIT_ANT_SHORT, ///< antenna cable short circuited
- TM_BIT_NO_WARM, ///< OCXO has not warmed up
+ TM_BIT_NO_WARM, ///< oscillator control loop not settled
TM_BIT_ANT_DISCONN, ///< antenna currently disconnected
- TM_BIT_SYN_FLAG, ///< TIME_SYN output is low
+ TM_BIT_SYN_FLAG, ///< clock not synchronized, reflects the state of the "time sync error" output pin
TM_BIT_NO_SYNC, ///< time sync actually not verified
TM_BIT_NO_POS ///< position actually not verified, LOCK LED off
};
@@ -1911,28 +2547,6 @@ typedef struct
-/**
- * @brief A timestamp with nanosecond resolution
- */
-typedef struct
-{
- int32_t nano_secs; ///< [nanoseconds]
- int32_t secs; ///< [seconds]
-
-} NANO_TIME;
-
-#define _mbg_swab_nano_time( _p ) \
-{ \
- _mbg_swab32( &(_p)->nano_secs ); \
- _mbg_swab32( &(_p)->secs ); \
-}
-
-// The macro below checks if a ::NANO_TIME value is negative.
-#define _nano_time_negative( _nt ) \
- ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
-
-
-
#ifndef _XYZ_DEFINED
/**
* @brief Sequence and number of components of a cartesian position
@@ -2131,9 +2745,15 @@ typedef char TZ_NAME[6];
/**
* @brief Time zone / daylight saving parameters
*
- * This structure is used to specify how a device is to convert
- * on-board %UTC to local time, including computation of beginning
- * and end of daylight saving time (DST), if required.
+ * This structure is used to specify how a device converts on-board %UTC
+ * to local time, including computation of beginning and end of daylight
+ * saving time (DST), if required.
+ *
+ * @note The ::TZDL structure contains members of type ::TM_GPS to specify
+ * the times for beginning and end of DST. However, the ::TM_GPS::frac,
+ * ::TM_GPS::offs_from_utc, and ::TM_GPS::status fields of these ::TZDL::tm_on
+ * and ::TZDL::tm_off members are ignored for the conversion to local time,
+ * and thus should be 0.
*/
typedef struct
{
@@ -2166,7 +2786,7 @@ typedef struct
// Below there are some initializers for commonly used TZDL configurations:
-#define DEFAULT_TZDL_AUTO_YEAR ( 2007 | DL_AUTO_FLAG )
+#define DEFAULT_TZDL_AUTO_YEAR ( (int16_t) ( 2007L | DL_AUTO_FLAG ) )
#define DEFAULt_TZDL_OFFS_DL 3600L ///< usually DST is +1 hour
@@ -3039,6 +3659,52 @@ enum STR_MODE_MASKS
+/**
+ * @brief The number of string types supported by legacy DCF77 receivers
+ *
+ * For receivers supporting a ::RECEIVER_INFO this should be determined
+ * from ::RECEIVER_INFO::n_str_type.
+ *
+ * @see ::DEFAULT_SUPP_STR_TYPES_DCF
+ */
+#define DEFAULT_N_STR_TYPE_DCF 1
+
+/**
+ * @brief Bit mask of string types supported by legacy DCF77 receivers
+ *
+ * For receivers supporting a ::RECEIVER_INFO this should be determined
+ * from ::PORT_INFO::supp_str_types.
+ *
+ * @see ::DEFAULT_N_STR_TYPE_DCF
+ */
+#define DEFAULT_SUPP_STR_TYPES_DCF \
+ ( ( 1UL << DEFAULT_N_STR_TYPE_DCF ) - 1 )
+
+
+
+/**
+ * @brief The number of string types supported by legacy GPS receivers
+ *
+ * For receivers supporting a ::RECEIVER_INFO this should be determined
+ * from ::RECEIVER_INFO::n_str_type.
+ *
+ * @see ::DEFAULT_SUPP_STR_TYPES_GPS
+ */
+#define DEFAULT_N_STR_TYPE_GPS 2
+
+/**
+ * @brief Bit mask of string types supported by legacy GPS receivers
+ *
+ * For receivers supporting a ::RECEIVER_INFO this should be determined
+ * from ::PORT_INFO::supp_str_types.
+ *
+ * @see ::DEFAULT_N_STR_TYPE_GPS
+ */
+#define DEFAULT_SUPP_STR_TYPES_GPS \
+ ( ( 1UL << DEFAULT_N_STR_TYPE_GPS ) - 1 )
+
+
+
/*
* The number of serial ports which are at least available
* even with very old GPS receiver models. For devices providing
@@ -3117,6 +3783,50 @@ enum
* well defined extensions like the year number, local time offset, DST status,
* etc., in the control fields:
*
+ * The following specification can be found in IRIG Standard 200-04 (September 2004):
+ *
+ * Format A: 1k pps
+ * Format B: 100 pps
+ * Format D: 1 ppm
+ * Format E: 10 pps
+ * Format G: 10k pps
+ * Format H: 1 pps
+ *
+ * 1st digit: Modulation Frequency
+ * 0 Pulse width code
+ * 1 Sine wave, amplitude modulated
+ * 2 Manchester modulated
+ *
+ * 2nd digit: Frequency / Resolution
+ * 0: No carrier / index count interval
+ * 1: 100 Hz / 10 ms
+ * 2: 1 kHz / 1 ms
+ * 3: 10 kHz / 0.1 ms
+ * 4: 100 kHz / 10 ms
+ * 5: 1 MHz / 1 ms
+ *
+ * 3rd digit: Coded expressions
+ * 0: DOY+TOD, CF, SBS
+ * 1: DOY+TOD, CF
+ * 2: DOY+TOD
+ * 3: DOY+TOD, SBS
+ * 4: DOY+TOD, Year, CF, SBS
+ * 5: DOY+TOD, Year, CF
+ * 6: DOY+TOD, Year
+ * 7: DOY+TOD, Year, SBS
+ *
+ *
+ * Table of Permissible Code Formats
+ *
+ * Letter 1st digit 2nd digit 3rd digit
+ * ----------------------------------------------
+ * A 0,1,2 0,3,4,5 0,1,2,3,4,5,6,7
+ * B 0,1,2 0,2,3,4,5 0,1,2,3,4,5,6,7
+ * D 0,1 0,1,2 1,2
+ * E 0,1 0,1,2 1,2,5,6
+ * G 0,1,2 0,4,5 1,2,5,6
+ * H 0,1 0,1,2 1,2
+ *
* - Known IRIG signal code types:
* - \b A002: 1000 bps, DCLS, time-of-year
* - \b A003: 1000 bps, DCLS, time-of-year, SBS
@@ -3205,38 +3915,42 @@ enum ICODE_TX_CODES
ICODE_TX_TXC101,
ICODE_TX_E002_E112,
ICODE_TX_NASA36,
+ ICODE_TX_A006_A136,
+ ICODE_TX_A007_A137,
N_ICODE_TX ///< number of known codes
};
/**
- * @brief Initializers for timecode format name strings
+ * @brief Initializers for TX timecode format name strings
*
* @see ::ICODE_TX_CODES
*/
-#define DEFAULT_ICODE_TX_NAMES \
-{ \
- "B002+B122", \
- "B003+B123", \
- "A002+A132", \
- "A003+A133", \
- "AFNOR NF S87-500", \
- "IEEE1344", \
- "B220(1344) DCLS", \
- "B222 DCLS", \
- "B223 DCLS", \
- "B006+B126", \
- "B007+B127", \
- "G002+G142", \
- "G006+G146", \
- "C37.118", \
- "TXC-101 DTR-6", \
- "E002+E112", \
- "NASA 36" \
-}
-
-/**
- * @brief Initializers for short timecode format name strings
+#define DEFAULT_ICODE_TX_NAMES \
+{ \
+ /* B002_B122 */ "B002+B122", \
+ /* B003_B123 */ "B003+B123", \
+ /* A002_A132 */ "A002+A132", \
+ /* A003_A133 */ "A003+A133", \
+ /* AFNOR */ "AFNOR NF S87-500", \
+ /* IEEE1344 */ "IEEE 1344", \
+ /* B2201344 */ "B220(1344) DCLS", \
+ /* B222 */ "B222 DCLS", \
+ /* B223 */ "B223 DCLS", \
+ /* B006_B126 */ "B006+B126", \
+ /* B007_B127 */ "B007+B127", \
+ /* G002_G142 */ "G002+G142", \
+ /* G006_G146 */ "G006+G146", \
+ /* C37118 */ "IEEE C37.118", \
+ /* TXC101 */ "TXC-101 DTR-6", \
+ /* E002_E112 */ "E002+E112", \
+ /* NASA36 */ "NASA 36", \
+ /* A006_A136 */ "A006+A136", \
+ /* A007_A137 */ "A007+A137" \
+}
+
+/**
+ * @brief Initializers for short TX timecode format name strings
*
* @note Must not be longer than 10 printable characters
*
@@ -3244,55 +3958,59 @@ enum ICODE_TX_CODES
*/
#define DEFAULT_ICODE_TX_NAMES_SHORT \
{ \
- "B002+B122", \
- "B003+B123", \
- "A002+A132", \
- "A003+A133", \
- "AFNOR NF S", \
- "IEEE1344", \
- "B220/1344", \
- "B222 DC", \
- "B223 DC", \
- "B006+B126", \
- "B007+B127", \
- "G002+G142", \
- "G006+G146", \
- "C37.118", \
- "TXC-101", \
- "E002+E112", \
- "NASA 36" \
+ /* B002_B122 */ "B002+B122", \
+ /* B003_B123 */ "B003+B123", \
+ /* A002_A132 */ "A002+A132", \
+ /* A003_A133 */ "A003+A133", \
+ /* AFNOR */ "AFNOR NF S", \
+ /* IEEE1344 */ "IEEE 1344", \
+ /* B2201344 */ "B220/1344", \
+ /* B222 */ "B222 DC", \
+ /* B223 */ "B223 DC", \
+ /* B006_B126 */ "B006+B126", \
+ /* B007_B127 */ "B007+B127", \
+ /* G002_G142 */ "G002+G142", \
+ /* G006_G146 */ "G006+G146", \
+ /* C37118 */ "C37.118", \
+ /* TXC101 */ "TXC-101", \
+ /* E002_E112 */ "E002+E112", \
+ /* NASA36 */ "NASA 36", \
+ /* A006_A136 */ "A006+A136", \
+ /* A007_A137 */ "A007+A137" \
}
/**
- * @brief Initializers for English format description strings
+ * @brief Initializers for English TX format description strings
*
* @see ::ICODE_TX_CODES
*/
-#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG \
-{ \
- "100 bps, DCLS or 1 kHz carrier", \
- "100 bps, DCLS or 1 kHz carrier, SBS", \
- "1000 bps, DCLS or 10 kHz carrier", \
- "1000 bps, DCLS or 10 kHz carrier, SBS", \
- "100 bps, DCLS or 1 kHz carrier, SBS, complete date", \
- "100 bps, DCLS or 1 kHz carrier, SBS, complete date, time zone info", \
- "100 bps, Manchester enc., DCLS only, SBS, complete date, time zone info", \
- "100 bps, Manchester enc., DCLS only", \
- "100 bps, Manchester enc., DCLS only, SBS", \
- "100 bps, DCLS or 1 kHz carrier, complete date", \
- "100 bps, DCLS or 1 kHz carrier, complete date, SBS", \
- "10 kbps, DCLS or 100 kHz carrier", \
- "10 kbps, DCLS or 100 kHz carrier, complete date", \
- "like IEEE1344, but UTC offset with reversed sign", \
- "code from TV time sync device TXC-101 DTR-6", \
- "10 bps, DCLS or 100 Hz carrier", \
- "100 bps, DCLS or 1 kHz carrier" \
+#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG \
+{ \
+ /* B002_B122 */ "100 bps, DCLS or 1 kHz carrier", \
+ /* B003_B123 */ "100 bps, DCLS or 1 kHz carrier, SBS", \
+ /* A002_A132 */ "1000 bps, DCLS or 10 kHz carrier", \
+ /* A003_A133 */ "1000 bps, DCLS or 10 kHz carrier, SBS", \
+ /* AFNOR */ "100 bps, DCLS or 1 kHz carrier, complete date, SBS", \
+ /* IEEE1344 */ "100 bps, DCLS or 1 kHz carrier, 2 digit year number, SBS, UTC offset, DST and Leap sec status", \
+ /* B2201344 */ "100 bps, Manchester enc., DCLS only, 2 digit year number, SBS, UTC offset, DST and Leap sec status", \
+ /* B222 */ "100 bps, Manchester enc., DCLS only", \
+ /* B223 */ "100 bps, Manchester enc., DCLS only, SBS", \
+ /* B006_B126 */ "100 bps, DCLS or 1 kHz carrier, 2 digit year number", \
+ /* B007_B127 */ "100 bps, DCLS or 1 kHz carrier, 2 digit year number, SBS", \
+ /* G002_G142 */ "10 kbps, DCLS or 100 kHz carrier", \
+ /* G006_G146 */ "10 kbps, DCLS or 100 kHz carrier, 2 digit year number", \
+ /* 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" \
+ /* 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" \
}
/**
- * @brief Bit masks used with ::IRIG_INFO::supp_codes
+ * @brief Bit masks used with ::IRIG_INFO::supp_codes for TX
*
* These bit masks are used with timecode receivers only
*
@@ -3319,12 +4037,14 @@ enum ICODE_TX_CODES
#define MSK_ICODE_TX_TXC101 ( 1UL << ICODE_TX_TXC101 )
#define MSK_ICODE_TX_E002_E112 ( 1UL << ICODE_TX_E002_E112 )
#define MSK_ICODE_TX_NASA36 ( 1UL << ICODE_TX_NASA36 )
+#define MSK_ICODE_TX_A006_A136 ( 1UL << ICODE_TX_A006_A136 )
+#define MSK_ICODE_TX_A007_A137 ( 1UL << ICODE_TX_A007_A137 )
/** @} anchor ICODE_TX_MASKS */
/**
- * @brief A mask of IRIG formats with manchester encoded DC output
+ * @brief A mask of IRIG TX formats with manchester encoded DC output
*/
#define MSK_ICODE_TX_DC_MANCH \
( \
@@ -3334,7 +4054,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 100 Hz carrier
+ * @brief A mask of IRIG TX formats with 100 Hz carrier
*/
#define MSK_ICODE_TX_100HZ \
( \
@@ -3342,7 +4062,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 1 kHz carrier
+ * @brief A mask of IRIG TX formats with 1 kHz carrier
*/
#define MSK_ICODE_TX_1KHZ \
( \
@@ -3360,16 +4080,18 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 10 kHz carrier
+ * @brief A mask of IRIG TX formats with 10 kHz carrier
*/
#define MSK_ICODE_TX_10KHZ \
( \
MSK_ICODE_TX_A002_A132 | \
- MSK_ICODE_TX_A003_A133 \
+ MSK_ICODE_TX_A003_A133 | \
+ MSK_ICODE_TX_A006_A136 | \
+ MSK_ICODE_TX_A007_A137 \
)
/**
- * @brief A mask of IRIG formats with 100 kHz carrier
+ * @brief A mask of IRIG TX formats with 100 kHz carrier
*/
#define MSK_ICODE_TX_100KHZ \
( \
@@ -3378,7 +4100,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 10 bps data rate
+ * @brief A mask of IRIG TX formats with 10 bps data rate
*/
#define MSK_ICODE_TX_10BPS \
( \
@@ -3386,7 +4108,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 100 bps data rate
+ * @brief A mask of IRIG TX formats with 100 bps data rate
*/
#define MSK_ICODE_TX_100BPS \
( \
@@ -3400,16 +4122,18 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats with 1000 bps data rate
+ * @brief A mask of IRIG TX formats with 1000 bps data rate
*/
#define MSK_ICODE_TX_1000BPS \
( \
MSK_ICODE_TX_A002_A132 | \
- MSK_ICODE_TX_A003_A133 \
+ MSK_ICODE_TX_A003_A133 | \
+ MSK_ICODE_TX_A006_A136 | \
+ MSK_ICODE_TX_A007_A137 \
)
/**
- * @brief A mask of IRIG formats with 10 kbps data rate
+ * @brief A mask of IRIG TX formats with 10 kbps data rate
*/
#define MSK_ICODE_TX_10000BPS \
( \
@@ -3418,18 +4142,20 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting 10ths of seconds
+ * @brief A mask of IRIG TX formats supporting 10ths of seconds
*/
#define MSK_ICODE_TX_HAS_SEC10THS \
( \
MSK_ICODE_TX_A002_A132 | \
MSK_ICODE_TX_A003_A133 | \
MSK_ICODE_TX_G002_G142 | \
- MSK_ICODE_TX_G006_G146 \
+ MSK_ICODE_TX_G006_G146 | \
+ MSK_ICODE_TX_A006_A136 | \
+ MSK_ICODE_TX_A007_A137 \
)
/**
- * @brief A mask of IRIG formats supporting 100ths of seconds
+ * @brief A mask of IRIG TX formats supporting 100ths of seconds
*/
#define MSK_ICODE_TX_HAS_SEC100THS \
( \
@@ -3438,19 +4164,33 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting a 2 digit year number
+ * @brief A mask of IRIG TX formats supporting a 2 digit year number
*/
#define MSK_ICODE_TX_HAS_SHORT_YEAR \
( \
MSK_ICODE_TX_AFNOR | \
MSK_ICODE_TX_IEEE1344 | \
+ MSK_ICODE_TX_B2201344 | \
MSK_ICODE_TX_B006_B126 | \
MSK_ICODE_TX_B007_B127 | \
- MSK_ICODE_TX_C37118 \
+ MSK_ICODE_TX_G006_G146 | \
+ MSK_ICODE_TX_C37118 | \
+ MSK_ICODE_TX_A006_A136 | \
+ MSK_ICODE_TX_A007_A137 \
+)
+
+/**
+ * @brief A mask of IRIG TX formats supporting a 2 digit year number
+ *
+ * This is after the P6 identifier.
+ */
+ #define MSK_ICODE_TX_HAS_SHORT_YEAR_AFTER_P6 \
+( \
+ MSK_ICODE_TX_G006_G146 \
)
/**
- * @brief A mask of IRIG formats supporting TFOM
+ * @brief A mask of IRIG TX formats supporting TFOM
*/
#define MSK_ICODE_TX_HAS_TFOM \
( \
@@ -3459,7 +4199,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting CTQ continuous time quality
+ * @brief A mask of IRIG TX formats supporting CTQ continuous time quality
*
* This has been introduced in IEEE C37.118.1-2011
*/
@@ -3470,7 +4210,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting time zone information
+ * @brief A mask of IRIG TX formats supporting time zone information
*/
#define MSK_ICODE_TX_HAS_TZI \
( \
@@ -3479,7 +4219,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief IRIG formats where UTC offset must be subtracted to yield UTC
+ * @brief IRIG TX formats where UTC offset must be subtracted to yield UTC
*
* A mask of IRIG formats where the decoded UTC offset must be
* subtracted from the time decoded from the IRIG signal to yield UTC, e.g.:<br>
@@ -3491,7 +4231,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief IRIG formats where UTC offset must be added to yield UTC
+ * @brief IRIG TX formats where UTC offset must be added to yield UTC
*
* A mask of IRIG formats where the decoded UTC offset must be
* added to the time decoded from the IRIG signal to yield UTC, e.g.:<br>
@@ -3503,7 +4243,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting a day of week number
+ * @brief A mask of IRIG TX formats supporting a day of week number
*/
#define MSK_ICODE_TX_HAS_AFNOR_WDAY \
( \
@@ -3512,7 +4252,7 @@ enum ICODE_TX_CODES
)
/**
- * @brief A mask of IRIG formats supporting a date (day-of-month, month)
+ * @brief A mask of IRIG TX formats supporting a date (day-of-month, month)
*/
#define MSK_ICODE_TX_HAS_AFNOR_DATE \
( \
@@ -3522,7 +4262,7 @@ enum ICODE_TX_CODES
/**
- * @brief The default mask of IRIG formats supported by IRIG transmitters
+ * @brief The default mask of IRIG TX formats supported by IRIG transmitters
*
* @note The formats which are actually supported should be retrieved
* from the device
@@ -3564,8 +4304,8 @@ enum ICODE_RX_CODES
ICODE_RX_IEEE1344_DC, ///< DCLS
ICODE_RX_B126_B127, ///< modulated
ICODE_RX_B006_B007, ///< DCLS
- ICODE_RX_G142_G146, ///< modulated
- ICODE_RX_G002_G006, ///< DCLS
+ ICODE_RX_G142, ///< modulated (G143 is undefined, SBS not supported with Gxxx)
+ ICODE_RX_G002, ///< DCLS (G003 is undefined, SBS not supported with Gxxx)
ICODE_RX_C37118, ///< modulated
ICODE_RX_C37118_DC, ///< DCLS
ICODE_RX_TXC101, ///< modulated
@@ -3574,101 +4314,117 @@ enum ICODE_RX_CODES
ICODE_RX_E002, ///< DCLS
ICODE_RX_NASA36, ///< modulated
ICODE_RX_NASA36_DC, ///< DCLS
+ ICODE_RX_A136_A137, ///< modulated
+ ICODE_RX_A006_A007, ///< DCLS
+ ICODE_RX_G146, ///< modulated (G147 is undefined, SBS not supported with Gxxx)
+ ICODE_RX_G006, ///< DCLS (G007 is undefined, SBS not supported with Gxxx)
N_ICODE_RX ///< the number of known codes
};
/**
- * @brief Initializers for timecode format name strings
+ * @brief Initializers for RX timecode format name strings
*
* @see ::ICODE_RX_CODES
*/
#define DEFAULT_ICODE_RX_NAMES \
{ \
- "B122/B123", \
- "A132/A133", \
- "B002/B003 (DCLS)", \
- "A002/A003 (DCLS)", \
- "AFNOR NF S87-500", \
- "AFNOR NF S87-500 (DCLS)", \
- "IEEE1344", \
- "IEEE1344 (DCLS)", \
- "B126/B127", \
- "B006/B007 (DCLS)", \
- "G142/G146", \
- "G002/G006 (DCLS)", \
- "C37.118", \
- "C37.118 (DCLS)", \
- "TXC-101 DTR-6", \
- "TXC-101 DTR-6 (DCLS)", \
- "E112", \
- "E002 (DCLS)", \
- "NASA-36", \
- "NASA-36 (DCLS)" \
-}
-
-/**
- * @brief Initializers for short timecode format name strings
+ /* B122_B123 */ "B122/B123", \
+ /* A132_A133 */ "A132/A133", \
+ /* B002_B003 */ "B002/B003 (DCLS)", \
+ /* A002_A003 */ "A002/A003 (DCLS)", \
+ /* AFNOR */ "AFNOR NF S87-500", \
+ /* AFNOR_DC */ "AFNOR NF S87-500 (DCLS)", \
+ /* IEEE1344 */ "IEEE1344", \
+ /* IEEE1344_DC */ "IEEE1344 (DCLS)", \
+ /* B126_B127 */ "B126/B127", \
+ /* B006_B007 */ "B006/B007 (DCLS)", \
+ /* G142 */ "G142", \
+ /* G002 */ "G002 (DCLS)", \
+ /* C37118 */ "C37.118", \
+ /* C37118_DC */ "C37.118 (DCLS)", \
+ /* TXC101 */ "TXC-101 DTR-6", \
+ /* TXC101_DC */ "TXC-101 DTR-6 (DCLS)", \
+ /* E112 */ "E112", \
+ /* E002 */ "E002 (DCLS)", \
+ /* NASA36 */ "NASA-36", \
+ /* NASA36_DC */ "NASA-36 (DCLS)", \
+ /* A136_A137 */ "A136/A137", \
+ /* A006_A007 */ "A006/A007 (DCLS)", \
+ /* G146 */ "G146", \
+ /* G006 */ "G006 (DCLS)" \
+}
+
+/**
+ * @brief Initializers for short RX timecode format name strings
*
* @note Must not be longer than 11 printable characters
*
* @see ::ICODE_RX_CODES
*/
-#define DEFAULT_ICODE_RX_NAMES_SHORT \
-{ \
- "B122/B123", \
- "A132/A133", \
- "B002/B003", \
- "A002/A003", \
- "AFNOR NF S", \
- "AFNOR DC", \
- "IEEE1344", \
- "IEEE1344 DC", \
- "B126/B127", \
- "B006/B007", \
- "G142/G146", \
- "G002/G006", \
- "C37.118", \
- "C37.118 DC", \
- "TXC-101", \
- "TXC-101 DC", \
- "E112", \
- "E002 DC", \
- "NASA-36", \
- "NASA-36 DC" \
-}
-
-
-/**
- * @brief Initializers for English format description strings
+#define DEFAULT_ICODE_RX_NAMES_SHORT \
+{ \
+ /* B122_B123 */ "B122/B123", \
+ /* A132_A133 */ "A132/A133", \
+ /* B002_B003 */ "B002/B003", \
+ /* A002_A003 */ "A002/A003", \
+ /* AFNOR */ "AFNOR NF S", \
+ /* AFNOR_DC */ "AFNOR DC", \
+ /* IEEE1344 */ "IEEE1344", \
+ /* IEEE1344_DC */ "IEEE1344 DC", \
+ /* B126_B127 */ "B126/B127", \
+ /* B006_B007 */ "B006/B007", \
+ /* G142 */ "G142", \
+ /* G002 */ "G002 DC", \
+ /* C37118 */ "C37.118", \
+ /* C37118_DC */ "C37.118 DC", \
+ /* TXC101 */ "TXC-101", \
+ /* TXC101_DC */ "TXC-101 DC", \
+ /* E112 */ "E112", \
+ /* E002 */ "E002 DC", \
+ /* NASA36 */ "NASA-36", \
+ /* NASA36_DC */ "NASA-36 DC", \
+ /* A136_A137 */ "A136/A137", \
+ /* A006_A007 */ "A006/A007", \
+ /* G146 */ "G146", \
+ /* G006 */ "G006 DC" \
+}
+
+
+/**
+ * @brief Initializers for English RX format description strings
*
* @see ::ICODE_RX_CODES
*/
-#define DEFAULT_ICODE_RX_DESCRIPTIONS_ENG \
-{ \
- "100 bps, 1 kHz carrier, SBS optionally", \
- "1000 bps, 10 kHz carrier, SBS optionally", \
- "100 bps, DCLS, SBS optionally", \
- "1000 bps, DCLS, SBS optionally", \
- "100 bps, 1 kHz carrier, SBS, complete date", \
- "100 bps, DCLS, SBS, complete date", \
- "100 bps, 1 kHz carrier, SBS, time zone info", \
- "100 bps, DCLS, SBS, time zone info", \
- "100 bps, 1 kHz carrier, complete date, SBS optionally", \
- "100 bps, DCLS, complete date, SBS optionally", \
- "10 kbps, 100 kHz carrier, complete date optionally", \
- "10 kbps, DCLS, complete date optionally", \
- "like IEEE1344, but UTC offset with reversed sign", \
- "like IEEE1344 DC, but UTC offset with reversed sign", \
- "code from TV time sync device TXC-101 DTR-6", \
- "DC code from TV time sync device TXC-101 DTR-6", \
- "10 bps, 100 Hz carrier", \
- "10 bps, DCLS", \
- "100 bps, 1 kHz carrier", \
- "100 bps, DCLS" \
-}
-
-/**
- * @brief Bit masks used with ::IRIG_INFO::supp_codes
+#define DEFAULT_ICODE_RX_DESCRIPTIONS_ENG \
+{ \
+ /* B122_B123 */ "100 bps, 1 kHz carrier, SBS optionally", \
+ /* A132_A133 */ "1000 bps, 10 kHz carrier, SBS optionally", \
+ /* B002_B003 */ "100 bps, DCLS, SBS optionally", \
+ /* A002_A003 */ "1000 bps, DCLS, SBS optionally", \
+ /* AFNOR */ "100 bps, 1 kHz carrier, complete date, SBS", \
+ /* AFNOR_DC */ "100 bps, DCLS, complete date, SBS", \
+ /* IEEE1344 */ "100 bps, 1 kHz carrier, SBS, time zone info", \
+ /* IEEE1344_DC */ "100 bps, DCLS, SBS, time zone info", \
+ /* B126_B127 */ "100 bps, 1 kHz carrier, 2 digit year number, SBS optionally", \
+ /* B006_B007 */ "100 bps, DCLS, 2 digit year number, SBS optionally", \
+ /* G142 */ "10 kbps, 100 kHz carrier", \
+ /* G002 */ "10 kbps, DCLS", \
+ /* C37118 */ "like IEEE1344, but UTC offset with reversed sign", \
+ /* C37118_DC */ "like IEEE1344 DC, but UTC offset with reversed sign", \
+ /* TXC101 */ "code from TV time sync device TXC-101 DTR-6", \
+ /* TXC101_DC */ "DC code from TV time sync device TXC-101 DTR-6", \
+ /* E112 */ "10 bps, 100 Hz carrier", \
+ /* E002 */ "10 bps, DCLS", \
+ /* NASA36 */ "100 bps, 1 kHz carrier", \
+ /* NASA36_DC */ "100 bps, DCLS", \
+ /* A136_A137 */ "1000 bps, 10 kHz carrier, 2 digit year number, SBS optionally", \
+ /* A006_A007 */ "1000 bps, DCLS, 2 digit year number, SBS optionally", \
+ /* G146 */ "10 kbps, 100 kHz carrier, 2 digit year number", \
+ /* G006 */ "10 kbps, DCLS, 2 digit year number" \
+}
+
+/**
+ * @brief Bit masks used with ::IRIG_INFO::supp_codes for RX
*
* These bit masks are used with timecode receivers only
*
@@ -3688,8 +4444,8 @@ enum ICODE_RX_CODES
#define MSK_ICODE_RX_IEEE1344_DC ( 1UL << ICODE_RX_IEEE1344_DC )
#define MSK_ICODE_RX_B126_B127 ( 1UL << ICODE_RX_B126_B127 )
#define MSK_ICODE_RX_B006_B007 ( 1UL << ICODE_RX_B006_B007 )
-#define MSK_ICODE_RX_G142_G146 ( 1UL << ICODE_RX_G142_G146 )
-#define MSK_ICODE_RX_G002_G006 ( 1UL << ICODE_RX_G002_G006 )
+#define MSK_ICODE_RX_G142 ( 1UL << ICODE_RX_G142 )
+#define MSK_ICODE_RX_G002 ( 1UL << ICODE_RX_G002 )
#define MSK_ICODE_RX_C37118 ( 1UL << ICODE_RX_C37118 )
#define MSK_ICODE_RX_C37118_DC ( 1UL << ICODE_RX_C37118_DC )
#define MSK_ICODE_RX_TXC101 ( 1UL << ICODE_RX_TXC101 )
@@ -3698,12 +4454,16 @@ enum ICODE_RX_CODES
#define MSK_ICODE_RX_E002 ( 1UL << ICODE_RX_E002 )
#define MSK_ICODE_RX_NASA36 ( 1UL << ICODE_RX_NASA36 )
#define MSK_ICODE_RX_NASA36_DC ( 1UL << ICODE_RX_NASA36_DC )
+#define MSK_ICODE_RX_A136_A137 ( 1UL << ICODE_RX_A136_A137 )
+#define MSK_ICODE_RX_A006_A007 ( 1UL << ICODE_RX_A006_A007 )
+#define MSK_ICODE_RX_G146 ( 1UL << ICODE_RX_G146 )
+#define MSK_ICODE_RX_G006 ( 1UL << ICODE_RX_G006 )
/** @} anchor ICODE_RX_MASKS */
/**
- * @brief A mask of IRIG DCLS formats
+ * @brief A mask of IRIG RX DCLS formats
*/
#define MSK_ICODE_RX_DC \
( \
@@ -3712,24 +4472,25 @@ enum ICODE_RX_CODES
MSK_ICODE_RX_AFNOR_DC | \
MSK_ICODE_RX_IEEE1344_DC | \
MSK_ICODE_RX_B006_B007 | \
- MSK_ICODE_RX_G002_G006 | \
+ MSK_ICODE_RX_G002 | \
MSK_ICODE_RX_C37118_DC | \
MSK_ICODE_RX_TXC101_DC | \
MSK_ICODE_RX_E002 | \
- MSK_ICODE_RX_NASA36_DC \
+ MSK_ICODE_RX_NASA36_DC | \
+ MSK_ICODE_RX_A006_A007 | \
+ MSK_ICODE_RX_G006 \
)
/**
- * @brief A mask of IRIG formats with 100 Hz carrier
+ * @brief A mask of IRIG RX formats with 100 Hz carrier
*/
#define MSK_ICODE_RX_100HZ \
( \
- MSK_ICODE_RX_E112 | \
- MSK_ICODE_RX_E002 \
+ MSK_ICODE_RX_E112 \
)
/**
- * @brief A mask of IRIG formats with 1 kHz carrier
+ * @brief A mask of IRIG RX formats with 1 kHz carrier
*/
#define MSK_ICODE_RX_1KHZ \
( \
@@ -3743,23 +4504,25 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats with 10 kHz carrier
+ * @brief A mask of IRIG RX formats with 10 kHz carrier
*/
#define MSK_ICODE_RX_10KHZ \
( \
- MSK_ICODE_RX_A132_A133 \
+ MSK_ICODE_RX_A132_A133 | \
+ MSK_ICODE_RX_A136_A137 \
)
/**
- * @brief A mask of IRIG formats with 100 kHz carrier
+ * @brief A mask of IRIG RX formats with 100 kHz carrier
*/
#define MSK_ICODE_RX_100KHZ \
( \
- MSK_ICODE_RX_G142_G146 \
+ MSK_ICODE_RX_G142 | \
+ MSK_ICODE_RX_G146 \
)
/**
- * @brief A mask of IRIG formats with 10 bps data rate
+ * @brief A mask of IRIG RX formats with 10 bps data rate
*/
#define MSK_ICODE_RX_10BPS \
( \
@@ -3768,7 +4531,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats with 100 bps data rate
+ * @brief A mask of IRIG RX formats with 100 bps data rate
*/
#define MSK_ICODE_RX_100BPS \
( \
@@ -3789,45 +4552,55 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats with 1000 bps data rate
+ * @brief A mask of IRIG RX formats with 1000 bps data rate
*/
#define MSK_ICODE_RX_1000BPS \
( \
MSK_ICODE_RX_A132_A133 | \
- MSK_ICODE_RX_A002_A003 \
+ MSK_ICODE_RX_A002_A003 | \
+ MSK_ICODE_RX_A136_A137 | \
+ MSK_ICODE_RX_A006_A007 \
)
/**
- * @brief A mask of IRIG formats with 10 kbps data rate
+ * @brief A mask of IRIG RX formats with 10 kbps data rate
*/
#define MSK_ICODE_RX_10000BPS \
( \
- MSK_ICODE_RX_G142_G146 | \
- MSK_ICODE_RX_G002_G006 \
+ MSK_ICODE_RX_G142 | \
+ MSK_ICODE_RX_G002 | \
+ MSK_ICODE_RX_G146 | \
+ MSK_ICODE_RX_G006 \
)
/**
- * @brief A mask of IRIG formats supporting 10ths of seconds
+ * @brief A mask of IRIG RX formats supporting 10ths of seconds
*/
#define MSK_ICODE_RX_HAS_SEC10THS \
( \
MSK_ICODE_RX_A132_A133 | \
MSK_ICODE_RX_A002_A003 | \
- MSK_ICODE_RX_G142_G146 | \
- MSK_ICODE_RX_G002_G006 \
+ MSK_ICODE_RX_G142 | \
+ MSK_ICODE_RX_G002 | \
+ MSK_ICODE_RX_A136_A137 | \
+ MSK_ICODE_RX_A006_A007 | \
+ MSK_ICODE_RX_G146 | \
+ MSK_ICODE_RX_G006 \
)
/**
- * @brief A mask of IRIG formats which support 100ths of seconds
+ * @brief A mask of IRIG RX formats which support 100ths of seconds
*/
#define MSK_ICODE_RX_HAS_SEC100THS \
( \
- MSK_ICODE_RX_G142_G146 | \
- MSK_ICODE_RX_G002_G006 \
+ MSK_ICODE_RX_G142 | \
+ MSK_ICODE_RX_G002 | \
+ MSK_ICODE_RX_G146 | \
+ MSK_ICODE_RX_G006 \
)
/**
- * @brief A mask of IRIG formats supporting a 2 digit year number
+ * @brief A mask of IRIG RX formats supporting a 2 digit year number
*/
#define MSK_ICODE_RX_HAS_SHORT_YEAR \
( \
@@ -3838,11 +4611,24 @@ enum ICODE_RX_CODES
MSK_ICODE_RX_B126_B127 | \
MSK_ICODE_RX_B006_B007 | \
MSK_ICODE_RX_C37118 | \
- MSK_ICODE_RX_C37118_DC \
+ MSK_ICODE_RX_C37118_DC | \
+ MSK_ICODE_RX_A136_A137 | \
+ MSK_ICODE_RX_A006_A007 \
)
/**
- * @brief A mask of IRIG formats supporting TFOM time quality indicator
+ * @brief A mask of IRIG RX formats supporting a 2 digit year number
+ *
+ * This is after the P6 identifier.
+ */
+#define MSK_ICODE_RX_HAS_SHORT_YEAR_AFTER_P6 \
+( \
+ MSK_ICODE_RX_G146 | \
+ MSK_ICODE_RX_G006 \
+)
+
+/**
+ * @brief A mask of IRIG RX formats supporting TFOM time quality indicator
*/
#define MSK_ICODE_RX_HAS_TFOM \
( \
@@ -3853,7 +4639,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats supporting CTQ continuous time quality
+ * @brief A mask of IRIG RX formats supporting CTQ continuous time quality
*
* This has been introduced in IEEE C37.118.1-2011
*/
@@ -3866,7 +4652,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats supporting time zone information
+ * @brief A mask of IRIG RX formats supporting time zone information
*/
#define MSK_ICODE_RX_HAS_TZI \
( \
@@ -3877,7 +4663,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief IRIG formats where UTC offset must be subtracted to yield UTC
+ * @brief IRIG RX formats where UTC offset must be subtracted to yield UTC
*
* A mask of IRIG formats where the decoded UTC offset must be
* subtracted from the time decoded from the IRIG signal to yield UTC, e.g.:<br>
@@ -3890,7 +4676,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief IRIG formats where UTC offset must be added to yield UTC
+ * @brief IRIG RX formats where UTC offset must be added to yield UTC
*
* A mask of IRIG formats where the decoded UTC offset must be
* added to the time decoded from the IRIG signal to yield UTC, e.g.:<br>
@@ -3903,7 +4689,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats supporting a day of week number
+ * @brief A mask of IRIG RX formats supporting a day of week number
*/
#define MSK_ICODE_RX_HAS_AFNOR_WDAY \
( \
@@ -3912,7 +4698,7 @@ enum ICODE_RX_CODES
)
/**
- * @brief A mask of IRIG formats supporting a date (day-of-month, month)
+ * @brief A mask of IRIG RX formats supporting a date (day-of-month, month)
*/
#define MSK_ICODE_RX_HAS_AFNOR_DATE \
( \
@@ -3922,7 +4708,7 @@ enum ICODE_RX_CODES
/**
- * @brief The default mask of IRIG formats supported by IRIG receivers
+ * @brief The default mask of IRIG RX formats supported by IRIG receivers
*
* @note The formats which are actually supported should be retrieved
* from the device
@@ -4479,12 +5265,17 @@ typedef struct
/** @} defgroup group_time_scale */
-/*
- * The structures below are required to setup the programmable
+
+/**
+ * @defgroup group_pout_api Programmable Output API
+ *
+ * These structures below are used to configure the programmable
* pulse outputs which are provided by some GPS receivers.
* The number of programmable pulse outputs supported by a GPS
- * receiver is reported in the RECEIVER_INFO::n_str_type field.
- */
+ * receiver is reported in the RECEIVER_INFO::n_prg_out field.
+ *
+ * @{ */
+
/**
* @brief A calendar date including full year number
@@ -4511,7 +5302,7 @@ typedef struct
uint8_t hour; ///< 0..23
uint8_t min; ///< 0..59
uint8_t sec; ///< 0..59,60
- uint8_t sec100; ///< reserved, currently always 0
+ uint8_t sec100; ///< 100ths of seconds
} MBG_TIME;
@@ -4540,6 +5331,10 @@ typedef struct
/**
* @brief A structure to define on/off cycle times
+ *
+ * @note The ::MBG_TIME::sec100 field in ::POUT_TIME:on and
+ * ::POUT_TIME:off is not evaluated by the firmware and thus
+ * should always be set to 0.
*/
typedef struct
{
@@ -4563,19 +5358,6 @@ typedef struct
#define N_POUT_TIMES 3
/**
- * @brief Configuration settings for a single programmable pulse output
- */
-typedef struct
-{
- uint16_t mode; ///< mode of operation, see ::POUT_MODES
- uint16_t mode_param; ///< depending on the mode, e.g. pulse length, or index of a signal source
- uint16_t timeout; ///< timeout after which output signal is disabled [min], used with ::POUT_DCF77 and ::POUT_DCF77_M59 only, see ::MAX_POUT_DCF_TIMOUT
- uint16_t flags; ///< @see ::POUT_SETTINGS_FLAGS
- POUT_TIME tm[N_POUT_TIMES]; ///< switching times, or other data, see ::POUT_DATA
-
-} POUT_SETTINGS;
-
-/**
* @brief A Generic data field for programmable output settings
*
* If the mode is set to ::POUT_TIME_SLOTS then ::POUT_SETTINGS::tm must be
@@ -4584,12 +5366,27 @@ typedef struct
*/
typedef union
{
+ POUT_TIME tm[N_POUT_TIMES]; ///< switching times, or other data, see ::POUT_DATA
uint8_t b[N_POUT_TIMES * sizeof( POUT_TIME )];
+ int32_t pulse_shift;
} POUT_DATA;
/**
+ * @brief Configuration settings for a single programmable pulse output
+ */
+typedef struct
+{
+ uint16_t mode; ///< mode of operation, see ::POUT_MODES
+ uint16_t mode_param; ///< depending on the mode, e.g. pulse length, or index of a signal source
+ uint16_t timeout; ///< timeout after which output signal is disabled [min], used with ::POUT_DCF77 and ::POUT_DCF77_M59 only, see ::MAX_POUT_DCF_TIMOUT
+ uint16_t flags; ///< @see ::POUT_SETTINGS_FLAGS
+ POUT_DATA pout_data; ///< additional configuration data, see ::POUT_DATA
+
+} POUT_SETTINGS;
+
+/**
* @brief Convert ::POUT_SETTINGS endianess after reading from a device
*
* When reading data from a device we first need to correct the endianess
@@ -4678,7 +5475,7 @@ typedef union
*
* These codes are used with ::POUT_SETTINGS::mode. One or more of
* the remaining fields in ::POUT_SETTINGS are evaluated depending
- * on the selected mode.
+ * on the selected mode. Unused fields should be set to 0.
*
* Unless ::POUT_NOT_INVERTIBLE is set in ::POUT_INFO::flags
* the output signal level can be inverted if ::POUT_INVERTED
@@ -4687,29 +5484,90 @@ typedef union
* @note Not every programmable pulse output supports all modes.
*
* @see @ref POUT_MODE_MASKS
+ * @see @ref ENG_POUT_NAMES
+ * @see @ref ENG_POUT_HINTS
*/
enum POUT_MODES
{
- POUT_IDLE, ///< always off, or on if ::POUT_INVERTED flag is set
- POUT_TIMER, ///< switch on/off at times specified in ::POUT_SETTINGS::tm
- POUT_SINGLE_SHOT, ///< pulse at time POUT_SETTINGS::tm[0].on, pulse length in ::POUT_SETTINGS::mode_param [10 ms units], see ::MAX_POUT_PULSE_LEN
- POUT_CYCLIC_PULSE, ///< pulse every POUT_SETTINGS::tm[0].on.t interval, pulse length in ::POUT_SETTINGS::mode_param [10 ms units], see ::MAX_POUT_PULSE_LEN
- POUT_PER_SEC, ///< pulse if second changes, pulse length in ::POUT_SETTINGS::mode_param [10 ms units], see ::MAX_POUT_PULSE_LEN
- POUT_PER_MIN, ///< pulse if minute changes, pulse length in ::POUT_SETTINGS::mode_param [10 ms units], see ::MAX_POUT_PULSE_LEN
- POUT_PER_HOUR, ///< pulse if hour changes, pulse length in ::POUT_SETTINGS::mode_param [10 ms units], see ::MAX_POUT_PULSE_LEN
- POUT_DCF77, ///< emulate DCF77 signal, uses ::POUT_SETTINGS::timeout, see ::MAX_POUT_DCF_TIMOUT
- POUT_POS_OK, ///< on if receiver position verified (nav_solved)
- POUT_TIME_SYNC, ///< on if time synchronized (time_syn)
- POUT_ALL_SYNC, ///< on if position verified and time synchronized
- POUT_TIMECODE, ///< IRIG/AFNOR DCLS signal output
- POUT_TIMESTR, ///< serial time string, ::POUT_SETTINGS::mode_param contains the number of the COM port, see ::MAX_POUT_TIMESTR_PORTS
- POUT_10MHZ, ///< 10 MHz fixed frequency
- POUT_DCF77_M59, ///< DCF77-like signal with 500 ms pulse in 59th second, uses ::POUT_SETTINGS::timeout, see ::MAX_POUT_DCF_TIMOUT
- POUT_SYNTH, ///< programmable frequency synthesizer output signal
- POUT_TIME_SLOTS, ///< programmable time slots during each minute, uses ::POUT_DATA, ::POUT_SETTINGS::mode_param contains time slots per minute
- POUT_GPIO, ///< GPIO input or output signal, ::POUT_SETTINGS::mode_param specifies the GPIO number, see ::MBG_GPIO_CFG_LIMITS::num_io
- // New modes have to be added here at the end of the enumeration, and
- // the POUT_MODE_MASKS and string initializers (also in pcpslstr.h)
+ /// 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.
+ POUT_TIMER,
+
+ /// 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.
+ /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units.
+ /// See ::MAX_POUT_PULSE_LEN.
+ POUT_CYCLIC_PULSE,
+
+ /// Generate a pulse whenever the second changes.
+ /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units.
+ /// See ::MAX_POUT_PULSE_LEN.
+ POUT_PER_SEC,
+
+ /// Generate a pulse whenever the minute changes.
+ /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units.
+ /// See ::MAX_POUT_PULSE_LEN.
+ POUT_PER_MIN,
+
+ /// Generate a pulse whenever the hour changes.
+ /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units.
+ /// See ::MAX_POUT_PULSE_LEN.
+ POUT_PER_HOUR,
+
+ /// Generate DCF77-compatible second marks.
+ /// Stops generating the output signal when receiver lost sync
+ /// and ::POUT_SETTINGS::timeout expired.
+ /// See ::MAX_POUT_DCF_TIMOUT.
+ POUT_DCF77,
+
+ /// Output switched on if receiver position verified (condition nav_solved).
+ POUT_POS_OK,
+
+ /// Output switched on if time synchronized (condition time_syn).
+ POUT_TIME_SYNC,
+
+ /// Output switched on if both position verified and time synchronized.
+ POUT_ALL_SYNC,
+
+ /// IRIG/AFNOR DCLS time code signal mapped to this output.
+ POUT_TIMECODE,
+
+ /// Serial time string of one one of the serial ports mapped to this output.
+ /// ::POUT_SETTINGS::mode_param contains the number of the COM port.
+ /// See ::MAX_POUT_TIMESTR_PORTS.
+ POUT_TIMESTR,
+
+ /// 10 MHz fixed frequency output.
+ POUT_10MHZ,
+
+ /// DCF77-like signal with extra 500 ms pulse in 59th second.
+ /// The original DCF77 signal has no pulse in the 59th second.
+ /// Stops generating the output signal when receiver lost sync
+ /// and ::POUT_SETTINGS::timeout expired.
+ /// See ::MAX_POUT_DCF_TIMOUT.
+ POUT_DCF77_M59,
+
+ /// Output signal generated by the programmable frequency synthesizer.
+ POUT_SYNTH,
+
+ /// Programmable time slots during each minute.
+ /// ::POUT_SETTINGS::mode_param specifies the time slots per minute.
+ /// Uses ::POUT_DATA. ::TODO
+ POUT_TIME_SLOTS,
+
+ /// A GPIO input or output signal is reflected at this pulse output.
+ /// ::POUT_SETTINGS::mode_param specifies the GPIO number which must
+ /// be in the range 0..::MBG_GPIO_CFG_LIMITS::num_io.
+ POUT_GPIO,
+
+ // 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.
N_POUT_MODES ///< the number of known modes
};
@@ -4747,10 +5605,17 @@ enum POUT_MODES
/** @} anchor POUT_MODE_MASKS */
-/*
- * Default initializers for English pulse mode names. Initializers
- * for multi-language strings can be found in pcpslstr.h.
- */
+/**
+ * @brief Name strings associated with ::POUT_MODES
+ *
+ * Default initializers for English programmable output mode names.
+ * Initializers for multi-language strings can be found in pcpslstr.h.
+ *
+ * @see ::POUT_MODES
+ * @see ::DEFAULT_ENG_POUT_NAMES
+ *
+ * @anchor ENG_POUT_NAMES @{ */
+
#define ENG_POUT_NAME_IDLE "Idle"
#define ENG_POUT_NAME_TIMER "Timer"
#define ENG_POUT_NAME_SINGLE_SHOT "Single Shot"
@@ -4770,6 +5635,15 @@ enum POUT_MODES
#define ENG_POUT_NAME_TIME_SLOTS "Time Slots per Minute"
#define ENG_POUT_NAME_GPIO "GPIO Signal"
+/** @} anchor ENG_POUT_NAMES */
+
+
+
+/**
+ * @brief An initializer for a table of English POUT name strings
+ *
+ * @see @ref ENG_POUT_NAMES
+ */
#define DEFAULT_ENG_POUT_NAMES \
{ \
ENG_POUT_NAME_IDLE, \
@@ -4793,6 +5667,17 @@ enum POUT_MODES
}
+/**
+ * @brief Hint strings associated with ::POUT_MODES
+ *
+ * Default initializers for English programmable output mode hints.
+ * Initializers for multi-language strings can be found in pcpslstr.h.
+ *
+ * @see ::POUT_MODES
+ * @see ::DEFAULT_ENG_POUT_HINTS
+ *
+ * @anchor ENG_POUT_HINTS @{ */
+
#define ENG_POUT_HINT_IDLE "Constant output level"
#define ENG_POUT_HINT_TIMER "Switch based on configured on/off times"
#define ENG_POUT_HINT_SINGLE_SHOT "Generate a single pulse of determined length"
@@ -4812,6 +5697,14 @@ enum POUT_MODES
#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"
+/** @} anchor ENG_POUT_HINTS */
+
+
+/**
+ * @brief An initializer for a table of English POUT hint strings
+ *
+ * @see @ref ENG_POUT_HINTS
+ */
#define DEFAULT_ENG_POUT_HINTS \
{ \
ENG_POUT_HINT_IDLE, \
@@ -4982,6 +5875,8 @@ typedef struct
_mbg_swab_pout_info_on_get( &(_p)->pout_info ); \
}
+/** @} defgroup group_pout_api */
+
/**
@@ -5019,7 +5914,7 @@ typedef struct
/**
* @brief Enumeration of all known types of reference time source
*
- * All known types of input signals which may possibly be supported
+ * All known types of input signal which may possibly be supported
* by devices which support several different input signals, i.e.
* have the ::GPS_HAS_MULTI_REF or ::GPS_HAS_XMULTI_REF bit set
* in ::RECEIVER_INFO::features. Not all devices support each known
@@ -5034,7 +5929,7 @@ enum MULTI_REF_TYPES
{
/// This ref type must not be used as index, but marks particular
/// ::XMULTI_REF_SETTINGS structures as "unused". It is only
- /// supported if bit ::XMRIF_BIT_MRF_NONE_SUPP is set
+ /// supported if bit ::XMRIF_BIT_MRF_NONE_SUPP is set.
MULTI_REF_NONE = -1,
MULTI_REF_GPS = 0, ///< standard GPS
@@ -5054,6 +5949,7 @@ enum MULTI_REF_TYPES
MULTI_REF_GRC, ///< Glonass / GPS receiver
MULTI_REF_HAVEQUICK, ///< HaveQuick input
MULTI_REF_EXT_OSC, ///< external oscillator disciplined and looped back via 1 PPS I/O
+ MULTI_REF_SYNCE, ///< Synchronous Ethernet, needs (external) ethernet interface
N_MULTI_REF ///< the number of defined sources, must not exceed ::MAX_N_MULTI_REF_TYPES
};
@@ -5089,7 +5985,8 @@ enum MULTI_REF_TYPES
"Long Wave Receiver", \
"GLONASS/GPS Receiver", \
"HaveQuick Input", \
- "ext. Osc." \
+ "ext. Osc.", \
+ "Synchronous Ethernet" \
}
/**
@@ -5107,17 +6004,18 @@ enum MULTI_REF_TYPES
"10MHZ+PPS", \
"TCR", \
"NTP", \
- "PTP hq", \
- "PTP E1", \
- "Fixed in", \
- "STR in", \
- "GPIO in", \
+ "PTP", \
+ "PTP_E1", \
+ "FIXED_FREQ", \
+ "STRING+PPS", \
+ "GPIO", \
"(reserved)", \
"PZF", \
"LWR", \
"GGR", \
"HQI", \
- "EXT" \
+ "EXT", \
+ "SYNCE" \
}
@@ -5150,6 +6048,7 @@ enum MULTI_REF_TYPES
#define HAS_MULTI_REF_HAVEQUICK ( 1UL << MULTI_REF_HAVEQUICK ) ///< see ::MULTI_REF_HAVEQUICK
#define HAS_MULTI_REF_EXT_OSC ( 1UL << MULTI_REF_EXT_OSC ) ///< see ::MULTI_REF_EXT_OSC
+#define HAS_MULTI_REF_SYNCE ( 1UL << MULTI_REF_SYNCE ) ///< see ::MULTI_REF_SYNCE
/** @} anchor MULTI_REF_TYPE_MASKS */
@@ -5264,22 +6163,21 @@ enum MULTI_REF_STATUS_BIT_MASKS
*
* If the ::GPS_HAS_XMULTI_REF feature is set in ::RECEIVER_INFO::features then
* the XMULTI_REF (extended multi ref, XMR) feature and API are supported and
- * must be used in favor of the older multi ref API (see @ref group_multi_ref_old).
+ * have to be used in favor of the older multi ref API (see @ref group_multi_ref_old).
*
* Devices supporting the XMULTI_REF feature provide a number of
* priority levels addressed by the priority index, starting at 0
* for highest priority. A single reference time source from the set
* of supported sources can be assigned to each priority level.
*
- * These structures are used to configure the individual
- * time source for each priority level, and retrieve the status
- * of the time source at each priority level.
+ * These structures are used to configure the individual time source for each
+ * priority level, and retrieve the status of the time source at each priority level.
*
* If ::GPS_HAS_XMRS_MULT_INSTC is also set in ::RECEIVER_INFO::features then
* ::XMULTI_REF_INSTANCES can be used to find out which types of input source
* are supported (::XMULTI_REF_INSTANCES::n_inst array entries != 0), and
- * how many priority levels are supported to get an input source assigned
- * (::XMULTI_REF_INSTANCES::n_xmr_settings).
+ * how many priority levels are supported to which an input source can be
+ * assigned (::XMULTI_REF_INSTANCES::n_xmr_settings).
*
* If ::XMRIF_MSK_HOLDOVER_STATUS_SUPP is set in ::XMULTI_REF_INSTANCES::flags
* then ::XMR_HOLDOVER_STATUS can be used to monitor the switching between
@@ -5328,7 +6226,7 @@ typedef struct
typedef struct
{
XMULTI_REF_ID id; ///< reference time source identifier
- uint16_t flags; ///< reserved, currently always 0
+ uint16_t flags; ///< see ::XMR_SETTINGS_FLAG_MSKS and ::XMR_EXT_SRC_INFO::supp_flags
NANO_TIME bias; ///< time bias, e.g. path delay @todo specify sign vs. earlier/later
NANO_TIME precision; ///< precision of the time source
uint32_t reserved; ///< reserved, currently always 0
@@ -5354,6 +6252,30 @@ typedef struct
/**
+ * @brief Bit masks used to define ::XMR_SETTINGS_FLAG_MSKS
+ */
+enum XMR_SETTINGS_FLAG_BITS
+{
+ XMRSF_BIT_AUTO_BIAS_MASTER, ///< src is allowed to operate as zero asymmetry master
+ XMRSF_BIT_AUTO_BIAS_SLAVE, ///< accept static bias correction from zero asymmetry master
+ XMRSF_BIT_ASYMMETRY_STEP_DETECTION, ///< static bias auto correction in case of step
+ N_XMRSF_BITS ///< number of known flag bits
+};
+
+
+/**
+ * @brief Bit masks used with ::XMULTI_REF_SETTINGS::flags and ::XMR_EXT_SRC_INFO::supp_flags
+ */
+enum XMR_SETTINGS_FLAG_MSKS
+{
+ XMRSF_MSK_AUTO_BIAS_MASTER = ( 1UL << XMRSF_BIT_AUTO_BIAS_MASTER ), ///< see ::XMRSF_BIT_AUTO_BIAS_MASTER
+ XMRSF_MSK_AUTO_BIAS_SLAVE = ( 1UL << XMRSF_BIT_AUTO_BIAS_SLAVE ), ///< see ::XMRSF_BIT_AUTO_BIAS_SLAVE
+ XMRSF_MSK_ASYMMETRY_STEP_DETECTION = ( 1UL << XMRSF_BIT_ASYMMETRY_STEP_DETECTION ) ///< see ::XMRSF_BIT_ASYMMETRY_STEP_DETECTION
+};
+
+
+
+/**
* @brief Reference source capabilities and current configuration
*/
typedef struct
@@ -5375,8 +6297,8 @@ typedef struct
*/
uint8_t n_supp_ref;
- uint8_t reserved; ///< reserved, don't use, currently always 0
- uint16_t flags; ///< reserved, don't use, currently always 0
+ uint8_t n_prio; ///< reserved, don't use, currently always 0 //##++++ TODO: check which devices support/use this field
+ uint16_t flags; ///< reserved, don't use, currently always 0
} XMULTI_REF_INFO;
@@ -5402,7 +6324,7 @@ typedef struct
XMULTI_REF_ID id; ///< time source identifier
uint16_t status; ///< status bits, see @ref XMR_REF_STATUS_BIT_MASKS
NANO_TIME offset; ///< time offset from main time base @todo specify sign vs. earlier/later
- uint16_t flags; ///< flags, currently unused
+ uint16_t flags; ///< flags, see ::XMR_QL // TODO ###
uint8_t ssm; ///< synchronization status message, if supported by signal source
uint8_t soc; ///< signal outage counter, incremented on loss of signal
@@ -5423,25 +6345,64 @@ typedef struct
/**
+ * @brief ::TODO
+ *
+ * Used with the ::... field of ::XMULTI_REF_STATUS::flags
+ *
+ * @see ::XMULTI_REF_STATUS::flags
+ * @see ::XMR_QL_MASK
+ * @see ::_GET_XMR_QL
+ * @see ::_PUT_XMR_QL
+ */
+enum XMR_QL
+{
+ XMR_QL_UNKNOWN,
+ XMR_QL_GREEN,
+ XMR_QL_YELLOW,
+ XMR_QL_RED,
+ N_XMR_QL
+};
+
+#define XMR_QL_TDEV_MASK ( 0x03 << 0 )
+#define XMR_QL_MTIE_MASK ( 0x03 << 2 )
+
+#define _GET_XMR_QL_TDEV( _x ) ( ( ( _x ) & XMR_QL_TDEV_MASK ) >> 0 )
+#define _PUT_XMR_QL_TDEV( _x, _ql ) \
+do { \
+ ( _x ) = ( ( _x ) & ~XMR_QL_TDEV_MASK ) | ( ( ( _ql ) << 0 ) & XMR_QL_TDEV_MASK ); \
+} while ( 0 )
+
+
+#define _GET_XMR_QL_MTIE( _x ) ( ( ( _x ) & XMR_QL_MTIE_MASK ) >> 2 )
+#define _PUT_XMR_QL_MTIE( _x, _ql ) \
+do { \
+ ( _x ) = ( ( _x ) & ~XMR_QL_MTIE_MASK ) | ( ( ( _ql ) << 2 ) & XMR_QL_MTIE_MASK ); \
+} while ( 0 )
+
+
+
+/**
* @brief XMULTI_REF status bits
*/
enum XMR_REF_STATUS_BITS
{
- XMRS_BIT_NOT_SUPP, ///< ref type cfg'd for this level is not supported
- XMRS_BIT_NO_CONN, ///< input signal is disconnected
- XMRS_BIT_NO_SIGNAL, ///< no input signal
- XMRS_BIT_IS_MASTER, ///< reference is master source
- XMRS_BIT_IS_LOCKED, ///< locked to input signal
- XMRS_BIT_IS_ACCURATE, ///< oscillator control has reached full accuracy
- XMRS_BIT_NOT_SETTLED, ///< reference time signal not settled
- XMRS_BIT_NOT_PHASE_LOCKED, ///< oscillator not phase locked to PPS
- XMRS_BIT_NUM_SRC_EXC, ///< number of available sources exceeds what can be handled
- XMRS_BIT_IS_EXTERNAL, ///< this ref source is on extension card
- XMRS_BIT_LOW_JITTER, ///< this ref source has low jitter
- N_XMRS_BITS ///< number of know status bits
+ XMRS_BIT_NOT_SUPP, ///< ref type cfg'd for this level is not supported
+ XMRS_BIT_NO_CONN, ///< input signal is disconnected
+ XMRS_BIT_NO_SIGNAL, ///< no input signal
+ XMRS_BIT_IS_MASTER, ///< reference is master source
+ XMRS_BIT_IS_LOCKED, ///< locked to input signal
+ XMRS_BIT_IS_ACCURATE, ///< oscillator control has reached full accuracy
+ XMRS_BIT_NOT_SETTLED, ///< reference time signal not settled
+ XMRS_BIT_NOT_PHASE_LOCKED, ///< oscillator not phase locked to PPS
+ XMRS_BIT_NUM_SRC_EXC, ///< number of available sources exceeds what can be handled
+ XMRS_BIT_IS_EXTERNAL, ///< this ref source is on extension card
+ XMRS_BIT_LOW_JITTER, ///< this ref source has low jitter
+ XMRS_BIT_ITU_LIMIT_VIOLATED, ///< ITU limits violated (valid if device has ::XMR_METRICS)
+ N_XMRS_BITS ///< number of know status bits
};
+
/**
* @brief Bit masks associated with ::XMR_REF_STATUS_BITS
*
@@ -5451,21 +6412,23 @@ enum XMR_REF_STATUS_BITS
*
* @anchor XMR_REF_STATUS_BIT_MASKS @{ */
-#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP ) ///< see ::XMRS_BIT_NOT_SUPP
-#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN ) ///< see ::XMRS_BIT_NO_CONN
-#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL ) ///< see ::XMRS_BIT_NO_SIGNAL
-#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER ) ///< see ::XMRS_BIT_IS_MASTER
-#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED ) ///< see ::XMRS_BIT_IS_LOCKED
-#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE ) ///< see ::XMRS_BIT_IS_ACCURATE
-#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED ) ///< see ::XMRS_BIT_NOT_SETTLED
-#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED ) ///< see ::XMRS_BIT_NOT_PHASE_LOCKED
-#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC ) ///< see ::XMRS_BIT_NUM_SRC_EXC
-#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL ) ///< see ::XMRS_BIT_IS_EXTERNAL
-#define XMRS_MSK_LOW_JITTER ( 1UL << XMRS_BIT_LOW_JITTER ) ///< see ::XMRS_BIT_LOW_JITTER
+#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP ) ///< see ::XMRS_BIT_NOT_SUPP
+#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN ) ///< see ::XMRS_BIT_NO_CONN
+#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL ) ///< see ::XMRS_BIT_NO_SIGNAL
+#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER ) ///< see ::XMRS_BIT_IS_MASTER
+#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED ) ///< see ::XMRS_BIT_IS_LOCKED
+#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE ) ///< see ::XMRS_BIT_IS_ACCURATE
+#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED ) ///< see ::XMRS_BIT_NOT_SETTLED
+#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED ) ///< see ::XMRS_BIT_NOT_PHASE_LOCKED
+#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC ) ///< see ::XMRS_BIT_NUM_SRC_EXC
+#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL ) ///< see ::XMRS_BIT_IS_EXTERNAL
+#define XMRS_MSK_LOW_JITTER ( 1UL << XMRS_BIT_LOW_JITTER ) ///< see ::XMRS_BIT_LOW_JITTER
+#define XMRS_MSK_ITU_LIMIT_VIOLATED ( 1UL << XMRS_BIT_ITU_LIMIT_VIOLATED ) ///< see ::XMRS_BIT_ITU_LIMIT_VIOLATED
/** @} anchor XMR_REF_STATUS_BIT_MASKS */
+
/**
* @brief XMRS status bit name strings
*
@@ -5483,10 +6446,12 @@ enum XMR_REF_STATUS_BITS
"Phase not locked", \
"Number sources exceeds limit", \
"Is external", \
- "Low jitter" \
+ "Low jitter", \
+ "ITU Limit violated" \
}
+
/*
* An initializer for a ::XMULTI_REF_STATUS variable
* with status invalid / not used
@@ -5500,6 +6465,7 @@ enum XMR_REF_STATUS_BITS
}
+
/**
* @brief General info on supported XMR sources and instances
*
@@ -5528,7 +6494,7 @@ enum XMR_REF_STATUS_BITS
typedef struct
{
uint32_t flags; ///< see ::XMR_INST_FLAG_BIT_MASKS
- uint16_t n_xmr_settings; ///< number of entries in the input source priority table
+ uint16_t n_xmr_settings; ///< number of ::XMULTI_REF_INFO_IDX or ::XMULTI_REF_STATUS_IDX which can be retrieved
uint8_t slot_id; ///< ID of the slot in which this device is installed, 0 or up to 15, if multiple slots not supported
uint8_t reserved; ///< reserved, don't use, currently always 0
uint8_t n_inst[MAX_N_MULTI_REF_TYPES]; ///< the number of supported instances of each input signal type
@@ -5546,13 +6512,15 @@ enum XMR_INST_FLAGS
{
/// This flag indicates that configuration programs may set
/// ::XMULTI_REF_ID::type to ::MULTI_REF_NONE in ::XMULTI_REF_SETTINGS::id
- /// for unused priority levels, and that this will be reflected in
+ /// for unused priority levels, and that this will be reflected in
/// ::XMULTI_REF_STATUS::id accordingly. With some older firmware versions
/// this was not supported.
XMRIF_BIT_MRF_NONE_SUPP,
XMRIF_BIT_HOLDOVER_STATUS_SUPP, ///< ::XMR_HOLDOVER_STATUS and associated types supported
+ XMRIF_BIT_EXT_SRC_INFO_SUPP, ///< ::XMR_EXT_SRC_INFO structure supported
+
N_XMRIF_BITS ///< number of known flag bits
};
@@ -5567,10 +6535,12 @@ enum XMR_INST_FLAGS
enum XMR_INST_FLAG_BIT_MASKS
{
XMRIF_MSK_MRF_NONE_SUPP = ( 1UL << XMRIF_BIT_MRF_NONE_SUPP ), ///< see ::XMRIF_BIT_MRF_NONE_SUPP
- XMRIF_MSK_HOLDOVER_STATUS_SUPP = ( 1UL << XMRIF_BIT_HOLDOVER_STATUS_SUPP ) ///< see ::XMRIF_BIT_HOLDOVER_STATUS_SUPP
+ XMRIF_MSK_HOLDOVER_STATUS_SUPP = ( 1UL << XMRIF_BIT_HOLDOVER_STATUS_SUPP ), ///< see ::XMRIF_BIT_HOLDOVER_STATUS_SUPP
+ XMRIF_MSK_EXT_SRC_INFO_SUPP = ( 1UL << XMRIF_BIT_EXT_SRC_INFO_SUPP ) ///< see ::XMRIF_BIT_EXT_SRC_INFO_SUPP
};
+
/**
* @brief XMR holdover interval, or elapsed holdover time, in [s]
*/
@@ -5587,6 +6557,7 @@ typedef uint32_t XMR_HOLDOVER_INTV;
#define XMR_PRIO_LVL_UNSPEC -1
+
/**
* @brief XMR holdover status
*
@@ -5620,7 +6591,7 @@ typedef struct
int8_t curr_prio; ///< current priority level, 0..::XMULTI_REF_INSTANCES::n_xmr_settings, or ::XMR_PRIO_LVL_UNSPEC
int8_t nxt_prio; ///< next priority level after holdover, 0..::XMULTI_REF_INSTANCES::n_xmr_settings, or ::XMR_PRIO_LVL_UNSPEC
uint8_t remote_watchdog; ///< counts down in ::XMR_HLDOVR_PRE_AUTONOMOUS mode
- uint32_t reserved; ///< reserved, don't use, currently 0
+ uint32_t time_offset_ns; ///< estimated time offset in holdover operation
XMR_HOLDOVER_INTV elapsed; ///< elapsed time in holdover mode, only valid if ::XMR_HLDOVR_MSK_IN_HOLDOVER is set
XMR_HOLDOVER_INTV interval; ///< current holdover interval, only valid if ::XMR_HLDOVR_MSK_IN_HOLDOVER is set
uint32_t flags; ///< holdover status flags, see ::XMR_HOLDOVER_STATUS_FLAG_MASKS
@@ -5628,6 +6599,7 @@ typedef struct
} XMR_HOLDOVER_STATUS;
+
/**
* @brief XMR holdover status modes
*
@@ -5651,9 +6623,9 @@ enum XMR_HOLDOVER_STATUS_MODES
*/
#define XMR_HOLDOVER_STATUS_MODE_NAMES \
{ \
- "autonomous", \
- "pre-autonomous", \
- "remote" \
+ "Autonomous", \
+ "Pre-Autonomous", \
+ "Remote" \
}
@@ -5668,6 +6640,7 @@ enum XMR_HOLDOVER_STATUS_FLAG_BITS
XMR_HLDOVR_BIT_IN_HOLDOVER, ///< the device is currently in holdover mode
XMR_HLDOVR_BIT_TRANSITION_ENBD, ///< timebase is in transition (being slewed) after sources have been switched
XMR_HLDOVR_BIT_IN_TRANSITION, ///< transition is currently active, slewing in progress
+ XMR_HLDOVR_BIT_TIME_OFFS_VALID, ///< values in field ::XMR_HOLDOVER_STATUS::time_offset_ns are valid
N_XMR_HOLDOVER_STATUS_FLAG_BITS ///< the number of known status flags
};
@@ -5681,16 +6654,287 @@ enum XMR_HOLDOVER_STATUS_FLAG_MASKS
{
XMR_HLDOVR_MSK_IN_HOLDOVER = ( 1UL << XMR_HLDOVR_BIT_IN_HOLDOVER ), ///< see ::XMR_HLDOVR_BIT_IN_HOLDOVER
XMR_HLDOVR_MSK_TRANSITION_ENBD = ( 1UL << XMR_HLDOVR_BIT_TRANSITION_ENBD ), ///< see ::XMR_HLDOVR_BIT_TRANSITION_ENBD
- XMR_HLDOVR_MSK_IN_TRANSITION = ( 1UL << XMR_HLDOVR_BIT_IN_TRANSITION ) ///< see ::XMR_HLDOVR_BIT_IN_TRANSITION
+ XMR_HLDOVR_MSK_IN_TRANSITION = ( 1UL << XMR_HLDOVR_BIT_IN_TRANSITION ), ///< see ::XMR_HLDOVR_BIT_IN_TRANSITION
+ XMR_HLDOVR_MSK_TIME_OFFS_VALID = ( 1UL << XMR_HLDOVR_BIT_TIME_OFFS_VALID ) ///< see ::XMR_HLDOVR_BIT_TIME_OFFS_VALID
+};
+
+
+
+/**
+ * @brief XMR source feature flag bits
+ *
+ * Used to define ::XMR_EXT_SRC_FEAT_FLAG_MSKS
+ */
+enum XMR_EXT_SRC_FEAT_FLAG_BITS
+{
+ XMR_EXT_SRC_FEAT_FLAG_BIT_STATS, ///< XMR source provides ::XMR_STATS
+ XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS, ///< XMR source provides ::XMR_METRICS
+ N_XMR_EXT_SRC_FEAT_FLAG_BITS
+};
+
+
+
+/**
+ * @brief XMR source feature flag bit masks
+ *
+ * Used with ::XMR_EXT_SRC_INFO::feat_flags.
+ *
+ * @see ::XMR_EXT_SRC_FEAT_FLAG_BITS
+ */
+enum XMR_EXT_SRC_FEAT_FLAG_MSKS
+{
+ XMR_EXT_SRC_FEAT_FLAG_MSK_STATS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_STATS ), ///< see ::XMR_EXT_SRC_FEAT_FLAG_BIT_STATS
+ XMR_EXT_SRC_FEAT_FLAG_MSK_METRICS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS ) ///< see ::XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS
};
+
+typedef struct
+{
+ uint16_t supp_flags; ///< indicates which flags are supported by ::XMULTI_REF_SETTINGS::flags, see ::XMR_SETTINGS_FLAG_MSKS
+ uint16_t feat_flags; ///< see ::XMR_EXT_SRC_FEAT_FLAG_MSKS
+ uint32_t reserved_0;
+
+} XMR_EXT_SRC_INFO;
+
+
+
+typedef struct
+{
+ uint16_t idx; //
+ XMR_EXT_SRC_INFO info; //
+
+} XMR_EXT_SRC_INFO_IDX; //
+
+
+
+/**
+ * @brief XMR statistics for a particular source
+ *
+ * This structure is only provided by an XMR source which has
+ * ::XMR_EXT_SRC_FEAT_FLAG_MSK_STATS set in ::XMR_EXT_SRC_INFO::feat_flags.
+ *
+ * @see ::XMR_STATS_IDX
+ * @see ::XMR_EXT_SRC_INFO::feat_flags
+ * @see ::XMR_EXT_SRC_FEAT_FLAG_MSK_STATS
+ */
+typedef struct
+{
+ uint32_t timestamp; ///< time stamp when the record was taken, UTC, seconds since 1970
+ NANO_TIME last_mue; ///< mean value (mue) of prev. interval
+ NANO_TIME last_sigma; ///< standard deviation (sigma) of prev. interval
+ NANO_TIME last_max; ///< maximum value within interval
+ NANO_TIME last_min; ///< minimum value within interval
+ NANO_TIME reserved_0; ///< currently reserved, unused, always 0
+ NANO_TIME step_comp_val; ///< current step compensation value
+ NANO_TIME auto_bias; ///< current time automatic bias compensation
+ uint32_t reserved_1; ///< currently reserved, unused, always 0
+ uint32_t reserved_2; ///< currently reserved, unused, always 0
+ uint32_t flags; ///< see ::XMR_STATS_FLAGS_MSKS
+
+} XMR_STATS;
+
+
+
+/**
+ * @brief Enumeration of bits used to define ::XMR_STATS_FLAGS_MSKS
+ *
+ * @see ::XMR_STATS_FLAGS_MSKS
+ */
+enum XMR_STATS_FLAGS_BITS
+{
+ XMR_STATS_FLAG_BIT_STEP_DETECTED, ///< A time step was detected at the input source
+ XMR_STATS_FLAG_BIT_STEP_COMPENSATED, ///< A time step was compensated at the input source
+ XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID, ///< The value in ::XMR_STATS::auto_bias is valid
+ N_XMR_STATS_FLAGS_BITS
+};
+
+
+
+/**
+ * @brief Flag bit masks used with ::XMR_STATS::flags
+ *
+ * @see ::XMR_STATS_FLAGS_BITS
+ */
+enum XMR_STATS_FLAGS_MSKS
+{
+ XMR_STATS_FLAG_MSK_STEP_DETECTED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_DETECTED ), ///< see ::XMR_STATS_FLAG_BIT_STEP_DETECTED
+ XMR_STATS_FLAG_MSK_STEP_COMPENSATED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_COMPENSATED ), ///< see ::XMR_STATS_FLAG_BIT_STEP_COMPENSATED
+ XMR_STATS_FLAG_MSK_AUTO_BIAS_VALID = ( 1UL << XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID ) ///< see ::XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID
+};
+
+
+
+/**
+ * @brief String initializers for XMR Stats Flags
+ *
+ * @see ::XMR_STATS_FLAGS_MSKS
+ */
+#define DEFAULT_XMR_STATS_FLAG_NAMES \
+{ \
+ "Step Detected", \
+ "Step Compensated", \
+ "Auto BIAS valid" \
+}
+
+
+
+/**
+ * @brief XMR statistics for a particular source, with index
+ *
+ * @see ::XMR_STATS
+ */
+typedef struct
+{
+ uint16_t idx; ///< the priority level index (highest == 0), 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1
+ XMR_STATS stats; ///< XMR statistics of the particular source
+
+} XMR_STATS_IDX;
+
+
+
+#define MAX_XMR_METRICS 20
+
+typedef struct
+{
+ uint32_t timestamp;
+ uint32_t flags; ///< idx bit set if mtie[idx] is valid
+ uint8_t mtie_scale; ///< scale factors of MTIE
+ uint8_t tdev_scale; ///< scale factors of TDEV
+ uint16_t reserved_0; ///< currently unused
+ uint32_t reserved_1; ///< currently unused
+ uint32_t reserved_2; ///< currently unused
+ uint32_t mtie[MAX_XMR_METRICS]; ///< mtie scaled 32 bit fixed point unsigned
+ uint32_t tdev[MAX_XMR_METRICS]; ///< tdev scaled 32 bit fixed point unsigned
+
+} XMR_METRICS;
+
+// conversion factor scaled FPU32 to double
+#define _fpu32_to_double_fac( _x ) ( 1.0 / ( 4294967296.0 * ( _x ) ) )
+
+
+
+/**
+ * @brief XMR timing metrics for a particular source, with index
+ *
+ * @see ::XMR_METRICS
+ */
+typedef struct
+{
+ uint16_t idx;
+ XMR_METRICS metrics;
+
+} XMR_METRICS_IDX;
+
+
+
+/**
+ * @brief Enumeration of ITU limit masks
+ *
+ * Used for detection of ::XMR_METRICS mask violation.
+ *
+ * @see ::ITU_LIMIT_MASKS
+ * @see ::XMR_METRICS
+ */
+enum ITU_LIMITS
+{
+ ITU_LIMIT_G811_PRC,
+ ITU_LIMIT_G823_SSU,
+ ITU_LIMIT_G823_SEC,
+ ITU_LIMIT_G8272_PRTC,
+ ITU_LIMIT_G82721_EPRTC,
+ N_ITU_LIMITS
+} ;
+
+
+
+/**
+ * @brief Enumeration of ITU limit masks
+ *
+ * Used for detection of ::XMR_METRICS mask violation.
+ *
+ * @see ::ITU_LIMITS
+ * @see ::XMR_METRICS
+ */
+enum ITU_LIMIT_MASKS
+{
+ MSK_ITU_LIMIT_G811_PRC = ( 1UL << ITU_LIMIT_G811_PRC ),
+ MSK_ITU_LIMIT_G823_SSU = ( 1UL << ITU_LIMIT_G823_SSU ),
+ MSK_ITU_LIMIT_G823_SEC = ( 1UL << ITU_LIMIT_G823_SEC ),
+ MSK_ITU_LIMIT_G8272_PRTC = ( 1UL << ITU_LIMIT_G8272_PRTC ),
+ MSK_ITU_LIMIT_G82721_EPRTC = ( 1UL << ITU_LIMIT_G82721_EPRTC )
+};
+
+
+
+/**
+ * @brief String initializers for ITU limit masks
+ *
+ * Used for detection of ::XMR_METRICS mask violation.
+ *
+ * @see ::ITU_LIMITS
+ * @see ::XMR_METRICS
+ */
+#define ITU_LIMIT_SHORT_STRS \
+{ \
+ "G811 (PRC)", \
+ "G823 (SSU)", \
+ "G823 (SEC)", \
+ "G8272 (PRTC)", \
+ "G82721 (ePRTC)" \
+}
+
+
+
+/**
+ * @brief supported limits for qualtity metrics
+ *
+ * @see ::XMR_METRICS
+ */
+typedef struct
+{
+ uint8_t ql_mask; ///< see :ITU_LIMIT_MASKS
+ uint8_t hysteresis; ///< hysteresis (percent) between yellow and red alarm
+ uint16_t reserved_0;
+ uint32_t reserved_1;
+
+} XMR_QL_SETTINGS;
+
+
+
+typedef struct
+{
+ uint32_t supp_ql_masks; ///< see :ITU_LIMIT_MASKS
+ uint32_t reserved_0;
+ uint32_t reserved_1;
+ XMR_QL_SETTINGS settings;
+
+} XMR_QL_INFO;
+
+
+
+typedef struct
+{
+ uint16_t idx;
+ XMR_QL_SETTINGS settings;
+
+} XMR_QL_SETTINGS_IDX;
+
+
+
+typedef struct
+{
+ uint16_t idx;
+ XMR_QL_INFO info;
+
+} XMR_QL_INFO_IDX;
+
+
/** @} defgroup group_multi_ref_ext */
/** @} defgroup group_multi_ref_all */
-
/**
* @defgroup group_gpio GPIO port configuration stuff
*
@@ -5716,17 +6960,17 @@ typedef struct
} MBG_GPIO_CFG_LIMITS;
-#define _mbg_swab_gpio_cfg_limits( p ) \
-{ \
- _mbg_swab32( &(_p)->num_io ); \
- _mbg_swab32( &(_p)->reserved ); \
- _mbg_swab32( &(_p)->flags ); \
+#define _mbg_swab_mbg_gpio_cfg_limits( _p ) \
+{ \
+ _mbg_swab32( &(_p)->num_io ); \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
}
/**
- * @brief GPIO limits flag bits uded to define ::MBG_GPIO_CFG_LIMIT_FLAG_MASKS
+ * @brief GPIO limits flag bits used to define ::MBG_GPIO_CFG_LIMIT_FLAG_MASKS
*
* @see ::MBG_GPIO_CFG_LIMIT_FLAG_MASKS
*/
@@ -5764,12 +7008,15 @@ enum MBG_GPIO_CFG_LIMIT_FLAG_MASKS
*/
enum MBG_GPIO_TYPES
{
- MBG_GPIO_TYPE_FREQ_IN, ///< variable frequency input, freq == 0 if input not used
- MBG_GPIO_TYPE_FREQ_OUT, ///< variable frequency output
- MBG_GPIO_TYPE_FIXED_FREQ_OUT, ///< fixed frequency output
- MBG_GPIO_TYPE_BITS_IN, ///< framed data stream input
- MBG_GPIO_TYPE_BITS_OUT, ///< framed data stream output
- N_MBG_GPIO_TYPES ///< number of known types
+ MBG_GPIO_TYPE_FREQ_IN, ///< Variable frequency input, freq == 0 if input not used
+ MBG_GPIO_TYPE_FREQ_OUT, ///< Variable frequency output
+ MBG_GPIO_TYPE_FIXED_FREQ_OUT, ///< Fixed frequency output
+ MBG_GPIO_TYPE_BITS_IN, ///< Framed data stream input
+ MBG_GPIO_TYPE_BITS_OUT, ///< Framed data stream output
+ 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
+ N_MBG_GPIO_TYPES ///< Number of known types
};
@@ -5779,7 +7026,10 @@ enum MBG_GPIO_TYPES
"Freq. Out", \
"Fixed Freq Out", \
"BITS In", \
- "BITS Out" \
+ "BITS Out", \
+ "Video Out", \
+ "Video Sync Out", \
+ "Studio Clock Out" \
}
@@ -5802,6 +7052,7 @@ enum MBG_GPIO_SIGNAL_SHAPES
};
+
/**
* @brief Bit masks associated with ::MBG_GPIO_SIGNAL_SHAPES
*
@@ -5846,6 +7097,12 @@ typedef struct
} MBG_GPIO_FREQ;
+#define _mbg_swab_mbg_gpio_freq( _p ) \
+{ \
+ _mbg_swab32( &(_p)->hz ); \
+ _mbg_swab32( &(_p)->frac); \
+}
+
/**
@@ -5867,6 +7124,7 @@ typedef struct
} MBG_GPIO_FREQ_IN_SETTINGS;
+
/**
* @brief Supported options for a variable frequency GPIO input
*
@@ -5881,7 +7139,7 @@ typedef struct
uint32_t freq_max; ///< maximum output frequency [Hz]
uint32_t csc_limit_max; ///< 1/1000 units of the signal period, limited due to 10 ns sampling interval, see ::MBG_GPIO_FREQ_IN_SETTINGS::csc_limit //##++++++++++++++++
uint32_t supp_shapes; ///< bit mask of supported signal shapes, see ::MBG_GPIO_SIGNAL_SHAPE_MASKS
- uint32_t reserved; ///< reserved, currently always 0
+ uint32_t supp_limits; ///< supported ITU limit masks for BITS signal see ::ITU_LIMIT_MASKS
uint32_t flags; ///< reserved, currently always 0
} MBG_GPIO_FREQ_IN_SUPP;
@@ -5949,6 +7207,7 @@ enum MBG_GPIO_FIXED_FREQS
N_MBG_GPIO_FIXED_FREQ ///< number of predefined fixed frequencies
};
+
/**
* @brief Bit masks associated with ::MBG_GPIO_FIXED_FREQS
*
@@ -5987,6 +7246,7 @@ enum MBG_GPIO_FIXED_FREQ_MASKS
}
+
/**
* @brief Configuration of a GPIO fixed frequency output
*
@@ -6005,6 +7265,7 @@ typedef struct
} MBG_GPIO_FIXED_FREQ_OUT_SETTINGS;
+
/**
* @brief Supported options for a fixed frequency output
*
@@ -6040,6 +7301,7 @@ enum MBG_GPIO_BITS_FORMATS
N_MBG_GPIO_BITS_FORMATS ///< number of defined formats
};
+
/**
* @brief Bit masks associated with ::MBG_GPIO_BITS_FORMATS
*
@@ -6056,6 +7318,21 @@ enum MBG_GPIO_BITS_FORMAT_MASKS
};
+/**
+ * @brief Initializers for an array of GPIO bit format strings
+ *
+ * @see ::MBG_GPIO_BITS_FORMATS
+ * @see ::MBG_GPIO_BITS_FORMAT_MASKS
+ */
+#define MBG_GPIO_BITS_FORMAT_STRS \
+{ \
+ "E1 Framed", \
+ "T1 Framed", \
+ "E1 Timing", \
+ "T1 Timing" \
+}
+
+
/**
* @brief Minimum and maximum known SSM values
@@ -6101,6 +7378,7 @@ enum GPIO_SA_BITS_GROUPS
};
+
/**
* @brief Configuration of a GPIO as BITS input module
*
@@ -6111,9 +7389,9 @@ enum GPIO_SA_BITS_GROUPS
*/
typedef struct
{
- uint32_t format; ///< signal format, see ::MBG_GPIO_BITS_FORMATS
- uint32_t reserved; ///< reserved, currently always 0
- uint32_t csc_limit; ///< max. cycle slip [1/1000 cycle units]
+ uint32_t format; ///< signal format, see ::MBG_GPIO_BITS_FORMATS
+ uint32_t reserved; ///< reserved, currently always 0
+ uint32_t csc_limit; ///< max. cycle slip [1/1000 cycle units]
union quality
{
@@ -6152,6 +7430,7 @@ enum MBG_GPIO_BITS_ERRS
N_MBG_GPIO_BITS_ERRS ///< number of known errors
};
+
/**
* @brief Bit masks associated with BITS input error conditions
*
@@ -6166,6 +7445,7 @@ enum MBG_GPIO_BITS_ERR_MASKS
};
+
/**
* @brief Supported options of a BITS GPIO input
*
@@ -6176,8 +7456,8 @@ enum MBG_GPIO_BITS_ERR_MASKS
*/
typedef struct
{
- uint32_t supp_fmts; ///< bit mask of supported formats, see ::MBG_GPIO_BITS_FORMAT_MASKS
- uint32_t reserved; ///< reserved, currently always 0
+ uint32_t supp_fmts; ///< bit mask of supported formats, see ::MBG_GPIO_BITS_FORMAT_MASKS
+ uint32_t reserved; ///< reserved, currently always 0
} MBG_GPIO_BITS_IN_SUPP;
@@ -6206,8 +7486,12 @@ typedef struct
} MBG_GPIO_BITS_OUT_SETTINGS;
+
/**
* @brief Enumeration of flags used with BITS type GPIO outputs
+ *
+ * @see ::MBG_GPIO_BITS_OUT_FLAG_MASKS
+ * @see ::MBG_GPIO_BITS_OUT_FLAG_STRS
*/
enum MBG_GPIO_BITS_OUT_FLAGS
{
@@ -6216,12 +7500,14 @@ enum MBG_GPIO_BITS_OUT_FLAGS
N_MBG_GPIO_BITS_OUT_FLAGS ///< number of known flags
};
+
/**
* @brief Bit masks associated with ::MBG_GPIO_BITS_OUT_FLAGS
*
* Used with ::MBG_GPIO_BITS_OUT_SETTINGS::flags
*
* @see ::MBG_GPIO_BITS_OUT_FLAGS
+ * @see ::MBG_GPIO_BITS_OUT_FLAG_STRS
*/
enum MBG_GPIO_BITS_OUT_FLAG_MASKS
{
@@ -6231,6 +7517,19 @@ enum MBG_GPIO_BITS_OUT_FLAG_MASKS
/**
+ * @brief String initializers for an array of GPIO BITS out flags
+ *
+ * @see ::MBG_GPIO_BITS_OUT_FLAGS
+ * @see ::MBG_GPIO_BITS_OUT_FLAG_MASKS
+ */
+#define MBG_GPIO_BITS_OUT_FLAG_STRS \
+{ \
+ "HDB3", \
+ "B8ZS" \
+}
+
+
+/**
* @brief Supported options of a BITS type GPIO output
*
* Used as sub-structure of ::MBG_GPIO_LIMITS.
@@ -6248,6 +7547,519 @@ typedef struct
/**
+ * @brief Enumeration of Video signal formats
+ *
+ * Used with ::MBG_GPIO_VIDEO_OUT_SETTINGS::format
+ *
+ * @see ::MBG_GPIO_VIDEO_FORMAT_MASKS
+ */
+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_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
+ N_MBG_GPIO_VIDEO_FORMATS ///< number of defined video formats
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_VIDEO_FORMATS
+ *
+ * Used with ::MBG_GPIO_VIDEO_OUT_SUPP::supp_formats
+ *
+ * @see ::MBG_GPIO_VIDEO_FORMATS
+ */
+enum MBG_GPIO_VIDEO_FORMAT_MASKS
+{
+ MSK_MBG_GPIO_VIDEO_FORMAT_OFF = ( 1UL << MBG_GPIO_VIDEO_FORMAT_OFF ), ///< see ::MBG_GPIO_VIDEO_FORMAT_OFF
+ MSK_MBG_GPIO_VIDEO_SD_FORMAT_NTSC = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_NTSC ), ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_NTSC
+ MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL ), ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_PAL
+ 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
+};
+
+
+
+/**
+ * @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 )
+
+/**
+ * @brief A combination of bit masks for HD video formats
+ * @see ::MBG_GPIO_VIDEO_FORMAT_MASKS
+ */
+#define MBG_GPIO_VIDEO_HD_FORMATS ( MSK_MBG_GPIO_VIDEO_FORMAT_OFF | MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz | MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz | \
+ MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz | MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz )
+
+
+
+/**
+ * @brief Initializers for an array of video output name strings
+ *
+ * @see ::MBG_GPIO_VIDEO_FORMATS
+ * @see ::MBG_GPIO_VIDEO_FORMAT_MASKS
+ */
+#define MBG_GPIO_VIDEO_OUT_STRS \
+{ \
+ "OFF", \
+ "NTSC", \
+ "PAL", \
+ "720p 50 Hz", \
+ "1080i 50 Hz", \
+ "720p 59.94 Hz", \
+ "1080i 59.94 Hz" \
+}
+
+
+
+/**
+ * @brief Enumeration of flags used with video type GPIO outputs
+ */
+enum MBG_GPIO_VIDEO_OUT_FLAGS
+{
+ MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF, ///< if set, Out1: HD, Out2: SD
+ N_MBG_GPIO_VIDEO_OUT_FLAGS ///< number of known flags
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_VIDEO_OUT_FLAGS
+ *
+ * Used with ::MBG_GPIO_VIDEO_OUT_SETTINGS::flags
+ *
+ * @see ::MBG_GPIO_VIDEO_OUT_FLAGS
+ */
+enum MBG_GPIO_VIDEO_OUT_FLAG_MASKS
+{
+ MSK_MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF = ( 1UL << MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF ) ///< see ::MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF
+};
+
+
+
+/**
+ * @brief Enumeration of epochs used with video type GPIO outputs
+ *
+ * Used with ::MBG_GPIO_VIDEO_OUT_SETTINGS::epoch, and used to
+ * define ::MBG_GPIO_VIDEO_EPOCH_MASKS
+ *
+ * @see ::MBG_GPIO_VIDEO_EPOCH_MASKS
+ * @see ::MBG_GPIO_VIDEO_EPOCH_STRS
+ */
+enum MBG_GPIO_VIDEO_EPOCHS
+{
+ SMPTE_TAI_EPOCH_1970, ///< 1970-01-01 00:00:00
+ SMPTE_TAI_EPOCH_1958, ///< 1958-01-01 00:00:00
+ SMPTE_UTC_EPOCH_1972, ///< 1972-01-01 00:00:00
+ SMPTE_GPS_EPOCH_1980, ///< 1980-01-06 00:00:00
+ N_MBG_GPIO_VIDEO_EPOCHS ///< number of known epochs
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_VIDEO_EPOCHS
+ *
+ * Used with :: MBG_GPIO_VIDEO_OUT_SUPP::supp_epochs
+ *
+ * @see ::MBG_GPIO_VIDEO_EPOCHS
+ */
+enum MBG_GPIO_VIDEO_EPOCH_MASKS
+{
+ MSK_SMPTE_TAI_EPOCH_1970 = ( 1UL << SMPTE_TAI_EPOCH_1970 ), ///< see ::SMPTE_TAI_EPOCH_1970
+ MSK_SMPTE_TAI_EPOCH_1958 = ( 1UL << SMPTE_TAI_EPOCH_1958 ), ///< see ::SMPTE_TAI_EPOCH_1958
+ MSK_SMPTE_UTC_EPOCH_1972 = ( 1UL << SMPTE_UTC_EPOCH_1972 ), ///< see ::SMPTE_UTC_EPOCH_1972
+ MSK_SMPTE_GPS_EPOCH_1980 = ( 1UL << SMPTE_GPS_EPOCH_1980 ) ///< see ::SMPTE_GPS_EPOCH_1980
+};
+
+
+
+/**
+ * @brief Initializers for an array of video epoch strings
+ *
+ * @see ::MBG_GPIO_VIDEO_EPOCHS
+ */
+#define MBG_GPIO_VIDEO_EPOCH_STRS \
+{ \
+ "TAI D1970-01-01 T00:00:00", \
+ "TAI D1958-01-01 T00:00:00", \
+ "UTC D1972-01-01 T00:00:00", \
+ "GPS D1980-01-06 T00:00:00" \
+}
+
+
+
+/**
+ * @brief Configuration of a GPIO as video output module
+ *
+ * Used as sub-structure of ::MBG_GPIO_SETTINGS.
+ *
+ * @see ::MBG_GPIO_TYPE_VIDEO_OUT
+ * @see ::MBG_GPIO_SETTINGS
+ */
+typedef struct
+{
+ uint32_t format; ///< video format, see ::MBG_GPIO_VIDEO_FORMATS
+ uint32_t flags; ///< flags, see ::MBG_GPIO_VIDEO_OUT_FLAG_MASKS
+ int32_t phase_offset; ///< Phase offset in [ns]
+ uint8_t epoch; ///< epoch, see ::MBG_GPIO_VIDEO_EPOCHS
+ uint8_t reserved2; ///< reserved, currently always 0
+ uint16_t reserved3; ///< reserved, currently always 0
+ uint32_t reserved0; ///< reserved, currently always 0
+ uint32_t reserved1; ///< reserved, currently always 0
+
+} MBG_GPIO_VIDEO_OUT_SETTINGS;
+
+
+
+/**
+ * @brief Supported options of a video type GPIO output
+ *
+ * Used as sub-structure of ::MBG_GPIO_LIMITS.
+ *
+ * @see ::MBG_GPIO_TYPE_VIDEO_OUT
+ * @see ::MBG_GPIO_LIMITS
+ */
+typedef struct
+{
+ uint32_t supp_formats; ///< supported video formats, see ::MBG_GPIO_VIDEO_FORMAT_MASKS
+ uint32_t supp_flags; ///< supported flags, see::MBG_GPIO_VIDEO_OUT_FLAG_MASKS
+ uint32_t supp_epochs; ///< supported epochs, see::MBG_GPIO_VIDEO_EPOCH_MASKS
+ uint32_t reserved1; ///< reserved, currently always 0
+
+} MBG_GPIO_VIDEO_OUT_SUPP;
+
+
+
+/**
+ * @brief Enumeration of types used with video sync GPIO outputs
+ * Depends on configured video output
+ */
+enum MBG_GPIO_VIDEO_SYNC_TYPES
+{
+ MBG_GPIO_VIDEO_SYNC_TYPE_OFF, ///< Output Off
+ MBG_GPIO_VIDEO_SYNC_TYPE_SD_HSYNC, ///< SD horizontal sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_SD_VSYNC, ///< SD vertical sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_SD_FRAME, ///< SD frame/field sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_SD_BLANK, ///< SD blanking interval
+ MBG_GPIO_VIDEO_SYNC_TYPE_HD_HSYNC, ///< HD horizontal sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_HD_VSYNC, ///< HD vertical sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_HD_FRAME, ///< HD frame/field sync
+ MBG_GPIO_VIDEO_SYNC_TYPE_HD_BLANK, ///< HD blanking interval
+ N_MBG_GPIO_VIDEO_SYNC_TYPES ///< number of known types
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_VIDEO_SYNC_TYPES
+ *
+ * Used with ::MBG_GPIO_VIDEO_SYNC_OUT_SUPP::supp_types
+ *
+ * @see ::MBG_GPIO_VIDEO_SYNC_TYPES
+ */
+enum MBG_GPIO_VIDEO_SYNC_TYPE_MASKS
+{
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_OFF = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_OFF ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_HSYNC = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_SD_HSYNC ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_VSYNC = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_SD_VSYNC ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_FRAME = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_SD_FRAME ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_BLANK = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_SD_BLANK ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_HSYNC = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_HD_HSYNC ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_VSYNC = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_HD_VSYNC ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_FRAME = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_HD_FRAME ),
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_BLANK = ( 1UL << MBG_GPIO_VIDEO_SYNC_TYPE_HD_BLANK )
+};
+
+
+
+/**
+ * @brief Initializers for an array of video sync output name strings
+ *
+ * @see ::MBG_GPIO_VIDEO_SYNC_TYPES
+ * @see ::MBG_GPIO_VIDEO_SYNC_TYPE_MASKS
+ */
+#define MBG_GPIO_VIDEO_SYNC_OUT_STRS \
+{ \
+ "OFF", \
+ "SD H-Sync", \
+ "SD V-Sync", \
+ "SD Frame", \
+ "SD Blank", \
+ "HD H-Sync", \
+ "HD V-Sync", \
+ "HD Frame", \
+ "HD Blank" \
+}
+
+
+
+/**
+ * @brief A combination of bit masks for SD video sync types
+ * @see ::MBG_GPIO_VIDEO_SYNC_TYPE_MASKS
+ */
+#define MBG_GPIO_VIDEO_SYNC_SD_TYPES ( MSK_MBG_GPIO_VIDEO_SYNC_TYPE_OFF | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_HSYNC | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_VSYNC | \
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_FRAME | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_SD_BLANK )
+
+/**
+ * @brief A combination of bit masks for HD video sync types
+ * @see ::MBG_GPIO_VIDEO_SYNC_TYPE_MASKS
+ */
+#define MBG_GPIO_VIDEO_SYNC_HD_TYPES ( MSK_MBG_GPIO_VIDEO_SYNC_TYPE_OFF | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_HSYNC | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_VSYNC | \
+ MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_FRAME | MSK_MBG_GPIO_VIDEO_SYNC_TYPE_HD_BLANK )
+
+
+
+/**
+ * @brief Configuration of a GPIO as sync output module
+ *
+ * Used as sub-structure of ::MBG_GPIO_SETTINGS.
+ *
+ * @see ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT
+ * @see ::MBG_GPIO_SETTINGS
+ */
+typedef struct
+{
+ uint32_t type; ///< sync type, see :: MBG_GPIO_SYNC_TYPES
+ uint32_t flags; ///< flags, currently always 0
+ uint32_t reserved0; ///< reserved, currently always 0
+ uint32_t reserved1; ///< reserved, currently always 0
+ uint32_t reserved2; ///< reserved, currently always 0
+ uint32_t reserved3; ///< reserved, currently always 0
+
+} MBG_GPIO_VIDEO_SYNC_OUT_SETTINGS;
+
+
+
+/**
+ * @brief Supported options of a sync type GPIO output
+ *
+ * Used as sub-structure of ::MBG_GPIO_LIMITS.
+ *
+ * @see ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT
+ * @see ::MBG_GPIO_LIMITS
+ */
+typedef struct
+{
+ uint32_t supp_types; ///< supported types, see ::MBG_GPIO_VIDEO_SYNC_TYPE_MASKS
+ uint32_t supp_flags; ///< supported flags, currently always 0
+ uint32_t reserved0; ///< reserved, currently always 0
+ uint32_t reserved1; ///< reserved, currently always 0
+
+} MBG_GPIO_VIDEO_SYNC_OUT_SUPP;
+
+
+
+/**
+ * @brief Enumeration of studio clock base frequencies
+ *
+ * Used with ::MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS::base_freq
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_MASKS
+ */
+enum MBG_GPIO_STUDIO_CLOCK_BASE_FREQS
+{
+ MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ, ///< 32 kHz base frequency
+ MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ, ///< 44.1 kHz base frequency
+ MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ, ///< 48 kHz base frequency
+ N_MBG_GPIO_STUDIO_CLOCK_BASE_FREQS ///< number of defined base frequencies
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQS
+ *
+ * Used with ::MBG_GPIO_STUDIO_CLOCK_OUT_SUPP::supp_base_freqs
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQS
+ */
+enum MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_MASKS
+{
+ MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ ), ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ
+ MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ ), ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ
+ MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ ) ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ
+};
+
+
+
+/**
+ * @brief Initializers for an array of base frequencies of studio clock output name strings
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQS
+ * @see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_MASKS
+ */
+#define MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_STRS \
+{ \
+ "32 kHz", \
+ "44.1 kHz", \
+ "48 kHz" \
+}
+
+
+
+/**
+ * @brief Enumeration of studio clock scales
+ *
+ * Used with ::MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS::scale
+ * Multiply scale with base frequency
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_SCALE_MASKS
+ */
+enum MBG_GPIO_STUDIO_CLOCK_SCALES
+{
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_1,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_2,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_4,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_8,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_16,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_32,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_64,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_128,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_256,
+ MBG_GPIO_STUDIO_CLOCK_SCALE_512,
+ N_MBG_GPIO_STUDIO_CLOCK_SCALES ///< number of defined scales
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_STUDIO_CLOCK_SCALES
+ *
+ * Used with ::MBG_GPIO_STUDIO_CLOCK_OUT_SUPP::supp_scales[N_MBG_GPIO_STUDIO_CLOCK_BASE_FREQS]
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_SCALES
+ */
+enum MBG_GPIO_STUDIO_CLOCK_SCALE_MASKS
+{
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_2 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_2
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_4 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_4
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_8 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_8
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_16 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_16
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_32 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_32
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_64 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_64 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_64
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_128 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_128 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_128
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_256 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_256 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_256
+ MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_512 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_512 ) ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_512
+};
+
+
+
+/**
+ * @brief Initializers for an array of scales of studio clock output name strings
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_SCALES
+ * @see ::MBG_GPIO_STUDIO_CLOCK_SCALE_MASKS
+ */
+#define MBG_GPIO_STUDIO_CLOCK_SCALE_STRS \
+{ \
+ "1/32", \
+ "1/16", \
+ "1/8", \
+ "1/4", \
+ "1/2", \
+ "1", \
+ "2", \
+ "4", \
+ "8", \
+ "16", \
+ "32", \
+ "64", \
+ "128", \
+ "256", \
+ "512" \
+}
+
+
+
+/**
+ * @brief Enumeration of flags used with studio clock type GPIO outputs
+ */
+enum MBG_GPIO_STUDIO_CLOCK_FLAGS
+{
+ MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED, ///< if set, enables output
+ N_MBG_GPIO_STUDIO_CLOCK_FLAGS ///< number of known flags
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::MBG_GPIO_STUDIO_CLOCK_FLAGS
+ *
+ * Used with ::MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS::flags
+ *
+ * @see ::MBG_GPIO_STUDIO_CLOCK_FLAGS
+ */
+enum MBG_GPIO_STUDIO_CLOCK_FLAG_MASKS
+{
+ MSK_MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED = ( 1UL << MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED ) ///< see ::MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED
+};
+
+
+
+/**
+ * @brief Configuration of a GPIO as studio clock output module
+ *
+ * Used as sub-structure of ::MBG_GPIO_SETTINGS.
+ *
+ * @see ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT
+ * @see ::MBG_GPIO_SETTINGS
+ */
+typedef struct
+{
+ uint32_t base_freq; ///< base frequency, see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQS
+ uint32_t scale; ///< scale, see ::MBG_GPIO_STUDIO_CLOCK_SCALES
+ uint32_t flags; ///< flags, see ::MBG_GPIO_STUDIO_CLOCK_FLAGS
+ uint32_t reserved0; ///< reserved, currently always 0
+ uint32_t reserved1; ///< reserved, currently always 0
+
+} MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS;
+
+
+#define MAX_SUPP_BASE_FREQUENCIES 8 ///< max. supported base frequencies for studio clock outputs
+
+/**
+ * @brief Configuration of a GPIO as studio clock output module
+ *
+ * Used as sub-structure of ::MBG_GPIO_LIMITS.
+ *
+ * @see ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT
+ * @see ::MBG_GPIO_LIMITS
+ */
+typedef struct
+{
+ uint8_t supp_base_freqs; ///< supported base frequencies, see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_MASKS
+ uint8_t reserved0; ///< reserved, currently always 0
+ uint16_t reserved1; ///< reserved, currently always 0
+ uint16_t supp_scales[MAX_SUPP_BASE_FREQUENCIES]; ///< supported scales for each base frequency, see ::MBG_GPIO_STUDIO_CLOCK_SCALE_MASKS
+ uint32_t supp_flags; ///< supported flags, see::MBG_GPIO_STUDIO_CLOCK_FLAG_MASKS
+ uint32_t reserved2; ///< reserved, currently always 0
+
+} MBG_GPIO_STUDIO_CLOCK_OUT_SUPP;
+
+
+
+/**
* @brief A generic structure used to hold a GPIO port's settings
*/
typedef struct
@@ -6259,11 +8071,14 @@ typedef struct
/// 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_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
} u;
} MBG_GPIO_SETTINGS;
@@ -6294,11 +8109,14 @@ typedef struct
/// limits depending on the GPIO type, see ::MBG_GPIO_TYPES
union
{
- MBG_GPIO_FREQ_IN_SUPP freq_in; ///< if type is ::MBG_GPIO_TYPE_FREQ_IN
- MBG_GPIO_FREQ_OUT_SUPP freq_out; ///< if type is ::MBG_GPIO_TYPE_FREQ_OUT
- MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; ///< if type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT
- MBG_GPIO_BITS_IN_SUPP bits_in; ///< if type is ::MBG_GPIO_TYPE_BITS_IN
- MBG_GPIO_BITS_OUT_SUPP bits_out; ///< if type is ::MBG_GPIO_TYPE_BITS_OUT
+ 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
} u;
} MBG_GPIO_LIMITS;
@@ -6755,7 +8573,7 @@ typedef struct
uint8_t slot_id; ///< slot number on the chassis
uint16_t num_sensors; ///< number of sensors provided by the device
uint32_t reserved; ///< reserved, currently always 0
- uint32_t flags; ///< unused, currently always 0
+ uint32_t flags; ///< see ::MBG_IMS_STATE_FLAG_MASKS
} MBG_IMS_STATE;
@@ -6769,6 +8587,30 @@ typedef struct
/**
+ * @brief Enumeration of bits used to define ::MBG_IMS_STATE_FLAG_MASKS
+ *
+ * @see ::MBG_IMS_STATE_FLAG_MASKS
+ */
+enum MBG_IMS_STATE_FLAG_BITS
+{
+ MBG_IMS_STATE_FLAG_BIT_HAS_FDM, ///< device supports FDM API
+ N_MBG_IMS_STATE_FLAG_BITS
+};
+
+
+/**
+ * @brief Bit masks used with ::MBG_IMS_STATE::flags
+ *
+ * @see ::MBG_IMS_STATE_FLAG_BITS
+ */
+enum MBG_IMS_STATE_FLAG_MASKS
+{
+ MBG_IMS_STATE_FLAG_MSK_HAS_FDM = ( 1UL << MBG_IMS_STATE_FLAG_BIT_HAS_FDM ) ///< see ::MBG_IMS_STATE_FLAG_BIT_HAS_FDM
+};
+
+
+
+/**
* @brief Generic state of an IMS sensor
*/
typedef struct
@@ -6813,6 +8655,8 @@ typedef struct
/**
* @brief IMS sensor types
+ *
+ * Used with ::MBG_IMS_SENSOR_STATE::type
*/
enum MBG_IMS_SENSORS
{
@@ -6824,16 +8668,423 @@ enum MBG_IMS_SENSORS
-// Definitions used with ::MBG_IMS_SENSOR_STATE::flags:
+/**
+ * @brief IMS sensor state flags for voltage
+ *
+ * Used with ::MBG_IMS_SENSOR_STATE::flags in case ::MBG_IMS_SENSOR_STATE::type
+ * is ::MBG_IMS_SENSOR_VOLTAGE.
+ */
+enum MBG_IMS_SENSOR_STATE_FLAG_MASK_VOLTAGE
+{
+ MBG_IMS_SENSOR_VOLTAGE_OUT_ENB = 0x01, ///< output is enabled
+ MBG_IMS_SENSOR_VOLTAGE_OUT_OVR = 0x02 ///< output overload
+};
+
+
+/**
+ * @brief IMS sensor state flags for PLL
+ *
+ * Used with ::MBG_IMS_SENSOR_STATE::flags in case ::MBG_IMS_SENSOR_STATE::type
+ * is ::MBG_IMS_SENSOR_PLL.
+ */
+enum MBG_IMS_SENSOR_STATE_FLAG_MASK_PLL
+{
+ MBG_IMS_SENSOR_PLL_LOCKED = 0x01 ///< PLL is locked
+};
+
+
+
+/**
+ * @brief DAC limit specs
+ */
+typedef struct
+{
+ int32_t dac_val_min; ///< min. possible DAC Value, positive or negative
+ int32_t dac_val_max; ///< max. possible DAC Value, positive or negative
+
+ int32_t u_min; ///< min. possible real voltage range [mV], positive or negative, depending on ::MBG_DAC_SPECS::dac_val_min
+ int32_t u_max; ///< max. possible real voltage range [mV], positive or negative, depending on ::MBG_DAC_SPECS::dac_val_max
-// if ::MBG_IMS_SENSOR_STATE::type == ::MBG_IMS_SENSOR_VOLTAGE
-#define MBG_IMS_SENSOR_VOLTAGE_OUT_ENB 0x01 // output is enabled
-#define MBG_IMS_SENSOR_VOLTAGE_OUT_OVR 0x02 // output overload
+ uint32_t reserved_0; ///< reserved, currently always 0
+ uint32_t reserved_1; ///< reserved, currently always 0
-// if ::MBG_IMS_SENSOR_STATE::type == ::MBG_IMS_SENSOR_PLL
-#define MBG_IMS_SENSOR_PLL_LOCKED 0x01
+} MBG_DAC_SPECS;
+
+#define _mbg_swab_mbg_dac_specs( _p ) \
+{ \
+ _mbg_swab32( &(_p)->dac_val_min ); \
+ _mbg_swab32( &(-p)->dac_val_max ); \
+ _mbg_swab32( &(_P)->u_min ); \
+ _mbg_swab32( &(_p)->u_max ); \
+ _mbg_swab32( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+}
+
+
+
+/**
+ * @brief Output state of FDM device.
+ *
+ * @note This is only supported if ::MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in ::MBG_IMS_STATE::flags
+ */
+typedef struct
+{
+ int32_t dac_val; ///< current DAC value, positive or negative
+ uint32_t mode; ///< current output mode, see ::MBG_IMS_FDM_OUTPUT_MODES
+
+ MBG_DAC_SPECS dac_specs; ///< DAC specific limits
+
+ uint32_t reserved_0; ///< reserved, currently always 0
+ uint32_t reserved_1; ///< reserved, currently always 0
+
+} MBG_IMS_FDM_OUTPUT_STATE;
+
+#define _mbg_swab_mbg_ims_fdm_output_state( _p ) \
+{ \
+ _mbg_swab32( &(_p)->dac_val ); \
+ _mbg_swab32( &(_p)->mode ); \
+ _mbg_swab_mbg_dac_specs( &(_p)->dac_specs ); \
+ _mbg_swab32( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+}
+
+
+/**
+ * @brief Output state of FDM device plus index.
+ */
+typedef struct
+{
+ uint32_t idx;
+ MBG_IMS_FDM_OUTPUT_STATE state;
+
+} MBG_IMS_FDM_OUTPUT_STATE_IDX;
+
+#define _mbg_swab_mbg_ims_fdm_output_state_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_mbg_ims_fdm_output_state( &(_p)->state ); \
+}
+
+
+
+/**
+ * @brief Output settings of FDM device
+ *
+ * @note This is only supported if ::MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in ::MBG_IMS_STATE::flags
+ */
+typedef struct
+{
+ uint32_t mode; ///< mode, see ::MBG_IMS_FDM_OUTPUT_MODES
+ uint32_t reserved; ///< reserved, currently always 0
+
+} MBG_IMS_FDM_OUTPUT_SETTINGS;
+
+#define _mbg_swab_mbg_ims_fdm_output_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->mode ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+
+/**
+ * @brief Output settings for FDM devices plus index.
+ */
+typedef struct
+{
+ uint32_t idx;
+ MBG_IMS_FDM_OUTPUT_SETTINGS settings;
+
+} MBG_IMS_FDM_OUTPUT_SETTINGS_IDX;
+
+#define _mbg_swab_mbg_ims_fdm_output_settings_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_mbg_ims_fdm_output_settings( &(_p)->settings ); \
+}
+
+
+
+/**
+ * @brief Specific output settings and limits.
+ */
+typedef struct
+{
+ MBG_IMS_FDM_OUTPUT_SETTINGS settings; ///< current settings
+ uint32_t supp_modes; ///< supported modes, see ::MBG_IMS_FDM_OUTPUT_MODE_MASKS
+ MBG_DAC_SPECS dac_specs; ///< DAC specific limits
+
+} MBG_IMS_FDM_OUTPUT_INFO;
+
+#define _mbg_swab_mbg_ims_fdm_output_info( _p ) \
+{ \
+ _mbg_swab_mbg_ims_fdm_output_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_modes ); \
+ _mbg_swab_mbg_dac_specs( &(_p)->dac_specs ); \
+}
+
+
+
+/**
+ * @brief Specific output settings and limits, plus index.
+ */
+typedef struct
+{
+ uint32_t idx;
+ MBG_IMS_FDM_OUTPUT_INFO info;
+
+} MBG_IMS_FDM_OUTPUT_INFO_IDX;
+
+#define _mbg_swab_mbg_ims_fdm_output_info_idx( _p ) \
+{ \
+ _mbg_swab32( &(_p)->idx ); \
+ _mbg_swab_mbg_ims_fdm_output_info( &(_p)->info ); \
+}
+
+
+
+/**
+ * @brief Enumeration of known output modes
+ *
+ * Used with ::MBG_IMS_FDM_OUTPUT_STATE::mode
+ *
+ * @see ::MBG_IMS_FDM_OUTPUT_MODE_MASKS
+ */
+enum MBG_IMS_FDM_OUTPUT_MODES
+{
+ MBG_IMS_FDM_OUTPUT_MODE_FD, ///< Analog output reflects frequency deviation
+ MBG_IMS_FDM_OUTPUT_MODE_TD, ///< Analog output reflects time deviation
+ N_MBG_IMS_FDM_OUTPUT_MODES ///< Number of known output modes
+};
+
+
+
+/**
+ * @brief Bit masks used with ::MBG_IMS_FDM_OUTPUT_STATE::mode
+ *
+ * @see ::MBG_IMS_FDM_OUTPUT_MODES
+ */
+enum MBG_IMS_FDM_OUTPUT_MODE_MASKS
+{
+ MBG_IMS_FDM_OUTPUT_MODE_MSK_FD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_FD ), ///< see ::MBG_IMS_FDM_OUTPUT_MODE_FD
+ MBG_IMS_FDM_OUTPUT_MODE_MSK_TD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_TD ) ///< see ::MBG_IMS_FDM_OUTPUT_MODE_TD
+};
+
+
+
+/**
+ * @brief A generic structure used to specify FDM limits
+ */
+typedef struct
+{
+ uint8_t n_outputs; ///< number of outputs per module
+ uint8_t reserved_0; ///< reserved, currently always 0
+ uint16_t reserved_1; ///< reserved, currently always 0
+
+ uint32_t fd_neg_limit; ///< min. frequency deviation limit, 1/::MBG_IMS_FDM_LIMITS::fd_scale Hz units
+ uint32_t fd_pos_limit; ///< max. frequency deviation limit, 1/::MBG_IMS_FDM_LIMITS::fd_scale Hz units
+ uint32_t fd_scale; ///< scale for ::MBG_IMS_FDM_LIMITS::fd_neg_limit and ::MBG_IMS_FDM_LIMITS::fd_pos_limit
+
+ uint32_t td_neg_limit; ///< min. time deviation limit, 1/::MBG_IMS_FDM_LIMITS::td_scale s units
+ uint32_t td_pos_limit; ///< max. time deviation limit, 1/::MBG_IMS_FDM_LIMITS::td_scale s units
+ uint32_t td_scale; ///< scale for ::MBG_IMS_FDM_LIMITS::td_neg_limit and ::MBG_IMS_FDM_LIMITS::td_pos_limit
+
+ uint32_t reserved_2; ///< reserved, currently always 0
+
+} MBG_IMS_FDM_LIMITS;
+
+#define _mbg_swab_mbg_ims_fdm_limits( _p ) \
+{ \
+ _mbg_swab8( &(_p)->n_outputs ); \
+ _mbg_swab8( &(_p)->reserved_0 ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->fd_min ); \
+ _mbg_swab32( &(_p)->fd_max ); \
+ _mbg_swab32( &(_p)->td_min ); \
+ _mbg_swab32( &(_p)->td_max ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief State of FDM device
+ *
+ * @note This is only supported if ::MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in ::MBG_IMS_STATE::flags.
+ *
+ */
+typedef struct
+{
+ MBG_GPIO_FREQ freq; ///< Current frequency
+
+ NANO_TIME_64 t_ref; ///< Current reference time
+ NANO_TIME_64 t_plt; ///< Current power line time
+ NANO_TIME_64 t_sync; ///< Last sync Time (reference time)
+
+ uint32_t line_freq; ///< Nominal line frequency, see ::MBG_IMS_FDM_LINE_FREQS
+ uint32_t flags; ///< Flags, see ::MBG_IMS_FDM_STATE_FLAG_MASKS
+ uint32_t reserved; ///< Reserved, currently always 0
+
+} MBG_IMS_FDM_STATE;
+
+#define _mbg_swab_mbg_ims_fdm_state( _p ) \
+{ \
+ _mbg_swab_mbg_gpio_freq( &(_p)->freq ); \
+ _mbg_swab_nano_time_64( &(_p)->t_ref ); \
+ _mbg_swab_nano_time_64( &(_p)->t_plt ); \
+ _mbg_swab_nano_time_64( &(_p)->t_sync ); \
+ _mbg_swab32( &(_p)->line_freq ); \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+/**
+ * @brief Enumeration known line frequencies
+ *
+ * Used with ::MBG_IMS_FDM_STATE::line_freq
+ *
+ * @see ::MBG_IMS_FDM_LINE_FREQ_MASKS
+ */
+enum MBG_IMS_FDM_LINE_FREQS
+{
+ MBG_IMS_FDM_LINE_FREQ_AUTO, ///< Auto detect line frequency
+ MBG_IMS_FDM_LINE_FREQ_50HZ, ///< 50Hz line frequency
+ MBG_IMS_FDM_LINE_FREQ_60HZ, ///< 60Hz line frequency
+ N_MBG_IMS_FDM_LINE_FREQS ///< number of known line frequencies
+};
+
+
+/**
+ * @brief Bit masks corresponding to defined line frequencies
+ *
+ * @see ::MBG_IMS_FDM_LINE_FREQS
+ */
+enum MBG_IMS_FDM_LINE_FREQ_MASKS
+{
+ MBG_IMS_FDM_LINE_FREQ_MSK_AUTO = ( 1UL << MBG_IMS_FDM_LINE_FREQ_AUTO ), ///< see ::MBG_IMS_FDM_LINE_FREQ_AUTO
+ MBG_IMS_FDM_LINE_FREQ_MSK_50HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_50HZ ), ///< see ::MBG_IMS_FDM_LINE_FREQ_50HZ
+ MBG_IMS_FDM_LINE_FREQ_MSK_60HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_60HZ ) ///< see ::MBG_IMS_FDM_LINE_FREQ_60HZ
+};
+
+
+/**
+ * @brief Initializers for an array of line freq. name strings
+ *
+ * @see ::MBG_IMS_FDM_LINE_FREQS
+ */
+#define MBG_IMS_FDM_LINE_FREQ_STRS \
+{ \
+ "Auto", \
+ "50 Hz", \
+ "60 Hz", \
+}
+
+
+/**
+ * @brief Enumeration of flag bits used to define ::MBG_IMS_FDM_STATE_FLAG_MASKS
+ */
+enum MBG_IMS_FDM_STATE_FLAG_BITS
+{
+ MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET, ///< if sync'ed after reset
+ MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED, ///< Power Line Time is locked
+ MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW, ///< Frequency deviation overflow occurred
+ MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW, ///< Time deviation overflow occurred
+ N_MBG_IMS_FDM_STATE_FLAG_BITS ///< number of known state flag bits
+};
+
+
+/**
+ * @brief Bit masks used with ::MBG_IMS_FDM_STATE::flags
+ *
+ * @see ::MBG_IMS_FDM_STATE_FLAG_BITS
+ */
+enum MBG_IMS_FDM_STATE_FLAG_MASKS
+{
+ MBG_IMS_FDM_STATE_FLAG_MSK_SYNC_AFTER_RESET = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET
+ MBG_IMS_FDM_STATE_FLAG_MSK_PLT_IS_LOCKED = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED
+ MBG_IMS_FDM_STATE_FLAG_MSK_FD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW
+ MBG_IMS_FDM_STATE_FLAG_MSK_TD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW ) ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW
+};
+
+
+
+/**
+ * @brief FDM device settings
+ *
+ * @note This is only supported if ::MBG_IMS_STATE_FLAG_BIT_HAS_FDM is set in ::MBG_IMS_STATE::flags.
+ *
+ */
+typedef struct
+{
+ uint32_t fd_neg_limit; ///< min. frequency deviation limit in 1 mHz steps
+ uint32_t fd_pos_limit; ///< max. frequency deviation limit in 1 mHz steps
+
+ uint32_t td_neg_limit; ///< min. time deviation limit in 1 ms steps
+ uint32_t td_pos_limit; ///< max. time deviation limit in 1 ms steps
+
+ uint32_t line_freq; ///< nominal line frequency, see ::MBG_IMS_FDM_LINE_FREQS
+ uint32_t reserved; ///< reserved, currently always 0
+
+} MBG_IMS_FDM_SETTINGS;
+
+#define _mbg_swab_mbg_ims_fdm_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->fd_min ); \
+ _mbg_swab32( &(_p)->fd_max ); \
+ _mbg_swab32( &(_p)->td_min ); \
+ _mbg_swab32( &(_p)->td_max ); \
+ _mbg_swab32( &(_p)->mode ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+
+
+/**
+ * @brief IMS FDM flags
+ *
+ * @see ::MBG_IMS_FDM_FLAG_MASKS
+ */
+enum MBG_IMS_FDM_FLAGS
+{
+ MBG_IMS_FDM_FLAG_CAN_SET_TDEV, ///< Device supports command GPS_FDM_SET_TD
+ N_MBG_IMS_FDM_FLAGS ///< Number of known FDM flags
+};
+
+
+
+/**
+ * @brief IMS FDM flag masks
+ *
+ * @see ::MBG_IMS_FDM_FLAGS
+ */
+enum MBG_IMS_FDM_FLAG_MASKS
+{
+ MBG_IMS_FDM_FLAG_MASK_CAN_SET_TDEV = ( 1UL << MBG_IMS_FDM_FLAG_CAN_SET_TDEV ) ///< see ::MBG_IMS_FDM_FLAG_CAN_SET_TDEV
+};
+
+
+
+/**
+ * @brief Specific FDM settings and limits.
+ */
+typedef struct
+{
+ MBG_IMS_FDM_SETTINGS settings;
+ uint32_t supp_line_freqs; ///< Bit mask of supported line frequencies, see ::MBG_IMS_FDM_LINE_FREQ_MASKS
+ uint32_t reserved; ///< Reserved, currently always 0
+ uint32_t flags; ///< Flags, see ::MBG_IMS_FDM_FLAG_MASKS
+
+} MBG_IMS_FDM_INFO;
+
+#define _mbg_swab_mbg_ims_fdm_info( _p ) \
+{ \
+ _mbg_swab_mbg_ims_fdm_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_line_freqs ); \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
/** @} defgroup group_ims */
@@ -7149,7 +9400,7 @@ typedef struct
{
uint32_t gnss_set; ///< bit mask of currently used GNSS systems, see ::MBG_GNSS_TYPE_MASKS
uint8_t prio[N_GNSS_MODE_PRIO]; ///< see ::MBG_GNSS_TYPES, unused fields set to 0xFF, idx 0 is highest prio
- uint32_t flags; ///< see ::MBG_GNSS_MODE_FLAG_MASKS
+ uint32_t flags; ///< unused, currently always 0 // ### TODO or see ::MBG_GNSS_MODE_FLAG_MASKS ?
} MBG_GNSS_MODE_SETTINGS;
@@ -7178,21 +9429,21 @@ typedef struct
/**
- * @brief Flag bits used with ::MBG_GNSS_MODE_SETTINGS and ::MBG_GNSS_MODE_INFO
+ * @brief Flag bits used to define ::MBG_GNSS_MODE_FLAG_MASKS
*
* @see ::MBG_GNSS_MODE_FLAG_MASKS
*/
enum MBG_GNSS_MODE_FLAG_BITS
{
MBG_GNSS_FLAG_EXCLUSIVE, ///< (read only) only one of the supported GNSS systems can be used at the same time
- MBG_GNSS_FLAG_HAS_PRIORITY, ///< (read only) priority can be configured using the MBG_GNSS_MODE_SETTINGS::prio field
- MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER, ///< (read only)
+ MBG_GNSS_FLAG_HAS_PRIORITY, ///< (read only) priority can be configured using the ::MBG_GNSS_MODE_SETTINGS::prio field
+ MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER, ///< (read only) the ::GNSS_SAT_INFO_IDX structure is supported by the device
N_MBG_GNSS_FLAGS
};
/**
- * @brief Flag masks used with MBG_GNSS_MODE_SETTINGS::flags and MBG_GNSS_MODE_INFO::flags
+ * @brief Flag masks used with MBG_GNSS_MODE_INFO::flags
*
* @see ::MBG_GNSS_MODE_FLAG_BITS
*/
@@ -7236,7 +9487,13 @@ typedef struct
*/
typedef struct
{
- uint16_t idx; ///< GNSS system type index
+ /// GNSS system type index according to ::MBG_GNSS_MODE_INFO::supp_gnss_types.
+ /// I.e., idx 0 corresponds to the GNSS system for which the least significant
+ /// bit is set in ::MBG_GNSS_MODE_INFO::supp_gnss_types, idx 1 corresponds to
+ /// GNSS system for which the next higher bit is set, etc. This must *not*
+ /// necessarily match the sequence of the ::MBG_GNSS_TYPES enumeration.
+ uint16_t idx;
+
GNSS_SAT_INFO gnss_sat_info; ///< see ::GNSS_SAT_INFO
} GNSS_SAT_INFO_IDX;
@@ -7297,6 +9554,9 @@ typedef struct
} MBG_MAC_ADDR;
+#define _mbg_swab_mbg_mac_addr( _p ) \
+ _nop_macro_fnc();
+
/**
@@ -7320,12 +9580,25 @@ typedef uint32_t IP4_ADDR;
*/
typedef struct
{
- uint8_t b[IP6_ADDR_BYTES]; ///< bytes holding the address bits, b[0] == LSBs
+ uint8_t b[IP6_ADDR_BYTES]; ///< bytes holding the address bits (not the string notation), b[0] == LSBs
} IP6_ADDR;
+/**
+ * @brief An IPv6 address plus number of netmask bits
+ */
+typedef struct
+{
+ IP6_ADDR addr; ///< bit mask of the bytes holding the address bits, b[0] == LSBs
+ uint8_t prefix; ///< Number of subnet mask bits for CIDR notation, e.g. 24 for /24
+ uint8_t reserved[3]; ///< Reserved, alignment, currently 0
+
+} IP6_ADDR_CIDR;
+
+
+
/** @brief The max number of chars required for an IPv6 address string */
#define MAX_IP6_ADDR_STR_LEN 43 ///< e.g. 2001:0db8:85a3:08d3:1319:8a2e:0370:7344/128
@@ -7336,18 +9609,78 @@ typedef struct
typedef char IP6_ADDR_STR[IP6_ADDR_STR_SIZE];
+
/**
- * @brief A host's fully qualified domain name (FQDN), or a numeric IP address string
+ * @brief Possible IPv6 Multicast Scopes
+ *
+ * If the first (most significant) byte of an IPv6 address is 0xFF this
+ * indicates that the address is a multicast address, and in this case
+ * the second byte determines the scope for which the specified address
+ * is valid. These scope ID numbers are assigned in RFC 7346 which
+ * supersedes RFC 4291.
+ *
+ * @see ::IPV6_MULTICAST_SCOPE_NAME_TABLE_ENTRIES
+ */
+enum IPV6_MULTICAST_SCOPES
+{
+ IPV6_MULTICAST_SCOPE_INTF_LOCAL = 0x01, ///< Interface-Local scope
+ IPV6_MULTICAST_SCOPE_LINK_LOCAL, ///< Link-Local scope
+ IPV6_MULTICAST_SCOPE_REALM_LOCAL, ///< Realm-Local scope
+ IPV6_MULTICAST_SCOPE_ADMIN_LOCAL, ///< Admin-Local scope
+ IPV6_MULTICAST_SCOPE_SITE_LOCAL, ///< Site-Local scope
+ IPV6_MULTICAST_SCOPE_ORGA_LOCAL = 0x08, ///< Organization-Local scope
+ IPV6_MULTICAST_SCOPE_GLOBAL_SCOPE = 0x0E ///< Global scope
+};
+
+
+/**
+ * @brief Name strings for IPv6 multicast scopes
+ *
+ * This can e.g. be used to initialize an array of ::MBG_CODE_NAME_TABLE_ENTRY elements.
+ *
+ * @see ::IPV6_MULTICAST_SCOPES
+ */
+#define IPV6_MULTICAST_SCOPE_NAME_TABLE_ENTRIES \
+{ \
+ { IPV6_MULTICAST_SCOPE_INTF_LOCAL, "FF01 - Interface-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_LINK_LOCAL, "FF02 - Link-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_REALM_LOCAL, "FF03 - Realm-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_ADMIN_LOCAL, "FF04 - Admin-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_SITE_LOCAL, "FF05 - Site-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_ORGA_LOCAL, "FF08 - Organization-Local Scope" }, \
+ { IPV6_MULTICAST_SCOPE_GLOBAL_SCOPE, "FF0E - Global Scope" }, \
+ { 0, NULL } \
+}
+
+
+
+/**
+ * @brief The maximum length of a fully qualified host/domain domain name (FQDN)
*
* In theory each single component (host name, domain name, top level domain name)
* of a FQDN can have up to 63 characters, but the overall length is limited to
- * 255 characters. We specify one more character for the trailing 0.
+ * 255 characters (see RFC-1123). We specify one more character for the trailing 0.
+ */
+#define MBG_MAX_HOSTNAME_LEN 256
+
+
+/**
+ * @brief A buffer for a fully qualified domain name (FQDN) or a numeric IP address string
*/
-typedef char MBG_HOSTNAME[256]; ///< ASCIIZ format
+typedef char MBG_HOSTNAME[MBG_MAX_HOSTNAME_LEN]; ///< ASCIIZ format
/** @} defgroup group_net_basic_types */
+/**
+ * @brief The maximum length of an interface name
+ *
+ * We use an extra name here for the Meinberg-specific structures
+ * to avoid a name clash with system definitions, e.g. Linux systems
+ * define IFNAMSIZ usually as 16 in linux/if.h.
+ */
+#define MBG_IFNAMSIZ 16
+
/**
* @defgroup group_vlan_cfg Definitions used with VLAN configuration
@@ -7481,10 +9814,20 @@ enum LAN_IF_TYPES
*/
enum MBG_IP4_FLAG_BITS
{
- IP4_BIT_DHCP, ///< DHCP supported (::LAN_IF_INFO) / enabled (::IP4_SETTINGS)
- IP4_BIT_LINK, ///< only used in ::IP4_SETTINGS to report link state
- IP4_BIT_VLAN, ///< VLAN supported (::LAN_IF_INFO) / enabled (::IP4_SETTINGS)
- N_IP4_BIT ///< number of defined flag bits
+ /// In ::LAN_IF_INFO::flags this reports if DHCP is supported by the device.
+ /// If supported then it can also be used with ::IP4_SETTINGS::flags to enable
+ /// or disable DHCP for the network interface.
+ IP4_BIT_DHCP,
+
+ /// Only used with ::IP4_SETTINGS::flags. Set if port link has been established.
+ IP4_BIT_LINK,
+
+ /// In ::LAN_IF_INFO::flags this reports if VLAN is supported by the device.
+ /// If supported then it can also be used with ::IP4_SETTINGS::flags to enable
+ /// or disable VLAN for the network interface.
+ IP4_BIT_VLAN,
+
+ N_IP4_BIT ///< number of defined flag bits
};
@@ -7516,7 +9859,8 @@ enum MBG_IP_ADDR_TYPES
{
MBG_IP_ADDR_TYPE_UNKNOWN,
MBG_IP_ADDR_TYPE_IP4,
- MBG_IP_ADDR_TYPE_IP6
+ MBG_IP_ADDR_TYPE_IP6,
+ N_MBG_IP_ADDR_TYPES
};
/*
@@ -7536,83 +9880,176 @@ enum MBG_IP_ADDR_TYPES
/**
- * @brief Network link speed modes
+ * @brief Network interface link speed mode enumeration
*
- * @see ::MBG_NET_LINK_MODE_MASKS
- *
- * Note: Half duplex is not supported for 10GBit
+ * @see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS
*/
-enum MBG_NET_LINK_MODES
+enum MBG_NET_INTF_LINK_SPEED_MODE
{
- MBG_NET_LINK_MODE_AUTONEG, ///< auto negotiation
- MBG_NET_LINK_MODE_10_BT_H, ///< 10 MBit half duplex
- MBG_NET_LINK_MODE_10_BT_F, ///< 10 MBit full duplex
- MBG_NET_LINK_MODE_100_BT_H, ///< 100 MBit half duplex
- MBG_NET_LINK_MODE_100_BT_F, ///< 100 MBit full duplex
- MBG_NET_LINK_MODE_1000_BT_H, ///< 1 GBit half duplex
- MBG_NET_LINK_MODE_1000_BT_F, ///< 1 GBit full duplex
- MBG_NET_LINK_MODE_10000_BT_F, ///< 10 GBit Full Duplex
- N_MBG_NET_LINK_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)
+ MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL, ///< 10baseT Full Duplex (10 MBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF, ///< 100baseT Half Duplex (100 MBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL, ///< 100baseT Full Duplex (100 MBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF, ///< 1000baseT Half Duplex (1 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL, ///< 1000baseT Full Duplex (1 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL, ///< 1000baseKX Full Duplex (1 GBit/s)
+
+ MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL, ///< 2500baseX Full Duplex (2.5 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL, ///< 10000baseT Full Duplex (10 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL, ///< 10000baseKX4 Full Duplex (10 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL, ///< 10000baseKR Full Duplex (10 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC, ///< 10000baseR FEC (forward error correction) (10 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL, ///< 20000baseMLD2 Full Duplex (20 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL, ///< 20000baseKR2 Full Duplex (20 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL, ///< 40000baseKR4 Full Duplex (40 GBit/s)
+
+ MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL, ///< 40000baseCR4 Full Duplex (40 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL, ///< 40000baseSR4 Full Duplex (40 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL, ///< 40000baseLR4 Full Duplex (40 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL, ///< 56000baseKR4 Full Duplex (56 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL, ///< 56000baseCR4 Full Duplex (56 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL, ///< 56000baseSR4 Full Duplex (56 GBit/s)
+ MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL, ///< 56000baseLR4 Full Duplex (56 GBit/s)
+
+ N_MBG_NET_INTF_LINK_SPEED_MODES
};
+
/**
- * @brief Network link speed mode masks
+ * @brief Network interface link speed mode masks
*
- * @see ::MBG_NET_LINK_MODES
+ * @see ::MBG_NET_INTF_LINK_SPEED_MODE
+ *
+ * @anchor MBG_NET_INTF_LINK_SPEED_MODE_MASKS @{ */
+
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_UNKNOWN ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_KX_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL
+
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_2500_X_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KX4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KR_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_R_FEC ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_MLD2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_KR2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL
+
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL
+#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL
+
+/** @} anchor MBG_NET_INTF_LINK_SPEED_MODE_MASKS */
+
+
+
+/**
+ * @brief Network interface link speeds [Mb/s]
+ *
+ * @see ::MBG_NET_INTF_LINK_SPEED_MODE_MASKS
*/
-enum MBG_NET_LINK_MODE_MASKS
+enum MBG_NET_INTF_LINK_SPEED
{
- MBG_NET_LINK_MODE_MASK_AUTONEG = ( 1UL << MBG_NET_LINK_MODE_AUTONEG ), ///< see ::MBG_NET_LINK_MODE_AUTONEG
- MBG_NET_LINK_MODE_MASK_10_BT_H = ( 1UL << MBG_NET_LINK_MODE_10_BT_H ), ///< see ::MBG_NET_LINK_MODE_10_BT_H
- MBG_NET_LINK_MODE_MASK_10_BT_F = ( 1UL << MBG_NET_LINK_MODE_10_BT_F ), ///< see ::MBG_NET_LINK_MODE_10_BT_F
- MBG_NET_LINK_MODE_MASK_100_BT_H = ( 1UL << MBG_NET_LINK_MODE_100_BT_H ), ///< see ::MBG_NET_LINK_MODE_100_BT_H
- MBG_NET_LINK_MODE_MASK_100_BT_F = ( 1UL << MBG_NET_LINK_MODE_100_BT_F ), ///< see ::MBG_NET_LINK_MODE_100_BT_F
- MBG_NET_LINK_MODE_MASK_1000_BT_H = ( 1UL << MBG_NET_LINK_MODE_1000_BT_H ), ///< see ::MBG_NET_LINK_MODE_1000_BT_H
- MBG_NET_LINK_MODE_MASK_1000_BT_F = ( 1UL << MBG_NET_LINK_MODE_1000_BT_F ), ///< see ::MBG_NET_LINK_MODE_1000_BT_F
- MBG_NET_LINK_MODE_MASK_10000_BT_F = ( 1UL << MBG_NET_LINK_MODE_10000_BT_F ) ///< see ::MBG_NET_LINK_MODE_10000_BT_F
+ MBG_NET_INTF_LINK_SPEED_UNKNOWN = 0UL,
+ MBG_NET_INTF_LINK_SPEED_10 = 10UL,
+ MBG_NET_INTF_LINK_SPEED_100 = 100UL,
+ MBG_NET_INTF_LINK_SPEED_1000 = 1000UL,
+ MBG_NET_INTF_LINK_SPEED_2500 = 2500UL,
+ MBG_NET_INTF_LINK_SPEED_10000 = 10000UL,
+ MBG_NET_INTF_LINK_SPEED_20000 = 20000UL,
+ MBG_NET_INTF_LINK_SPEED_40000 = 40000UL,
+ MBG_NET_INTF_LINK_SPEED_56000 = 56000UL
};
/**
- * @brief Network link port types
+ * @brief Network interface link port types
*
- * @see ::MBG_NET_LINK_PORT_MASKS
+ * @see ::MBG_NET_INTF_LINK_PORT_TYPE_MASKS
*/
-enum MBG_NET_LINK_PORTS
+enum MBG_NET_INTF_LINK_PORT_TYPE
{
- MBG_NET_LINK_PORT_AUTO, ///< auto detection
- MBG_NET_LINK_PORT_TP, ///< Twisted Pair (TP)
- MBG_NET_LINK_PORT_AUI, ///< Attachment Unit Interface (AUI), externel transceiver
- MBG_NET_LINK_PORT_MII, ///< Media Independent Interface (MII), external receiver
- MBG_NET_LINK_PORT_FIBRE, ///< fibre optic
- MBG_NET_LINK_PORT_BNC, ///< coaxial cable
- N_MBG_NET_LINK_PORTS
+ MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN, ///< Unknown port type
+ MBG_NET_INTF_LINK_PORT_TYPE_TP, ///< Twisted Pair (TP) copper cable
+ MBG_NET_INTF_LINK_PORT_TYPE_FIBRE, ///< Fibre Optic (FO) cable
+ MBG_NET_INTF_LINK_PORT_TYPE_BNC, ///< Coaxial BNC cable
+ MBG_NET_INTF_LINK_PORT_TYPE_AUI, ///< Attachment Unit Interface (AUI), externel transceiver
+ MBG_NET_INTF_LINK_PORT_TYPE_MII, ///< Media Independent Interface (MII), external receiver
+ MBG_NET_INTF_LINK_PORT_TYPE_DA, ///< Direct attach SFP+ connection
+ N_MBG_NET_INTF_LINK_PORT_TYPES
};
+
/**
- * @brief Network link port type masks
+ * @brief Network interface link port masks
*
- * @see ::MBG_NET_LINK_PORTS
+ * @see ::MBG_NET_INTF_LINK_PORT_TYPE
*/
-enum MBG_NET_LINK_PORT_MASKS
+enum MBG_NET_INTF_LINK_PORT_TYPE_MASKS
{
- MBG_NET_LINK_PORT_MASK_AUTO = ( 1UL << MBG_NET_LINK_PORT_AUTO ), ///< see ::MBG_NET_LINK_PORT_AUTO
- MBG_NET_LINK_PORT_MASK_TP = ( 1UL << MBG_NET_LINK_PORT_TP ), ///< see ::MBG_NET_LINK_PORT_TP
- MBG_NET_LINK_PORT_MASK_AUI = ( 1UL << MBG_NET_LINK_PORT_AUI ), ///< see ::MBG_NET_LINK_PORT_AUI
- MBG_NET_LINK_PORT_MASK_MII = ( 1UL << MBG_NET_LINK_PORT_MII ), ///< see ::MBG_NET_LINK_PORT_MII
- MBG_NET_LINK_PORT_MASK_FIBRE = ( 1UL << MBG_NET_LINK_PORT_FIBRE ), ///< see ::MBG_NET_LINK_PORT_FIBRE
- MBG_NET_LINK_PORT_MASK_BNC = ( 1UL << MBG_NET_LINK_PORT_BNC ) ///< see ::MBG_NET_LINK_PORT_BNC
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_UNKNOWN = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_TP = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_TP ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_TP
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_FIBRE = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_FIBRE ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_FIBRE
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_BNC = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_BNC ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_BNC
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_AUI = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_AUI ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_AUI
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_MII = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_MII ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_MII
+ MBG_NET_INTF_LINK_PORT_TYPE_MASK_DA = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_DA ) ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_DA
};
/**
- * @brief Network link state bits
+ * @brief Initializers for network interface link port type long strings
*
- * @see ::MBG_NET_LINK_STATE_MASKS
+ * @see ::MBG_NET_INTF_LINK_PORT_TYPE
+ */
+#define MBG_NET_INTF_LINK_PORT_TYPE_LONG_STRS \
+{ \
+ "Unknown", \
+ "Twisted Pair", \
+ "Fibre Optic", \
+ "Coaxial BNC", \
+ "Attachment Unit Interface", \
+ "Media Independent Interface", \
+ "Direct Attach SFP+" \
+}
+
+
+/**
+ * @brief Initializers for network interface link port type short strings
+ *
+ * @see ::MBG_NET_INTF_LINK_PORT_TYPE
+ */
+#define MBG_NET_INTF_LINK_PORT_TYPE_SHORT_STRS \
+{ \
+ "Unknown", \
+ "TP", \
+ "FO", \
+ "BNC", \
+ "AUI", \
+ "MII", \
+ "DA" \
+}
+
+
+
+/**
+ * @brief Network interface link state bits
+ *
+ * @see @ref MBG_NET_INTF_LINK_STATE_MASKS
*
* @note See official Linux kernel documentation
* https://www.kernel.org/doc/Documentation/networking/operstates.txt
@@ -7620,199 +10057,232 @@ enum MBG_NET_LINK_PORT_MASKS
* using similar names struct IP_ADAPTER_ADDRESSES which is explained at
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa366058%28v=vs.85%29.aspx
*/
-enum MBG_NET_LINK_STATE_BITS
-{
- MBG_NET_LINK_STATE_BIT_UP,
- MBG_NET_LINK_STATE_BIT_BROADCAST,
- MBG_NET_LINK_STATE_BIT_LOOPBACK,
- MBG_NET_LINK_STATE_BIT_P2P,
- MBG_NET_LINK_STATE_BIT_RUNNING,
- MBG_NET_LINK_STATE_BIT_NO_ARP,
- MBG_NET_LINK_STATE_BIT_PROMISC,
- MBG_NET_LINK_STATE_BIT_MASTER,
- MBG_NET_LINK_STATE_BIT_SLAVE,
- MBG_NET_LINK_STATE_BIT_MULTICAST,
- MBG_NET_LINK_STATE_BIT_LOWER_UP,
- MBG_NET_LINK_STATE_BIT_DORMANT,
- MBG_NET_LINK_STATE_BIT_ECHO,
- N_MBG_NET_LINK_STATE_BITS
+enum MBG_NET_INTF_LINK_STATE_BITS
+{
+ MBG_NET_INTF_LINK_STATE_BIT_UP,
+ MBG_NET_INTF_LINK_STATE_BIT_RUNNING,
+ MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP,
+ MBG_NET_INTF_LINK_STATE_BIT_DORMANT,
+ MBG_NET_INTF_LINK_STATE_BIT_BROADCAST,
+ MBG_NET_INTF_LINK_STATE_BIT_MULTICAST,
+ MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI,
+ MBG_NET_INTF_LINK_STATE_BIT_DEBUG,
+
+ MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK,
+ MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT,
+ MBG_NET_INTF_LINK_STATE_BIT_NO_ARP,
+ MBG_NET_INTF_LINK_STATE_BIT_PROMISC,
+ MBG_NET_INTF_LINK_STATE_BIT_MASTER,
+ MBG_NET_INTF_LINK_STATE_BIT_SLAVE,
+ MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL,
+ MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA,
+
+ MBG_NET_INTF_LINK_STATE_BIT_ECHO,
+ MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC,
+ MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS,
+
+ N_MBG_NET_INTF_LINK_STATE_BITS
};
+
/**
- * @brief Network link state masks
+ * @brief Network interface link state masks
+ *
+ * @see ::MBG_NET_INTF_LINK_STATE_BITS (reclined to Linux' if.h, Windows is similiar)
*
- * @see ::MBG_NET_LINK_STATE_BITS (reclined to Linux' if.h, Windows is similiar)
*/
-enum MBG_NET_LINK_STATE_MASKS
+enum MBG_NET_INTF_LINK_STATE_MASKS
{
- MBG_NET_LINK_STATE_MASK_UP = ( 1UL << MBG_NET_LINK_STATE_BIT_UP ), ///< see ::MBG_NET_LINK_STATE_BIT_UP
- MBG_NET_LINK_STATE_MASK_BROADCAST = ( 1UL << MBG_NET_LINK_STATE_BIT_BROADCAST ), ///< see ::MBG_NET_LINK_STATE_BIT_BROADCAST
- MBG_NET_LINK_STATE_MASK_LOOPBACK = ( 1UL << MBG_NET_LINK_STATE_BIT_LOOPBACK ), ///< see ::MBG_NET_LINK_STATE_BIT_LOOPBACK
- MBG_NET_LINK_STATE_MASK_P2P = ( 1UL << MBG_NET_LINK_STATE_BIT_P2P ), ///< see ::MBG_NET_LINK_STATE_BIT_P2P
- MBG_NET_LINK_STATE_MASK_RUNNING = ( 1UL << MBG_NET_LINK_STATE_BIT_RUNNING ), ///< see ::MBG_NET_LINK_STATE_BIT_RUNNING
- MBG_NET_LINK_STATE_MASK_NO_ARP = ( 1UL << MBG_NET_LINK_STATE_BIT_NO_ARP ), ///< see ::MBG_NET_LINK_STATE_BIT_NO_ARP
- MBG_NET_LINK_STATE_MASK_PROMISC = ( 1UL << MBG_NET_LINK_STATE_BIT_PROMISC ), ///< see ::MBG_NET_LINK_STATE_BIT_PROMISC
- MBG_NET_LINK_STATE_MASK_MASTER = ( 1UL << MBG_NET_LINK_STATE_BIT_MASTER ), ///< see ::MBG_NET_LINK_STATE_BIT_MASTER
- MBG_NET_LINK_STATE_MASK_SLAVE = ( 1UL << MBG_NET_LINK_STATE_BIT_SLAVE ), ///< see ::MBG_NET_LINK_STATE_BIT_SLAVE
- MBG_NET_LINK_STATE_MASK_MULTICAST = ( 1UL << MBG_NET_LINK_STATE_BIT_MULTICAST ), ///< see ::MBG_NET_LINK_STATE_BIT_MULTICAST
- MBG_NET_LINK_STATE_MASK_LOWER_UP = ( 1UL << MBG_NET_LINK_STATE_BIT_LOWER_UP ), ///< see ::MBG_NET_LINK_STATE_BIT_LOWER_UP
- MBG_NET_LINK_STATE_MASK_DORMANT = ( 1UL << MBG_NET_LINK_STATE_BIT_DORMANT ), ///< see ::MBG_NET_LINK_STATE_BIT_DORMANT
- MBG_NET_LINK_STATE_MASK_ECHO = ( 1UL << MBG_NET_LINK_STATE_BIT_ECHO ) ///< see ::MBG_NET_LINK_STATE_BIT_ECHO
-};
+ 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
+};
/**
- * @brief Network link option bits
+ * @brief Network interface link option bits
*
- * @see ::MBG_NET_LINK_OPT_MASKS
+ * @see ::MBG_NET_INTF_LINK_OPT_MASKS
*/
-enum MBG_NET_LINK_OPTS
+enum MBG_NET_INTF_LINK_OPTS
{
- MBG_NET_LINK_OPT_CAN_SET_MAC,
- MBG_NET_LINK_OPT_CAN_BOND,
- N_MBG_NET_LINK_OPTS
+ MBG_NET_INTF_LINK_OPT_CAN_SET_MAC,
+ MBG_NET_INTF_LINK_OPT_CAN_SYNCE,
+ MBG_NET_INTF_LINK_OPT_CAN_AUTONEG,
+ N_MBG_NET_INTF_LINK_OPTS
};
+
/**
- * @brief Network link option masks
+ * @brief Network interface link option masks
*
- * @see ::MBG_NET_LINK_OPTS
+ * @see ::MBG_NET_INTF_LINK_OPTS
*/
-enum MBG_NET_LINK_OPT_MASKS
+enum MBG_NET_INTF_LINK_OPT_MASKS
{
- MBG_NET_LINK_OPT_MASK_CAN_SET_MAC = ( 1UL << MBG_NET_LINK_OPT_CAN_SET_MAC ), ///< see ::MBG_NET_LINK_OPT_CAN_SET_MAC
- MBG_NET_LINK_OPT_MASK_CAN_BOND = ( 1UL << MBG_NET_LINK_OPT_CAN_BOND ) ///< see ::MBG_NET_LINK_OPT_CAN_BOND
+ 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
};
/**
- * @brief Network link roles
+ * @brief Network interface link bonding mode
+ *
+ * Used with ::MBG_NET_INTF_LINK_SETTINGS::bond_mode
*
- * Used with ::MBG_NET_LINK_SETTINGS::role to determine
- * if a network link operates in normal mode, or in
- * a special mode, e.g. as part of a higher level pseudo
- * interface (bonding, etc.)
+ * @note if_bonding.h contains bonding modes under Linux, found no hint under Windows.
+ * BUT: Something similiar (concerning naming) can be configured under Windows
+ * via GUI in device manager, if supported.
*/
-enum MBG_NET_LINK_ROLES
+enum MBG_NET_INTF_LINK_BOND_MODES
{
- MBG_NET_LINK_ROLE_UNKNOWN, ///< role can't be determined
- MBG_NET_LINK_ROLE_NORMAL, ///< link is normal physical interface
- MBG_NET_LINK_ROLE_MASTER, ///< link is master (e.g. bonding)
- MBG_NET_LINK_ROLE_SLAVE, ///< link is slave (e.g. bonding)
- N_MBG_NET_LINK_ROLES
+ MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN,
+ MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP,
+ MBG_NET_INTF_LINK_BOND_MODE_XOR,
+ MBG_NET_INTF_LINK_BOND_MODE_BROADCAST,
+ MBG_NET_INTF_LINK_BOND_MODE_8023AD,
+ MBG_NET_INTF_LINK_BOND_MODE_TLB,
+ MBG_NET_INTF_LINK_BOND_MODE_ALB,
+ N_MBG_NET_INTF_LINK_BOND_MODES
};
-//##++++++++++++++++ TODO define masks?
/**
- * @brief Network link bonding bits
+ * @brief Network interface link bonding mode masks
*
- * @see SIOCGIFPFLAGS under Linux, found no hint under Windows
+ * @see ::MBG_NET_INTF_LINK_BOND_MODES
*/
-enum MBG_NET_LINK_ROLE_BITS
+enum MBG_NET_INTF_LINK_BOND_MODE_MASKS
{
- MBG_NET_LINK_ROLE_BIT_BONDING, ///< Bonding master
- MBG_NET_LINK_ROLE_BIT_BOND_SLAVE_INACTIVE, ///< Bonding slave is not active
- MBG_NET_LINK_ROLE_BIT_BOND_MASTER_8023AD, ///< 802.3ad bonding master
- MBG_NET_LINK_ROLE_BIT_BOND_MASTER_ALB, ///< Balanced-alb bonding master
- N_MBG_NET_LINK_ROLE_BITS
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_ROUNDROBIN = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_ACTIVEBACKUP = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_XOR = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_XOR ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_XOR
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_BROADCAST = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_BROADCAST ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_BROADCAST
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_8023AD = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_8023AD ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_8023AD
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_TLB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_TLB ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_TLB
+ MBG_NET_INTF_LINK_BOND_MODE_MASK_ALB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ALB ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ALB
};
+
/**
- * @brief Network link role masks
+ * @brief Network interface link bonding mode name strings
*
- * @see ::MBG_NET_LINK_ROLE_BITS
+ * @see ::MBG_NET_INTF_LINK_BOND_MODES
*/
-enum MBG_NET_LINK_ROLE_MASKS
-{
- MBG_NET_LINK_ROLE_MASK_BONDING = ( 1UL << MBG_NET_LINK_ROLE_BIT_BONDING ), ///< see ::MBG_NET_LINK_ROLE_BIT_BONDING
- MBG_NET_LINK_ROLE_MASK_BOND_SLAVE_INACTIVE = ( 1UL << MBG_NET_LINK_ROLE_BIT_BOND_SLAVE_INACTIVE ), ///< see ::MBG_NET_LINK_ROLE_BIT_BOND_SLAVE_INACTIVE
- MBG_NET_LINK_ROLE_MASK_BOND_MASTER_8023AD = ( 1UL << MBG_NET_LINK_ROLE_BIT_BOND_MASTER_8023AD ), ///< see ::MBG_NET_LINK_ROLE_BIT_BOND_MASTER_8023AD
- MBG_NET_LINK_ROLE_MASK_BOND_MASTER_ALB = ( 1UL << MBG_NET_LINK_ROLE_BIT_BOND_MASTER_ALB ), ///< see ::MBG_NET_LINK_ROLE_BIT_BOND_MASTER_ALB
- N_MBG_NET_LINK_ROLE_MASKS
-};
+#define MBG_NET_INTF_LINK_BOND_MODE_STRS \
+{ \
+ "Round Robin", \
+ "Active Backup", \
+ "XOR", \
+ "Broadcast", \
+ "802.3ad (LACP)", \
+ "TLB", \
+ "ALB" \
+}
/**
- * @brief Network link bonding mode
- *
- * Used with ::MBG_NET_LINK_SETTINGS::role_value
+ * @brief Network interface link bonding states
*
- * @note if_bonding.h contains bonding modes under Linux, found no hint under Windows.
- * BUT: Something similiar (concerning naming) can be configured under Windows
- * via GUI in device manager, if supported.
+ * Used with ::MBG_NET_INTF_LINK_SETTINGS::bond_state
*/
-enum MBG_NET_LINK_BOND_MODES
+enum MBG_NET_INTF_LINK_BOND_STATES
{
- MBG_NET_LINK_BOND_MODE_UNKNOWN,
- MBG_NET_LINK_BOND_MODE_ROUNDROBIN,
- MBG_NET_LINK_BOND_MODE_ACTIVEBACKUP,
- MBG_NET_LINK_BOND_MODE_XOR,
- MBG_NET_LINK_BOND_MODE_BROADCAST,
- MBG_NET_LINK_BOND_MODE_8023AD,
- MBG_NET_LINK_BOND_MODE_TLB,
- MBG_NET_LINK_BOND_MODE_ALB,
- N_MBG_NET_LINK_BOND_MODES
+ MBG_NET_INTF_LINK_BOND_STATE_ACTIVE,
+ MBG_NET_INTF_LINK_BOND_STATE_BACKUP,
+ N_MBG_NET_INTF_LINK_BOND_STATES
};
/**
- * @brief Network logical interface commands
+ * @brief Network interface link type bits
+ *
+ * @see ::MBG_NET_INTF_LINK_TYPE_MASKS
*
- * Used with ::MBG_NET_INTF_SETTINGS::cmd
+ * Used with ::MBG_NET_INTF_LINK_INFO::type
*/
-enum MBG_NET_LOG_INTF_CMDS
+enum MBG_NET_INTF_LINK_TYPE
{
- MBG_NET_LOG_CMD_NONE,
- MBG_NET_LOG_CMD_ADD_UPDATE,
- MBG_NET_LOG_CMD_REMOVE,
- N_MBG_NET_LOG_CMDS
+ MBG_NET_INTF_LINK_TYPE_PHYS, ///< Real physical network interface
+ MBG_NET_INTF_LINK_TYPE_VLAN, ///< VLAN interface, assigned to physical interface
+ MBG_NET_INTF_LINK_TYPE_BOND, ///< Bonding interface, which acts as bonding master
+ N_MBG_NET_INTF_LINK_TYPE_BITS
};
/**
- * @brief Network logical interface roles
+ * @brief Network interface link type masks
*
- * Used with ::MBG_NET_INTF_SETTINGS::role
+ * @see ::MBG_NET_INTF_LINK_TYPE
*/
-enum MBG_NET_LOG_INTF_ROLES
+enum MBG_NET_INTF_LINK_TYPE_MASKS
{
- MBG_NET_LOG_ROLE_STANDARD,
- MBG_NET_LOG_ROLE_BOND,
- MBG_NET_LOG_ROLE_VLAN,
- N_MBG_NET_INTF_ROLE
+ 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
};
/**
- * @brief Network interface bits
+ * @brief Network interface address bits
*
- * @see ::MBG_NET_INTF_MASKS
+ * @see ::MBG_NET_INTF_ADDR_MASKS
*
- * Used with ::MBG_NET_INTF_INFO::supp_flags
+ * Used with ::MBG_NET_INTF_ADDR_INFO::supp_flags and ::MBG_NET_INTF_ADDR_SETTINGS::flags
*/
-enum MBG_NET_INTF_BITS
+enum MBG_NET_INTF_ADDR_BITS
{
- MBG_NET_INTF_BIT_EXT_ROUTING,
- N_MBG_NET_INTF_BITS
+ MBG_NET_INTF_ADDR_BIT_DHCP4, ///< Address has been automatically assigned by DHCP via IPv4
+ MBG_NET_INTF_ADDR_BIT_DHCP6, ///< Address has been automatically assigned by DHCP via IPv6
+ N_MBG_NET_INTF_ADDR_FLAGS
};
+
/**
- * @brief Network interface masks
+ * @brief Network interface address masks
*
- * @see ::MBG_NET_INTF_BITS
+ * @see ::MBG_NET_INTF_ADDR_BITS
*/
-enum MBG_NET_INTF_MASKS
+enum MBG_NET_INTF_ADDR_MASKS
+{
+ MBG_NET_INTF_ADDR_MASK_DHCP4 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP4 ), ///< see ::MBG_NET_INTF_ADDR_BIT_DHCP4
+ MBG_NET_INTF_ADDR_MASK_DHCP6 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP6 ) ///< see ::MBG_NET_INTF_ADDR_BIT_DHCP6
+};
+
+
+enum MBG_NET_INTF_ROUTE_TYPES
{
- MBG_NET_INTF_MASK_EXT_ROUTING = ( 1UL << MBG_NET_INTF_BIT_EXT_ROUTING ) ///< see ::MBG_NET_INTF_BIT_EXT_ROUTING
+ MBG_NET_INTF_ROUTE_TYPE_UNKNOWN,
+ MBG_NET_INTF_ROUTE_TYPE_DEFAULT_GATEWAY,
+ MBG_NET_INTF_ROUTE_TYPE_DEST_GATEWAY,
+ MBG_NET_INTF_ROUTE_TYPE_DEST_ADDR,
+ N_MBG_NET_INTF_ROUTE_TYPES
};
/** @} defgroup group_ext_net_cfg_types */
@@ -7832,16 +10302,21 @@ enum MBG_NET_INTF_MASKS
*/
typedef struct
{
- MBG_HOSTNAME hostname; ///< hostname, eventually FQDN including domain name
- uint32_t reserved; ///< currently reserved, always 0
- uint32_t flags; ///< currently reserved, always 0
- //##++++ TODO: flags could control IPv6, enable forwarding, etc.
+ MBG_HOSTNAME hostname; ///< hostname, eventually FQDN including domain name
+
+ uint8_t num_intf_link; ///< number of detected/configured physical network interfaces (links), see ::MBG_NET_INTF_LINK_INFO_IDX
+ 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 reserved; ///< currently reserved, always 0
+ uint16_t flags; ///< currently reserved, always 0
} MBG_NET_GLB_CFG_SETTINGS;
#define _mbg_swab_net_glb_cfg_settings( _p ) \
{ \
- _mbg_swab32( &(_p)->reserved ); \
_mbg_swab32( &(_p)->flags ); \
}
@@ -7852,27 +10327,27 @@ typedef struct
typedef struct
{
MBG_NET_GLB_CFG_SETTINGS glb_settings;
- uint16_t num_link; ///< max. supported links (physical interfaces), see ::MBG_NET_LINK_SETTINGS_IDX, ::MBG_NET_LINK_INFO_IDX
- uint16_t num_intf; ///< max. logical (including virtual) interfaces, see ::MBG_NET_INTF_SETTINGS_IDX, ::MBG_NET_INTF_INFO_IDX
- uint16_t num_dns_srvr; ///< max. configurable DNS server addresses, using ::MBG_IP_ADDR_IDX records
- uint16_t num_dns_srch_dom; ///< max. configurable DNS search domain records, using ::MBG_NET_NAME_IDX records
- uint16_t num_static_routes; ///< max. configurable static routes
- 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 flags_2; ///< currently reserved, always 0
+ uint16_t n_supp_intf_link; ///< max. number of supported physical network interfaces (links), see ::MBG_NET_INTF_LINK_SETTINGS_IDX, ::MBG_NET_INTF_LINK_INFO_IDX
+ uint16_t n_supp_intf_addr; ///< max. number of supported interface addresses, see ::MBG_NET_INTF_ADDR_SETTINGS_IDX, ::MBG_NET_INTF_ADDR_INFO_IDX
+ uint16_t n_supp_dns_srvr; ///< max. number of supported DNS server addresses, using ::MBG_IP_ADDR_IDX records
+ uint16_t n_supp_dns_srch_dom; ///< max. number of supported DNS search domain records, using ::MBG_NET_NAME_IDX records
+ uint16_t n_supp_intf_route; ///< max. number of supported interface routes, see ::MBG_NET_INTF_ROUTE_SETTINGS_IDX, ::MBG_NET_INTF_ROUTE_INFO_IDX
+ 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 flags_2; ///< currently reserved, always 0
} MBG_NET_GLB_CFG_INFO;
#define _mbg_swab_net_glb_cfg_info( _p ) \
{ \
_mbg_swab_net_glb_cfg_settings( &(_p)->glb_settings ); \
- _mbg_swab16( &(_p)->num_link ); \
- _mbg_swab16( &(_p)->num_intf ); \
- _mbg_swab16( &(_p)->num_dns_srvr ); \
- _mbg_swab16( &(_p)->num_dns_srch_dom ); \
- _mbg_swab16( &(_p)->num_static_routes ); \
+ _mbg_swab16( &(_p)->n_supp_intf_link ); \
+ _mbg_swab16( &(_p)->n_supp_intf_addr ); \
+ _mbg_swab16( &(_p)->n_supp_dns_srvr ); \
+ _mbg_swab16( &(_p)->n_supp_dns_srch_dom ); \
+ _mbg_swab16( &(_p)->n_supp_intf_route ); \
_mbg_swab16( &(_p)->max_hostname_len ); \
_mbg_swab32( &(_p)->reserved_1 ); \
_mbg_swab32( &(_p)->reserved_2 ); \
@@ -7881,6 +10356,7 @@ typedef struct
}
+
/**
* @brief An IPv4 or IPv6 network address
*/
@@ -7890,7 +10366,7 @@ typedef struct
uint8_t reserved_1; ///< reserved, currently always 0 @todo Do we need this as scope indicator?
uint16_t reserved_2; ///< reserved, currently always 0
- union
+ union u_addr
{
IP4_ADDR ip4_addr; ///< IPv4 address if ::MBG_IP_ADDR::type == MBG_IP_ADDR_TYPE_IP4
IP6_ADDR ip6_addr; ///< IPv6 address if ::MBG_IP_ADDR::type == MBG_IP_ADDR_TYPE_IP6
@@ -7898,6 +10374,12 @@ typedef struct
} MBG_IP_ADDR;
+#define _mbg_swab_ip_addr( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+}
+
+
/**
* @brief An IPv4 or IPv6 network address, plus index
@@ -7909,6 +10391,33 @@ typedef struct
} MBG_IP_ADDR_IDX;
+#define _mbg_swab_ip_addr_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_ip_addr( &(_p)->addr ); \
+}
+
+
+/**
+ * @brief An IPv4 or IPv6 network address plus UDP or TCP port number
+ */
+typedef struct
+{
+ MBG_IP_ADDR addr; ///< see ::MBG_IP_ADDR
+
+ uint16_t port; ///< UDP or TCP port
+ uint16_t flags; ///< currently always 0
+ //##+++++ TODO should the flags field indicate if the port is UDP and/or TCP?
+
+} MBG_IP_ADDR_PORT;
+
+#define _mbg_swab_ip_addr_port( _p ) \
+{ \
+ _mbg_swab_ip_addr( &(_p)->addr ); \
+ _mbg_swab16( &(_p)->port ); \
+ _mbg_swab16( &(_p)->flags ); \
+}
+
/**
* @brief Network host or domain name
@@ -7920,6 +10429,7 @@ typedef struct
} MBG_NET_NAME;
+
/**
* @brief Network host or domain name, plus index
*/
@@ -7930,55 +10440,92 @@ typedef struct
} MBG_NET_NAME_IDX;
+#define _mbg_swab_net_name_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+}
/**
- * @brief Link (physical interface) specific settings
+ * @brief Physical network interface link specific settings
*/
typedef struct
{
- MBG_MAC_ADDR mac_addr; ///< Physical hardware address
- MBG_MAC_ADDR broadcast; ///< Physical broadcast address
- uint32_t mtu; ///< Max. packet size in bytes
- uint32_t states; ///< see ::MBG_NET_LINK_STATE_BITS
- uint32_t flags; ///< Reserved, currently 0
- uint32_t reserved_1; ///< Reserved, currently 0
- uint32_t reserved_2; ///< Reserved, currently 0
- uint16_t bond_idx; ///< Current primary slave link index in ::MBG_NET_LINK_ROLE_MASTER role,
- ///< current bonding master link index in ::MBG_NET_LINK_ROLE_SLAVE role,
- ///< otherwise reserved and usually 0.
- uint8_t speed_mode; ///< see ::MBG_NET_LINK_MODES
- uint8_t port; ///< see ::MBG_NET_LINK_PORTS
- uint8_t role; ///< see ::MBG_NET_LINK_ROLES
- uint8_t reserved[3]; ///< Alignment. Can be used in future for usefull stuff.
-//##+++++ TODO check reserved above
- uint32_t role_flags; ///< see ::MBG_NET_LINK_ROLE_BITS
- uint32_t role_value; ///< Additional role parameters depending on role and role_flags,
- ///< e.g. if role is master and flags contain bonding.
- ///< See ::MBG_NET_LINK_BOND_MODES.
-} MBG_NET_LINK_SETTINGS;
+ char name[MBG_IFNAMSIZ]; ///< Interface name
+ MBG_MAC_ADDR mac_addr; ///< Physical hardware address
+ MBG_MAC_ADDR broadcast; ///< Physical broadcast address
+
+ 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
+ uint32_t ass_if_index; ///< Interface index of the associated physical interface link,
+ ///< Valid, if ::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 hw_type; ///< Hardware type of interface (see linux/if_arp.h, i.e. ARPHRD_ETHER)
+ 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 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
-#define _mbg_swab_net_link_settings( _p ) \
+ 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
+ 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
+ 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
+
+ uint16_t vlan_cfg; ///< VLAN configuration options, see ::MBG_VLAN_CFG
+ ///< Valid, if ::type is ::MBG_NET_INTF_LINK_TYPE_VLAN
+ uint16_t reserved_1; ///< Reserved, currently 0
+
+ uint32_t reserved_2; ///< Reserved, currently 0
+ uint32_t reserved_3; ///< Reserved, currently 0
+
+} MBG_NET_INTF_LINK_SETTINGS;
+
+#define _mbg_swab_net_intf_link_settings( _p ) \
{ \
- _mbg_swab32( &(_p)->mtu ); \
- _mbg_swab32( &(_p)->states ); \
+ _mbg_swab32( &(_p)->if_index ); \
+ _mbg_swab32( &(_p)->common_if_index ); \
+ _mbg_swab32( &(_p)->ass_if_index ); \
_mbg_swab32( &(_p)->flags ); \
- _mbg_swab32( &(_p)->reserved_1 ); \
- _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->states ); \
+ _mbg_swab32( &(_p)->hw_type ); \
+ _mbg_swab32( &(_p)->mtu ); \
+ _mbg_swab32( &(_p)->txqlen ); \
+ _mbg_swab32( &(_p)->speed ); \
_mbg_swab16( &(_p)->bond_idx ); \
- _mbg_swab32( &(_p)->role_flags ); \
- _mbg_swab32( &(_p)->role_value ); \
+ _mbg_swab16( &(_p)->vlan_cfg ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
}
+
+
/**
* @brief Link (physical interface) specific settings, plus index
*/
typedef struct
{
- uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::num_link-1
- MBG_NET_LINK_SETTINGS settings;
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::n_supp_intf_link-1
+ MBG_NET_INTF_LINK_SETTINGS settings;
+
+} MBG_NET_INTF_LINK_SETTINGS_IDX;
+
+#define _mbg_swab_net_intf_link_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_link_settings( &(_p)->settings ); \
+}
-} MBG_NET_LINK_SETTINGS_IDX;
/**
@@ -7986,142 +10533,246 @@ typedef struct
*/
typedef struct
{
- MBG_NET_LINK_SETTINGS link_settings; ///< see ::MBG_NET_LINK_SETTINGS
- uint32_t supp_opts; ///< see ::MBG_NET_LINK_OPT_MASKS
- uint32_t supp_speed_modes; ///< see ::MBG_NET_LINK_MODE_MASKS
- uint32_t supp_link_ports; ///< see ::MBG_NET_LINK_PORT_MASKS
- uint32_t supp_states; ///< see ::MBG_NET_LINK_STATE_MASKS
+ 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_types; ///< see ::MBG_NET_INTF_LINK_TYPE_MASKS
+ uint32_t supp_speed_modes; ///< see ::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
+ uint32_t reserved_1;
uint32_t reserved_2;
uint32_t reserved_3;
-
-} MBG_NET_LINK_INFO;
-
-#define _mbg_swab_net_link_info( _p ) \
-{ \
- _mbg_swab_net_link_settings( &(_p)->link_settings ); \
- _mbg_swab32( &(_p)->supp_opts ); \
- _mbg_swab32( &(_p)->supp_speed_modes ); \
- _mbg_swab32( &(_p)->supp_link_ports ); \
- _mbg_swab32( &(_p)->supp_states ); \
- _mbg_swab32( &(_p)->reserved_2 ); \
- _mbg_swab32( &(_p)->reserved_3 ); \
+ uint32_t reserved_4;
+} MBG_NET_INTF_LINK_INFO;
+
+#define _mbg_swab_net_intf_link_info( _p ) \
+{ \
+ _mbg_swab_net_intf_link_settings( &(_p)->link_settings ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->supp_states ); \
+ _mbg_swab32( &(_p)->supp_types ); \
+ _mbg_swab32( &(_p)->supp_speed_modes ); \
+ _mbg_swab32( &(_p)->supp_port_types ); \
+ _mbg_swab32( &(_p)->supp_opts ); \
+ _mbg_swab32( &(_p)->supp_bond_modes ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
}
+
/**
- * @brief Query MBG_NET_LINK_INFO by its index
+ * @brief Query MBG_NET_INTF_LINK_INFO by its index
*/
typedef struct
{
- uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::num_link-1
- MBG_NET_LINK_INFO info;
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_link-1
+ MBG_NET_INTF_LINK_INFO info; ///< see ::MBG_NET_INTF_LINK_INFO
-} MBG_NET_LINK_INFO_IDX;
+} MBG_NET_INTF_LINK_INFO_IDX;
+
+#define _mbg_swab_net_intf_link_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_link_info( &(_p)->info ); \
+}
/**
- * @brief Interface specific settings, flags and supported features
- *
- * @note Use link_mac and role to identify uniquely its associated network link.
+ * @brief Network interface address specific settings, flags and supported features
+ *
+ * @note Use if_index to identify uniquely its associated network link.
*/
typedef struct
{
- uint8_t cmd; ///< see ::MBG_NET_LOG_INTF_CMDS
- uint8_t role; ///< see ::MBG_NET_LOG_INTF_ROLES
- uint16_t reserved_1; ///< Reserved, currently 0
- uint32_t role_value; ///< Role specific value. E.g. VLAN ID
- uint32_t flags; ///< Reserved, currently 0
- uint32_t reserved_2; ///< Reserved, currently 0
- MBG_IP_ADDR ip; ///< IP address associated with this interface
- MBG_IP_ADDR gateway; ///< Interface specific. Reserved for future use. see ::MBG_IP_ADDR and ::MBG_NET_INTF_BIT_EXT_ROUTING
- MBG_MAC_ADDR link_mac; ///< Unique identifier for related link (physical) interface
- uint8_t prefix; ///< Subnet mask bits for CIDR notation, e.g. /24
- uint8_t reserved_3; ///< Reserved, currently 0
+ char label[MBG_IFNAMSIZ]; ///< Interface label
+
+ uint32_t addr_index; ///< Index of the address on the physical interface it is assigned to
+ uint32_t ass_if_index; ///< Index of the associated interface link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index
+
+ uint32_t flags; ///< see ::MBG_NET_INTF_ADDR_MASKS
-} MBG_NET_INTF_SETTINGS;
+ MBG_IP_ADDR ip; ///< IP address associated with this interface
+ MBG_IP_ADDR broadcast; ///< Broadcast address associated with this interface
+
+ uint8_t prefix_bits; ///< Number of subnet mask bits for CIDR notation, e.g. 24 for /24
+ uint8_t reserved_1; ///< Reserved, currently 0
+ uint16_t reserved_2; ///< Reserved, currently 0
+
+ uint32_t reserved_3; ///< Reserved, currently 0
+ uint32_t reserved_4; ///< Reserved, currently 0
+ uint32_t reserved_5; ///< Reserved, currently 0
+
+} MBG_NET_INTF_ADDR_SETTINGS;
+
+#define _mbg_swab_net_intf_addr_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->addr_index ); \
+ _mbg_swab32( &(_p)->if_index ); \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab_ip_addr( &(_p)->ip ); \
+ _mbg_swab_ip_addr( &(_p)->broadcast ); \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
+ _mbg_swab32( &(_p)->reserved_5 ); \
+}
/**
- * @brief Query MBG_NET_INTF_INFO by its index
+ * @brief Query MBG_NET_INTF_ADDR_SETTINGS by its index
*/
typedef struct
{
- uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::num_intf-1
- MBG_NET_INTF_SETTINGS settings;
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1
+ MBG_NET_INTF_ADDR_SETTINGS settings; ///< see ::MBG_NET_INTF_ADDR_SETTINGS
+
+} MBG_NET_INTF_ADDR_SETTINGS_IDX;
-} MBG_NET_INTF_SETTINGS_IDX;
+#define _mbg_swab_net_intf_addr_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_addr_settings( &(_p)->settings ); \
+}
/**
- * @brief Interface specific settings, flags and supported features
+ * @brief Network interface address specific settings, flags and supported features
*/
typedef struct
{
- MBG_NET_INTF_SETTINGS intf_settings;
- uint32_t supp_flags; ///< see ::MBG_NET_INTF_MASKS
- uint32_t reserved_1; ///< Reserved, currently 0
- uint32_t reserved_2; ///< Reserved, currently 0
+ MBG_NET_INTF_ADDR_SETTINGS addr_settings; ///< see ::MBG_NET_INTF_ADDR_SETTINGS
+ uint32_t supp_flags; ///< see ::MBG_NET_INTF_ADDR_MASKS
+ uint32_t reserved_1; ///< Reserved, currently 0
+ uint32_t reserved_2; ///< Reserved, currently 0
-} MBG_NET_INTF_INFO;
+} MBG_NET_INTF_ADDR_INFO;
+
+#define _mbg_swab_net_intf_addr_info( _p ) \
+{ \
+ _mbg_swab_net_intf_addr_settings( &(_p)->addr_settings ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
/**
- * @brief Query MBG_NET_INTF_INFO by its index
+ * @brief Query MBG_NET_INTF_ADDR_INFO by its index
*/
typedef struct
{
- uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::num_intf-1
- MBG_NET_INTF_INFO info;
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1
+ MBG_NET_INTF_ADDR_INFO info; ///< see ::MBG_NET_INTF_ADDR_INFO
+
+} MBG_NET_INTF_ADDR_INFO_IDX;
-} MBG_NET_INTF_INFO_IDX;
+#define _mbg_swab_net_intf_addr_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_addr_info( &(_p)->info ); \
+}
/**
- * @brief An IPv4 or IPv6 network address plus UDP or TCP port number
+ * @brief Network interface route specific settings
+ *
+ * @note Use link_mac and ass_addr_idx to identify the associated network address and network link (via address)
*/
typedef struct
{
- MBG_IP_ADDR addr; ///< see ::MBG_IP_ADDR
+ uint8_t type; ///< Type of the route entry, see ::MBG_NET_INTF_ROUTE_TYPES
+ uint8_t reserved_1; ///< Reserved, currently 0
+ uint16_t reserved_2; ///< Reserved, currently 0
+
+ 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
+ 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
+
+ uint32_t reserved_3; ///< Reserved, currently 0
+ uint32_t reserved_4; ///< Reserved, currently 0
+ uint32_t reserved_5; ///< Reserved, currently 0
+
+} MBG_NET_INTF_ROUTE_SETTINGS;
+
+#define _mbg_swab_net_intf_route_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab_ip_addr( &(_p)->gateway ); \
+ _mbg_swab_ip_addr( &(_p)->dst ); \
+ _mbg_swab32( &(_p)->ass_if_index ); \
+ _mbg_swab32( &(_p)->ass_addr_index ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
+ _mbg_swab32( &(_p)->reserved_5 ); \
+}
- uint16_t port; ///< UDP or TCP port
- uint16_t flags; ///< currently always 0
- //##+++++ TODO should the flags field indicate if the port is UDP and/or TCP?
-} MBG_IP_ADDR_PORT;
+/**
+ * @brief Query MBG_NET_INTF_ROUTE_SETTINGS by its index
+ */
+typedef struct
+{
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1
+ MBG_NET_INTF_ROUTE_SETTINGS settings; ///< see ::MBG_NET_INTF_ROUTE_SETTINGS
+} MBG_NET_INTF_ROUTE_SETTINGS_IDX;
+#define _mbg_swab_net_intf_route_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_route_settings( &(_p)->settings ); \
+}
-#if 0 //##++++++++++++++++++++++
/**
- * @brief Network service configuration
- *
- * Used to configure known services, e.g SSH, FTP, etc.
+ * @brief Network interface address specific settings
*/
typedef struct
{
- uint16_t svc_type; ///< see ::MBG_NET_SVC_TYPES
- uint16_t reserved; ///< reserved, currently always 0
- MBG_IP_ADDR_PORT settings; ///< The network address and port a service listens on
- uint32_t flags; ///< reserved, currently always 0
-
-} MBG_NET_INTF_CFG;
-
+ MBG_NET_INTF_ROUTE_SETTINGS route_settings; ///< see ::MBG_NET_INTF_ROUTE_SETTINGS
+ uint32_t reserved_1; ///< Reserved, currently 0
+ uint32_t reserved_2; ///< Reserved, currently 0
+ uint32_t reserved_3; ///< Reserved, currently 0
+ uint32_t reserved_4; ///< Reserved, currently 0
+} MBG_NET_INTF_ROUTE_INFO;
+
+#define _mbg_swab_net_intf_route_info( _p ) \
+{ \
+ _mbg_swab_net_intf_route_settings( &(_p)->route_settings ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
+}
/**
- * @brief
+ * @brief Query MBG_NET_INTF_ROUTE_INFO by its index
*/
typedef struct
{
- uint8_t b[IP6_ADDR_BYTES]; ///< bytes holding the address bits, b[0] == LSBs
-//##+++ uint8_t cidr_net_mask; ///< number of CIDR net mask bits, 0..::IP6_ADDR_BITS
-// uint8_t reserved; ///< not yet used, always 0
-// uint16_t flags; ///< not yet used, always 0
+ uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1
+ MBG_NET_INTF_ROUTE_INFO info; ///< see ::MBG_NET_INTF_ROUTE_INFO
-} MBG_NET_INTF_CFG;
+} MBG_NET_INTF_ROUTE_INFO_IDX;
+
+#define _mbg_swab_net_intf_route_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_net_intf_route_info( &(_p)->info ); \
+}
-#endif
/** @} defgroup group_ext_net_cfg */
@@ -8333,6 +10984,8 @@ enum PTP_CLOCK_ACCURACIES
PTP_CLOCK_ACCURACY_RESERVED_3,
PTP_CLOCK_ACCURACY_RESERVED_4,
N_PTP_CLOCK_ACCURACY
+ //##++++ TODO: Add a code for 0xFE (unknown), or eventually
+ // redesign the lookup of associated strings completely.
};
@@ -8434,6 +11087,9 @@ enum PTP_ROLES
PTP_ROLE_UNICAST_MASTER, ///< unicast master
PTP_ROLE_MULTICAST_AUTO, ///< multicast master or slave (auto selection)
PTP_ROLE_BOTH_MASTER, ///< simultanous multicast and unicast master
+ PTP_ROLE_NTP_SERVER, ///< NTP Unicast Server
+ PTP_ROLE_NTP_CLIENT, ///< NTP Unicast Client
+ PTP_ROLE_TIME_MONITOR, ///< Time Monitor for external PTP or NTP devices
N_PTP_ROLES ///< number of defined roles
};
@@ -8459,7 +11115,10 @@ enum PTP_ROLE_MASKS
PTP_ROLE_MSK_MULTICAST_MASTER = ( 1UL << PTP_ROLE_MULTICAST_MASTER ), ///< see ::PTP_ROLE_MULTICAST_MASTER
PTP_ROLE_MSK_UNICAST_MASTER = ( 1UL << PTP_ROLE_UNICAST_MASTER ), ///< see ::PTP_ROLE_UNICAST_MASTER
PTP_ROLE_MSK_MULTICAST_AUTO = ( 1UL << PTP_ROLE_MULTICAST_AUTO ), ///< see ::PTP_ROLE_MULTICAST_AUTO
- PTP_ROLE_MSK_BOTH_MASTER = ( 1UL << PTP_ROLE_BOTH_MASTER ) ///< see ::PTP_ROLE_BOTH_MASTER
+ PTP_ROLE_MSK_BOTH_MASTER = ( 1UL << PTP_ROLE_BOTH_MASTER ), ///< see ::PTP_ROLE_BOTH_MASTER
+ PTP_ROLE_MSK_NTP_SERVER = ( 1UL << PTP_ROLE_NTP_SERVER ), ///< see ::PTP_ROLE_NTP_SERVER
+ PTP_ROLE_MSK_NTP_CLIENT = ( 1UL << PTP_ROLE_NTP_CLIENT ), ///< see ::PTP_ROLE_NTP_CLIENT
+ PTP_ROLE_MSK_TIME_MONITOR = ( 1UL << PTP_ROLE_TIME_MONITOR ) ///< see ::PTP_ROLE_TIME_MONITOR
};
@@ -8486,7 +11145,10 @@ enum PTP_ROLE_MASKS
"Multicast Master", \
"Unicast Master", \
"Multicast (Auto)", \
- "UC+MC Master" \
+ "UC+MC Master", \
+ "NTP Server", \
+ "NTP Client", \
+ "Time Monitor" \
}
@@ -8503,7 +11165,10 @@ enum PTP_ROLE_MASKS
"MCM", \
"UCM", \
"MCA", \
- "UMM" \
+ "UMM", \
+ "NSV", \
+ "NCL", \
+ "MON" \
}
@@ -8612,7 +11277,7 @@ typedef struct
uint8_t clock_class;
uint8_t clock_accuracy; ///< see ::PTP_CLOCK_ACCURACIES
- uint32_t reserved_1; ///< reserved, currently always 0
+ uint32_t tsu_secs; ///< current seconds value of time stamp unit
uint32_t reserved_2; ///< reserved, currently always 0
uint8_t domain_number; ///< the PTP clock domain number, 0:3
@@ -8640,7 +11305,7 @@ typedef struct
_mbg_swab_nano_time( &(_p)->delay_asymmetry ); \
_mbg_swab_ptp_clock_id( &(_p)->gm_id ); \
_mbg_swab16( &(_p)->clock_offset_scaled_log_variance ); \
- _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->tsu_secs ); \
_mbg_swab32( &(_p)->reserved_2 ); \
_mbg_swab16( &(_p)->utc_offset ); \
_mbg_swab_dac_val( &(_p)->osc_dac_cal ); \
@@ -8715,7 +11380,7 @@ typedef struct
uint32_t lower_bound; ///< sync state set to true if below this limit [ns]
uint32_t reserved; ///< reserved, currently always 0
- uint32_t flags; ///< see ::PTP_CFG_FLAG_MASKS
+ uint32_t flags; ///< see @ref PTP_CFG_FLAG_MASKS
} PTP_CFG_SETTINGS;
@@ -8739,7 +11404,7 @@ typedef struct
enum PTP_ANN_RCPT_TIMEOUT_LIMITS
{
PTP_ANN_RCPT_TIMEOUT_MIN = 2,
- PTP_ANN_RCPT_TIMEOUT_MAX = 255,
+ PTP_ANN_RCPT_TIMEOUT_MAX = 8,
DEFAULT_PTP_ANN_RCPT_TIMEOUT = 3
};
@@ -8763,7 +11428,7 @@ typedef struct
int16_t delay_req_intv_min; ///< log2 of minimum delay request interval [s]
int16_t delay_req_intv_max; ///< log2 of maximum delay request interval [s]
- uint32_t supp_flags; ///< a bit mask of supported features, see ::PTP_CFG_FLAG_MASKS
+ uint32_t supp_flags; ///< a bit mask of supported features, see @ref PTP_CFG_FLAG_MASKS
uint32_t supp_nw_prot; ///< a bit mask of supported network protocols, see ::PTP_NW_PROT_MASKS
uint32_t supp_opt_ext; ///< a bit mask of supported optional extensions, see ::PTP_OPT_EXT_MASKS
uint32_t supp_delay_mech; ///< a bit mask of supported delay mechanisms, see ::PTP_DELAY_MECH_MASKS
@@ -8808,7 +11473,7 @@ typedef struct
* If ::PTP_CFG_SUPP_MCAST_SLAVE_FLAG is not set then the device
* definitely supports the multicast slave role.
*
- * @see ::PTP_CFG_FLAG_MASKS
+ * @see @ref PTP_CFG_FLAG_MASKS
*/
enum PTP_CFG_FLAGS
{
@@ -8830,35 +11495,58 @@ enum PTP_CFG_FLAGS
PTP_CFG_ONE_STEP_L2, ///< [R/-] supports the combination of One-Step and Layer2 mode
PTP_CFG_ONE_STEP_P2P, ///< [R/-] supports the combination of One-Step and P2P Delay Mechanism
+ PTP_CFG_TSU_RESET, ///< [R/-] supports TSU reset via register cmd
+ PTP_CFG_NTP_HW_TS_MASTER, ///< [R/-] supports the NTP HW time stamping in Master mode
+ PTP_CFG_NTP_HW_TS_SLAVE, ///< [R/-] supports the NTP HW time stamping in Slave mode
+ PTP_CFG_SYNCE_MASTER, ///< [R/-] Hardware supports Synchronous Ethernet Out
+ PTP_CFG_SYNCE_SLAVE, ///< [R/-] Hardware supports Synchronous Ethernet In
+ PTP_CFG_HAS_MUX, ///< [R/-] Hardware supports multiplexed signal outputs
+ PTP_CFG_CAN_BE_TIME_MONITOR, ///< [R/-] can be Monitoring device for external PTP or NTP devices //### TODO Shouldn't this be an XFEATURE flag?
+ PTP_CFG_HAS_STATISTICS, ///< [R/-] ::MBG_PTP_STATISTICS_INFO can be queried
+
N_PTP_CFG_FLAGS ///< the number of defined flags
};
/**
- * @brief Bit masks used with ::PTP_CFG_INFO::supp_flags and ::PTP_CFG_SETTINGS::flags
+ * @defgroup group_PTP_CFG_FLAG_MASKS Bit masks used with PTP_CFG_INFO::supp_flags and PTP_CFG_SETTINGS::flags
*
+ * @see ::PTP_CFG_INFO::supp_flags
+ * @see ::PTP_CFG_SETTINGS::flags
* @see ::PTP_CFG_FLAGS
- */
-enum PTP_CFG_FLAG_MASKS
-{
- PTP_CFG_MSK_TIME_SCALE_IS_PTP = ( 1UL << PTP_CFG_TIME_SCALE_IS_PTP ), ///< see ::PTP_CFG_TIME_SCALE_IS_PTP
- PTP_CFG_MSK_V1_HW_COMPAT = ( 1UL << PTP_CFG_V1_HW_COMPAT ), ///< see ::PTP_CFG_V1_HW_COMPAT
- PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE = ( 1UL << PTP_CFG_CAN_BE_UNICAST_SLAVE ), ///< see ::PTP_CFG_CAN_BE_UNICAST_SLAVE
- PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER = ( 1UL << PTP_CFG_CAN_BE_MULTICAST_MASTER ), ///< see ::PTP_CFG_CAN_BE_MULTICAST_MASTER
- PTP_CFG_MSK_CAN_BE_UNICAST_MASTER = ( 1UL << PTP_CFG_CAN_BE_UNICAST_MASTER ), ///< see ::PTP_CFG_CAN_BE_UNICAST_MASTER
- PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO = ( 1UL << PTP_CFG_CAN_BE_MULTICAST_AUTO ), ///< see ::PTP_CFG_CAN_BE_MULTICAST_AUTO
- PTP_CFG_MSK_SUPP_UTC_VALID = ( 1UL << PTP_CFG_SUPP_UTC_VALID ), ///< see ::PTP_CFG_SUPP_UTC_VALID
- PTP_CFG_MSK_CAN_BE_BOTH_MASTER = ( 1UL << PTP_CFG_CAN_BE_BOTH_MASTER ), ///< see ::PTP_CFG_CAN_BE_BOTH_MASTER
+ *
+ * @anchor PTP_CFG_FLAG_MASKS
+ *
+ * @{ */
- PTP_CFG_MSK_HYBRID_MASTER = ( 1UL << PTP_CFG_HYBRID_MASTER ), ///< see ::PTP_CFG_HYBRID_MASTER
- PTP_CFG_MSK_HYBRID_SLAVE = ( 1UL << PTP_CFG_HYBRID_SLAVE ), ///< see ::PTP_CFG_HYBRID_SLAVE
- PTP_CFG_MSK_ONE_STEP_MASTER = ( 1UL << PTP_CFG_ONE_STEP_MASTER ), ///< see ::PTP_CFG_ONE_STEP_MASTER
- PTP_CFG_MSK_MNGMNT_MSGS_DISB = ( 1UL << PTP_CFG_MNGMNT_MSGS_DISB ), ///< see ::PTP_CFG_MNGMNT_MSGS_DISB
- PTP_CFG_MSK_SUPP_MCAST_SLAVE_FLAG = ( 1UL << PTP_CFG_SUPP_MCAST_SLAVE_FLAG ), ///< see ::PTP_CFG_SUPP_MCAST_SLAVE_FLAG
- PTP_CFG_MSK_CAN_BE_MULTICAST_SLAVE = ( 1UL << PTP_CFG_CAN_BE_MULTICAST_SLAVE ), ///< see ::PTP_CFG_CAN_BE_MULTICAST_SLAVE
- PTP_CFG_MSK_ONE_STEP_L2 = ( 1UL << PTP_CFG_ONE_STEP_L2 ), ///< see ::PTP_CFG_ONE_STEP_L2
- PTP_CFG_MSK_ONE_STEP_P2P = ( 1UL << PTP_CFG_ONE_STEP_P2P ), ///< see ::PTP_CFG_ONE_STEP_P2P
-};
+#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_TIME_SCALE_IS_PTP ) ///< see ::PTP_CFG_TIME_SCALE_IS_PTP
+#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_V1_HW_COMPAT ) ///< see ::PTP_CFG_V1_HW_COMPAT
+#define PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_UNICAST_SLAVE ) ///< see ::PTP_CFG_CAN_BE_UNICAST_SLAVE
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_MULTICAST_MASTER ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_MASTER
+#define PTP_CFG_MSK_CAN_BE_UNICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_UNICAST_MASTER ) ///< see ::PTP_CFG_CAN_BE_UNICAST_MASTER
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO ( 1UL << PTP_CFG_CAN_BE_MULTICAST_AUTO ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_AUTO
+#define PTP_CFG_MSK_SUPP_UTC_VALID ( 1UL << PTP_CFG_SUPP_UTC_VALID ) ///< see ::PTP_CFG_SUPP_UTC_VALID
+#define PTP_CFG_MSK_CAN_BE_BOTH_MASTER ( 1UL << PTP_CFG_CAN_BE_BOTH_MASTER ) ///< see ::PTP_CFG_CAN_BE_BOTH_MASTER
+
+#define PTP_CFG_MSK_HYBRID_MASTER ( 1UL << PTP_CFG_HYBRID_MASTER ) ///< see ::PTP_CFG_HYBRID_MASTER
+#define PTP_CFG_MSK_HYBRID_SLAVE ( 1UL << PTP_CFG_HYBRID_SLAVE ) ///< see ::PTP_CFG_HYBRID_SLAVE
+#define PTP_CFG_MSK_ONE_STEP_MASTER ( 1UL << PTP_CFG_ONE_STEP_MASTER ) ///< see ::PTP_CFG_ONE_STEP_MASTER
+#define PTP_CFG_MSK_MNGMNT_MSGS_DISB ( 1UL << PTP_CFG_MNGMNT_MSGS_DISB ) ///< see ::PTP_CFG_MNGMNT_MSGS_DISB
+#define PTP_CFG_MSK_SUPP_MCAST_SLAVE_FLAG ( 1UL << PTP_CFG_SUPP_MCAST_SLAVE_FLAG ) ///< see ::PTP_CFG_SUPP_MCAST_SLAVE_FLAG
+#define PTP_CFG_MSK_CAN_BE_MULTICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_MULTICAST_SLAVE ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_SLAVE
+#define PTP_CFG_MSK_ONE_STEP_L2 ( 1UL << PTP_CFG_ONE_STEP_L2 ) ///< see ::PTP_CFG_ONE_STEP_L2
+#define PTP_CFG_MSK_ONE_STEP_P2P ( 1UL << PTP_CFG_ONE_STEP_P2P ) ///< see ::PTP_CFG_ONE_STEP_P2P
+
+#define PTP_CFG_MSK_TSU_RESET ( 1UL << PTP_CFG_TSU_RESET ) ///< see ::PTP_CFG_TSU_RESET
+#define PTP_CFG_MSK_NTP_HW_TS_MASTER ( 1UL << PTP_CFG_NTP_HW_TS_MASTER ) ///< see ::PTP_CFG_NTP_HW_TS_MASTER
+#define PTP_CFG_MSK_NTP_HW_TS_SLAVE ( 1UL << PTP_CFG_NTP_HW_TS_SLAVE) ///< see ::PTP_CFG_NTP_HW_TS_SLAVE
+#define PTP_CFG_MSK_SYNCE_MASTER ( 1UL << PTP_CFG_SYNCE_MASTER ) ///< see ::PTP_CFG_SYNCE_MASTER
+#define PTP_CFG_MSK_SYNCE_SLAVE ( 1UL << PTP_CFG_SYNCE_SLAVE ) ///< see ::PTP_CFG_SYNCE_SLAVE
+#define PTP_CFG_MSK_HAS_MUX ( 1UL << PTP_CFG_HAS_MUX ) ///< see ::PTP_CFG_HAS_MUX
+#define PTP_CFG_MSK_CAN_BE_TIME_MONITOR ( 1UL << PTP_CFG_CAN_BE_TIME_MONITOR ) ///< see ::PTP_CFG_CAN_BE_TIME_MONITOR
+#define PTP_CFG_MSK_HAS_STATISTICS ( 1UL << PTP_CFG_HAS_STATISTICS ) ///< see ::PTP_CFG_HAS_STATISTICS
+
+/** @} defgroup group_PTP_CFG_FLAG_MASKS */
@@ -8869,16 +11557,51 @@ enum PTP_CFG_FLAG_MASKS
/**
+ * @brief Register in TSU-GbE FPGA to determine board features of the current TSU board revision
+ */
+typedef uint16_t PTP_HW_FEATURES;
+
+
+
+/**
+ * @brief Bits used to define ::PTP_HW_FEAT_MASKS
+ */
+enum PTP_HW_FEAT_BITS
+{
+ PTP_FEAT_SYNCE_EXT_MUX, ///< [R] supports SyncE and external signal multiplexer
+ N_PTP_HW_FEAT ///< the number of defined features
+};
+
+
+// TODO fix comment linkage
+/**
+ * @brief Bit masks used with ::PTP_HW_FEATURES
+ *
+ * @see ::PTP_HW_FEAT_BITS
+ */
+enum PTP_HW_FEAT_MASKS
+{
+ PTP_HW_FEAT_MSK_SYNCE_EXT_MUX = ( 1UL << PTP_FEAT_SYNCE_EXT_MUX ) ///< see ::PTP_FEAT_SYNCE_EXT_MUX
+};
+
+
+
+/**
* @brief Known optional PTP protocol extensions, see ::PTP_CFG_SETTINGS::opt_ext
*
* @see ::PTP_OPT_EXT_MASKS
*/
enum PTP_OPT_EXTS
{
- PTP_OPT_EXT_NONE, ///< no extension used
- PTP_OPT_EXT_POWER, ///< IEEE C37.238 profile extension
- PTP_OPT_EXT_TELECOM, ///< ITU-T G.8265.1 profile extension
- N_PTP_OPT_EXT ///< number of known optional extension
+ PTP_OPT_EXT_NONE, ///< no extension used
+ PTP_OPT_EXT_POWER, ///< IEEE C37.238-2011 profile extension
+ PTP_OPT_EXT_TELECOM, ///< ITU-T G.8265.1 profile extension
+ PTP_OPT_EXT_TELECOM_PHASE, ///< ITU-T G.8275.1 profile extension
+ PTP_OPT_EXT_SMPTE, ///< SMPTE ST 2059-2 profile extension
+ PTP_OPT_EXT_8021AS, ///< IEEE 802.1AS profile extension
+ PTP_OPT_EXT_6185093, ///< IEC/IEEE FDIS 61850-9-3 Power Utility profile extension
+ PTP_OPT_EXT_TELECOM_PTS, ///< ITU-T G.8275.2 profile extension
+ N_PTP_OPT_EXT ///< number of known optional extensions
};
@@ -8889,9 +11612,14 @@ enum PTP_OPT_EXTS
*/
enum PTP_OPT_EXT_MASKS
{
- PTP_MSK_OPT_EXT_NONE = ( 1UL << PTP_OPT_EXT_NONE ), ///< this is actually not used, see ::PTP_OPT_EXT_NONE
- PTP_MSK_OPT_EXT_POWER = ( 1UL << PTP_OPT_EXT_POWER ), ///< see ::PTP_OPT_EXT_POWER
- PTP_MSK_OPT_EXT_TELECOM = ( 1UL << PTP_OPT_EXT_TELECOM ) ///< see ::PTP_OPT_EXT_TELECOM
+ PTP_MSK_OPT_EXT_NONE = ( 1UL << PTP_OPT_EXT_NONE ), ///< this is actually not used, see ::PTP_OPT_EXT_NONE
+ PTP_MSK_OPT_EXT_POWER = ( 1UL << PTP_OPT_EXT_POWER ), ///< see ::PTP_OPT_EXT_POWER
+ PTP_MSK_OPT_EXT_TELECOM = ( 1UL << PTP_OPT_EXT_TELECOM ), ///< see ::PTP_OPT_EXT_TELECOM
+ PTP_MSK_OPT_EXT_TELECOM_PHASE = ( 1UL << PTP_OPT_EXT_TELECOM_PHASE ), ///< see ::PTP_OPT_EXT_TELECOM_PHASE
+ PTP_MSK_OPT_EXT_SMPTE = ( 1UL << PTP_OPT_EXT_SMPTE ), ///< see ::PTP_OPT_EXT_SMPTE
+ PTP_MSK_OPT_EXT_8021AS = ( 1UL << PTP_OPT_EXT_8021AS ), ///< see ::PTP_OPT_EXT_8021AS
+ PTP_MSK_OPT_EXT_6185093 = ( 1UL << PTP_OPT_EXT_6185093 ), ///< see ::PTP_OPT_EXT_6185093
+ PTP_MSK_OPT_EXT_TELECOM_PTS = ( 1UL << PTP_OPT_EXT_TELECOM_PTS ) ///< see ::PTP_OPT_EXT_TELECOM_PTS
};
@@ -8907,12 +11635,18 @@ enum PTP_OPT_EXT_MASKS
*/
enum PTP_PRESETS
{
- PTP_PRESETS_CUSTOM, ///< customizable, always supported
- PTP_PRESETS_DFLT_E2E, ///< pure IEEE1588-2008 (PTPv2) with E2E
- PTP_PRESETS_DFLT_P2P, ///< pure IEEE1588-2008 (PTPv2) with P2P
- PTP_PRESETS_POWER, ///< IEEE C37.238 profile extension, only if ::PTP_MSK_OPT_EXT_POWER is set
- PTP_PRESETS_TELECOM, ///< ITU-T G.8265.1 profile extension, only if ::PTP_MSK_OPT_EXT_TELECOM is set
- N_PTP_PRESETS ///< number of supported profiles
+ PTP_PRESETS_CUSTOM, ///< customizable, always supported
+ PTP_PRESETS_DFLT_E2E, ///< pure IEEE1588-2008 (PTPv2) with E2E
+ PTP_PRESETS_DFLT_P2P, ///< pure IEEE1588-2008 (PTPv2) with P2P
+ PTP_PRESETS_POWER, ///< IEEE C37.238 profile extension, only if ::PTP_MSK_OPT_EXT_POWER is set
+ PTP_PRESETS_TELECOM, ///< ITU-T G.8265.1 profile extension, only if ::PTP_MSK_OPT_EXT_TELECOM is set
+ PTP_PRESETS_TELECOM_PHASE, ///< ITU-T G.8275.1 profile extension, only if ::PTP_MSK_OPT_EXT_TELECOM_PHASE is set
+ PTP_PRESETS_SMPTE, ///< SMPTE ST 2059-2 profile extension, only if ::PTP_MSK_OPT_EXT_SMPTE is set
+ PTP_PRESETS_AES67, ///< AES67 media profile
+ PTP_PRESETS_8021AS, ///< IEEE 802.1AS -like profile, only if ::PTP_MSK_OPT_EXT_8021AS is set
+ PTP_PRESETS_6185093, ///< IEC/IEEE FDIS 61850-9-3, only if ::PTP_MSK_OPT_EXT_6185093 is set
+ PTP_PRESETS_TELECOM_PTS, ///< ITU-T G.8275.2 profile extension, only if ::PTP_MSK_OPT_EXT_TELECOM_PTS is set
+ N_PTP_PRESETS ///< number of supported presets
};
@@ -8923,11 +11657,17 @@ enum PTP_PRESETS
*/
enum PTP_PRESETS_MASKS
{
- PTP_MSK_PRESETS_CUSTOM = ( 1UL << PTP_PRESETS_CUSTOM ), ///< see ::PTP_PRESETS_CUSTOM
- PTP_MSK_PRESETS_DFLT_E2E = ( 1UL << PTP_PRESETS_DFLT_E2E ), ///< see ::PTP_PRESETS_DFLT_E2E
- PTP_MSK_PRESETS_DFLT_P2P = ( 1UL << PTP_PRESETS_DFLT_P2P ), ///< see ::PTP_PRESETS_DFLT_P2P
- PTP_MSK_PRESETS_POWER = ( 1UL << PTP_PRESETS_POWER ), ///< see ::PTP_PRESETS_POWER
- PTP_MSK_PRESETS_TELECOM = ( 1UL << PTP_PRESETS_TELECOM ) ///< see ::PTP_PRESETS_TELECOM
+ PTP_MSK_PRESETS_CUSTOM = ( 1UL << PTP_PRESETS_CUSTOM ), ///< see ::PTP_PRESETS_CUSTOM
+ PTP_MSK_PRESETS_DFLT_E2E = ( 1UL << PTP_PRESETS_DFLT_E2E ), ///< see ::PTP_PRESETS_DFLT_E2E
+ PTP_MSK_PRESETS_DFLT_P2P = ( 1UL << PTP_PRESETS_DFLT_P2P ), ///< see ::PTP_PRESETS_DFLT_P2P
+ PTP_MSK_PRESETS_POWER = ( 1UL << PTP_PRESETS_POWER ), ///< see ::PTP_PRESETS_POWER
+ PTP_MSK_PRESETS_TELECOM = ( 1UL << PTP_PRESETS_TELECOM ), ///< see ::PTP_PRESETS_TELECOM
+ PTP_MSK_PRESETS_TELECOM_PHASE = ( 1UL << PTP_PRESETS_TELECOM_PHASE ), ///< see ::PTP_PRESETS_TELECOM_PHASE
+ PTP_MSK_PRESETS_SMPTE = ( 1UL << PTP_PRESETS_SMPTE ), ///< see ::PTP_PRESETS_SMPTE
+ PTP_MSK_PRESETS_AES67 = ( 1UL << PTP_PRESETS_AES67 ), ///< see ::PTP_PRESETS_AES67
+ PTP_MSK_PRESETS_8021AS = ( 1UL << PTP_PRESETS_8021AS ), ///< see ::PTP_PRESETS_8021AS
+ PTP_MSK_PRESETS_6185093 = ( 1UL << PTP_PRESETS_6185093), ///< see ::PTP_PRESETS_6185093
+ PTP_MSK_PRESETS_TELECOM_PTS = ( 1UL << PTP_PRESETS_TELECOM_PTS) ///< see ::PTP_PRESETS_TELECOM_PTS
};
@@ -8936,13 +11676,19 @@ enum PTP_PRESETS_MASKS
*
* @see ::PTP_PRESETS
*/
-#define PTP_PRESETS_STRS \
-{ \
- "Custom", \
- "Default E2E", \
- "Default P2P", \
- "Power", \
- "Telecom" \
+#define PTP_PRESETS_STRS \
+{ \
+ "Custom", \
+ "Default E2E IEEE1588-2008", \
+ "Default P2P IEEE1588-2008", \
+ "Power IEEE C37.238", \
+ "Telecom ITU-T G.8265.1", \
+ "Telecom ITU-T G.8275.1", \
+ "SMPTE ST 2059-2", \
+ "AES67 Media Profile", \
+ "IEEE 802.1AS", \
+ "Utility IEC 61850-9-3", \
+ "Telecom ITU-T G.8275.2" \
}
@@ -8974,6 +11720,739 @@ typedef struct
}
+
+#if defined( _PRELIMINARY_CODE )
+
+// TODO: These definitions are preliminary and maybe subject to changes.
+
+/**
+ * @brief SMPTE System Frame Rates according to SMPTE ST 2059-2
+ *
+ * @see ::TODO
+ */
+enum SMPTE_SYSTEM_FRAME_RATES
+{
+ SMPTE_23_98HZ,
+ SMPTE_24HZ,
+ SMPTE_25HZ,
+ SMPTE_29_97HZ,
+ SMPTE_50HZ,
+ SMPTE_59_94HZ,
+ N_SMPTE_SYSTEM_FRAME_RATES
+};
+
+
+#define SMPTE_SYSTEM_FRAME_RATE_STR \
+{ \
+ "24Hz (23.98)", \
+ "24Hz", \
+ "25Hz", \
+ "30Hz (29.97)", \
+ "50Hz", \
+ "60Hz (59.94)" \
+}
+
+
+#define SMPTE_FRAME_RATE_NUM \
+{ \
+ 24000, \
+ 24000, \
+ 25000, \
+ 30000, \
+ 50000, \
+ 60000, \
+}
+
+#define SMPTE_FRAME_RATE_DENUM \
+{ \
+ 1001, \
+ 1000, \
+ 1000, \
+ 1001, \
+ 1000, \
+ 1001, \
+}
+
+
+/**
+ * @brief Additional parameters for SMPTE ST 2059-2 profile
+ *
+ * This stucture holds the synchronization metadata required for the SMPTE profile.
+ * This structure is only used for internal storage of the data. The data is
+ * distributed through a network by using management messages and the dedicated
+ * organization extension TLV defined in the SMPTE profile.
+ */
+typedef struct
+{
+ /// Default system frame rate
+ /// Default video frame rate of the slave system as a lowest term rational.
+ /// The data type shall be composed of a pair of unsigned Int32 values coded
+ /// in big-endian form where the first shall be the numerator and the second
+ /// shall be the denominator. The denominator shall be the smallest value
+ /// that represents the frame rate denominator
+ /// For example, 29.97 Hz: (30000/1001) or 25 Hz: (25/1).
+ uint32_t defaultSystemFrameRateNum;
+ uint32_t defaultSystemFrameRateDenum;
+ /// Master locking status
+ /// Complementary information to clockClass (0: Not in use, 1: Free Run,
+ /// 2: Cold Locking, 3: Warm Locking, 4: Locked)
+ uint8_t masterLockingStatus;
+ /// Time Address Flags
+ /// Indicates the intended ST 12-1 flags.
+ /// Bit 0: Drop frame (0: Non-drop-frame, 1: Drop-frame)
+ /// Bit 1: Color Frame Identification (0: Not in use, 1: In use)
+ /// Bits 2-7: Reserved
+ uint8_t timeAddressFlags;
+ /// Current local offset
+ /// Offset in seconds of Local Time from grandmaster PTP time. For example,
+ /// if Local Time is Eastern Standard Time (North America) UTC-5 and the
+ /// number of leap seconds is 35, the value will be -18035 (decimal).
+
+ uint8_t reserved_1;
+ uint8_t reserved_2;
+
+ int32_t currentLocalOffset;
+ /// Jump seconds
+ /// The size of the next discontinuity, in seconds, of Local Time. A value
+ /// of zero indicates that no discontinuity is expected. A positive value
+ /// indicates that the discontinuity will cause the currentLocalOffset to increase.
+ int32_t jumpSeconds;
+ /// Time of next jump
+ /// The value of the seconds portion of the grandmastermaster PTP time at the time
+ /// that the next discontinuity of the currentLocalOffset will occur. The
+ /// discontinuity occurs at the start of the second indicated
+ uint8_t timeOfNextJump[6];
+ /// Time of next jam
+ /// The value of the seconds portion of the PTP time corresponding to the next
+ /// scheduled occurrence of the Daily Jam. If no Daily Jam is scheduled, the
+ /// value of timeOfNextJam shall be zero.
+ uint8_t timeOfNextJam[6];
+ /// Time of previous jam
+ /// The value of the seconds portion of the PTP time corresponding to the
+ /// previous occurrence of the Daily Jam.
+ uint8_t timeOfPreviousJam[6];
+ /// Previous jam local offset
+ /// The value of currentLocalOffset at the previous daily jam time.
+ /// If a discontinuity of Local Time occurs at the jam time, this parameter
+ /// reflects the offset after the discontinuity.
+ uint8_t reserved_3;
+ uint8_t reserved_4;
+ uint32_t reserved_5;
+
+ int32_t previousJamLocalOffset;
+ /// Daylight saving
+ /// Bit 0: Current Daylight Saving (0: Not in effect, 1: In effect)
+ /// Bit 1: Daylight Saving at next discontinuity (0: Not in effect, 1: In effect)
+ /// Bit 2: Daylight Saving at previous daily jam time (0: Not in effect, 1: In effect)
+ /// Bits 3-7: Reserved
+ uint8_t daylightSaving;
+ /// Leap second jump
+ /// The reason for the forthcoming discontinuity of currentLocalOffset indicated by
+ /// timeOfNextJump
+ /// Bit 0:
+ /// 0: Other than a change in the number of leap seconds (default)
+ /// 1: A change in number of leap seconds
+ /// Bits 1-7: Reserved
+ uint8_t leapSecondJump;
+
+ uint8_t reserved_6;
+ uint8_t reserved_7;
+
+ uint32_t reserved_8;
+ uint32_t reserved_9;
+ uint32_t reserved_10;
+
+} PTP_SMPTE_PROFILE_CFG;
+
+
+
+/**
+ * @brief Additional parameters for Telecom8275.1 profile
+ */
+typedef struct
+{
+ uint8_t use_alternate_multicast_address;
+ uint8_t reserved_1;
+ uint8_t reserved_2;
+ uint8_t reserved_3;
+ uint32_t reserved_4;
+
+} 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 ); \
+}
+
+
+
+/**
+ * @brief A type which holds one of the ITU-T SSM codes
+ *
+ * @see ::ITU_SSM_CODES
+ */
+typedef uint16_t ITU_SSM_CODE;
+
+
+
+/**
+ * @brief ITU-T SSM codes acc. to Recommendation G.781
+ *
+ * @see ::ITU_SSM_CODE
+ */
+enum ITU_SSM_CODES
+{
+ ITU_SSM_CODE_STU_UKN,
+ ITU_SSM_CODE_PRS,
+ ITU_SSM_CODE_PRC,
+ ITU_SSM_CODE_INV3,
+ ITU_SSM_CODE_SSU_A_TNC,
+ ITU_SSM_CODE_INV5,
+ ITU_SSM_CODE_INV6,
+ ITU_SSM_CODE_ST2,
+ ITU_SSM_CODE_SSU_B,
+ ITU_SSM_CODE_INV9,
+ ITU_SSM_CODE_ST3,
+ ITU_SSM_CODE_SEC,
+ ITU_SSM_CODE_SMC,
+ ITU_SSM_CODE_ST3E,
+ ITU_SSM_CODE_PROV,
+ ITU_SSM_CODE_DNU_DUS,
+ N_ITU_SSM_CODES
+};
+
+
+#define N_SSM_CODES_OPTION_1 5
+#define N_SSM_CODES_OPTION_2 9
+
+
+/**
+ * @brief Name strings for SSM codes, network option I
+ *
+ * @see ::ITU_SSM_CODES
+ */
+#define ITU_SSM_CODE_OPT_1_STRS \
+{ \
+ "", \
+ "", \
+ "QL-PRC", \
+ "", \
+ "QL-SSU-A", \
+ "", \
+ "", \
+ "", \
+ "QL-SSU-B", \
+ "", \
+ "", \
+ "QL-SEC", \
+ "", \
+ "", \
+ "", \
+ "QL-DNU" \
+}
+
+
+
+/**
+ * @brief Name strings for SSM codes, network option II
+ *
+ * @see ::ITU_SSM_CODES
+ */
+#define ITU_SSM_CODE_OPT_2_STRS \
+{ \
+ "QL-STU", \
+ "QL-PRS", \
+ "", \
+ "", \
+ "QL-TNC", \
+ "", \
+ "", \
+ "QL-ST2", \
+ "", \
+ "", \
+ "QL-ST3", \
+ "", \
+ "QL-SMC", \
+ "QL-ST3E", \
+ "QL-PROV", \
+ "QL-DUS" \
+}
+
+
+
+/**
+ * @brief Name strings for SSM codes, option I and II combined
+ *
+ * @see ::ITU_SSM_CODES
+ */
+#define ITU_SSM_CODE_STRS_COMBINED \
+{ \
+ "QL-STU/UKN", \
+ "QL-PRS", \
+ "QL-PRC", \
+ "QL-INV3", \
+ "QL-SSU-A/TNC", \
+ "QL-INV5", \
+ "QL-INV6", \
+ "QL-ST2", \
+ "QL-SSU-B", \
+ "QL-INV9", \
+ "QL-EEC2/ST3", \
+ "QL-EEC1/SEC", \
+ "QL-SMC", \
+ "QL-ST3E", \
+ "QL-PROV", \
+ "QL-DNU/DUS", \
+}
+
+
+
+/**
+ * @brief Maximum T1 SSM only quality levels
+ *
+ * @see ::T1_SSM_QLVL
+ * @see ::T1_SSM_QLVL_STRS
+ * @see ::T1_SSM_QLVL_ARRAY
+ */
+#define MAX_T1_SSM_QLVL 8
+
+
+
+/**
+ * @brief T1 SSM only quality level (6 bit encoded)
+ *
+ * @see ::MAX_T1_SSM_QLVL
+ * @see ::T1_SSM_QLVL_STRS
+ * @see ::T1_SSM_QLVL_ARRAY
+ */
+enum T1_SSM_QLVL
+{
+ T1_SSM_QLVL_ST1_TRACE = 2,
+ T1_SSM_QLVL_SYNC_TRACE_UNKNOWN = 4,
+ T1_SSM_QLVL_ST2_TRACE = 6,
+ T1_SSM_QLVL_ST3_TRACE = 8,
+ T1_SSM_QLVL_SONET_MIN_CLOCK_TRACE = 17,
+ T1_SSM_QLVL_ST4_TRACE = 20,
+ T1_SSM_QLVL_DNU_FOR_SYNC = 24,
+ T1_SSM_QLVL_RESERVED = 32
+};
+
+
+
+/**
+ * @brief T1 SSM only quality level array
+ *
+ * @see ::MAX_T1_SSM_QLVL
+ * @see ::T1_SSM_QLVL_STRS
+ * @see ::T1_SSM_QLVL
+ */
+#define T1_SSM_QLVL_ARRAY \
+{ \
+ T1_SSM_QLVL_ST1_TRACE, \
+ T1_SSM_QLVL_SYNC_TRACE_UNKNOWN, \
+ T1_SSM_QLVL_ST2_TRACE, \
+ T1_SSM_QLVL_ST3_TRACE, \
+ T1_SSM_QLVL_SONET_MIN_CLOCK_TRACE, \
+ T1_SSM_QLVL_ST4_TRACE, \
+ T1_SSM_QLVL_DNU_FOR_SYNC, \
+ T1_SSM_QLVL_RESERVED \
+}
+
+
+
+/**
+ * @brief Name strings for T1 SSM quality levels
+ *
+ * @see ::MAX_T1_SSM_QLVL
+ * @see ::T1_SSM_QLVL
+ * @see ::T1_SSM_QLVL_ARRAY
+ */
+#define T1_SSM_QLVL_STRS \
+{ \
+ "Stratum 1 traceable", \
+ "Synchronized traceability unknown", \
+ "Stratum 2 traceable", \
+ "Stratum 3 traceable", \
+ "SONET minimum clock traceable", \
+ "Stratum 4 traceable", \
+ "Do not use for sync", \
+ "Reserved for network sync" \
+}
+
+
+
+/**
+ * @brief SDH network options
+ *
+ * @see ::SDH_NETWORK_OPTION_MASKS
+ */
+enum SDH_NETWORK_OPTION
+{
+ SDH_NETWORK_OPTION_1,
+ SDH_NETWORK_OPTION_2,
+ N_SDH_NETWORK_OPTIONS
+
+};
+
+
+
+/**
+ * @brief Flag masks used with ::MBG_SYNC_E_INFO::supp_sdh_network_opts
+ *
+ * @see ::SDH_NETWORK_OPTION
+ */
+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
+};
+
+
+
+/**
+ * @brief Name strings for SDH network options
+ *
+ * @see ::SDH_NETWORK_OPTION
+ */
+#define SDH_NETWORK_OPTION_STRS \
+{ \
+ "SDH Network Opt. 1", \
+ "SDH Network Opt. 2", \
+}
+
+
+
+//##++++ TODO: shouldn't this be merged with / replaced by MBG_NET_LINK_MODES?
+/**
+ * @brief Link modes for SyncE on a 1000BASE-T interface
+ *
+ * @see ::GBIT_LINK_COPPER_MODE_MASKS
+ */
+enum GBIT_LINK_COPPER_MODE
+{
+ GBIT_LINK_COPPER_AUTO, // valid if synce is disabled
+ GBIT_LINK_COPPER_FORCE_SYNCE_AUTO,
+ GBIT_LINK_COPPER_FORCE_OR_IS_MASTER, // Used in both structures, settings and status
+ GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE, // Used in both structures, settings and status
+ GBIT_LINK_COPPER_PREFER_MASTER,
+ GBIT_LINK_COPPER_PREFER_SLAVE,
+ N_GBIT_LINK_COPPER_MODES
+};
+
+
+
+/**
+ * @brief Flag masks used with ::MBG_SYNC_E_INFO::supp_gbit_link_copper_modes
+ *
+ * @see ::GBIT_LINK_COPPER_MODE
+ */
+enum GBIT_LINK_COPPER_MODE_MASKS
+{
+ GBIT_LINK_COPPER_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_AUTO ), ///< see ::GBIT_LINK_COPPER_AUTO_MSK
+ GBIT_LINK_COPPER_FORCE_SYNCE_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_SYNCE_AUTO ), ///< see ::GBIT_LINK_COPPER_FORCE_SYNCE_AUTO
+ GBIT_LINK_COPPER_FORCE_OR_IS_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_MASTER ), ///< see ::GBIT_LINK_COPPER_FORCE_OR_IS_MASTER
+ GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE ), ///< see ::GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE
+ GBIT_LINK_COPPER_PREFER_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_MASTER ), ///< see ::GBIT_LINK_COPPER_PREFER_MASTER
+ GBIT_LINK_COPPER_PREFER_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_SLAVE ) ///< see ::GBIT_LINK_COPPER_PREFER_SLAVE
+};
+
+
+
+//##++++ TODO: shouldn't this be merged with MBG_NET_LINK_ROLE_BITS / MBG_NET_LINK_ROLE_MASKS?
+/**
+ * @brief Link status for SyncE on a 1000BASE-T interface
+ *
+ * @see ::TODO
+ */
+enum GBIT_LINK_STATUS
+{
+ GBIT_LINK_COPPER_IS_MASTER, ///< GBIT Link is currently clock master
+ GBIT_LINK_COPPER_IS_SLAVE, ///< GBIT Link is currently clock slave
+ GBIT_LINK_COPPER_CFG_FAULT, ///< GBIT Link has a configruation fault (conflict with link partner
+ GBIT_LINK_COPPER_IS_FE, ///< Link is running on Fast Ethernet (no MASTER/SLAVE decision)
+ GBIT_LINK_DOWN, ///< Currently no link
+ GBIT_LINK_FIBER, ///< GBIT Linkup on SFP interface
+ N_GBIT_LINK_STATUS
+};
+
+
+#define GBIT_LINK_STATUS_STRS \
+{ \
+ "MASTER (1000BASE-T)", \
+ "SLAVE (1000BASE-T)", \
+ "CFG FAULT", \
+ "AUTO (100BASE-TX)", \
+ "LINK DOWN", \
+ "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 )
+
+
+
/**
* @brief Limits to be considered when specifying PTP unicast masters
*/
@@ -9007,6 +12486,7 @@ typedef struct
}
+
/**
* @brief Configuration settings specifiying how to query a PTP unicast master
*
@@ -9049,6 +12529,7 @@ typedef struct
}
+
/**
* @brief Unicast PTP master message duration limits
*
@@ -9085,6 +12566,7 @@ typedef struct
}
+
/**
* @brief Current settings and general capabilities of a unicast master
*
@@ -9107,6 +12589,7 @@ typedef struct
}
+
/**
* @brief Current settings and general capabilities of a specific unicast master
*
@@ -9133,6 +12616,96 @@ typedef struct
_mbg_swab_ptp_uc_master_info( &(_p)->info ); \
}
+
+
+#if defined( _PRELIMINARY_CODE )
+
+typedef struct
+{
+ uint32_t counter_cfg;
+ uint32_t flags;
+ uint32_t reserved_1;
+ uint32_t reserved_2;
+
+} MBG_PTP_STATISTICS_SETTINGS;
+
+
+
+typedef struct
+{
+ MBG_PTP_STATISTICS_SETTINGS settings;
+ uint32_t supp_flags; ///< Supported settings, currently 0
+ uint32_t reserved_1;
+
+} MBG_PTP_STATISTICS_INFO;
+
+
+
+typedef struct
+{
+ uint32_t status; ///< status word flags (use PacketCounterStat_e)
+ uint32_t rx; ///< overall Rx packet counter
+ uint32_t rxPerSec; ///< overall Rx packet counter
+ uint32_t tx; ///< overall Tx packet counter
+ uint32_t txPerSec; ///< overall Tx packet counter
+ /// invalid Rx packet counter
+ /// Indicates one of the following issues: wrong PTP version, wrong domain number,
+ /// message from self, message from other BC port, multicast message in unicast mode
+ /// or message extraction error (size error or inconsistent format).
+ uint32_t errorRx;
+ uint32_t announceMsgRx; ///< Accepted Announce message Rx counter
+ uint32_t announceMsgPerSecRx; ///< Accepted Announce message Rx counter
+ uint32_t announceMsgTx; ///< Announce message Tx counter
+ uint32_t announceMsgPerSecTx; ///< Announce message Tx counter
+ uint32_t syncMsgRx; ///< Accepted Sync message Rx counter
+ uint32_t syncMsgPerSecRx; ///< Accepted Sync message Rx counter
+ uint32_t syncMsgTx; ///< Sync message Tx counter
+ uint32_t syncMsgPerSecTx; ///< Sync message Tx counter
+ uint32_t followUpMsgRx; ///< Accepted Follow-up message Rx counter
+ uint32_t followUpMsgPerSecRx; ///< Accepted Follow-up message Rx counter
+ uint32_t followUpMsgTx; ///< Follow-up message Tx counter
+ uint32_t followUpMsgPerSecTx; ///< Follow-up message Tx counter
+ uint32_t dlyReqMsgRx; ///< Accepted Delay request message Rx counter
+ uint32_t dlyReqMsgPerSecRx; ///< Accepted Delay request message Rx counter
+ uint32_t dlyReqMsgTx; ///< Delay request message Tx counter
+ uint32_t dlyReqMsgPerSecTx; ///< Delay request message Tx counter
+ uint32_t dlyRespMsgRx; ///< Accepted Delay response message Rx counter
+ uint32_t dlyRespMsgPerSecRx; ///< Accepted Delay response message Rx counter
+ uint32_t dlyRespMsgTx; ///< Delay response message Tx counter
+ uint32_t dlyRespMsgPerSecTx; ///< Delay response message Tx counter
+ uint32_t pDlyReqMsgRx; ///< Accepted PDelay Request message Rx counter
+ uint32_t pDlyReqMsgPerSecRx; ///< Accepted PDelay Request message Rx counter
+ uint32_t pDlyReqMsgTx; ///< PDelay Request message Tx counter
+ uint32_t pDlyReqMsgPerSecTx; ///< PDelay Request message Tx counter
+ uint32_t pDlyRespMsgRx; ///< Accepted PDelay Response message Rx counter
+ uint32_t pDlyRespMsgPerSecRx; ///< Accepted PDelay Response message Rx counter
+ uint32_t pDlyRespMsgTx; ///< PDelay Response message Tx counter
+ uint32_t pDlyRespMsgPerSecTx; ///< PDelay Response message Tx counter
+ uint32_t pDlyFollowUpRx; ///< Accepted PDelay Follow-Up message Rx counter
+ uint32_t pDlyFollowUpPerSecRx; ///< Accepted PDelay Follow-Up message Rx counter
+ uint32_t pDlyFollowUpTx; ///< PDelay Follow-Up message Tx counter
+ uint32_t pDlyFollowUpPerSecTx; ///< PDelay Follow-Up message Tx counter
+ uint32_t signallingRx; ///< Accepted Signalling message Rx counter
+ uint32_t signallingPerSecRx; ///< Accepted Signalling message Rx counter
+ uint32_t signallingTx; ///< Signalling message Tx counter
+ uint32_t signallingPerSecTx; ///< Signalling message Tx counter
+ uint32_t mgmtRx; ///< Accepted Management message Rx counter
+ uint32_t mgmtPerSecRx; ///< Accepted Management message Rx counter
+ uint32_t mgmtTx; ///< Management message Tx counter
+ uint32_t mgmtPerSecTx; ///< Management message Tx counter
+ uint32_t mgmtErr; ///< Management error counter (rx)
+ uint32_t annReceptTout; ///< Announce recept timeout count
+
+ uint32_t numUcConn; ///< Number of current Unicast client connections
+ uint32_t maxNumUcConn; ///< Maximum Number of Unicast client connections (due to licence or CPU performance)
+ uint32_t numMsgPerSec; ///< Number of all messages per second (TX/RX)
+ uint32_t maxMsgPerSec; ///< max allowed number of all messages per second in Multicast/Hybrid mode (due to licence or CPU performance)
+
+} MBG_PTP_STATISTICS_STATUS;
+
+#endif // !defined( _PRELIMINARY_CODE )
+
+
/** @} defgroup group_ptp */
@@ -9175,7 +12748,7 @@ enum NTP_ROLE_MASKS
/**
* @brief Enumeration of global NTP flags
*
- * @see ::NTP_FLAG_MASKS
+ * @see @ref NTP_FLAG_MASKS
*/
enum NTP_FLAGS
{
@@ -9193,10 +12766,23 @@ enum NTP_FLAGS
NTP_MULTICAST, ///< transmission via multicast, point to multipoint
NTP_MANYCAST, ///< transmission via manycast, point to multipoint
NTP_POOL, ///< peer shall be treated as a pool server
+#if defined( _PRELIMINARY_CODE )
+ NTP_PEER, ///< specifies a symmetric-active association should be used with this server
+ NTP_BROADCASTCLIENT, ///< receive broadcast messages on all interfaces
+ NTP_MULTICASTCLIENT, ///< receive messages from the given multicast group
+ NTP_MANYCASTCLIENT, ///< manycast shall be used on the given multicast address to discover peers
+ NTP_RESTRICTIONS, ///< NTP supports restrictions
+ NTP_DISCARD, ///< NTP supports "discard" rate limiting
+ NTP_REFCLOCKS, ///< NTP supports refclocks
+ NTP_STATISTICS, ///< NTP supports statistics (e.g. clockstats, loopstats, etc...)
+ NTP_MISCELLANEOUS, ///< NTP supports misc options (e.g. tinker, driftfile, orphan mode, etc...)
+ NTP_TRUSTED_KEYS, ///< NTP supports specifying trusted symmetric keys
+#endif // defined( _PRELIMINARY_CODE )
N_NTP_FLAGS
};
+
/**
* @brief Flag masks associated with ::NTP_FLAGS
*
@@ -9207,24 +12793,39 @@ enum NTP_FLAGS
* @todo We may need structures to configure symmetric keys, and autokey certificates.
*
* @see ::NTP_FLAGS
- */
-enum NTP_FLAG_MASKS
-{
- NTP_MSK_IPV4 = ( 1UL << NTP_IPV4 ), ///< see ::NTP_IPV4
- NTP_MSK_IPV6 = ( 1UL << NTP_IPV6 ), ///< see ::NTP_IPV6
- NTP_MSK_SYMM_KEYS = ( 1UL << NTP_SYMM_KEYS ), ///< see ::NTP_SYMM_KEYS
- NTP_MSK_AUTOKEY = ( 1UL << NTP_AUTOKEY ), ///< see ::NTP_AUTOKEY
- NTP_MSK_BURST = ( 1UL << NTP_BURST ), ///< see ::NTP_BURST
- NTP_MSK_IBURST = ( 1UL << NTP_IBURST ), ///< see ::NTP_IBURST
- NTP_MSK_NO_SELECT = ( 1UL << NTP_NO_SELECT ), ///< see ::NTP_NO_SELECT
- NTP_MSK_PREEMPT = ( 1UL << NTP_PREEMPT ), ///< see ::NTP_PREEMPT
- NTP_MSK_PREFER = ( 1UL << NTP_PREFER ), ///< see ::NTP_PREFER
- NTP_MSK_TRUE = ( 1UL << NTP_TRUE ), ///< see ::NTP_TRUE
- NTP_MSK_BROADCAST = ( 1UL << NTP_BROADCAST ), ///< see ::NTP_BROADCAST
- NTP_MSK_MULTICAST = ( 1UL << NTP_MULTICAST ), ///< see ::NTP_MULTICAST
- NTP_MSK_MANYCAST = ( 1UL << NTP_MANYCAST ), ///< see ::NTP_MANYCAST
- NTP_MSK_POOL = ( 1UL << NTP_POOL ) ///< see ::NTP_POOL
-};
+ *
+ * @anchor NTP_FLAG_MASKS @{ */
+
+#define NTP_MSK_IPV4 ( 1UL << NTP_IPV4 ) ///< see ::NTP_IPV4
+#define NTP_MSK_IPV6 ( 1UL << NTP_IPV6 ) ///< see ::NTP_IPV6
+#define NTP_MSK_SYMM_KEYS ( 1UL << NTP_SYMM_KEYS ) ///< see ::NTP_SYMM_KEYS; if set, ::NTP_SYMM_KEY_LIMITS can be queried
+#define NTP_MSK_AUTOKEY ( 1UL << NTP_AUTOKEY ) ///< see ::NTP_AUTOKEY
+#define NTP_MSK_BURST ( 1UL << NTP_BURST ) ///< see ::NTP_BURST
+#define NTP_MSK_IBURST ( 1UL << NTP_IBURST ) ///< see ::NTP_IBURST
+#define NTP_MSK_NO_SELECT ( 1UL << NTP_NO_SELECT ) ///< see ::NTP_NO_SELECT
+#define NTP_MSK_PREEMPT ( 1UL << NTP_PREEMPT ) ///< see ::NTP_PREEMPT
+#define NTP_MSK_PREFER ( 1UL << NTP_PREFER ) ///< see ::NTP_PREFER
+#define NTP_MSK_TRUE ( 1UL << NTP_TRUE ) ///< see ::NTP_TRUE
+#define NTP_MSK_BROADCAST ( 1UL << NTP_BROADCAST ) ///< see ::NTP_BROADCAST
+#define NTP_MSK_MULTICAST ( 1UL << NTP_MULTICAST ) ///< see ::NTP_MULTICAST
+#define NTP_MSK_MANYCAST ( 1UL << NTP_MANYCAST ) ///< see ::NTP_MANYCAST
+#define NTP_MSK_POOL ( 1UL << NTP_POOL ) ///< see ::NTP_POOL
+
+#if defined( _PRELIMINARY_CODE )
+ #define NTP_MSK_PEER ( 1UL << NTP_PEER ) ///< see ::NTP_PEER
+ #define NTP_MSK_BROADCASTCLIENT ( 1UL << NTP_BROADCASTCLIENT) ///< see ::NTP_BROADCASTCLIENT
+ #define NTP_MSK_MULTICASTCLIENT ( 1UL << NTP_MULTICASTCLIENT) ///< see ::NTP_MULTICASTCLIENT
+ #define NTP_MSK_MANYCASTCLIENT ( 1UL << NTP_MANYCASTCLIENT) ///< see ::NTP_MANYCASTCLIENT
+ #define NTP_MSK_RESTRICTIONS ( 1UL << NTP_RESTRICTIONS ) ///< see ::NTP_RESTRICTIONS
+ #define NTP_MSK_DISCARD ( 1UL << NTP_DISCARD ) ///< see ::NTP_DISCARD
+ #define NTP_MSK_REFCLOCKS ( 1UL << NTP_REFCLOCKS ) ///< see ::NTP_REFCLOCKS
+ #define NTP_MSK_STATISTICS ( 1UL << NTP_STATISTICS ) ///< see ::NTP_STATISTICS; if set, ::NTP_STATS_GLB_INFO can be queried
+ #define NTP_MSK_MISCELLANEOUS ( 1UL << NTP_MISCELLANEOUS ) ///< see ::NTP_MISCELLANEOUS
+ #define NTP_MSK_TRUSTED_KEYS ( 1UL << NTP_TRUSTED_KEYS ) ///< see ::NTP_TRUSTED_KEYS
+#endif // defined( _PRELIMINARY_CODE )
+
+/** @} anchor NTP_FLAG_MASKS */
+
/**
@@ -9250,11 +12851,880 @@ typedef struct
_mbg_swab16( &(_p)->reserved_2 ); \
_mbg_swab32( &(_p)->reserved_3 ); \
_mbg_swab32( &(_p)->reserved_4 ); \
- _mbg_swab32( &(_p)->cfg_flags ); \
+ _mbg_swab32( &(_p)->flags ); \
}
+#if defined( _PRELIMINARY_CODE )
+
+/**
+ * @brief Enumeration of supported NTP restriction types/keywords
+ *
+ * Used with ::NTP_RESTR::type
+ *
+ * @see https://www.eecis.udel.edu/~mills/ntp/html/accopt.html#restrict
+ * @see ::NTP_RESTR_TYPE_MSKS
+ */
+enum NTP_RESTR_TYPES
+{
+ NTP_RESTR_TYPE_DEFAULT,
+ NTP_RESTR_TYPE_SOURCE,
+ NTP_RESTR_TYPE_ADDRESS,
+ N_NTP_RESTR_TYPES
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::NTP_RESTR_TYPES
+ *
+ * Used with ::NTP_RESTR_LIMITS::supp_types
+ *
+ * @see ::NTP_RESTR_TYPES
+ */
+enum NTP_RESTR_TYPE_MSKS
+{
+ NTP_RESTR_TYPE_MSK_DEFAULT = ( 1UL << NTP_RESTR_TYPE_DEFAULT ), ///< see ::NTP_RESTR_TYPE_DEFAULT
+ NTP_RESTR_TYPE_MSK_SOURCE = ( 1UL << NTP_RESTR_TYPE_SOURCE ), ///< see ::NTP_RESTR_TYPE_SOURCE
+ NTP_RESTR_TYPE_MSK_ADDRESS = ( 1UL << NTP_RESTR_TYPE_ADDRESS ) ///< see ::NTP_RESTR_TYPE_ADDRESS
+};
+
+
+
+/**
+ * @brief Enumeration of supported NTP restriction flags
+ *
+ * Used to define ::NTP_RESTR_FLAG_MSKS
+ *
+ * @see https://www.eecis.udel.edu/~mills/ntp/html/accopt.html#restrict
+ * @see ::NTP_RESTR_FLAG_MSKS
+ */
+enum NTP_RESTR_FLAGS
+{
+ NTP_RESTR_FLAG_FLAKE,
+ NTP_RESTR_FLAG_IGNORE,
+ NTP_RESTR_FLAG_KOD,
+ NTP_RESTR_FLAG_LIMITED,
+ NTP_RESTR_FLAG_LOWPRIOTRAP,
+ NTP_RESTR_FLAG_MSSNTP,
+ NTP_RESTR_FLAG_NOMODIFY,
+ NTP_RESTR_FLAG_NOQUERY,
+ NTP_RESTR_FLAG_NOPEER,
+ NTP_RESTR_FLAG_NOSERVE,
+ NTP_RESTR_FLAG_NOTRAP,
+ NTP_RESTR_FLAG_NOTRUST,
+ NTP_RESTR_FLAG_NTPPORT,
+ NTP_RESTR_FLAG_VERSION,
+ NTP_RESTR_FLAG_IPV4, ///< This default restriction only applies to IPv4
+ NTP_RESTR_FLAG_IPV6, ///< This default restriction only applies to IPv6
+ N_NTP_RESTR_FLAGS
+};
+
+
+
+/**
+ * @brief Flag masks associated with ::NTP_RESTR_FLAGS
+ *
+ * Used with ::NTP_RESTR::flags and ::NTP_RESTR_LIMITS::supp_flags
+ *
+ * @see ::NTP_RESTR_FLAGS
+ */
+enum NTP_RESTR_FLAG_MSKS
+{
+ NTP_RESTR_FLAG_MSK_FLAKE = ( 1UL << NTP_RESTR_FLAG_FLAKE ), ///< see ::NTP_RESTR_FLAG_FLAKE
+ NTP_RESTR_FLAG_MSK_IGNORE = ( 1UL << NTP_RESTR_FLAG_IGNORE ), ///< see ::NTP_RESTR_FLAG_IGNORE
+ NTP_RESTR_FLAG_MSK_KOD = ( 1UL << NTP_RESTR_FLAG_KOD ), ///< see ::NTP_RESTR_FLAG_KOD
+ NTP_RESTR_FLAG_MSK_LIMITED = ( 1UL << NTP_RESTR_FLAG_LIMITED ), ///< see ::NTP_RESTR_FLAG_LIMITED
+ NTP_RESTR_FLAG_MSK_LOWPRIOTRAP = ( 1UL << NTP_RESTR_FLAG_LOWPRIOTRAP ),///< see ::NTP_RESTR_FLAG_LOWPRIOTRAP
+ NTP_RESTR_FLAG_MSK_MSSNTP = ( 1UL << NTP_RESTR_FLAG_MSSNTP ), ///< see ::NTP_RESTR_FLAG_MSSNTP
+ NTP_RESTR_FLAG_MSK_NOMODIFY = ( 1UL << NTP_RESTR_FLAG_NOMODIFY ), ///< see ::NTP_RESTR_FLAG_NOMODIFY
+ NTP_RESTR_FLAG_MSK_NOQUERY = ( 1UL << NTP_RESTR_FLAG_NOQUERY ), ///< see ::NTP_RESTR_FLAG_NOQUERY
+ NTP_RESTR_FLAG_MSK_NOPEER = ( 1UL << NTP_RESTR_FLAG_NOPEER ), ///< see ::NTP_RESTR_FLAG_NOPEER
+ NTP_RESTR_FLAG_MSK_NOSERVE = ( 1UL << NTP_RESTR_FLAG_NOSERVE ), ///< see ::NTP_RESTR_FLAG_NOSERVE
+ NTP_RESTR_FLAG_MSK_NOTRAP = ( 1UL << NTP_RESTR_FLAG_NOTRAP ), ///< see ::NTP_RESTR_FLAG_NOTRAP
+ NTP_RESTR_FLAG_MSK_NOTRUST = ( 1UL << NTP_RESTR_FLAG_NOTRUST ), ///< see ::NTP_RESTR_FLAG_NOTRUST
+ NTP_RESTR_FLAG_MSK_NTPPORT = ( 1UL << NTP_RESTR_FLAG_NTPPORT ), ///< see ::NTP_RESTR_FLAG_NTPPORT
+ NTP_RESTR_FLAG_MSK_VERSION = ( 1UL << NTP_RESTR_FLAG_VERSION ), ///< see ::NTP_RESTR_FLAG_VERSION
+ NTP_RESTR_FLAG_MSK_IPV4 = ( 1UL << NTP_RESTR_FLAG_IPV4 ), ///< see ::NTP_RESTR_FLAG_IPV4
+ NTP_RESTR_FLAG_MSK_IPV6 = ( 1UL << NTP_RESTR_FLAG_IPV6 ) ///< see ::NTP_RESTR_FLAG_IPV6
+};
+
+
+
+/**
+ * @brief General NTP restriction limits to be read from a device
+ *
+ * Used to query from a device how many NTP restrictions are supported
+ * by the device, then index 0..::NTP_RESTR_LIMITS::cur_restrs-1
+ * restriction records can be read from a device. A maximum of
+ * ::NTP_RESTR_LIMITS::max_restrs can be configured at all.
+ */
+typedef struct
+{
+ uint16_t max_restrs; ///< Number of maximum supported restrictions
+ uint16_t cur_restrs; ///< Number of currently configured restrictions
+ uint32_t supp_types; ///< Supported restriction types, see ::NTP_RESTR_TYPE_MSKS
+ uint32_t supp_flags; ///< Supported restriction flags, see ::NTP_RESTR_FLAG_MSKS
+ uint32_t reserved; ///< Future use
+
+} NTP_RESTR_LIMITS;
+
+#define _mbg_swab_ntp_restr_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->max_restrs ); \
+ _mbg_swab16( &(_p)->cur_restrs ); \
+ _mbg_swab32( &(_p)->supp_types ); \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+/**
+ * @brief NTP restriction
+ *
+ * Structure contains all flags and information needed for a valid NTP restriction
+ * as described at ntp.org's manual page.
+ */
+typedef struct
+{
+ uint8_t type; ///< Restriction type, see ::NTP_RESTR_TYPES
+ uint8_t reserved_1; ///< Future use
+ uint16_t reserved_2; ///< Future use
+ uint32_t flags; ///< Restriction flags, see ::NTP_RESTR_FLAG_MSKS
+
+ MBG_HOSTNAME addr; ///< used if ::NTP_RESTR::type == ::NTP_RESTR_TYPE_ADDRESS
+ ///< can contain a hostname, or an IPv4 or IPv6 address
+ ///< with or without CIDR extension (eg. 172.16.0.0/16).
+} NTP_RESTR;
+
+#define _mbg_swab_ntp_restr( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab_ntp_restr_discard( &(_p)->u.discard ); \
+}
+
+
+
+/**
+ * @brief General NTP "discard" rate limiting limits to be read from a device
+ *
+ * Used to query from a device what range of values is supported
+ * for the NTP "discard" rate limiting configuration.
+ */
+typedef struct
+{
+ uint8_t avg_min; ///< Minimum value for avg
+ uint8_t avg_max; ///< Maximum value for avg
+ uint8_t min_min; ///< Minimum value for min
+ uint8_t min_max; ///< Maximum value for min
+ uint16_t monitor_min; ///< Maximum value for min
+ uint16_t monitor_max; ///< Maximum value for min
+
+ uint32_t reserved; ///< Future use
+
+} NTP_DISCARD_LIMITS;
+
+#define _mbg_swab_ntp_discard_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->monitor_min ); \
+ _mbg_swab16( &(_p)->monitor_max ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+
+
+/**
+ * @brief NTP "discard" rate limiting settings as described at ntp.org's manual
+ */
+typedef struct
+{
+ uint8_t avg; ///< Specify the minimum average interpacket spacing in log2 s.
+ uint8_t min; ///< Specify the minimum interpacket spacing (guard time) in seconds.
+ uint16_t monitor; ///< ### TODO Which is the unit of this field?
+ uint32_t reserved; ///< Possible future use
+
+} NTP_DISCARD_SETTINGS;
+
+#define _mbg_swab_ntp_discard_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->monitor ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+
+
+/**
+ * @brief NTP restriction, plus index
+ *
+ * @see ::NTP_RESTR
+ */
+typedef struct
+{
+ uint16_t idx;
+ NTP_RESTR restr;
+
+} NTP_RESTR_IDX;
+
+#define _mbg_swab_ntp_restr_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_ntp_restr( &(_p)->restr ); \
+}
+
+
+
+/**
+ * @brief Enumeration of supported refclock types
+ *
+ * Used with ::NTP_REFCLK_CFG_SETTINGS::type
+ *
+ * @see https://www.eecis.udel.edu/~mills/ntp/html/refclock.html
+ * @see ::NTP_REFCLK_TYPE_MSKS
+ */
+enum NTP_REFCLK_TYPES
+{
+ NTP_REFCLK_TYPE_LOCAL, ///< NTP local clock
+ NTP_REFCLK_TYPE_TRUETIME, ///< NTP Truetime driver
+ NTP_REFCLK_TYPE_PARSE, ///< NTP parse driver
+ NTP_REFCLK_TYPE_NMEA, ///< NTP NMEA driver
+ NTP_REFCLK_TYPE_PPS, ///< NTP atom driver (standalone PPS)
+ NTP_REFCLK_TYPE_SHM, ///< NTP shared memory driver
+ N_NTP_REFCLK_TYPES
+};
+
+
+
+/**
+ * @brief Bit masks associated with ::NTP_REFCLK_TYPES
+ *
+ * Used with ::NTP_REFCLK_CFG_INFO::supp_refclk_types
+ *
+ * @see ::NTP_REFCLK_TYPES
+ */
+enum NTP_REFCLK_TYPE_MSKS
+{
+ NTP_REFCLK_TYPE_MSK_LOCAL = ( 1UL << NTP_REFCLK_TYPE_LOCAL ), ///< see ::NTP_REFCLK_TYPE_LOCAL
+ NTP_REFCLK_TYPE_MSK_TRUETIME = ( 1UL << NTP_REFCLK_TYPE_TRUETIME ), ///< see ::NTP_REFCLK_TYPE_TRUETIME
+ NTP_REFCLK_TYPE_MSK_PARSE = ( 1UL << NTP_REFCLK_TYPE_PARSE ), ///< see ::NTP_REFCLK_TYPE_PARSE
+ NTP_REFCLK_TYPE_MSK_NMEA = ( 1UL << NTP_REFCLK_TYPE_NMEA ), ///< see ::NTP_REFCLK_TYPE_NMEA
+ NTP_REFCLK_TYPE_MSK_PPS = ( 1UL << NTP_REFCLK_TYPE_PPS ), ///< see ::NTP_REFCLK_TYPE_PPS
+ NTP_REFCLK_TYPE_MSK_SHM = ( 1UL << NTP_REFCLK_TYPE_SHM ) ///< see ::NTP_REFCLK_TYPE_SHM
+};
+
+
+
+/**
+ * @brief General NTP refclock limits to be read from a device
+ *
+ * Used to query from a device how many NTP refclocks are supported
+ * by the device, then index 0..::NTP_REFCLK_CFG_LIMITS::cur_refclks-1
+ * refclock records can be read from a device. A maximum of
+ * ::NTP_REFCLK_CFG_LIMITS::max_refclks can be configured at all.
+ */
+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 reserved; ///< Future use
+
+} NTP_REFCLK_CFG_LIMITS;
+
+#define _mbg_swab_ntp_refclk_cfg_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->max_refclks ); \
+ _mbg_swab16( &(_p)->cur_refclks ); \
+ _mbg_swab32( &(_p)->feat_flags ); \
+ _mbg_swab32( &(_p)->reserved ); \
+}
+
+
+
+/**
+ * @brief Numbers related to the "fudge" flags used with ntpd's refclock interface
+ *
+ * Used with ::NTP_REFCLK_CFG_SETTINGS::drv_flags_enable
+ * and ::NTP_REFCLK_CFG_SETTINGS::drv_flags_value
+ *
+ * The refclock interface provided by ntpd supports a number of flags
+ * (flag1..flag4) which can be "fudged" in ntp.conf to control specific
+ * features of a particular refclock driver, e.g.:
+ * "fudge 127.127.8.0 flag1 1"
+ *
+ * Which feature is controlled by which flag depends on the refclock
+ * driver type, so usually each flag has a different meaning for
+ * different refclock types.
+ *
+ * There are different cases to be distinguished:
+ *
+ * - if a flag is not specified at all in ntp.conf then
+ * the controlled feature is enabled or disabled
+ * according to the driver's default settings
+ *
+ * - if a flag is specified as '0' or '1' in ntp.conf then
+ * the controlled feature is enabled or disabled
+ * according to the flag's setting.
+ *
+ * Thus, the bit mask in ::NTP_REFCLK_CFG_SETTINGS::drv_flags_enable
+ * controls if the associated fudge flag should be specified in ntp.conf,
+ * and if it is specified then the associated bit in
+ * ::NTP_REFCLK_CFG_SETTINGS::drv_flags_value controls if the fudge flag
+ * is set to 0 or 1.
+ *
+ * @anchor NTP_FUDGE_FLAG_NUMBERS @{ */
+
+#define NTP_MIN_REFCLOCK_FUDGE_FLAG 1 ///< minimum refclock fudge flag number, associated with bit 0
+#define N_NTP_REFCLOCK_FUDGE_FLAGS 4 ///< the number of supported fudge flags
+
+/** @} anchor NTP_FUDGE_FLAG_NUMBERS */
+
+
+
+/**
+ * @brief NTP refclock specific settings
+ *
+ * Used to configure a NTP refclock.
+ */
+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"?
+ 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"?
+
+ 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?
+
+ 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 reserved_3; ///< Future use
+
+} NTP_REFCLK_CFG_SETTINGS;
+
+#define _mbg_swab_ntp_refclk_cfg_settings( _p ) \
+{ \
+ _mbg_swab_nano_time_64( &(_p)->time1 ); \
+ _mbg_swab_nano_time_64( &(_p)->time2 ); \
+ _mbg_swab16( &(_p)->drv_flags_enable ); \
+ _mbg_swab16( &(_p)->drv_flags_value ); \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab16( &(_p)->reserved_3 ); \
+}
+
+
+
+/**
+ * @brief NTP refclock settings index
+ *
+ * @see ::NTP_REFCLK_CFG_SETTINGS
+ */
+typedef struct
+{
+ uint16_t idx;
+ NTP_REFCLK_CFG_SETTINGS settings; ///< See ::NTP_REFCLK_CFG_SETTINGS
+
+} NTP_REFCLK_CFG_SETTINGS_IDX;
+
+#define _mbg_swab_ntp_refclk_cfg_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_ntp_refclk_cfg_settings( &(_p)->settings ); \
+}
+
+
+
+/**
+ * @brief NTP refclock configuration and supported refclock types
+ *
+ * This structure can be used to set a NTP refclock's configuration
+ * and get to know its overall supported refclocks.
+ */
+typedef struct
+{
+ NTP_REFCLK_CFG_SETTINGS settings; ///< See ::NTP_REFCLK_CFG_SETTINGS
+
+ uint32_t supp_refclk_types; ///< See ::NTP_REFCLK_TYPE_MSKS
+
+} NTP_REFCLK_CFG_INFO;
+
+#define _mbg_swab_ntp_refclk_cfg_info( _p ) \
+{ \
+ _mbg_swab_ntp_refclk_cfg_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_refclk_types ); \
+}
+
+
+
+/**
+ * @brief NTP refclock info, with index
+ *
+ * @see ::NTP_REFCLK_CFG_INFO
+ */
+typedef struct
+{
+ uint16_t idx;
+ NTP_REFCLK_CFG_INFO info;
+
+} NTP_REFCLK_CFG_INFO_IDX;
+
+#define _mbg_swab_ntp_refclk_cfg_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_ntp_refclk_cfg_info( &(_p)->info ); \
+}
+
+
+
+/**
+ * @brief Enumeration of supported refclock driver specific flags
+ *
+ * @see ::NTP_REFCLK_SPEC_MASKS
+ */
+enum NTP_REFCLK_SPEC_FLAGS
+{
+ NTP_REFCLK_SPEC_FLAG_TIME1,
+ NTP_REFCLK_SPEC_FLAG_TIME2,
+ NTP_REFCLK_SPEC_FLAG_STRATUM,
+ NTP_REFCLK_SPEC_FLAG_FLAG1, //### TODO use a bit mask instead as for drv_flags_enable?
+ NTP_REFCLK_SPEC_FLAG_FLAG2,
+ NTP_REFCLK_SPEC_FLAG_FLAG3,
+ NTP_REFCLK_SPEC_FLAG_FLAG4,
+ N_NTP_REFCLK_SPEC_FLAGS
+};
+
+
+
+/**
+ * @brief Flag masks associated with ::NTP_REFCLK_SPEC_FLAGS
+ *
+ * @see ::NTP_REFCLK_SPEC_FLAGS
+ */
+enum NTP_REFCLK_SPEC_MASKS
+{
+ NTP_REFCLK_SPEC_MSK_TIME1 = ( 1UL << NTP_REFCLK_SPEC_FLAG_TIME1 ), ///< See ::NTP_REFCLK_SPEC_FLAG_TIME1
+ NTP_REFCLK_SPEC_MSK_TIME2 = ( 1UL << NTP_REFCLK_SPEC_FLAG_TIME2 ), ///< See ::NTP_REFCLK_SPEC_FLAG_TIME2
+ NTP_REFCLK_SPEC_MSK_STRATUM = ( 1UL << NTP_REFCLK_SPEC_FLAG_STRATUM ), ///< See ::NTP_REFCLK_SPEC_FLAG_STRATUM
+ NTP_REFCLK_SPEC_MSK_FLAG1 = ( 1UL << NTP_REFCLK_SPEC_FLAG_FLAG1 ), ///< See ::NTP_REFCLK_SPEC_FLAG_FLAG1
+ NTP_REFCLK_SPEC_MSK_FLAG2 = ( 1UL << NTP_REFCLK_SPEC_FLAG_FLAG2 ), ///< See ::NTP_REFCLK_SPEC_FLAG_FLAG2
+ NTP_REFCLK_SPEC_MSK_FLAG3 = ( 1UL << NTP_REFCLK_SPEC_FLAG_FLAG3 ), ///< See ::NTP_REFCLK_SPEC_FLAG_FLAG3
+ NTP_REFCLK_SPEC_MSK_FLAG4 = ( 1UL << NTP_REFCLK_SPEC_FLAG_FLAG4 ), ///< See ::NTP_REFCLK_SPEC_FLAG_FLAG4
+};
+
+
+
+#define N_NTP_REFCLK_CFG_CHARS 16 ///< Maximum number of chars for any refclock specifications
+
+/**
+ * @brief NTP refclock specification
+ *
+ * Structure describes in a refclock specific way how to handle commonly used
+ * ::NTP_REFCLK_CFG_SETTINGS for this specific refclock. It is informational and
+ * read-only.
+ *
+ * @note ::NTP_REFCLK_CFG_SPEC needs no limit or info structures since the number
+ * of supported and max. available structures corresponds to ::N_NTP_REFCLK_TYPES.
+ * Each refclock needs its own spec that is addressed by ::NTP_REFCLK_CFG_SETTINGS::type.
+ */
+typedef struct
+{
+ uint8_t max_instances; ///< Number of max. possible driver instances.
+ ///< For example: /dev/refclock-[0..3]
+ uint8_t reserved_1; ///< Future use
+ uint16_t reserved_2; ///< Future use
+ uint32_t supp_specs; ///< Supported refclock specific flags, see ::N_NTP_REFCLK_CFG_CHARS
+ uint32_t reserved_3; ///< Future use
+
+} NTP_REFCLK_CFG_SPEC;
+
+#define _mbg_swab_ntp_refclk_cfg_spec( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->supp_specs ); \
+ _mbg_swab_ntp_refclk_cfg_info( &(_p)->info ); \
+}
+
+
+
+/**
+ * @brief Enumeration of NTP supported symmetric key hashing algorithms
+ *
+ * @see ::NTP_SYMM_KEY_HASH_MASKS
+ *
+ * @note Support of external libraries (e.g.: OpenSSL) may be needed for
+ * some hashing algorithms.
+ */
+enum NTP_SYMM_KEY_HASHES
+{
+ NTP_SYMM_KEY_HASH_MD5, ///< NTP supports MD5 as key hashing algorithm
+ NTP_SYMM_KEY_HASH_SHA1, ///< NTP supports SHA1 as key hashing algorithm
+ N_NTP_SYMM_KEY_HASHES
+};
+
+
+
+/**
+ * @brief Flag masks associated with ::NTP_SYMM_KEY_HASHES
+ *
+ * @see ::NTP_SYMM_KEY_HASHES
+ */
+enum NTP_SYMM_KEY_HASH_MASKS
+{
+ NTP_SYMM_KEY_HASH_MSK_MD5 = ( 1UL << NTP_SYMM_KEY_HASH_MD5 ), ///< see ::NTP_SYMM_KEY_HASH_MD5
+ NTP_SYMM_KEY_HASH_MSK_SHA1 = ( 1UL << NTP_SYMM_KEY_HASH_SHA1 ), ///< see ::NTP_SYMM_KEY_HASH_SHA1
+};
+
+
+
+/**
+ * @brief General NTP symmetric key limits to be read from a device
+ *
+ * Used to query from a device how many symmetric keys are supported
+ * by the device, then index 0..::NTP_SYMM_KEY_LIMITS::n_cur_keys-1
+ * keys can be read from a device. A maximum of
+ * ::NTP_SYMM_KEY_LIMITS::n_supp_keys can be configured at all.
+ * ::NTP_SYMM_KEY_LIMITS::supp_hashes specifies supported hashing algorithms
+ * to create keys with. See ::NTP_SYMM_KEY_HASH_MASKS. Structure can be queried
+ * if ::NTP_MSK_SYMM_KEYS is set in ::NTP_GLB_INFO::supp_flags
+ */
+typedef struct
+{
+ uint16_t n_supp_keys; ///< Maximum number of supported NTP symmetric keys
+ uint16_t n_cur_keys; ///< Current number of configured NTP symmetric keys
+ uint16_t supp_hashes; ///< See ::NTP_SYMM_KEY_HASH_MASKS
+ uint16_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+
+} NTP_SYMM_KEY_LIMITS;
+
+#define _mbg_swab_ntp_symm_key_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->n_supp_keys ); \
+ _mbg_swab16( &(_p)->n_cur_keys ); \
+ _mbg_swab16( &(_p)->supp_hashes ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/// Maximum length of a symmetric key. 128 byte was chosen to be
+/// prepared for hash algorithms like SHA256, SH384, up to SHA512.
+#define N_NTP_SYMM_KEY_LEN 128
+
+
+/**
+ * @brief NTP symmetric key specific settings
+ *
+ * This structure is used to configure a symmetric key for NTP.
+ */
+typedef struct
+{
+ uint16_t id; ///< Configurable key id (1..65534)
+ uint8_t hash; ///< See ::NTP_SYMM_KEY_HASHES
+ uint8_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+ uint8_t key[N_NTP_SYMM_KEY_LEN]; ///< Hashed phrase, see ::N_NTP_SYMM_KEY_LEN
+
+} NTP_SYMM_KEY_SETTINGS;
+
+#define _mbg_swab_ntp_symm_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->id ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief NTP symmetric key settings, with index
+ *
+ * @see ::NTP_SYMM_KEY_SETTINGS
+ */
+typedef struct
+{
+ uint16_t idx;
+ NTP_SYMM_KEY_SETTINGS settings;
+
+} NTP_SYMM_KEY_SETTINGS_IDX;
+
+#define _mbg_swab_ntp_symm_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_ntp_symm_settings( &(_p)->settings ); \
+}
+
+
+
+/**
+ * @brief General NTP trusted symmetric key limits to be read from a device
+ *
+ * Used to query from a device how many trusted symmetric keys are supported
+ * by the device, then index 0..::NTP_TRUSTED_KEY_LIMITS::n_cur_keys-1
+ * keys can be read from a device. A maximum of
+ * ::NTP_TRUSTED_KEY_LIMITS::n_supp_keys can be configured at all. Structure can
+ * be queried if ::NTP_MSK_TRUSTED_KEYS is set in ::NTP_GLB_INFO::supp_flags
+ */
+typedef struct
+{
+ uint16_t n_supp_keys; ///< Maximum number of supported NTP trusted keys
+ uint16_t n_cur_keys; ///< Current number of configured NTP trusted keys
+
+ uint32_t reserved_1; ///< Future use
+
+} NTP_TRUSTED_KEY_LIMITS;
+
+#define _mbg_swab_ntp_trusted_key_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->n_supp_keys ); \
+ _mbg_swab16( &(_p)->n_cur_keys ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+}
+
+
+
+/**
+ * @brief NTP trusted key settings
+ *
+ * This structure is used to configure a trusted symmetric key for NTP.
+ */
+typedef struct
+{
+ uint16_t id; ///< Configurable key id (1..65534)
+ uint16_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+
+} NTP_TRUSTED_KEY_SETTINGS;
+
+#define _mbg_swab_ntp_trusted_key_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->id ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief Enumeration of NTP supported statistics
+ *
+ * @see ::NTP_GLB_STATS_MASKS
+ */
+enum NTP_GLB_STATS_FLAGS
+{
+ NTP_GLB_STATS_FLAG_ENABLE, ///< NTP stats can generally be enabled or disabled
+ NTP_GLB_STATS_FLAG_CLOCKSTATS, ///< NTP supports clockstats
+ NTP_GLB_STATS_FLAG_CRYPTOSTATS, ///< NTP supports cryptostats
+ NTP_GLB_STATS_FLAG_LOOPSTATS, ///< NTP supports loopstats
+ NTP_GLB_STATS_FLAG_PEERSTATS, ///< NTP supports peerstats
+ NTP_GLB_STATS_FLAG_RAWSTATS, ///< NTP supports rawstats
+ NTP_GLB_STATS_FLAG_SYSSTATS, ///< NTP supports sysstats
+ NTP_GLB_STATS_FLAG_FILEGEN, ///< NTP supports sets of files
+ ///< If flag is set there are structures needed
+ ///< that are not avail right now. Future use
+ N_NTP_GLB_STATS_FLAGS
+};
+
+
+
+/**
+ * @brief Flag masks associated with ::NTP_GLB_STATS_FLAGS
+ *
+ * @see ::NTP_GLB_STATS_FLAGS
+ */
+enum NTP_GLB_STATS_MASKS
+{
+ NTP_GLB_STATS_MSK_ENABLE = ( 1UL << NTP_GLB_STATS_FLAG_ENABLE ), ///< See ::NTP_GLB_STATS_FLAG_ENABLE
+ NTP_GLB_STATS_MSK_CLOCKSTATS = ( 1UL << NTP_GLB_STATS_FLAG_CLOCKSTATS ), ///< See ::NTP_GLB_STATS_FLAG_CLOCKSTATS
+ NTP_GLB_STATS_MSK_CRYPTOSTATS = ( 1UL << NTP_GLB_STATS_FLAG_CRYPTOSTATS ), ///< See ::NTP_GLB_STATS_FLAG_CRYPTOSTATS
+ NTP_GLB_STATS_MSK_LOOPSTATS = ( 1UL << NTP_GLB_STATS_FLAG_LOOPSTATS ), ///< See ::NTP_GLB_STATS_FLAG_LOOPSTATS
+ NTP_GLB_STATS_MSK_PEERSTATS = ( 1UL << NTP_GLB_STATS_FLAG_PEERSTATS ), ///< See ::NTP_GLB_STATS_FLAG_PEERSTATS
+ NTP_GLB_STATS_MSK_RAWSTATS = ( 1UL << NTP_GLB_STATS_FLAG_RAWSTATS ), ///< See ::NTP_GLB_STATS_FLAG_RAWSTATS
+ NTP_GLB_STATS_MSK_SYSSTATS = ( 1UL << NTP_GLB_STATS_FLAG_SYSSTATS ), ///< See ::NTP_GLB_STATS_FLAG_SYSSTATS
+ NTP_GLB_STATS_MSK_FILEGEN = ( 1UL << NTP_GLB_STATS_FLAG_FILEGEN ) ///< See ::NTP_GLB_STATS_FLAG_FILEGEN
+};
+
+
+
+/**
+ * @brief Global NTP statistics settings to be read from / written to a device
+ *
+ * ::NTP_GLB_STATS_MSK_ENABLE is the switch to enable / disable statistics in
+ * general. In case the bit is set all other bits stand for special statistic
+ * types that can be enabled or disabled by setting or deleting its specific bit.
+ */
+typedef struct
+{
+ uint32_t flags; ///< See ::NTP_GLB_STATS_MASKS
+ uint32_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+
+} NTP_STATS_GLB_SETTINGS;
+
+#define _mbg_swab_ntp_stats_glb_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief NTP statistics settings
+ *
+ * This structure can be used to determine possible NTP statistic options
+ * and can be queried if ::NTP_MSK_STATISTICS bit is set in ::NTP_GLB_INFO::supp_flags.
+ */
+typedef struct
+{
+ NTP_STATS_GLB_SETTINGS settings; ///< See ::NTP_STATS_GLB_SETTINGS
+
+ uint32_t supp_stats; ///< See ::NTP_GLB_STATS_MASKS
+ uint32_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+ uint32_t reserved_3; ///< Future use
+
+} NTP_STATS_GLB_INFO;
+
+#define _mbg_swab_ntp_stats_glb_info( _p ) \
+{ \
+ _mbg_swab_ntp_stats_glb_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_stats ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+}
+
+
+
+/**
+ * @brief Enumeration of NTP supported (various) misc options
+ *
+ * @see ::NTP_MISC_MSKS
+ */
+enum NTP_MISC_FLAGS
+{
+ NTP_MISC_FLAG_DRIFTFILE, ///< NTP supports driftfile
+ NTP_MISC_FLAG_ORPHAN_MODE, ///< NTP supports orphan mode
+ NTP_MISC_FLAG_LEAPFILE, ///< NTP supports leapfile
+ N_NTP_MISC_FLAGS
+};
+
+
+
+/**
+ * @brief Flag masks associated with ::NTP_MISC_FLAGS
+ *
+ * @see ::NTP_MISC_FLAGS
+ */
+enum NTP_MISC_MSKS
+{
+ NTP_MISC_MSK_DRIFTFILE = ( 1UL << NTP_MISC_FLAG_DRIFTFILE ), ///< See ::NTP_MISC_FLAG_DRIFTFILE
+ NTP_MISC_MSK_ORPHAN_MODE = ( 1UL << NTP_MISC_FLAG_ORPHAN_MODE ), ///< See ::NTP_MISC_FLAG_ORPHAN_MODE
+ NTP_MISC_MSK_LEAPFILE = ( 1UL << NTP_MISC_FLAG_LEAPFILE ) ///< See ::NTP_MISC_FLAG_LEAPFILE
+};
+
+
+
+/**
+ * @brief General NTP misc limits to be read from a device
+ *
+ * This structure can be used to determine various NTP options
+ * and can be queried if ::NTP_MSK_MISCELLANEOUS bit is set in ::NTP_GLB_INFO::supp_flags.
+ */
+typedef struct
+{
+ uint32_t supp_flags; ///< See ::NTP_MISC_MSKS
+ uint32_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+
+} NTP_MISC_LIMITS;
+
+#define _mbg_swab_ntp_misc_limits( _p ) \
+{ \
+ _mbg_swab32( &(_p)->supp_flags ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief NTP driftfile settings to be read from / written to a device
+ *
+ * If ::NTP_MISC_MSK_DRIFTFILE is set in ::NTP_MISC_LIMITS::supp_flags
+ * ::NTP_MISC_DRIFTFILE_SETTINGS can be read / written.
+ */
+typedef struct
+{
+ uint8_t enable; ///< Enable / disable writing a driftfile
+ uint8_t reserved_1; ///< Future use
+ uint16_t reserved_2; ///< Future use
+
+} NTP_MISC_DRIFTFILE_SETTINGS;
+
+#define _mbg_swab_ntp_misc_driftfile_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief NTP orphan mode settings to be read from / written to a device
+ *
+ * If ::NTP_MISC_MSK_ORPHAN_MODE is set in ::NTP_MISC_LIMITS::supp_flags
+ * ::NTP_MISC_ORPHAN_MODE_SETTINGS can be read / written.
+ */
+typedef struct
+{
+ uint8_t enable; ///< Generally enable / disable orphan mode
+ uint8_t mode; ///< Stratum level when no ref source available
+ uint16_t reserved_1; ///< Future use
+
+} NTP_MISC_ORPHAN_MODE_SETTINGS;
+
+#define _mbg_swab_ntp_misc_orphan_mode_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+}
+
+
+
+/**
+ * @brief NTP leapfile settings to be read from / written to a device
+ *
+ * If ::NTP_MISC_MSK_LEAPFILE is set in ::NTP_MISC_LIMITS::supp_flags
+ * ::NTP_MISC_LEAPFILE_SETTINGS can be read / written.
+ */
+typedef struct
+{
+ uint8_t enable; ///< Generally enable / disable leapfile
+ uint8_t reserved_1; ///< Stratum level when no ref source available
+ uint16_t reserved_2; ///< Future use
+
+} NTP_MISC_LEAPFILE_SETTINGS;
+
+#define _mbg_swab_ntp_misc_leapfile_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->reserved_2 ); \
+}
+
+#endif // defined( _PRELIMINARY_CODE )
+
+
+
/**
* @brief Global configuration info of an NTP device (client/server)
*
@@ -9282,6 +13752,7 @@ typedef struct
}
+
/**
* @brief Client settings of an NTP device
*
@@ -9304,6 +13775,7 @@ typedef struct
}
+
/**
* @brief Client settings info of an NTP device
*
@@ -9336,6 +13808,65 @@ typedef struct
}
+
+/**
+ * @brief General NTP peer settings limits to be read from a device
+ *
+ * Used to query from a device how many NTP associations are supported
+ * by the device, then index 0..::NTP_PEER_LIMITS::n_cur_peers-1
+ * peer records can be read from a device. A maximum of
+ * ::NTP_PEER_LIMITS::n_supp_peers can be configured at all.
+ */
+typedef struct
+{
+ uint16_t n_supp_peers; ///< maximum number of configurable peers
+ uint16_t n_cur_peers; ///< current number of configured peers
+
+ uint8_t poll_intv_min; ///< minimum supported NTP polling interval
+ uint8_t poll_intv_max; ///< maximum supported NTP polling interval
+ uint8_t reserved_1; ///< reserved, currently 0
+ uint8_t reserved_2; ///< reserved, currently 0
+
+ uint32_t supp_assoc_types; ///< supported types of NTP associations
+ uint32_t reserved_3; ///< reserved, currently 0
+
+ uint32_t supp_flags_server; ///< supported flags for unicast associations
+ uint32_t supp_flags_peer; ///< supported flags for unicast symmetric-active assocations
+ uint32_t supp_flags_pool; ///< supported flags for unicast pool associations
+ uint32_t supp_flags_broadcast; ///< supported flags for broadcast associations
+ uint32_t supp_flags_multicast; ///< supported flags for multicast associations
+ uint32_t supp_flags_manycast; ///< supported flags for manycast associations
+ uint32_t supp_flags_broadcastclient; ///< supported flags for broadcast client associations
+ uint32_t supp_flags_multicastclient; ///< supported flags for multicast client associations
+ uint32_t supp_flags_manycastclient; ///< supported flags for manycast client associations
+ uint32_t reserved_4; ///< reserved, currently 0
+ uint32_t reserved_5; ///< reserved, currently 0
+ uint32_t reserved_6; ///< reserved, currently 0
+
+} NTP_PEER_LIMITS;
+
+#define _mbg_swab_ntp_peer_limits( _p ) \
+{ \
+ _mbg_swab16( &(_p)->n_supp_peers ); \
+ _mbg_swab16( &(_p)->n_cur_peers ); \
+ _mbg_swab32( &(_p)->supp_assoc_types ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->supp_flags_server ); \
+ _mbg_swab32( &(_p)->supp_flags_peer ); \
+ _mbg_swab32( &(_p)->supp_flags_pool ); \
+ _mbg_swab32( &(_p)->supp_flags_broadcast ); \
+ _mbg_swab32( &(_p)->supp_flags_multicast ); \
+ _mbg_swab32( &(_p)->supp_flags_manycast ); \
+ _mbg_swab32( &(_p)->supp_flags_broadcastclient ); \
+ _mbg_swab32( &(_p)->supp_flags_multicastclient ); \
+ _mbg_swab32( &(_p)->supp_flags_manycastclient ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
+ _mbg_swab32( &(_p)->reserved_5 ); \
+ _mbg_swab32( &(_p)->reserved_6 ); \
+}
+
+
+
/**
* @brief Peer settings for NTP devices to configure an upload NTP server
*
@@ -9348,14 +13879,16 @@ typedef struct
*/
typedef struct
{
- MBG_HOSTNAME hostname; ///< hostname or IP address of the peer
+ MBG_HOSTNAME hostname; ///< hostname or IP address of the peer, not used
+ ///< when the NTP_BROADCASTCLIENT flag is set
uint8_t min_poll; ///< minimal configurable NTP polling interval
uint8_t max_poll; ///< maximal configurable NTP polling interval
uint8_t ttl; ///< time-to-live to use with broadcast/multicast/manycast
uint8_t reserved_1; ///< reserved, currently 0
- uint32_t reserved_2; ///< reserved, currently 0
+ uint32_t key; ///< ID of the symmetric key used with this association,
+ ///< this must be in the range 1-65534, 0 = disabled
uint32_t reserved_3; ///< reserved, currently 0
uint32_t reserved_4; ///< reserved, currently 0
@@ -9365,12 +13898,14 @@ typedef struct
#define _mbg_swab_ntp_peer_settings( _p ) \
{ \
- _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->key ); \
_mbg_swab32( &(_p)->reserved_3 ); \
_mbg_swab32( &(_p)->reserved_4 ); \
_mbg_swab32( &(_p)->flags ); \
}
+
+
/**
* @brief Peer settings for NTP devices
*
@@ -9389,7 +13924,10 @@ typedef struct
_mbg_swab_ntp_peer_settings( &(_p)->peer_settings ); \
}
-#ifdef DEBUG
+
+
+#if defined( DEBUG ) //### TODO or _PRELIMINARY_CODE ?
+
/**
* @brief Dummy structure for later NTP server implementations, not used, yet
*/
@@ -9431,9 +13969,16 @@ typedef struct
_mbg_swab32( &(_p)->reserved_2 ); \
_mbg_swab32( &(_p)->supp_flags ); \
}
+
+#else
+
+ typedef int NTP_SRV_MODE_INFO;
+ typedef int NTP_SRV_MODE_SETTINGS;
+
#endif // DEBUG
+
/**
* @brief Structure that represents a timestamp in NTP Short Format
*
@@ -9454,6 +13999,7 @@ typedef struct
}
+
/**
* @brief Structure that represents a timestamp in NTP Timestamp Format
*/
@@ -9471,6 +14017,7 @@ typedef struct
}
+
/**
* @brief Enumeration of known NTP implementations
*
@@ -9492,6 +14039,7 @@ enum NTP_IMPL
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_IMPL_STR_ENG "Implemetation Type:"
+
#define MBG_NTP_IMPL_STR_ENG_UNKNOWN "Unknown NTP implementation"
#define MBG_NTP_IMPL_STR_ENG_NTPD "Network Time Protocol daemon (ntpd)"
#define MBG_NTP_IMPL_STR_ENG_NTPDATE "NTP client only (ntpdate)"
@@ -9511,6 +14059,7 @@ enum NTP_IMPL
}
+
/**
* @brief Enumeration of CPU types using NTP
*
@@ -9533,6 +14082,7 @@ enum NTP_CPU_TYPES
};
+
/**
* @brief Name strings for known CPU types using NTP
*
@@ -9554,6 +14104,7 @@ enum NTP_CPU_TYPES
}
+
/**
* @brief Enumeration of operating systems using NTP
*
@@ -9571,6 +14122,7 @@ enum NTP_SYSTEMS
};
+
/**
* @brief Name strings for operating systens using NTP
*
@@ -9587,6 +14139,7 @@ enum NTP_SYSTEMS
}
+
/**
* @brief Enumeration of NTP leap indication bits
*
@@ -9602,11 +14155,14 @@ enum NTP_LI_BITS
N_NTP_LI_BITS
};
+
+
/*
* Default initializers for English leapsecond string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_LEAP_STR_ENG "Leapsecond indication:"
+
#define MBG_NTP_LEAP_STR_ENG_NONE "None"
#define MBG_NTP_LEAP_STR_ENG_ADD_SEC "Insert second"
#define MBG_NTP_LEAP_STR_ENG_DEL_SEC "Delete second"
@@ -9621,6 +14177,7 @@ enum NTP_LI_BITS
}
+
/**
* @brief Enumeration of NTP synchronization source bits
*
@@ -9642,11 +14199,14 @@ enum NTP_SYNC_SRC_BITS
N_NTP_SYNC_SRC_BITS
};
+
+
/*
* Default initializers for English sync source string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_SYNC_SRC_STR_ENG_LABEL "Sync Source:"
+
#define MBG_NTP_SYNC_SRC_STR_ENG_UNSPEC "Not yet synchronized"
#define MBG_NTP_SYNC_SRC_STR_ENG_PPS "Pulse per second signal"
#define MBG_NTP_SYNC_SRC_STR_ENG_LF_RADIO "VLF/LF radio"
@@ -9673,6 +14233,7 @@ enum NTP_SYNC_SRC_BITS
}
+
/**
* @brief Enumeration of NTP system event message bits
*
@@ -9700,12 +14261,15 @@ enum NTP_SYS_EVT_BITS
N_NTP_SYS_EVT_BITS
};
+
+
/*
* Default initializers for English sync source string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_SYS_EVT_STR_ENG_CNT_LABEL "System Event Counter:"
#define MBG_NTP_SYS_EVT_STR_ENG_MSG_LABEL "System Event Message:"
+
#define MBG_NTP_SYS_EVT_STR_ENG_UNSPEC "Unspecified NTP event"
#define MBG_NTP_SYS_EVT_STR_ENG_FREQ_NOT_SET "Frequency file not available"
#define MBG_NTP_SYS_EVT_STR_ENG_FREQ_SET "Frequency set from frequency file"
@@ -9744,6 +14308,8 @@ enum NTP_SYS_EVT_BITS
MBG_NTP_SYS_EVT_STR_ENG_STALE_LS_VALUES \
}
+
+
/**
* @brief Enumeration of supported NTP system state values
*
@@ -9764,6 +14330,7 @@ enum NTP_SYS_STATE_SUPP_FLAGS
};
+
/**
* @brief Flag masks for NTP_SYS_STATE_SUPP_FLAGS
*
@@ -9785,6 +14352,7 @@ enum NTP_SYS_STATE_SUPP_FLAG_MASKS
};
+
/**
* @brief Structure that represents the current system status of an NTP device
*
@@ -9815,7 +14383,7 @@ typedef struct
int32_t root_delay; ///< [us] Total roundtrip delay to the system peer
int32_t root_disp; ///< [us] Total dispersion to the system peer
- MBG_IP_ADDR ref_id; ///< Reference ID of the current system peer, see ::MBG_IP_ADDR
+ MBG_IP_ADDR ref_id; ///< Reference ID of the current system peer, see ::MBG_IP_ADDR
NTP_TSTAMP ref_time; ///< Last time the system time has been adjusted, see ::NTP_TSTAMP
NTP_TSTAMP sys_time; ///< Current system time, see ::NTP_TSTAMP
@@ -9837,6 +14405,7 @@ typedef struct
} NTP_SYS_STATE;
+
/**
* @brief Enumeration of NTP mode bits
*
@@ -9856,6 +14425,8 @@ enum NTP_MODE_BITS
N_NTP_MODE_BITS
};
+
+
/*
* Default initializers for English NTP peer mode string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
@@ -9885,6 +14456,7 @@ enum NTP_MODE_BITS
}
+
/**
* @brief Enumeration of NTP peer reach status
*
@@ -9903,6 +14475,8 @@ enum NTP_REACH_STAT_BITS
N_NTP_REACH_STAT_BITS
};
+
+
/*
* Default initializers for English reach status string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
@@ -9950,6 +14524,8 @@ enum NTP_PEER_SEL_STATUS_BITS
N_NTP_PEER_SEL_STATUS_BITS
};
+
+
/*
* Default initializers for English peer select status string names. Initializers
* for multi-language strings can be found in tmonlstr.h.
@@ -9978,6 +14554,7 @@ enum NTP_PEER_SEL_STATUS_BITS
}
+
/**
* @brief Enumeration of NTP peer status codes
*
@@ -10017,6 +14594,7 @@ enum NTP_PEER_STATUS_FLAG_MASKS
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_PEER_STATUS_STR_ENG_LABEL "Peer Status:"
+
#define MBG_NTP_PEER_STATUS_STR_ENG_BCST "Broadcast association"
#define MBG_NTP_PEER_STATUS_STR_ENG_REACH "Host reachable"
#define MBG_NTP_PEER_STATUS_STR_ENG_AUTHENB "Authentication enabled"
@@ -10032,6 +14610,7 @@ enum NTP_PEER_STATUS_FLAG_MASKS
}
+
/**
* @brief Enumeration of NTP peer event message codes
*
@@ -10059,12 +14638,15 @@ enum NTP_PEER_EVT_BITS
N_NTP_PEER_EVT_BITS
};
+
+
/*
* Default initializers for English event message codes. Initializers
* for multi-language strings can be found in tmonlstr.h.
*/
#define MBG_NTP_PEER_EVT_STR_ENG_CNT_LABEL "Peer Event Counter:"
#define MBG_NTP_PEER_EVT_STR_ENG_MSG_LABEL "Peer Event Message:"
+
#define MBG_NTP_PEER_EVT_STR_ENG_UNSPEC "Unspecified NTP event"
#define MBG_NTP_PEER_EVT_STR_ENG_MOBILIZE "Association mobilized"
#define MBG_NTP_PEER_EVT_STR_ENG_DEMOBILIZE "Association demobilized"
@@ -10129,6 +14711,7 @@ enum NTP_FLASH_STAT_FLAGS
};
+
/**
* @brief Flag masks for ::NTP_FLASH_STAT_FLAGS
*
@@ -10153,12 +14736,14 @@ enum NTP_FLASH_STAT_FLAG_MASKS
NTP_FLASH_STAT_PEER_UNREACH_MSK = ( 1UL << NTP_FLASH_STAT_PEER_UNREACH ), ///< see ::NTP_FLASH_STAT_PEER_UNREACH
};
+
+
/*
* Default initializers for English ntp flash state mask. Initializers
* for multi-language strings can be found in tmonlstr.h.
*/
-
#define MBG_NTP_FLASH_STR_ENG_LABEL "Flash Status:"
+
#define MBG_NTP_FLASH_STR_ENG_PKT_DUP "Duplicate packet"
#define MBG_NTP_FLASH_STR_ENG_PKT_BOGUS "Bogus packet"
#define MBG_NTP_FLASH_STR_ENG_PKT_UNSYNC "Server not synchronized"
@@ -10192,6 +14777,7 @@ enum NTP_FLASH_STAT_FLAG_MASKS
}
+
/**
* @brief Enumeration of supported NTP peer state values
*
@@ -10199,7 +14785,7 @@ enum NTP_FLASH_STAT_FLAG_MASKS
*/
enum NTP_PEER_STATE_SUPP_FLAGS
{
- NTP_PEER_STATE_SUPP_STD = 0, ///< supports standard values of ::NTP_PEER_STATE, all fields except below and reserved
+ NTP_PEER_STATE_SUPP_STD, ///< supports standard values of ::NTP_PEER_STATE, all fields except below and reserved
NTP_PEER_STATE_SUPP_ASS_ID, ///< supports association ID, see ::NTP_PEER_STATE::ass_id
NTP_PEER_STATE_SUPP_EVENTS, ///< supports peer state events (NTP_PEER_STATE::peer_evt_cnt, NTP_PEER_STATE::peer_rec_evt)
NTP_PEER_STATE_SUPP_REACH_STAT, ///< supports peer reach status, see ::NTP_PEER_STATE::peer_reach_stat
@@ -10241,6 +14827,7 @@ enum NTP_PEER_STATE_SUPP_FLAG_MASKS
};
+
/**
* @brief Structure that represents the status of an NTP peer
*
@@ -10264,8 +14851,8 @@ typedef struct
uint8_t reserved_1; ///< Reserved, currently always 0
uint16_t reserved_2; ///< Reserved, currently always 0
- MBG_IP_ADDR_PORT src_addr; ///< Source address of the NTP peer, see ::MBG_IP_ADDR_PORT
- MBG_IP_ADDR_PORT dst_addr; ///< Destination address of the NTP peer, see ::MBG_IP_ADDR_PORT
+ MBG_IP_ADDR_PORT src_addr; ///< Source address of the NTP peer, see ::MBG_IP_ADDR_PORT
+ MBG_IP_ADDR_PORT dst_addr; ///< Destination address of the NTP peer, see ::MBG_IP_ADDR_PORT
uint8_t stratum; ///< Current stratum level of the NTP peer
int8_t precision; ///< Precision of the peer clock (2^precision)
@@ -10274,7 +14861,7 @@ typedef struct
int32_t root_delay; ///< [us] Total roundtrip delay to the system peer of the NTP peer
int32_t root_disp; ///< [us] Total dispersion to the system peer of the NTP peer
- MBG_IP_ADDR ref_id; ///< Reference ID of the NTP peer, see ::MBG_IP_ADDR
+ MBG_IP_ADDR ref_id; ///< Reference ID of the NTP peer, see ::MBG_IP_ADDR
NTP_TSTAMP ref_time; ///< Last time the NTP peers time has been adjusted, see ::NTP_TSTAMP
NTP_TSTAMP rec_time; ///< Current system time of the NTP peer, see ::NTP_TSTAMP
@@ -10312,6 +14899,7 @@ typedef struct
} NTP_PEER_STATE;
+
/**
* @brief Structure that contains an index value and the NTP peer state
*
@@ -10326,6 +14914,7 @@ typedef struct
} NTP_PEER_STATE_IDX;
+
/** @} defgroup group_ntp */
@@ -10574,7 +15163,7 @@ enum SHS_FLAG_BITS
* tool in ::SHS_SETTINGS::flags to enable the associated feature.
* If a corresponding bit is set in ::SHS_STATUS::flags this means the
* associated feature has been enabled, e.g. an action has been taken.
- *
+ *
* @see ::SHS_FLAG_BITS
*/
enum SHS_FLAG_MASKS
@@ -10588,7 +15177,459 @@ enum SHS_FLAG_MASKS
-/*------------------------------------------------------------------------*/
+/**
+ * @defgroup group_xbp eXtended Binary Protocol definitions
+ *
+ * @note These structures are only supported if ::GPS_HAS_XBP is set
+ * in ::RECEIVER_INFO::features.
+ *
+ * @{ */
+
+/**
+ * @brief An identifier used to mark an XBP port unused
+ */
+#define XBP_PORT_RESERVED ( (uint8_t) -1 )
+
+/**
+ * @brief An XBP port specifier
+ *
+ * Each controller can provide up to 255 ports with numbers 0..254.
+ * XBP port number ::XBP_PORT_RESERVED is reserved to mark unused ports.
+ */
+typedef uint8_t XBP_PORT;
+
+
+/**
+ * @brief Maximum XBP bus/controller cascading level
+ *
+ * Should be 7 so the total size of ::XBP_ADDR is 8 bytes.
+ */
+#define MAX_XBP_CASC_LVL 7
+
+
+/**
+ * @brief An XBP address specifier
+ *
+ * A generic scheme to address devices connected to cascaded controllers.
+ */
+typedef struct
+{
+ uint8_t hop_count; ///< Used as index to the addr array
+ XBP_PORT addr[MAX_XBP_CASC_LVL]; ///< An array of port numbers on cascaded controllers
+
+} XBP_ADDR;
+
+
+
+/**
+ * @brief A structure used to report XBP features and limits
+ */
+typedef struct
+{
+ uint32_t features; ///< Mask of XBP features, see ::XBP_FEAT_MASKS
+ uint32_t flags; ///< XBP flags, currently not used
+ uint32_t reserved[4]; ///< reserved, currently not used
+
+} XBP_LIMITS;
+
+
+
+/**
+ * @brief Enumeration of bits used to define ::XBP_FEAT_MASKS
+ */
+enum XBP_FEAT_BITS
+{
+ XBP_FEAT_BIT_NODES, ///< Supports ::XBP_NODE_LIMITS and associated structures
+ N_XBP_FEAT_BITS
+};
+
+
+/**
+ * @brief XBP feature masks used with ::XBP_LIMITS::features
+ *
+ * @see ::XBP_FEAT_BITS
+ */
+enum XBP_FEAT_MASKS
+{
+ XBP_FEAT_MASK_NODES = ( 1UL << XBP_FEAT_BIT_NODES ) ///< See ::XBP_FEAT_BIT_NODES
+};
+
+
+
+/**
+ * @brief Information on available XBP nodes
+ *
+ * Only supported if ::XBP_FEAT_MASK_NODES is set in ::XBP_LIMITS::features.
+ */
+typedef struct
+{
+ uint32_t node_count; ///< Number of XBP nodes available in the system
+ uint32_t reserved_0; ///< Currently reserved, always 0
+ uint32_t reserved_1; ///< Currently reserved, always 0
+ // TODO: do we need additional fields here?
+
+} XBP_NODE_LIMITS;
+
+
+
+/**
+ * @brief Possible states of an XBP device
+ *
+ * Used with ::XBP_NODE_INFO::state.
+ */
+enum XBP_DEVICE_STATES
+{
+ XBP_DEVICE_STATE_UNKNOWN,
+ XBP_DEVICE_STATE_NOT_AVAILABLE,
+ XBP_DEVICE_STATE_INITIALIZING,
+ XBP_DEVICE_STATE_AVAILABLE,
+ XBP_DEVICE_STATE_DISCONNECTED,
+ N_XBP_DEVICE_STATES
+};
+
+
+
+/**
+ * @brief Information on a specific XBP node
+ *
+ * Only supported if ::XBP_FEAT_MASK_NODES is set in ::XBP_LIMITS::features.
+ * The number of instances supported by a device is specified
+ * in ::XBP_NODE_LIMITS::node_count.
+ */
+typedef struct
+{
+ XBP_ADDR addr; ///< The address of the specific node
+
+ /// ::RECEIVER_INFO of the device connected to this node.
+ /// If no device is available then ::RECEIVER_INFO::model_code
+ /// is set to ::GPS_MODEL_UNKNOWN (== 0).
+ RECEIVER_INFO ri;
+
+ uint8_t state; ///< The device state, see ::XBP_DEVICE_STATES
+ uint8_t reserved; ///< Currently reserved, always 0
+ uint32_t flags; ///< Currently reserved, always 0
+
+} XBP_NODE_INFO;
+
+
+/**
+ * @brief Information on an XBP node with specific index
+ *
+ * Only supported if ::XBP_FEAT_MASK_NODES is set in ::XBP_LIMITS::features.
+ */
+typedef struct
+{
+ uint32_t idx; ///< node index, 0..::XBP_NODE_LIMITS::node_count-1
+ XBP_NODE_INFO node_info; ///< ::RECEIVER_INFO of the device behind this node
+
+} XBP_NODE_INFO_IDX;
+
+/** @} defgroup group_xbp */
+
+
+
+/**
+ * @defgroup group_tlv_api Meinberg TLV API definitions
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::MBG_XFEATURE_TLV_API is set in the extended device features.
+ *
+ * @{ */
+
+/**
+ * @defgroup group_tlv_feat Meinberg TLV feature definitions
+ *
+ * @{ */
+
+/**
+ * @brief The maximum number of TLV feature types.
+ *
+ * Warning: Changing this number breaks API compatibility!
+ *
+ * @see ::MBG_TLV_FEAT_TYPES
+ */
+#define MAX_MBG_TLV_FEAT_TYPES 128 //### TODO Is this sufficient?
+
+
+/**
+ * @brief An 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.
+ *
+ * @see ::MBG_TLV_FEAT_BUFFER
+ * @see ::MBG_TLV_FEAT_TYPE_NAMES
+ */
+enum MBG_TLV_FEAT_TYPES
+{
+ /// Expects two TLV types in order:
+ /// 1) ::MBG_TLV_TYPE_STR => Firmware version as string
+ /// 2) ::MBG_TLV_TYPE_FILE => Firmware file as data blob
+ MBG_TLV_FEAT_TYPE_FW_UPDATE,
+
+ /// If announce message's total bytes are 0, it is a diagnostics file
+ /// request. If its total bytes are not 0, TLV type ::MBG_TLV_TYPE_FILE
+ /// is expected and it should contain a file as data blob.
+ MBG_TLV_FEAT_TYPE_DIAG_FILE,
+
+ /// Only used as action trigger on a remote site, expects no data.
+ MBG_TLV_FEAT_TYPE_FW_ROLLBACK,
+
+ /// Expects two TLV types in order:
+ /// 1) ::MBG_TLV_TYPE_STR => Full qualified path including filename on target system
+ /// 2) ::MBG_TLV_TYPE_FILE => File as data blob
+ MBG_TLV_FEAT_TYPE_FILE_TRANSFER,
+
+ /// 1) ::MBG_TLV_TYPE_STR => Command line call as string
+ MBG_TLV_FEAT_TYPE_EXEC_CMD,
+
+ /// 1) ::MBG_TLV_TYPE_FILE => Encrypted license file as data blob
+ MBG_TLV_FEAT_TYPE_LICENSE_UPGRADE,
+
+ /// 1) ::MBG_TLV_TYPE_BLOB => ::MBG_LICENSE_LIMITS, see @ref group_license_limits
+ MBG_TLV_FEAT_TYPE_LICENSE_LIMITS,
+
+ /// 1) ::MBG_TLV_TYPE_BLOB => ::MBG_LICENSE_PTPV2_IDX, see @ref group_license_limits
+ MBG_TLV_FEAT_TYPE_LICENSE_PTPV2_IDX,
+
+ /// 1) ::MBG_TLV_TYPE_BLOB => ::MBG_LICENSE_NTP_IDX, see @ref group_license_limits
+ MBG_TLV_FEAT_TYPE_LICENSE_NTP_IDX,
+
+ 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
+ // be taken that ::N_MBG_TLV_FEAT_TYPES doesn't exceed ::MAX_MBG_TLV_FEAT_TYPES.
+};
+
+
+
+/**
+ * @brief Names of TLV API features
+ *
+ * Can be used to initialize a string array of ::N_MBG_TLV_FEAT_TYPES entries,
+ * so the number of strings must correspond to ::N_MBG_TLV_FEAT_TYPES.
+ *
+ * @see ::MBG_TLV_FEAT_TYPES
+ */
+#define MBG_TLV_FEAT_TYPE_NAMES \
+{ \
+ "TLV Firmware Update", \
+ "TLV Diagnostics File", \
+ "TLV Firmware Rollback", \
+ "TLV File Transfer", \
+ "TLV Execute Command", \
+ "TLV License Upgrade" \
+}
+
+
+
+/**
+ * @brief Array size required to store up to ::MAX_MBG_TLV_FEAT_TYPES bits
+ *
+ * The number of bytes required to store up to ::MAX_MBG_TLV_FEAT_TYPES
+ * feature bits in a byte array.
+ */
+#define MAX_MBG_TLV_FEAT_BYTES ( MAX_MBG_TLV_FEAT_TYPES / 8 )
+
+
+/**
+ * @brief A structure used to store a bit mask of supported TLV context types.
+ *
+ * Bit masks for up to ::MAX_MBG_TLV_FEAT_TYPES totally can be stored,
+ * but only ::N_MBG_TLV_FEAT_TYPES types are currently defined.
+ * The ::_set_tlv_feat_bit macro should be used by the firmware
+ * to set a bit mask in the buffer, and the ::check_tlv_feat_supp
+ * function should be used to implement API calls which test if an
+ * extended TLV context type is supported.
+ *
+ * @see ::_set_tlv_feat_bit
+ * @see ::check_tlv_feat_supp
+ */
+typedef struct
+{
+ uint8_t b[MAX_MBG_TLV_FEAT_BYTES];
+
+} MBG_TLV_FEAT_BUFFER;
+
+
+
+/**
+ * @brief Set a TLV context type bit in a ::MBG_TLV_FEAT_BUFFER
+ *
+ * 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_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 )
+
+
+/** @} defgroup group_tlv_feat */
+
+
+
+/**
+ * @brief A structure used to query current TLV capabilities
+ *
+ * This is only supported by a device if the ::MBG_XFEATURE_TLV_API bit
+ * is set in the extended device features.
+ */
+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_INFO;
+
+#define _mbg_swab_tlv_info( _p ) \
+{ \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+/**
+ * @brief Enum specifying TLV type in ::MBG_TLV_HDR::type
+ */
+enum MBG_TLV_TYPES
+{
+ MBG_TLV_TYPE_STR,
+ MBG_TLV_TYPE_FILE,
+ MBG_TLV_TYPE_BLOB, ///< In fact, a file is also a blob but
+ ///< give the child a different name to avoid confusion.
+ ///< Use this for getting/setting fixed structures!
+ N_MBG_TLV_TYPES
+};
+
+
+
+/**
+ * @brief General TLV data structure
+ *
+ * Structure containing common, additional data required to send
+ * an announce message for following TLVs.
+ */
+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_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 ); \
+}
+
+
+
+/**
+ * @brief Structure containing state information while reading TLV data.
+ */
+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_RCV_STATE;
+
+
+
+/**
+ * @brief A structure initiating a TLV transfer
+ *
+ * ::MBG_TLV_ANNOUNCE should be sent first, before starting a
+ * TLV transfer, to inform the remote site about following TLVs.
+ * Following sequence of TLVs is not fixed and implementation
+ * dependent.
+ */
+typedef struct
+{
+ 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 MSG_TLV_MAX_VALUE_SIZE 480
+
+/**
+ * @brief TLV header structure containing information on current TLV transaction
+ */
+typedef struct
+{
+ uint32_t uid; ///< Unique source ID. See ::MBG_TLV_DATA::uid
+ uint32_t 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.
+ ///< It is fixed and must not be changed during a TLV transaction.
+ uint32_t reserved_1; ///< Future use
+ uint32_t reserved_2; ///< Future use
+ uint32_t reserved_3; ///< Future use
+
+} MBG_TLV_HDR;
+
+#define _mbg_swab_tlv_header( _p ) \
+{ \
+ _mbg_swab32( &(_p)->id ); \
+ _mbg_swab32( &(_p)->type ); \
+ _mbg_swab32( &(_p)->cur_bytes ); \
+ _mbg_swab32( &(_p)->trans_bytes ); \
+ _mbg_swab32( &(_p)->total_bytes ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+}
+
+
+
+/**
+ * @brief TLV structure containing information on current TLV transaction and its current data.
+ */
+typedef struct
+{
+ MBG_TLV_HDR hdr; ///< See ::MBG_TLV_HDR
+ uint8_t value[MSG_TLV_MAX_VALUE_SIZE]; ///< See ::MSG_TLV_MAX_VALUE_SIZE
+
+} MBG_TLV;
+
+#define _mbg_swab_tlv( _p ) \
+{ \
+ _mbg_swab_tlv_header( &(_p)->hdr ); \
+}
+
+/** @} defgroup group_tlv_api */
+
+
+
+/**
+ * @defgroup group_gps_nav_data Definitions used with navigational data received from GPS satellites
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::GPS_MODEL_IS_GPS is set in the @ref GPS_BUILTIN_FEATURE_MASKS
+ *
+ * @{ */
+
/**
* @brief Ephemeris parameters of one specific satellite
@@ -10682,8 +15723,8 @@ typedef struct
T_GPS tot_63; ///< time of transmission, page 63
T_GPS t0a; ///< complete reference time almanac
- CFG cfg[N_SVNO_GPS]; ///< SV configuration from page 63
- HEALTH health[N_SVNO_GPS]; ///< SV health from pages 51, 63
+ CFG cfg[N_SVNO_GPS]; ///< 4 bit SV configuration code from page 63
+ HEALTH health[N_SVNO_GPS]; ///< 6 bit SV health codes from pages 51, 63
} CFGH;
@@ -10712,17 +15753,18 @@ typedef struct
* after the next leap second event defined by WNlsf and DNt.
*
* The fields WNlsf and DNt specify the GPS week number and the day number
- * in that week at the end of which a leap second is scheduled.
+ * in that week for the end of which a leap second has been scheduled.
*
* @note: The satellites transmit WNlsf only as a signed 8 bit value, so it
- * can only define a point in time which is ± 127 weeks off the current time.
+ * can only define a point in time which is +/- 127 weeks off the current time.
* The firmware tries to expand this based on the current week number, but
* the result is ambiguous if the leap second occurs or occurred more
* than 127 weeks in the future or past.
*
- * So the leap second date should only be evaluated if the fields delta_tls
- * and delta_tlsf are different, in which case there is an actual leap second
- * announcement inside the ± 127 week range.
+ * So the leap second date should <b>only</b> be evaluated and displayed
+ * in a user interface if the fields delta_tls and delta_tlsf have
+ * different values, in which case there is indeed a leap second announcement
+ * inside the +/- 127 week range.
*/
typedef struct
{
@@ -10786,6 +15828,8 @@ typedef struct
} ASCII_MSG;
+/** @} defgroup group_gps_nav_data */
+
enum GPS_PLATFORMS
@@ -10843,6 +15887,7 @@ typedef struct
} NAV_TIME_MODE_SETTINGS;
+
/**
* Navigation Engine settings to set configuration
* parameters of a dynamic platform model.
@@ -10862,6 +15907,898 @@ typedef struct
} NAV_ENGINE_SETTINGS;
+
+/**
+ * @defgroup group_led_api Meinberg TLV API definitions
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::MBG_XFEATURE_LED_API is set in the extended device features.
+ *
+ * @{ */
+
+
+/**
+ * @brief General LED info to be read from a device
+ *
+ * Used to query from a device how many LEDs are supported
+ * by the device, then index 0..::MBG_LED_LIMITS::num_leds-1
+ * ::MBG_LED_INFO_IDX or ::MBG_LED_SETTINGS_IDX structures
+ * can be read from or written to the device.
+ *
+ * @see ::MBG_LED_SETTINGS_IDX
+ * @see ::MBG_LED_INFO_IDX
+ */
+typedef struct
+{
+ uint8_t num_leds; ///< Number of supported LEDs, see ::MBG_LED_SETTINGS_IDX::idx and ::MBG_LED_INFO_IDX::idx
+ uint8_t reserved_0; ///< Currently reserved, unused, always 0
+ uint16_t reserved_1; ///< Currently reserved, unused, always 0
+ uint32_t reserved_2; ///< Currently reserved, unused, always 0
+
+} MBG_LED_LIMITS;
+
+#define _mbg_swab_mbg_led_limits( _p ) \
+{ \
+ _mbg_swab8( &(_p)->num_leds ); \
+ _mbg_swab8( &(_p)->reserved_0 ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+/**
+ * @brief Possible modes of LEDs
+ *
+ * Used with ::MBG_LED_SETTINGS::mode
+ *
+ * @see ::MBG_LED_MODE_MASKS
+ */
+enum MBG_LED_MODES
+{
+ MBG_LED_MODE_OFF,
+ MBG_LED_MODE_ON,
+ MBG_LED_MODE_FLASH,
+ MBG_LED_MODE_FLASH_5S,
+ N_MBG_LED_MODES
+};
+
+
+
+/**
+ * @brief Bit masks associated with LED modes
+ *
+ * Used with ::MBG_LED_INFO::supp_modes
+ *
+ * @see ::MBG_LED_MODES
+ */
+enum MBG_LED_MODE_MASKS
+{
+ MBG_LED_MODE_MASK_OFF = ( 1UL << MBG_LED_MODE_OFF ), ///< see ::MBG_LED_MODE_OFF
+ MBG_LED_MODE_MASK_ON = ( 1UL << MBG_LED_MODE_ON ), ///< see ::MBG_LED_MODE_ON
+ MBG_LED_MODE_MASK_FLASH = ( 1UL << MBG_LED_MODE_FLASH ), ///< see ::MBG_LED_MODE_FLASH
+ MBG_LED_MODE_MASK_FLASH_5S = ( 1UL << MBG_LED_MODE_FLASH_5S ) ///< see ::MBG_LED_MODE_FLASH_5S
+};
+
+
+/**
+ * @brief Names of LED modes
+ *
+ * Can be used to initialize a string array of ::N_MBG_LED_MODES entries,
+ * so the number of strings must correspond to ::N_MBG_LED_MODES.
+ *
+ * @see ::MBG_LED_MODES
+ * @see ::MBG_LED_MODE_MASKS
+ */
+#define MBG_LED_MODE_STRS \
+{ \
+ "Off", \
+ "On", \
+ "Flash", \
+ "Flash 5s" \
+}
+
+
+
+/**
+ * @brief Possible colors of LEDs
+ *
+ * Used with ::MBG_LED_SETTINGS::color
+ *
+ * @see ::MBG_LED_COLOR_MASKS
+ */
+enum MBG_LED_COLORS
+{
+ MBG_LED_COLOR_GREEN,
+ MBG_LED_COLOR_RED,
+ MBG_LED_COLOR_YELLOW,
+ MBG_LED_COLOR_BLUE,
+ N_MBG_LED_COLORS
+};
+
+
+
+/**
+ * @brief Bit masks of possible LED colors
+ *
+ * Used with ::MBG_LED_INFO::supp_colors
+ *
+ * @see ::MBG_LED_COLORS
+ */
+enum MBG_LED_COLOR_MASKS
+{
+ MBG_LED_COLOR_MASK_GREEN = ( 1UL << MBG_LED_COLOR_GREEN ), ///< see ::MBG_LED_COLOR_GREEN
+ MBG_LED_COLOR_MASK_RED = ( 1UL << MBG_LED_COLOR_RED ), ///< see ::MBG_LED_COLOR_RED
+ MBG_LED_COLOR_MASK_YELLOW = ( 1UL << MBG_LED_COLOR_YELLOW ), ///< see ::MBG_LED_COLOR_YELLOW
+ MBG_LED_COLOR_MASK_BLUE = ( 1UL << MBG_LED_COLOR_BLUE ) ///< see ::MBG_LED_COLOR_BLUE
+};
+
+
+
+/**
+ * @brief Names of LED colors
+ *
+ * Can be used to initialize a string array of ::N_MBG_LED_COLORS entries,
+ * so the number of strings must correspond to ::N_MBG_LED_COLORS.
+ *
+ * @see ::MBG_LED_COLORS
+ * @see ::MBG_LED_COLOR_MASKS
+ */
+#define MBG_LED_COLOR_STRS \
+{ \
+ "Green", \
+ "Red", \
+ "Yellow", \
+ "Blue" \
+}
+
+
+
+/**
+ * @brief Configuration settings for a single LED
+ *
+ * @see ::MBG_LED_SETTINGS_IDX
+ */
+typedef struct
+{
+ uint8_t mode; ///< LED mode, see ::MBG_LED_MODES
+ uint8_t color; ///< LED color, see ::MBG_LED_COLORS
+ uint16_t reserved; ///< Currently reserved, unused, always 0
+
+} MBG_LED_SETTINGS;
+
+#define _mbg_swab_mbg_led_settings( _p ) \
+{ \
+ _mbg_swab8( &(_p)->mode ); \
+ _mbg_swab8( &(_p)->color ); \
+ _mbg_swab16( &(_p)->reserved ); \
+}
+
+
+
+/**
+ * @brief Configuration settings for a single LED, plus index
+ *
+ * @see ::MBG_LED_SETTINGS
+ * @see ::MBG_LED_LIMITS
+ */
+typedef struct
+{
+ uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1
+ MBG_LED_SETTINGS settings; ///< LED settings
+
+} MBG_LED_SETTINGS_IDX;
+
+#define _mbg_swab_mbg_led_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_mbg_led_settings( &(_p)->settings ); \
+}
+
+
+
+/**
+ * @brief Current settings and general capabilities of an LED
+ *
+ * This structure should be read from the device to retrieve the
+ * current settings of an LED plus its capabilities, e.g. the
+ * supported modes, colors, etc.
+ *
+ * @see ::MBG_LED_INFO_IDX
+ */
+typedef struct
+{
+ MBG_LED_SETTINGS settings; ///< Current LED settings
+ uint32_t supp_modes; ///< Supported modes, see ::MBG_LED_MODE_MASKS
+ uint32_t supp_colors; ///< Supported colors, see ::MBG_LED_COLOR_MASKS
+ uint32_t reserved; ///< Currently reserved, unused, always 0
+ uint32_t flags; ///< Currently reserved, unused, always 0
+
+} MBG_LED_INFO;
+
+#define _mbg_swab_mbg_led_info( _p ) \
+{ \
+ _mbg_swab_mbg_led_settings( &(_p)->settings ); \
+ _mbg_swab32( &(_p)->supp_modes ); \
+ _mbg_swab32( &(_p)->supp_colors ); \
+ _mbg_swab32( &(_p)->reserved ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+/**
+ * @brief Current settings and general capabilities of an LED, plus index
+ *
+ * @see ::MBG_LED_INFO
+ * @see ::MBG_LED_LIMITS
+ */
+typedef struct
+{
+ uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1
+ MBG_LED_INFO info; ///< LED info
+
+} MBG_LED_INFO_IDX;
+
+#define _mbg_swab_mbg_led_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_mbg_led_info( &(_p)->info ); \
+}
+
+/** @} defgroup group_led_api */
+
+
+
+/**
+ * @defgroup group_lne_api Definitions specific to LNE devices
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::MBG_XFEATURE_LNE_API is set in the extended device features.
+ *
+ * @{ */
+
+
+/**
+ * @brief General info to be read from an LNE device
+ *
+ * Used to query from a device e.g. how many LNE ports are provided
+ * by the device, then index 0..::MBG_LNE_LIMITS::num_ports-1
+ * ::MBG_LNE_PORT_INFO_IDX or ::MBG_LNE_PORT_SETTINGS_IDX structures
+ * can be read from or written to the device.
+ *
+ * @see ::MBG_LNE_PORT_SETTINGS_IDX
+ * @see ::MBG_LNE_PORT_INFO_IDX
+ */
+typedef struct
+{
+ uint8_t num_ports; ///< Number of supported ports, see ::MBG_LNE_PORT_SETTINGS_IDX::idx and ::MBG_LNE_PORT_INFO_IDX::idx
+ uint8_t reserved_0; ///< Currently reserved, unused, always 0
+ uint16_t reserved_1; ///< Currently reserved, unused, always 0
+ uint32_t features; // ### TODO Mask of supported features, see ::MBG_LNE_FEAT_MASKS
+ ///< Currently reserved, unused, always 0
+ uint32_t reserved_2; ///< Currently reserved, unused, always 0
+
+} MBG_LNE_LIMITS;
+
+#define _mbg_swab_mbg_lne_limits( _p ) \
+{ \
+ _mbg_swab8( &(_p)->num_ports ); \
+ _mbg_swab8( &(_p)->reserved_0 ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->features ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+}
+
+
+
+#if 0 //### TODO //#################
+
+/**
+ * @brief LNE feature bits
+ *
+ * Used to define ::MBG_LNE_FEAT_MASKS
+ *
+ * @see ::MBG_LNE_FEAT_MASKS
+ */
+enum MBG_LNE_FEAT_BITS
+{
+ MBG_LNE_FEAT_BIT_SWITCH_PWR, ///< Power switching off all LNE ports at once supported, see ::MBG_LNE_PWR_STATE
+ N_MBG_LNE_FEAT_BITS
+};
+
+
+
+/**
+ * @brief LNE feature bit masks
+ *
+ * Used with ::MBG_LNE_LIMITS::features
+ *
+ * @see ::MBG_LNE_FEAT_BITS
+ */
+enum MBG_LNE_FEAT_MASKS
+{
+ MBG_LNE_FEAT_MASK_SWITCH_PWR = ( 1UL << MBG_LNE_FEAT_BIT_SWITCH_PWR ) ///< see ::MBG_LNE_FEAT_BIT_SWITCH_PWR
+};
+
+#endif
+
+
+
+/**
+ * @brief Configuration settings for a single LNE port
+ *
+ * @see ::MBG_LNE_PORT_SETTINGS_IDX
+ */
+typedef struct
+{
+ uint32_t reserved_0; ///< currently reserved, unused, always 0
+ uint32_t reserved_1; ///< currently reserved, unused, always 0
+ uint32_t reserved_2; ///< currently reserved, unused, always 0
+ uint32_t flags; ///< currently reserved, unused, always 0
+
+} MBG_LNE_PORT_SETTINGS;
+
+#define _mbg_swab_mbg_lne_port_settings( _p ) \
+{ \
+ _mbg_swab32( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+/**
+ * @brief Configuration settings for a single LNE port, plus index
+ *
+ * @see ::MBG_LNE_PORT_SETTINGS
+ * @see ::MBG_LNE_LIMITS
+ */
+typedef struct
+{
+ uint16_t idx; ///< 0..::MBG_LNE_LIMITS::num_ports-1
+ MBG_LNE_PORT_SETTINGS settings; ///< LNE settings
+
+} MBG_LNE_PORT_SETTINGS_IDX;
+
+#define _mbg_swab_mbg_lne_port_settings_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_mbg_lne_port_settings( &(_p)->settings ); \
+}
+
+
+
+/**
+ * @brief Current settings and general capabilities of an LNE port
+ *
+ * This structure should be read from the device to retrieve the
+ * current settings of an LNE port plus its capabilities, ### e.g. the
+ * supported modes, colors, etc.
+ *
+ * @see ::MBG_LNE_PORT_INFO_IDX
+ */
+typedef struct
+{
+ MBG_LNE_PORT_SETTINGS settings; ///< Current LNE port settings
+ MBG_MAC_ADDR mac_addr; ///< The MAC address assigned to this port
+ uint32_t reserved_0; ///< currently reserved, unused, always 0
+ uint32_t reserved_1; ///< currently reserved, unused, always 0
+ uint32_t reserved_2; ///< currently reserved, unused, always 0
+ uint32_t flags; ///< see ::LNE_PORT_FLAG_MASKS
+
+} MBG_LNE_PORT_INFO;
+
+#define _mbg_swab_mbg_lne_port_info( _p ) \
+{ \
+ _mbg_swab_mbg_lne_port_settings( &(_p)->settings ); \
+ _mbg_swab_mbg_mac_addr( &(_p)->mac_addr ); \
+ _mbg_swab32( &(_p)->reserved_0 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+/**
+ * @brief Current settings and general capabilities of an LNE port, plus index
+ *
+ * @see ::MBG_LNE_PORT_INFO
+ * @see ::MBG_LNE_LIMITS
+ */
+typedef struct
+{
+ uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1
+ MBG_LNE_PORT_INFO info; ///< LNE port info
+
+} MBG_LNE_PORT_INFO_IDX;
+
+#define _mbg_swab_mbg_lne_port_info_idx( _p ) \
+{ \
+ _mbg_swab16( &(_p)->idx ); \
+ _mbg_swab_mbg_lne_port_info( &(_p)->info ); \
+}
+
+
+
+/**
+ * @brief LNE port flag bits
+ *
+ * Used to define ::LNE_PORT_FLAG_MASKS
+ *
+ * @see ::LNE_PORT_FLAG_MASKS
+ */
+enum LNE_PORT_FLAG_BITS
+{
+ LNE_PORT_FLAG_BIT_IS_SFP,
+ N_LNE_PORT_FLAG_BITS
+};
+
+
+
+/**
+ * @brief LNE port flag bit masks
+ *
+ * Used with ::MBG_LNE_PORT_INFO::flags
+ *
+ * @see ::LNE_PORT_FLAG_BITS
+ */
+enum LNE_PORT_FLAG_MASKS
+{
+ LNE_PORT_FLAG_MASK_IS_SFP = ( 1UL << LNE_PORT_FLAG_BIT_IS_SFP ) ///< see ::LNE_PORT_FLAG_BIT_IS_SFP
+};
+
+
+/** @} defgroup group_lne_api */
+
+
+
+/**
+ * @defgroup group_pwr_ctl_api Definitions for power control API
+ *
+ * @note These structures and definitions are only supported by a device
+ * if ::MBG_XFEATURE_PWR_CTL_API is set in the extended device features.
+ *
+ * @{ */
+
+
+/**
+ * @brief Device power states
+ *
+ * Used with ::MBG_PWR_CTL::state.
+ */
+enum MBG_PWR_STATES
+{
+ MBG_PWR_STATE_OFF,
+ MBG_PWR_STATE_ON,
+ N_MBG_PWR_STATES
+};
+
+
+
+/**
+ * @brief Device power control
+ *
+ * Used to change or retrieve a device's power state
+ */
+typedef struct
+{
+ uint8_t state; ///< see ::MBG_PWR_STATES
+ uint8_t reserved_0; ///< Currently reserved, unused, always 0
+ uint16_t reserved_1; ///< Currently reserved, unused, always 0
+
+} MBG_PWR_CTL;
+
+#define _mbg_swab_mbg_pwr_ctl( _p ) \
+{ \
+ _mbg_swab8( &(_p)->state ); \
+ _mbg_swab8( &(_p)->reserved_0 ); \
+ _mbg_swab16( &(_p)->reserved_1 ); \
+}
+
+/** @} defgroup group_pwr_ctl_api */
+
+
+
+
+/**
+ * @defgroup group_ext_sys_info Extended system information
+ *
+ * @note This structure and its definitions are only supported by a device
+ * if ::MBG_XFEATURE_EXT_SYS_INFO is set in the extended device features.
+ *
+ * @{ */
+
+
+/**
+ * @brief Bits used to define ::MBG_EXT_SYS_INFO_MSKS
+ *
+ * @see ::MBG_EXT_SYS_INFO_MSKS
+ */
+enum MBG_EXT_SYS_INFO_BITS
+{
+ MBG_EXT_SYS_INFO_BIT_SW_REV,
+ MBG_EXT_SYS_INFO_BIT_HW_REV,
+ MBG_EXT_SYS_INFO_BIT_OS_REV,
+ MBG_EXT_SYS_INFO_BIT_FPGA_REV,
+ N_MBG_EXT_SYS_INFO_BITS
+};
+
+
+
+/**
+ * @brief Bit masks of supported revision numbers
+ *
+ * Used with ::MBG_EXT_SYS_INFO::supp_members
+ *
+ * @see ::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
+};
+
+
+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,
+ N_MBG_EXT_SYS_INFO_PROC_TYPES
+};
+
+#define MBG_EXT_SYS_INFO_PROC_STRS \
+{ \
+ "None", \
+ "Cortex A9", \
+ "Cortex SAM3u" \
+}
+
+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
+ N_MBG_EXT_SYS_INFO_FPGA_TYPES
+};
+
+#define MBG_EXT_SYS_INFO_FPGA_STRS \
+{ \
+ "None", \
+ "Cyclone5 SoC", \
+ "Cyclone5" \
+}
+
+typedef struct
+{
+ uint32_t supp_members; ///< ::MBG_EXT_SYS_INFO_MSKS
+
+ uint32_t sw_rev;
+ 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
+
+ /* 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;
+ uint32_t reserved_rev_6;
+ uint32_t reserved_rev_7;
+ uint32_t reserved_rev_8;
+ uint32_t reserved_rev_9;
+ uint32_t reserved_rev_10;
+ uint32_t reserved_rev_11;
+
+} MBG_EXT_SYS_INFO;
+
+#define _mbg_swab_ext_sys_info( _p) \
+{ \
+ _mbg_swab32( &(_p)->supp_members ); \
+ _mbg_swab32( &(_p)->sw_rev ); \
+ _mbg_swab32( &(_p)->hw_rev ); \
+ _mbg_swab32( &(_p)->os_rev ); \
+ _mbg_swab32( &(_p)->fpga_rev ); \
+ _mbg_swab16( &(_p)->proc_type ); \
+ _mbg_swab16( &(_p)->fpga_type ); \
+}
+
+
+#define _mbg_encode_revision( _major, _minor, _patch ) \
+ ( ( (_major) << 24) | ( (_minor) << 16 ) | (_patch) )
+
+
+#define _mbg_decode_revision( _rev, _major, _minor, _patch ) \
+{ \
+ (_major) = ( (_rev) >> 24 ) & 0xff; \
+ (_minor) = ( (_rev) >> 16 ) & 0xff; \
+ (_patch) = (_rev) & 0xffff; \
+}
+
+
+/** @} defgroup group_ext_sys_info */
+
+
+/**
+ * @defgroup group_license_limits License information
+ *
+ * @note This structure and its definitions are only supported by a device
+ * if ::MBG_XFEATURE_LICENSE_LIMITS is set in the extended device features.
+ *
+ * @{ */
+
+
+#define MBG_MAX_LICENSES 32
+
+
+/**
+ * @brief General license information to be read from a device
+ *
+ * Used to query from a device how many and which different license types
+ * are supported. If a special type is supported (licenses[MBG_LICENSE_BASE_TYPES] > 0), its
+ * license specific information can be queried from 0..licenses[MBG_LICENSE_BASE_TYPES]-1 via
+ * its license specific [...]_IDX structures and TLV API command codes.
+ * See ::MBG_XFEATURE_TLV_API and ::MBG_TLV_FEAT_TYPES.
+ */
+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;
+
+
+enum MBG_LICENSE_BASE_TYPES
+{
+ MBG_LICENSE_BASE_TYPE_PTPV2,
+ MBG_LICENSE_BASE_TYPE_NTP,
+ N_MBG_LICENSE_BASE_TYPES
+};
+
+
+/**
+ * @brief Bits used to define ::MBG_LICENSE_BASE_MSKS
+ *
+ * @see ::MBG_LICENSE_BASE_MSKS
+ */
+enum MBG_LICENSE_BASE_FLAGS
+{
+ MBG_LICENSE_BASE_FLAG_SUPP_UPGRADE, ///< License supports upgrading / modifying
+ N_MBG_LICENSE_BASE_FLAGS
+};
+
+
+/**
+ * @brief Bit masks of common supported base license flags
+ *
+ * Used with ::MBG_LICENSE_BASE::supp_flags
+ *
+ * @see ::MBG_LICENSE_COMM_BITS
+ */
+enum MBG_LICENSE_BASE_MSKS
+{
+ MBG_LICENSE_BASE_MSK_SUPP_UPGRADE = ( 1UL << MBG_LICENSE_BASE_FLAG_SUPP_UPGRADE ) ///< See ::MBG_LICENSE_BASE_FLAG_SUPP_UPGRADE
+};
+
+
+/**
+ * @brief Common license information that should be part of each individual
+ * license type. Can be seen as a base / parent class in C++.
+ *
+ */
+typedef struct
+{
+ uint8_t type; ///< See ::MBG_LICENSE_BASE_TYPES
+ uint8_t reserved_1; ///< Reserved for future use, currently 0
+ uint16_t reserved_2; ///< Reserved for future use, currently 0
+ uint32_t supp_flags; ///< See ::MBG_LICENSE_BASE_MSKS
+ uint32_t reserved_3; ///< Reserved for future use, currently 0
+ uint32_t reserved_4; ///< Reserved for future use, currently 0
+
+} MBG_LICENSE_BASE;
+
+#define _mbg_swab_license_base( _p) \
+{ \
+ _mbg_swab32( &(_p)->supp_flags ); \
+}
+
+
+/**
+ * @brief Bits used to define ::MBG_LICENSE_PTPV2_MEMBER_MSKS
+ *
+ * @see ::MBG_LICENSE_PTPV2_MEMBER_MSKS
+ */
+enum MBG_LICENSE_PTPV2_MEMBERS
+{
+ MBG_LICENSE_PTPV2_MEMBER_MAX_UCLIENTS,
+ MBG_LICENSE_PTPV2_MEMBER_MAX_MTRANS,
+ N_MBG_LICENSE_PTPV2_MEMBERS
+};
+
+
+/**
+ * @brief Bit masks of PTPV2 license specific members
+ *
+ * Used with ::MBG_LICENSE_PTPV2::supp_members
+ *
+ * @see ::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
+};
+
+
+/**
+ * @brief PTPV2 specific license information
+ *
+ */
+typedef struct
+{
+ MBG_LICENSE_BASE base; ///< See ::MBG_LICENSE_BASE
+ uint32_t supp_members; ///< See ::MBG_LICENSE_PTPV2_MEMBER_MSKS
+ uint32_t reserved_1; ///< Reserved for future use, currently 0
+ uint16_t max_uclients; ///< Maximal number of supported unicast clients.
+ uint16_t reserved_2; ///< Reserved for future use, currently 0
+ uint32_t max_mtrans; ///< Maximal number of supported multicast transactions per second.
+ uint32_t reserved_3; ///< Reserved for future use, currently 0
+ uint32_t reserved_4; ///< Reserved for future use, currently 0
+ uint32_t reserved_5; ///< Reserved for future use, currently 0
+ uint32_t reserved_6; ///< Reserved for future use, currently 0
+
+} MBG_LICENSE_PTPV2;
+
+#define _mbg_swab_license_ptpv2( _p) \
+{ \
+ _mbg_swab_license_base( &(_p)->base ); \
+ _mbg_swab32( &(_p)->supp_members ); \
+ _mbg_swab16( &(_p)->max_uclients ); \
+ _mbg_swab32( &(_p)->max_mtrans ); \
+}
+
+
+typedef struct
+{
+ uint32_t idx;
+ MBG_LICENSE_PTPV2 license;
+
+} MBG_LICENSE_PTPV2_IDX;
+
+#define _mbg_swab_license_ptpv2_idx( _p) \
+{ \
+ _mbg_swab_license_ptpv2( &(_p)->license ); \
+ _mbg_swab32( &(_p)->idx ); \
+}
+
+
+/**
+ * @brief Bits used to define ::MBG_LICENSE_NTP_MEMBER_MSKS
+ *
+ * @see ::MBG_LICENSE_NTP_MEMBER_MSKS
+ */
+enum MBG_LICENSE_NTP_MEMBERS
+{
+ MBG_LICENSE_NTP_MEMBER_MAX_RPS,
+ N_MBG_LICENSE_NTP_MEMBERS
+};
+
+
+/**
+ * @brief Bit masks of NTP license specific members
+ *
+ * Used with ::MBG_LICENSE_NTP::supp_members
+ *
+ * @see ::MBG_LICENSE_PTPV2_MEMBERS
+ */
+enum MBG_LICENSE_NTP_MEMBER_MSKS
+{
+ MBG_LICENSE_NTP_MEMBER_MSK_MAX_RPS = ( 1UL << MBG_LICENSE_NTP_MEMBER_MAX_RPS ) ///< See ::MBG_LICENSE_NTP_MEMBER_MAX_RPS
+};
+
+
+/**
+ * @brief NTP specific license information
+ */
+typedef struct
+{
+ MBG_LICENSE_BASE base; ///< See ::MBG_LICENSE_BASE
+ uint32_t supp_members; ///< See ::MBG_LICENSE_NTP_MEMBER_MSKS
+ uint32_t max_rps; ///< Maximum number of supported requests per second
+ uint32_t reserved_1; ///< Reserved for future use, currently 0
+ uint32_t reserved_2; ///< Reserved for future use, currently 0
+ uint32_t reserved_3; ///< Reserved for future use, currently 0
+ uint32_t reserved_4; ///< Reserved for future use, currently 0
+ uint32_t reserved_5; ///< Reserved for future use, currently 0
+ uint32_t reserved_6; ///< Reserved for future use, currently 0
+
+} MBG_LICENSE_NTP;
+
+#define _mbg_swab_license_ntp( _p) \
+{ \
+ _mbg_swab_license_base( &(_p)->base ); \
+ _mbg_swab32( &(_p)->supp_members ); \
+ _mbg_swab32( &(_p)->max_rps ); \
+}
+
+
+typedef struct
+{
+ uint32_t idx;
+ MBG_LICENSE_NTP license;
+
+} MBG_LICENSE_NTP_IDX;
+
+#define _mbg_swab_license_ntp_idx( _p) \
+{ \
+ _mbg_swab_license_ntp( &(_p)->license ); \
+ _mbg_swab32( &(_p)->idx ); \
+}
+
+
+/** @} defgroup group_license_limits */
+
+
+
+/**
+ * @defgroup group_clk_res_info Clock resolution info
+ *
+ * @note This structure and its definitions are only supported by a device
+ * if ::MBG_XFEATURE_CLK_RES_INFO is set in the extended device features.
+ *
+ * @{ */
+
+/**
+ * @brief Clock resolution information
+ *
+ * @see @ref group_clk_res_info
+ */
+typedef struct
+{
+ uint32_t base_clk; ///< Base clock of the internal time base [MHz]
+ uint32_t num_clk_phase; ///< Number of multi-phase clock signals
+ uint32_t reserved_9;
+ uint32_t reserved_8;
+ uint32_t reserved_7;
+ uint32_t reserved_6;
+ uint32_t reserved_5;
+ uint32_t reserved_4;
+ uint32_t reserved_3;
+ uint32_t reserved_2;
+ uint32_t reserved_1;
+ uint32_t reserved_0;
+
+} MBG_CLK_RES_INFO;
+
+#define _mbg_swab_mbg_clk_res_info( _p) \
+{ \
+ _mbg_swab32( &(_p)->base_clk ); \
+ _mbg_swab32( &(_p)->base_clk ); \
+ _mbg_swab32( &(_p)->reserved_9 ); \
+ _mbg_swab32( &(_p)->reserved_8 ); \
+ _mbg_swab32( &(_p)->reserved_7 ); \
+ _mbg_swab32( &(_p)->reserved_6 ); \
+ _mbg_swab32( &(_p)->reserved_5 ); \
+ _mbg_swab32( &(_p)->reserved_4 ); \
+ _mbg_swab32( &(_p)->reserved_3 ); \
+ _mbg_swab32( &(_p)->reserved_2 ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->reserved_0 ); \
+}
+
+/** @} defgroup group_clk_res_info */
+
+
+
#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 9ae3d47..dd9630b 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.2 2014/09/24 09:25:44 martin REL_M $
+ * $Id: mbg_ntp_test_util.c 1.5 2016/08/05 12:35:43 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,15 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_ntp_test_util.c $
- * Revision 1.2 2014/09/24 09:25:44 martin
+ * Revision 1.5 2016/08/05 12:35:43 martin
+ * Proper evaluation of precision field.
+ * Use safe str_util functions.
+ * Revision 1.4 2016/07/18 14:53:28Z martin
+ * Use new functions from module timeutil.
+ * Fixed compiler warning under Windows.
+ * Revision 1.3 2016/07/14 09:17:02 martin
+ * Fixed build under Windows.
+ * Revision 1.2 2014/09/24 09:25:44Z martin
* Account for modified NTP_PACKET definition.
* Account for changed NTP_TSTAMP field names.
* Fixed some compiler warnings.
@@ -26,12 +34,22 @@
#include <mbg_ntp_test_util.h>
#undef _MBG_NTP_TEST_UTIL
+#include <timeutil.h>
+#include <str_util.h>
+#include <mbgerror.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
-#include <values.h>
+
+#if defined( MBG_TGT_POSIX )
+ #include <values.h>
+#elif defined( MBG_TGT_WIN32 )
+ #include <float.h>
+ #define MAXDOUBLE DBL_MAX
+#endif
@@ -99,14 +117,24 @@ void print_stats_double( const char *info, int info_width,
*/
void print_timespec_date_time( const struct timespec *p_ts )
{
- time_t t = p_ts->tv_sec;
- struct tm *tmp = gmtime( &t );
+ struct tm tm = { 0 };
+ time_t t = cvt_to_time_t( p_ts->tv_sec );
+ int rc = mbg_gmtime( &tm, &t );
- printf( "%04i-%02i-%02i %02i:%02i:%02i.%09li",
- tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
- tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
- (long) p_ts->tv_nsec
- );
+ if ( mbg_rc_is_success( rc ) )
+ {
+ printf( "%04i-%02i-%02i %02i:%02i:%02i.%09li",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ (long) p_ts->tv_nsec
+ );
+ }
+ else
+ {
+ char s[100];
+ snprint_gmtime_error( s, sizeof( s ), rc, t, __func__ );
+ printf( "%s", s );
+ }
} // print_timespec_date_time
@@ -156,6 +184,61 @@ void print_ntp_time( const char *msg, const NTP_TSTAMP *t, const char *tail, int
/*HDR*/
+int snprint_ntp_prec( char *s, size_t max_len, int8_t prec_exp )
+{
+ typedef struct
+ {
+ double limit;
+ double scale;
+ int frac_digits;
+ const char *units;
+ } SC_INFO;
+
+ const SC_INFO *p;
+
+ int shift_cnt = abs( prec_exp );
+ double d = (double) ( (uint64_t) 1UL << shift_cnt );
+
+ if ( prec_exp < 0 )
+ {
+ int i;
+
+ #define N_SC_INFO_NEG 7
+
+ static const SC_INFO sc_info_neg[N_SC_INFO_NEG] =
+ {
+ { 1., 1e3, 0, "ms" }, // 2^^0
+ { 8., 1e3, 2, "ms" }, // 2^^3
+ { 1024., 1e6, 0, "us" }, // 2^^10
+ { 8192., 1e6, 2, "us" }, // 2^^12
+ { 524288., 1e9, 0, "ns" }, // 2^^19
+ { 8388608., 1e9, 2, "ns" }, // 2^^23
+ { 134217728., 1e9, 3, "ns" } // 2^^27
+ };
+
+ for ( i = N_SC_INFO_NEG; i > 0; )
+ {
+ i--;
+ p = &sc_info_neg[i];
+ if ( d > p->limit )
+ break;
+ }
+
+ d = p->scale / d;
+ }
+ else
+ {
+ static const SC_INFO sc_info_pos = { 0, 0, 0, "s" };
+ p = &sc_info_pos;
+ }
+
+ return snprintf_safe( s, max_len, "%.*f %s", p->frac_digits, d, p->units );
+
+} // snprint_ntp_prec
+
+
+
+/*HDR*/
/**
* @brief Print contents of an NTP packet on several lines
*
@@ -166,22 +249,27 @@ void print_ntp_time( const char *msg, const NTP_TSTAMP *t, const char *tail, int
void print_ntp_packet( const char *msg, const NTP_PACKET_INFO *p, int print_date_time )
{
const NTP_BASE_PACKET *pbp = &p->packet.base;
- int i;
+ size_t i;
char ref_id_str[80];
char *cp = ref_id_str;
+ int8_t pkt_precision = pbp->flags.precision;
+ char prec_str[40];
+
+ snprint_ntp_prec( prec_str, sizeof( prec_str ), pkt_precision );
printf( "%s\n", msg );
printf( INDENT
"mode %u, version %u, leap_ind %u, "
- "stratum %u, poll %u, prec %u\n"
+ "stratum %u, poll %u, prec %i (%s)\n"
,
pbp->flags.mode,
pbp->flags.version,
pbp->flags.leap_ind,
pbp->flags.stratum,
pbp->flags.poll,
- pbp->flags.precision
+ pkt_precision,
+ prec_str
);
@@ -283,7 +371,7 @@ void init_ntp_req_packet( NTP_PACKET *p, int req_mode, int prot_version )
pbp->flags.leap_ind = 3;
pbp->flags.stratum = 0;
pbp->flags.poll = 6;
- pbp->flags.precision = 238;
+ 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 4fc380e..5ee050d 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.2 2014/09/24 11:12:20 martin REL_M $
+ * $Id: mbg_ntp_test_util.h 1.4 2016/08/05 12:37:31 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,12 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_ntp_test_util.h $
- * Revision 1.2 2014/09/24 11:12:20 martin
+ * Revision 1.4 2016/08/05 12:37:31 martin
+ * New variable client_precision.
+ * Updated function prototypes.
+ * Revision 1.3 2016/07/14 10:55:10Z martin
+ * Fixed build under Windows.
+ * Revision 1.2 2014/09/24 11:12:20Z martin
* New structure NTP_RESULTS.
* Account for changed NTP_TSTAMP field names.
* Added and updated doxygen comments.
@@ -61,6 +66,16 @@ extern "C" {
#define INDENT " "
+#if !defined( MBG_TGT_POSIX )
+ // LOG_WARNING and friends are syslog stuff which
+ // is not supported e.g. under Windows.
+ enum
+ {
+ LOG_WARNING,
+ LOG_ERR
+ };
+#endif
+
void mbglog( int priority, const char *fmt, ... );
_ext const char *newline
@@ -70,6 +85,13 @@ _ext const char *newline
;
+_ext int8_t client_precision
+#ifdef _DO_INIT
+ = -18
+#endif
+;
+
+
typedef struct
{
double min;
@@ -157,7 +179,7 @@ uint32_t nsec_to_ntp_frac( ulong nsec )
if ( tmp >= NTP_FRAC_PER_SEC )
mbglog( LOG_WARNING, "Range overflow in nsec_to_ntp_frac: %lu -> 0x%LX",
- (ulong) nsec, tmp );
+ (ulong) nsec, tmp );
return (uint32_t) tmp;
@@ -168,7 +190,7 @@ uint32_t nsec_to_ntp_frac( ulong nsec )
static __mbg_inline /*HDR*/
void timespec_to_ntp_tstamp( NTP_TSTAMP *t_ntp, const struct timespec *t_ts )
{
- t_ntp->seconds = t_ts->tv_sec + NTP_SEC_BIAS;
+ t_ntp->seconds = (uint32_t) t_ts->tv_sec + NTP_SEC_BIAS;
t_ntp->fractions = nsec_to_ntp_frac( t_ts->tv_nsec );
} // timespec_to_ntp_tstamp
@@ -280,6 +302,7 @@ int check_bounds( int opt_val, int min_val, int max_val, int default_val )
*/
void print_ntp_time( const char *msg, const NTP_TSTAMP *t, const char *tail, int print_date_time ) ;
+ int snprint_ntp_prec( char *s, size_t max_len, int8_t prec_exp ) ;
/**
* @brief Print contents of an NTP packet on several lines
*
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index 3c18952..a3511d6 100755
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.34 2015/03/03 13:32:49 martin REL_M $
+ * $Id: mbg_tgt.h 1.35 2016/08/05 12:21:34 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,68 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
+ * 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.
+ * New symbol MBG_TGT_HAS_ABS64.
+ * Moved some compatibility definitions from gpsserio.h here.
+ * Define ssize_t for Windows, if required.
+ * Conditionally provided struct timespec for Windows.
+ * Added compatible 64 bit type print format specifiers.
+ * Include inttypes.h for all targets providing also stdint.h.
+ * Added some MSVC version code information.
+ * Fixes for FreeBSD.
+ * Fixed some spelling.
+ * Tmp workaround for 2.6.32-5-sparc64.
+ * Proper fix required.
+ * Revision 1.34.1.26 2016/08/05 10:38:10 martin
+ * Revision 1.34.1.25 2016/08/04 14:51:25Z martin
+ * Moved some compatibility definitions from gpsserio.h to mbg_tgt.h.
+ * Revision 1.34.1.24 2016/08/02 13:10:58 martin
+ * Define ssize_t for Windows, if required.
+ * Revision 1.34.1.23 2016/07/18 14:41:27Z martin
+ * New symbol MBG_TGT_HAS_ABS64.
+ * Revision 1.34.1.22 2016/07/14 09:00:58Z martin
+ * Conditionally provided struct timespec for Windows.
+ * Revision 1.34.1.21 2016/07/07 10:01:28Z martin
+ * Modified inclusion of Windows header files.
+ * Revision 1.34.1.20 2016/06/06 12:59:03 thomas-b
+ * Include all necessary Windows headers in the needed sequence
+ * Revision 1.34.1.19 2016/04/26 14:53:06 martin
+ * Revision 1.34.1.18 2016/04/26 13:31:08Z martin
+ * Added compatible 64 bit type print format specifiers.
+ * Revision 1.34.1.17 2016/04/25 14:46:20Z martin
+ * Include inttypes.h for all targets providing also stdint.h.
+ * Revision 1.34.1.16 2016/03/02 12:26:15 martin
+ * *** empty log message ***
+ * Revision 1.34.1.15 2016/02/26 09:12:11 paul
+ * Revision 1.34.1.14 2015/12/10 12:34:14Z martin
+ * *** empty log message ***
+ * Revision 1.34.1.13 2015/12/01 14:55:52 martin
+ * Revision 1.34.1.12 2015/12/01 14:54:08Z martin
+ * *** empty log message ***
+ * Revision 1.34.1.11 2015/12/01 14:52:20 martin
+ * *** empty log message ***
+ * Revision 1.34.1.10 2015/12/01 14:43:44 martin
+ * *** empty log message ***
+ * Revision 1.34.1.9 2015/12/01 13:55:09 martin
+ * Conditionally define a macro _DEPRECATED_BY which can be used to
+ * tag functions as deprecated, so compilers can emit appropriate warnings.
+ * Revision 1.34.1.8 2015/10/28 13:45:25 martin
+ * Added some MSVC version code information.
+ * Revision 1.34.1.7 2015/10/19 09:34:56 martin
+ * Fixed some spelling.
+ * Revision 1.34.1.6 2015/10/15 12:49:10 marvin
+ * Revision 1.34.1.5 2015/10/08 08:55:16Z martin
+ * Revision 1.34.1.4 2015/10/05 15:07:23Z marvin
+ * Unicode support.
+ * Revision 1.34.1.3 2015/09/21 08:58:27Z martin
+ * *** empty log message ***
+ * Revision 1.34.1.2 2015/09/18 14:53:25 martin
+ * Fixes for FreeBSD.
+ * Revision 1.34.1.1 2015/04/07 15:40:59 martin
+ * Tmp workaround for 2.6.32-5-sparc64.
+ * Proper fix required.
* Revision 1.34 2015/03/03 13:32:49 martin
* Provide __func__ for MS Visual Studio.
* Revision 1.33 2015/03/02 11:27:59Z martin
@@ -78,9 +140,9 @@
* Recognize DOS target under Watcom compilers.
* Flag Watcom C always supports wchar_t.
* Revision 1.12 2008/01/17 09:38:50Z daniel
- * Added macros to determine whether C language extensions
+ * Added macros to determine whether C language extensions
* (e.g. C94, C99) are supported by the target environment.
- * Added macro to check whether wchar_t and friends are
+ * Added macro to check whether wchar_t and friends are
* supported, and some compatibility stuff.
* Revision 1.11 2007/10/31 16:58:03 martin
* Fixed __mbg_inline for Borland C (DOS).
@@ -89,7 +151,7 @@
* Added MBG_PORT_HANDLE type for serial ports.
* Added macros for unified inline code syntax.
* Revision 1.9 2006/12/08 12:45:54Z martin
- * Under Windows include ntddk.h rather than windows.h
+ * Under Windows include ntddk.h rather than windows.h
* if building kernel driver .
* Revision 1.8 2006/10/25 12:20:45Z martin
* Initial support for FreeBSD, NetBSD, and OpenBSD.
@@ -106,7 +168,7 @@
* Revision 1.3 2003/04/09 13:37:20Z martin
* Added definition for _MBG_API.
* Revision 1.2 2003/02/24 16:08:45Z martin
- * Don't setup for Win32 PNP if explicitely configured non-PNP.
+ * Don't setup for Win32 PNP if explicitly configured non-PNP.
* Revision 1.1 2002/02/19 13:46:20Z MARTIN
* Initial revision
*
@@ -146,7 +208,7 @@
#if ( _WIN32_WINNT >= 0x0500 )
// Win2k and above
#if !defined( MBG_TGT_WIN32_NON_PNP )
- // only if not explicitely disabled
+ // only if not explicitly disabled
#define MBG_TGT_WIN32_PNP
#endif
#endif
@@ -217,20 +279,21 @@
// GCC for target OpenBSD
#define MBG_TGT_OPENBSD
-#elif defined( __sun ) // Oracle Solaris or other SunOS derived operating system
+#elif defined( __sun ) // Oracle Solaris or other SunOS derived operating system
// __SUNPRO_C Oracle Solaris Studio C compiler, __SUNPRO_C value is the version number
// __SUNPRO_CC Oracle Solaris Studio C++ compiler, __SUNPRO_CC value is the version number
// __sparc generate code for SPARC (R) architecture (32-bit or 64-bit)
- // __sparcv9 generate code for 64-bit SPARC architecture
- // __i386 generate code for 32-bit x86 architecture
- // __amd64 generate code for 64-bit x64 architecture
+ // __sparcv9 generate code for 64-bit SPARC architecture
+ // __i386 generate code for 32-bit x86 architecture
+ // __amd64 generate code for 64-bit x64 architecture
#define MBG_TGT_SUNOS
#define __mbg_inline __inline__
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
@@ -283,6 +346,10 @@
#if defined( __GNUC__ )
+ #define _GCC_VERSION ( __GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__ )
+
#if defined( __i386__ )
#define MBG_ARCH_I386
@@ -314,12 +381,13 @@
#if defined( MBG_TGT_LINUX )
- #if defined( __KERNEL__ )
+ #if defined( MBG_TGT_KERNEL )
#include <linux/types.h>
#include <linux/version.h>
- #if ( LINUX_VERSION_CODE <= KERNEL_VERSION( 2, 6, 4 ) )
+ #if ( LINUX_VERSION_CODE <= KERNEL_VERSION( 2, 6, 4 ) ) || \
+ ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 4 ) ) //##++++ must be true for 2.6.32-5-sparc64
#define _ULONG_DEFINED 1
#define _USHORT_DEFINED 1
#define _UINT_DEFINED 1
@@ -327,8 +395,8 @@
#else
- #include <sys/types.h>
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#if defined( __u_char_defined )
@@ -341,16 +409,24 @@
#elif defined( MBG_TGT_BSD )
- #include <sys/types.h>
+ #if defined( MBG_TGT_KERNEL )
+ #include <sys/types.h>
+ #else
+ #include <stdint.h>
+ #include <inttypes.h>
+ #include <stdbool.h>
+ #endif
#elif defined( MBG_TGT_QNX_NTO ) // QNX 6.x (Neutrino)
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#else
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#endif
@@ -361,9 +437,18 @@
#define __mbg_inline __inline__
+
+ #if ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer support this
+ #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead")))
+ #else
+ #define _DEPRECATED_BY( _s ) __attribute__((deprecated))
+ #endif
+
#elif defined( _MSC_VER )
// Known predifined MS compiler version codes:
+ // 1900: MSVC++ 14.0 (Visual Studio 2015)
+ // 1800: MSVC++ 12.0 (Visual Studio 2013)
// 1700: MSVC++ 11.0 (Visual Studio 2012)
// 1600: MSVC++ 10.0 (Visual Studio 2010)
// 1500: MSVC++ 9.0 (Visual Studio 2008)
@@ -373,24 +458,78 @@
// 1200: MSVC++ 6.0
// 1100: MSVC++ 5.0
+ // "struct timespec" is supported only since VS2015
+ // If it is then also the symbol TIME_UTC should be defined.
+ // Functions to read the current time as struct timespec
+ // are timespec_get() and friends, which are also only provided
+ // by VS2015 and later.
+ // As of VS2015, only TIME_UTC is supported to read
+ // the UTC system time, there is no equivalent for
+ // the POSIX CLOCK_MONOTONIC. However, QPC can be used
+ // to get monotonic time stamps and intervals.
+ #if ( _MSC_VER < 1900 )
+ #if !defined( HAVE_STRUCT_TIMESPEC )
+ #include <time.h>
+
+ struct timespec
+ {
+ time_t tv_sec;
+ long tv_nsec;
+ };
+ #endif
+ #endif
+
#if ( _MSC_VER >= 1600 )
#include <stdint.h>
- #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
+ #include <inttypes.h>
+ #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
#else
- #define MBG_TGT_HAS_INT_8_16_32 1
+ #define MBG_TGT_HAS_INT_8_16_32 1
+ #define MBG_PRE64_PREFIX "I64"
#endif
- // no bool support anyway
- #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #if !defined( __cplusplus )
+ // no bool support anyway
+ #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #endif
- #define MBG_TGT_HAS_WCHAR_T 1
+ #define MBG_TGT_HAS_WCHAR_T 1
#define __mbg_inline __forceinline
- // At least up to VS2008 the builtin symbol __func__
- // is not supported, but __FUNCTION__ returns the name
+ // At least up to VS2008 the C99 builtin symbol __func__
+ // is not supported. Some VS versions support __FUNCTION__
+ // instead, but at least VC6 doesn't support this, either.
// of the current function instead.
- #define __func__ __FUNCTION__
+ #if ( _MSC_VER >= 1300 )
+ #define __func__ __FUNCTION__
+ #else
+ #define __func__ "func_???"
+ #endif
+
+ // "deprecated" attribute
+ #if ( _MSC_VER >= 1400 )
+ // This is supported since Visual Studio 2005
+ #define _DEPRECATED_BY( _s ) __declspec(deprecated("deprecated, use \"" _s "\""))
+ #endif
+
+ // availability of _abs64()
+ #if ( _MSC_VER >= 1500 )
+ // This is supported at least since Visual Studio 2008
+ #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;
+ #endif
#elif defined( _CVI_ )
@@ -404,6 +543,7 @@
#if ( _CVI_ >= 910 )
// LabWindows/CVI 2009 is the first version providing stdint.h.
#include <stdint.h>
+ #include <inttypes.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
#else
#define USE_LONG_FOR_INT32 1
@@ -443,16 +583,23 @@
#if ( __BORLANDC__ >= 0x630 )
// C++Builder XE starts to provide stdbool.h
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
#elif ( __BORLANDC__ >= 0x570 )
- // at least BDS 2006 starts to provide stdint.h
+ // BDS/Borland C++ Builder 2006 starts to provide at least stdint.h
#include <stdint.h>
+ #include <inttypes.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
- #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #if !defined( __cplusplus )
+ #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #endif
#elif ( __BORLANDC__ >= 0x0550 )
#define MBG_TGT_HAS_INT_8_16_32 1
- #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #define MBG_PRE64_PREFIX "I64"
+ #if !defined( __cplusplus )
+ #define MBG_TGT_MISSING_BOOL_TYPE 1
+ #endif
#else // e.g. BC 3.1 or earlier
#if ( __BORLANDC__ <= 0x410 )
#define MBG_TGT_MISSING_64_BIT_TYPES 1
@@ -483,15 +630,16 @@
#include <sys/types.h>
- #define MBG_TGT_MISSING_64_BIT_TYPES 1
+ #define MBG_TGT_MISSING_64_BIT_TYPES 1
#elif ( __WATCOMC__ > 1230 ) // Open Watcom C 1.3 and above
#include <stdint.h>
+ #include <inttypes.h>
#elif !defined( __WATCOM_INT64__ ) // Watcom C 11
- #define MBG_TGT_MISSING_64_BIT_TYPES 1
+ #define MBG_TGT_MISSING_64_BIT_TYPES 1
#endif
@@ -502,17 +650,36 @@
#endif
+// If the build environment doesn't provide a inttypes.h file
+// with print format specifiers for 64 bit fixed size types
+// then MBG_PRE64_PREFIX should be defined which is used
+// to define our own C99 compatible format specifiers.
+// Eventually, similar definitions are required for 32, 16,
+// and 8 bit fixed size types.
+#if defined( MBG_PRE64_PREFIX )
+ #define PRIi64 MBG_PRE64_PREFIX "i"
+ #define PRId64 MBG_PRE64_PREFIX "d"
+ #define PRIo64 MBG_PRE64_PREFIX "o"
+ #define PRIu64 MBG_PRE64_PREFIX "u"
+ #define PRIx64 MBG_PRE64_PREFIX "x"
+ #define PRIX64 MBG_PRE64_PREFIX "X"
+#endif
+
#if !defined( __GNUC__ ) && !defined( __attribute__ )
#define __attribute__( _x )
#endif
+#if !defined( _DEPRECATED_BY )
+ #define _DEPRECATED_BY( _s ) // empty definition
+#endif
+
#if defined( MBG_TGT_WIN32 )
- #define _CRT_SECURE_NO_WARNINGS
+ #define _CRT_SECURE_NO_WARNINGS 1
#if defined( _AMD64_ )
- // This is used for AMD64 architecture and for
+ // This is used for AMD64 architecture and for
// Intel XEON CPUs with 64 bit extension.
#define MBG_TGT_WIN32_PNP_X64
#define WIN32_FLAVOR "x64"
@@ -526,13 +693,18 @@
#include <ntddk.h>
#else
// This must not be used for kernel drivers.
+
+ // Prevent inclusion of obsolete winsock.h in windows.h
#if !defined( WIN32_LEAN_AND_MEAN )
#define WIN32_LEAN_AND_MEAN 1
#endif
-
- #define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
- #include <winsock2.h>
+ #if !defined( _WINSOCKAPI_ )
+ #define _WINSOCKAPI_
+ #endif
+
#include <windows.h>
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
typedef HANDLE MBG_HANDLE;
@@ -554,6 +726,12 @@
typedef DWORD DWORD_PTR;
#endif
+ // socklen_t support
+ #if ( _MSC_VER < 1500 )
+ // At least VS2008 has a socklen_t type
+ typedef int socklen_t;
+ #endif
+
#endif
#define _MBG_API WINAPI
@@ -585,6 +763,42 @@
#endif
+/**
+ * @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;
+#elif defined( MBG_TGT_POSIX )
+ typedef int MBG_SOCK_FD; //### TODO
+ //### TODO typedef int SOCKET;
+#endif
+
+
+
+/**
+ * @brief A value to mark an ::MBG_SOCK_FD as invalid
+ */
+#if defined( MBG_TGT_WIN32 )
+ #define MBG_INVALID_SOCK_FD INVALID_SOCKET // usually evaluates to (SOCKET)(~0) since SOCKET is unsigned
+#elif defined( MBG_TGT_POSIX )
+ #define MBG_INVALID_SOCK_FD -1
+#endif
+
+
+
+/**
+ * @brief The return code of socket functions in case of error
+ */
+#if defined( MBG_TGT_WIN32 )
+ #define MBG_SOCKET_ERR_RETVAL SOCKET_ERROR // usually evaluates to -1
+#elif defined( MBG_TGT_POSIX )
+ #define MBG_SOCKET_ERR_RETVAL -1
+#endif
+
+
+
#if !defined( _MBG_API )
#define _MBG_API
#endif
diff --git a/mbglib/common/mbgerror.c b/mbglib/common/mbgerror.c
new file mode 100755
index 0000000..faf7e98
--- /dev/null
+++ b/mbglib/common/mbgerror.c
@@ -0,0 +1,711 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgerror.c 1.2 2016/08/05 12:25:44 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Meinberg Library to communicate with USB devices from user space
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgerror.c $
+ * Revision 1.2 2016/08/05 12:25:44 martin
+ * Added some functions.
+ * Revision 1.1 2014/03/07 12:08:14 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#define _MBGERROR
+ #include <mbgerror.h>
+#undef _MBGERROR
+
+#include <mbg_tgt.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#if defined( MBG_TGT_POSIX ) || \
+ defined( MBG_TGT_WIN32 ) || \
+ defined( MBG_TGT_DOS )
+ #define _MBG_TGT_HAS_POSIX_ERRNO 1
+#else
+ #define _MBG_TGT_HAS_POSIX_ERRNO 0
+#endif
+
+#if _MBG_TGT_HAS_POSIX_ERRNO
+ #include <errno.h>
+#endif
+
+#if defined( MBG_TGT_DOS )
+ #include <stddef.h>
+#endif
+
+#if defined( MBG_TGT_POSIX )
+ #include <netdb.h>
+#endif
+
+#if defined(USE_MBG_ZLIB)
+ #include <zlib.h>
+#endif
+
+
+typedef struct
+{
+ int orig_errno;
+ int mbg_errno;
+
+} ERRNO_CNV_ENTRY;
+
+
+
+#if _MBG_TGT_HAS_POSIX_ERRNO
+
+static ERRNO_CNV_ENTRY posix_errno_table[] =
+{
+ // POSIX codes taken from Linux asm-generic/errno.h
+ { EPERM, MBG_ERR_PERM }, // 1, Operation not permitted
+ { ENOENT, MBG_ERR_NO_ENTITY }, // 2, No such file or directory
+ // { ESRCH, }, // 3, No such process
+ { EINTR, MBG_ERR_INTR }, // 4, Interrupted system call
+ { EIO, MBG_ERR_IO }, // 5, I/O error
+ { ENXIO, MBG_ERR_NOT_FOUND }, // 6, No such device or address
+ // { E2BIG, }, // 7, Argument list too long
+ // { ENOEXEC, }, // 8, Exec format error
+ // { EBADF, }, // 9, Bad file number
+ // { ECHILD, }, // 10, No child processes
+ // { EAGAIN, }, // 11, Try again
+ { ENOMEM, MBG_ERR_NO_MEM }, // 12, Out of memory
+ { EACCES, MBG_ERR_ACCESS }, // 13, Permission denied
+ // { EFAULT, }, // 14, Bad address
+ // { ENOTBLK, }, // 15, Block device required
+ { EBUSY, MBG_ERR_BUSY }, // 16, Device or resource busy
+ { EEXIST, MBG_ERR_EXIST }, // 17, File exists
+ { EXDEV, MBG_ERR_NO_DEV }, // 18, Cross-device link
+ // { ENODEV, }, // 19, No such device
+ // { ENOTDIR, }, // 20, Not a directory
+ // { EISDIR, }, // 21, Is a directory
+ { EINVAL, MBG_ERR_INV_PARM }, // 22, Invalid argument
+ // { ENFILE, }, // 23, File table overflow
+ // { EMFILE, }, // 24, Too many open files
+ // { ENOTTY, }, // 25, Not a typewriter
+ // { ETXTBSY, }, // 26, Text file busy
+ // { EFBIG, }, // 27, File too large
+ // { ENOSPC, }, // 28, No space left on device
+ { ESPIPE, MBG_ERR_PIPE }, // 29, Illegal seek
+ // { EROFS, }, // 30, Read-only file system
+ // { EMLINK, }, // 31, Too many links
+ // { EPIPE, }, // 32, Broken pipe
+ // { EDOM, }, // 33, Math argument out of domain of func
+ { ERANGE, MBG_ERR_RANGE }, // 34, Math result not representable
+#if defined( EOVERFLOW )
+ { EOVERFLOW, MBG_ERR_OVERFLOW }, // 75, Value too large for defined data type
+#endif
+#if defined( ENOTSOCK )
+ { ENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 88, Socket operation on non-socket
+#endif
+#if defined( ECONNRESET )
+ { ECONNRESET, MBG_ERR_CONN_RESET }, // 104, Connection reset by peer
+#endif
+ { 0, 0 } // end-of-table identifier
+
+}; // posix_errno_table
+
+#endif // _MBG_TGT_HAS_POSIX_ERRNO
+
+
+
+#if defined( MBG_TGT_POSIX )
+
+static ERRNO_CNV_ENTRY posix_h_errno_table[] =
+{
+ // POSIX codes taken from Linux netdb.h
+ { HOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // The specified host is unknown
+ // { NO_ADDRESS, }, // Usually same numeric value as NO_DATA
+ // { NO_DATA, }, // The requested name is valid but does not have an IP address
+ // { NO_RECOVERY, }, // A nonrecoverable name server error occurred
+ // { TRY_AGAIN, }, // A temporary error occurred on an authoritative name server. Try again later.
+ { 0, 0 } // end-of-table identifier
+
+}; // posix_h_errno_table
+
+#endif // defined( MBG_TGT_POSIX )
+
+
+
+#if defined( MBG_TGT_CVI )
+
+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.
+ // { kRS_UnknownIOError, }, // Unknown I/O error.
+ // { kRS_InternalError, }, // Unexpected internal error.
+ // { kRS_NoPortFound, }, // No serial port found.
+ // { kRS_CanNotOpenPort, }, // Cannot open port.
+ // { kRS_NullPointerPassed, }, // A NULL pointer was passed when a non-NULL pointer was expected.
+ // { kRS_OutOfMemory, }, // Out of memory.
+ // { kRS_OutOfSystemResources, }, // Unable to allocate system resources.
+ // { kRS_InvalidParameter, }, // Invalid parameter.
+ // { kRS_InvalidBaudRate, }, // Invalid baud rate.
+ // { kRS_InvalidParity, }, // Invalid parity.
+ // { kRS_InvalidDataBits, }, // Invalid number of data bits.
+ // { kRS_InvalidStopBits, }, // Invalid number of stop bits.
+ // { kRS_BadFileHandle, }, // Bad file handle.
+ // { kRS_FileIOError, }, // File I/O error.
+ // { kRS_InvalidCount, }, // Invalid count; must be greater than or equal to 0.
+ // { kRS_InvalidIntLevel, }, // Invalid interrupt level.
+ // { kRS_IOTimeOut, }, // I/O operation timed out.
+ // { kRS_InvalidBreakTime, }, // Break time must be a positive value.
+ // { kRS_InvalidInQSize, }, // Requested input queue size must be 0 or greater.
+ // { kRS_InvalidOutQSize, }, // Requested output queue size must be 0 or greater.
+ // { kRS_GeneralIOFailure, }, // General I/O error.
+ // { kRS_InvalidBufferPointer, }, // Buffer parameter is NULL.
+ // { kRS_VISALibrariesMissing, }, // A necessary run-time library could not be found or loaded.
+ // { kRS_NoAckReceived, }, // Packet was sent, but no acknowledgment was received.
+ // { kRS_MaxRetriesBeforeSend, }, // Packet was not sent within retry limit.
+ // { kRS_MaxRetriesBeforeReceived, }, // Packet was not received within retry limit.
+ // { kRS_UnexpectedEOT, }, // End of transmission character encountered when start of data character expected.
+ // { kRS_CanNotReadPackNum, }, // Unable to read packet number.
+ // { kRS_InconsistentPackNum, }, // Inconsistent packet number.
+ // { kRS_CanNotReadPackData, }, // Unable to read packet data.
+ // { kRS_CanNotReadCheckSum, }, // Unable to read checksum.
+ // { kRS_CheckSumError, }, // Checksum received did not match computed checksum.
+ // { kRS_PackSizeGTInQ, }, // Packet size exceeds input queue size.
+ // { kRS_OpenFileError, }, // Error opening file.
+ // { kRS_ReadFileError, }, // Error reading file.
+ // { kRS_NoInitNegAck, }, // Did not receive initial negative acknowledgment character.
+ // { kRS_NoAckAfterEOT, }, // Did not receive acknowledgment after end of transmission character was sent.
+ // { kRS_WriteFileError, }, // Error writing to file.
+ // { kRS_NoSOHorEOT, }, // Did not receive either a start of data or end of transmission character when expected.
+ // { kRS_TransferCancelled, }, // Transfer was canceled because CAN ASCII character was received.
+ // { kRS_InvalidStartDelay, }, // Invalid start delay.
+ // { kRS_InvalidMaxTries, }, // Invalid maximum number of retries.
+ // { kRS_InvalidWaitPeriod, }, // Invalid wait period.
+ // { kRS_InvalidPacketSize, }, // Invalid packet size.
+ // { kRS_CanNotReadCRC, }, // Unable to read Cyclical Redundancy Check.
+ // { kRS_CRCError, }, // Cyclical Redundancy Check error.
+ { 0, 0 } // end-of-table identifier
+
+}; // cvi_rs232_error_table
+
+#endif // defined( MBG_TGT_CVI )
+
+
+
+#if defined( MBG_TGT_WIN32 )
+
+static ERRNO_CNV_ENTRY win32_error_table[] =
+{
+ // System Error Codes (1300-1699)
+ { ERROR_ACCESS_DENIED, MBG_ERR_ACCESS }, //
+ { ERROR_PRIVILEGE_NOT_HELD, MBG_ERR_PERM }, //
+ { ERROR_INVALID_HANDLE, MBG_ERR_INV_HANDLE }, //
+ { ERROR_NOT_ENOUGH_MEMORY, MBG_ERR_NO_MEM }, //
+ { ERROR_OUTOFMEMORY, MBG_ERR_NO_MEM }, //
+ // { ERROR_WRITE_PROTECT, }, //
+ // { ERROR_BAD_UNIT, }, //
+ // { ERROR_NOT_READY, }, //
+ // { ERROR_WRITE_FAULT, }, //
+ // { ERROR_READ_FAULT, }, //
+ // { ERROR_GEN_FAILURE, }, //
+ // { ERROR_SHARING_VIOLATION, }, //
+ // { ERROR_LOCK_VIOLATION, }, //
+ // { ERROR_NOT_SUPPORTED, }, //
+ // { ERROR_DUP_NAME, }, //
+ // { ERROR_BAD_DEV_TYPE, }, //
+ // { ERROR_BUFFER_OVERFLOW, }, //
+ { ERROR_BUSY, MBG_ERR_BUSY }, //
+ // { ERROR_NOACCESS, }, //
+ { 0, 0 } // end-of-table identifier
+
+}; // win32_error_table
+
+
+
+static ERRNO_CNV_ENTRY win32_wsa_err_table[] =
+{
+ { WSAEINTR, MBG_ERR_INTR }, // 10004L A blocking operation was interrupted by a call to WSACancelBlockingCall.
+ // { WSAEBADF // 10009L The file handle supplied is not valid.
+ // { WSAEACCES // 10013L An attempt was made to access a socket in a way forbidden by its access permissions.
+ // { WSAEFAULT // 10014L The system detected an invalid pointer address in attempting to use a pointer argument in a call.
+ // { WSAEINVAL // 10022L An invalid argument was supplied.
+ // { WSAEMFILE // 10024L Too many open sockets.
+ // { WSAEWOULDBLOCK // 10035L A non-blocking socket operation could not be completed immediately.
+ // { WSAEINPROGRESS // 10036L A blocking operation is currently executing.
+ // { WSAEALREADY // 10037L An operation was attempted on a non-blocking socket that already had an operation in progress.
+ { WSAENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 10038L An operation was attempted on something that is not a socket.
+ // { WSAEDESTADDRREQ // 10039L A required address was omitted from an operation on a socket.
+ // { WSAEMSGSIZE // 10040L A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.
+ // { WSAEPROTOTYPE // 10041L A protocol was specified in the socket function call that does not support the semantics of the socket type requested.
+ // { WSAENOPROTOOPT // 10042L An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call.
+ // { WSAEPROTONOSUPPORT // 10043L The requested protocol has not been configured into the system, or no implementation for it exists.
+ // { WSAESOCKTNOSUPPORT // 10044L The support for the specified socket type does not exist in this address family.
+ // { WSAEOPNOTSUPP // 10045L The attempted operation is not supported for the type of object referenced.
+ // { WSAEPFNOSUPPORT // 10046L The protocol family has not been configured into the system or no implementation for it exists.
+ // { WSAEAFNOSUPPORT // 10047L An address incompatible with the requested protocol was used.
+ // { WSAEADDRINUSE // 10048L Only one usage of each socket address (protocol/network address/port) is normally permitted.
+ // { WSAEADDRNOTAVAIL // 10049L The requested address is not valid in its context.
+ // { WSAENETDOWN // 10050L A socket operation encountered a dead network.
+ // { WSAENETUNREACH // 10051L A socket operation was attempted to an unreachable network.
+ // { WSAENETRESET // 10052L The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
+ // { WSAECONNABORTED // 10053L An established connection was aborted by the software in your host machine.
+ { WSAECONNRESET, MBG_ERR_CONN_RESET }, // 10054L An existing connection was forcibly closed by the remote host.
+ // { WSAENOBUFS // 10055L An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
+ // { WSAEISCONN // 10056L A connect request was made on an already connected socket.
+ // { WSAENOTCONN // 10057L A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
+ // { WSAESHUTDOWN // 10058L A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.
+ // { WSAETOOMANYREFS // 10059L Too many references to some kernel object.
+ // { WSAETIMEDOUT // 10060L A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
+ // { WSAECONNREFUSED // 10061L No connection could be made because the target machine actively refused it.
+ // { WSAELOOP // 10062L Cannot translate name.
+ // { WSAENAMETOOLONG // 10063L Name component or name was too long.
+ // { WSAEHOSTDOWN // 10064L A socket operation failed because the destination host was down.
+ // { WSAEHOSTUNREACH // 10065L A socket operation was attempted to an unreachable host.
+ // { WSAENOTEMPTY // 10066L Cannot remove a directory that is not empty.
+ // { WSAEPROCLIM // 10067L A Windows Sockets implementation may have a limit on the number of applications that may use it simultaneously.
+ // { WSAEUSERS // 10068L Ran out of quota.
+ // { WSAEDQUOT // 10069L Ran out of disk quota.
+ // { WSAESTALE // 10070L File handle reference is no longer available.
+ // { WSAEREMOTE // 10071L Item is not available locally.
+ // { WSASYSNOTREADY // 10091L WSAStartup cannot function at this time because the underlying system it uses to provide network services is currently unavailable.
+ // { WSAVERNOTSUPPORTED // 10092L The Windows Sockets version requested is not supported.
+ { WSANOTINITIALISED, MBG_ERR_SOCK_INIT }, // 10093L Either the application has not called WSAStartup, or WSAStartup failed.
+ // { WSAEDISCON // 10101L Returned by WSARecv or WSARecvFrom to indicate the remote party has initiated a graceful shutdown sequence.
+ // { WSAENOMORE // 10102L No more results can be returned by WSALookupServiceNext.
+ // { WSAECANCELLED // 10103L A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.
+ // { WSAEINVALIDPROCTABLE // 10104L The procedure call table is invalid.
+ // { WSAEINVALIDPROVIDER // 10105L The requested service provider is invalid.
+ // { WSAEPROVIDERFAILEDINIT // 10106L The requested service provider could not be loaded or initialized.
+ // { WSASYSCALLFAILURE // 10107L A system call that should never fail has failed.
+ // { WSASERVICE_NOT_FOUND // 10108L No such service is known. The service cannot be found in the specified name space.
+ // { WSATYPE_NOT_FOUND // 10109L The specified class was not found.
+ // { WSA_E_NO_MORE // 10110L No more results can be returned by WSALookupServiceNext.
+ // { WSA_E_CANCELLED // 10111L A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.
+ // { WSAEREFUSED // 10112L A database query failed because it was actively refused.
+ { WSAHOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // 11001L No such host is known.
+ // { WSATRY_AGAIN // 11002L This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.
+ // { WSANO_RECOVERY // 11003L A non-recoverable error occurred during a database lookup.
+ // { WSANO_DATA // 11004L The requested name is valid, but no data of the requested type was found.
+ { 0, 0 } // end-of-table identifier
+
+}; // win32_wsa_err_table
+
+#endif // defined( MBG_TGT_WIN32 )
+
+
+
+/**
+ * @brief Lookup some error code in a conversion table
+ *
+ * @param[in] orig_errno
+ * @param[in] tbl
+ *
+ * @return @ref MBG_ERROR_CODES associated with the original error code,
+ * or ::MBG_ERR_UNSPEC if origianl code not found in table.
+ */
+static /*HDR*/
+int lookup_mbg_errno( int orig_errno, const ERRNO_CNV_ENTRY tbl[] )
+{
+ const ERRNO_CNV_ENTRY *p;
+
+ for ( p = tbl; p->orig_errno || p->mbg_errno; p++ )
+ if ( p->orig_errno == orig_errno )
+ return p->mbg_errno;
+
+ return MBG_ERR_UNSPEC;
+
+} // lookup_mbg_errno
+
+
+
+/*HDR*/
+/**
+ * @brief Return an error string associated with the @ref MBG_ERROR_CODES
+ *
+ * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES
+ *
+ * @return A constant string describing the error, or NULL for unknown error codes
+ */
+const char *mbg_strerror( int mbg_errno )
+{
+ static const MBG_CODE_NAME_TABLE_ENTRY tbl[] = MBG_ERR_NAMES_ENG;
+
+ const MBG_CODE_NAME_TABLE_ENTRY *p;
+
+ for ( p = tbl; p->name; p++ )
+ {
+ if ( p->code == mbg_errno )
+ return p->name;
+ }
+
+
+ return "Unknown error";
+
+} // mbg_strerror
+
+
+
+// test if ioctl error and print msg if true
+//### TODO check if this should be renamed
+/*HDR*/
+int mbg_ioctl_err( int rc, const char *descr )
+{
+ if ( mbg_rc_is_error( rc ) )
+ {
+ fprintf( stderr, "** %s: %s (rc: %i)\n", descr, mbg_strerror( rc ), rc );
+ return -1;
+ }
+
+ return 0;
+
+} // mbg_ioctl_err
+
+
+
+#if defined( MBG_TGT_CVI )
+
+/*HDR*/
+/**
+ * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] cvi_rc An error code returned by a CVI RS-232 library function
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ *
+ * @see http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvirs232_error_conditions/
+ */
+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 );
+ #endif
+
+ return ( cvi_rc < 0 ) ? lookup_mbg_errno( cvi_error, cvi_rs232_error_table ) : MBG_SUCCESS;
+
+} // mbg_cvi_rs232_error_to_mbg
+
+#endif
+
+
+
+#if defined( MBG_TGT_WIN32 )
+
+/*HDR*/
+/**
+ * @brief Translate a Windows non-socket API error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] last_err A Windows non-socket API error code as returned by GetLastError()
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+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 );
+ #endif
+
+ return ( last_err == ERROR_SUCCESS ) ? MBG_SUCCESS : lookup_mbg_errno( last_err, win32_error_table );
+
+} // mbg_win32_last_err_to_mbg
+
+
+
+/*HDR*/
+/**
+ * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] wsa_err A Windows socket API error code as returned by WSAGetLastError()
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+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 );
+ #endif
+
+ // The WSA error code is only retrieved after an error has occurred, so
+ // we don't need care for the success case here.
+ return lookup_mbg_errno( wsa_err, win32_wsa_err_table );
+
+} // mbg_win32_wsa_err_to_mbg
+
+#endif // defined( MBG_TGT_WIN32 )
+
+
+
+#if _MBG_TGT_HAS_POSIX_ERRNO
+
+/*HDR*/
+/**
+ * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] posix_errno A POSIX error code as usually defined in errno.h
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_posix_errno_to_mbg( int posix_errno, const char *info )
+{
+ #if DEBUG
+ if ( info )
+ fprintf( stderr, "%s: %s (errno: %i)\n", info,
+ strerror( posix_errno ), posix_errno );
+ #endif
+
+ return lookup_mbg_errno( posix_errno, posix_errno_table );
+
+} // mbg_posix_errno_to_mbg
+
+#endif // _MBG_TGT_HAS_POSIX_ERRNO
+
+
+
+#if defined( MBG_TGT_POSIX )
+
+/*HDR*/
+/**
+ * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES
+ *
+ * This function is specific to translate error codes returned by
+ * gethostbyname() and gethostbyaddr(). In case of error these functions
+ * don't set errno but h_errno to a specific value.
+ *
+ * The functions gethostbyname() and gethostbyaddr() are obsolete,
+ * and getaddressinfo() should be used preferably.
+ *
+ * @param[in] posix_h_errno An error code as usually defined in netdb.h
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info )
+{
+ #if DEBUG
+ if ( info )
+ fprintf( stderr, "%s: %s (h_errno: %i)\n", info,
+ hstrerror( posix_h_errno ), posix_h_errno );
+ #endif
+
+ return lookup_mbg_errno( posix_h_errno, posix_h_errno_table );
+
+} // mbg_posix_h_errno_to_mbg
+
+#endif // defined( MBG_TGT_POSIX )
+
+
+
+/*HDR*/
+/**
+ * @brief Get and translate last error after non-socket function call
+ *
+ * Retrieve the "last error" code after a non-socket function has been called
+ * and translate to one of the @ref MBG_ERROR_CODES.
+ *
+ * On POSIX systems the "last error" code is always stored in errno, but
+ * e.g. under Windows the "last error" code after a socket function
+ * has to be retrieved by calling WSAGetLastError(), whereas the "last error"
+ * code from non-socket POSIX-like functions has to be retrieved
+ * by calling GetLastError().
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_get_last_error( const char *info )
+{
+ #if defined( MBG_TGT_WIN32 )
+
+ // Under Windows the "last error" code after a non-socket function
+ // has to be retrieved by calling GetLastError(), whereas
+ // the "last error" code from POSIX-like socket functions
+ // is retrieved by calling WSAGetLastError().
+ return mbg_win32_last_err_to_mbg( GetLastError(), info );
+
+ #elif defined( MBG_TGT_POSIX )
+
+ // On POSIX systems the "last error" code is always stored in errno.
+ return mbg_posix_errno_to_mbg( errno, info );
+
+ #else
+
+ // ### TODO #error This function is not supported for this target.
+ return mbg_posix_errno_to_mbg( errno, info );
+
+ #endif
+
+} // mbg_get_last_error
+
+
+
+#if !defined( MBG_TGT_DOS )
+
+/*HDR*/
+/**
+ * @brief Get and translate last error after socket function call
+ *
+ * Retrieve the "last error" code after a socket function has been called
+ * and translate to one of the @ref MBG_ERROR_CODES.
+ *
+ * On POSIX systems the "last error" code is always stored in errno, but
+ * e.g. under Windows the "last error" code after a socket function
+ * has to be retrieved by calling WSAGetLastError, whereas the "last error"
+ * code from non-socket POSIX-like functions is stored in errno as usual.
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_get_last_socket_error( const char *info )
+{
+ #if defined( MBG_TGT_CVI )
+
+ #warning This needs to be implemented for CVI
+ return MBG_ERR_UNSPEC;
+
+ #elif defined( MBG_TGT_WIN32 )
+
+ // Under Windows the "last error" code after a socket function
+ // has to be retrieved by calling WSAGetLastError, whereas
+ // the "last error" code from non-socket POSIX-like functions
+ // is stored in errno as usual.
+ return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
+
+ #elif defined( MBG_TGT_POSIX )
+
+ // On POSIX systems the "last error" code is always stored in errno.
+ return mbg_posix_errno_to_mbg( errno, info );
+
+ #else
+
+ #error This function is not supported for this target.
+
+ #endif
+
+} // mbg_get_last_socket_error
+
+
+
+/*HDR*/
+/**
+ * @brief Retrieve and convert last error after gethostbyname()
+ *
+ * This function is specific to retrieve and translate error codes
+ * returned by gethostbyname() and gethostbyaddr(). In case of error
+ * these functions don't set errno but h_errno on POSIX systems, but
+ * under Windows the error code can be retrieved by WSAGetLastError()
+ * as usual.
+ *
+ * The functions gethostbyname() and gethostbyaddr() are obsolete,
+ * and getaddressinfo() should be used preferably.
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_get_gethostbyname_error( const char *info )
+{
+ #if defined( MBG_TGT_CVI )
+
+ #warning This needs to be implemented for CVI
+ return MBG_ERR_UNSPEC;
+
+ #elif defined( MBG_TGT_WIN32 )
+
+ return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
+
+ #elif defined( MBG_TGT_POSIX )
+
+ return mbg_posix_h_errno_to_mbg( h_errno, info );
+
+ #else
+
+ #error This function is not supported for this target.
+
+ #endif
+
+} // mbg_get_gethostbyname_error
+
+#endif // !defined( MBG_TGT_DOS )
+
+
+
+#if 0 // not yet finished
+// error handler for getaddressinfo()
+/*
+ * Handle specific error returned by getaddressinfo()
+ */
+ /*HDR*/
+int mbg_gai_error( int rc, const char *info )
+{
+ #if defined( MBG_TGT_CVI )
+
+ #warning This needs to be implemented for CVI
+ return MBG_ERR_UNSPEC;
+
+ #elif defined( MBG_TGT_WIN32 )
+
+ return mbg_win32_wsa_err_to_mbg( WSAGetLastError(), info );
+
+ #elif defined( MBG_TGT_POSIX )
+
+ return mbg_posix_h_errno_to_mbg( h_errno, info );
+
+ #else
+
+ return MBG_ERR_UNSPEC;
+
+ #endif
+
+} // mbg_get_gai_error
+
+#endif
+
+
+
+#if defined( USE_MBG_ZLIB )
+
+/*HDR*/
+/**
+ * @brief Retrieve and convert last zlib internal error code
+ *
+ * @param[in] zlib_error zlib internal error code
+ * @param[in] info An optional informational text string, or NULL
+ * @param[in] msg An optional zlib specific error msg, or NULL.
+ * Struct z_stream contains member msg.
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+int mbg_zlib_error_to_mbg( int zlib_error, const char *info, const char *msg )
+{
+ #if DEBUG
+ if ( info && msg )
+ fprintf( stderr, "%s: %s (zlib_error: %d)\n", info,
+ msg, zlib_error );
+ #endif
+
+ switch ( zlib_error )
+ {
+ case Z_ERRNO: return mbg_get_last_error( info );
+ case Z_MEM_ERROR: return MBG_ERR_NO_MEM;
+ /*
+ * All other zlib error codes are not specified any further.
+ * So, it's hard to guess what they mean and we return MBG_UNSPEC so far.
+ */
+ default:
+ return MBG_ERR_UNSPEC;
+ }
+
+} // mbg_zlib_error_to_mbg
+
+#endif // defined(USE_MBG_ZLIB)
+
+
diff --git a/mbglib/common/mbgerror.h b/mbglib/common/mbgerror.h
new file mode 100755
index 0000000..1e2b93a
--- /dev/null
+++ b/mbglib/common/mbgerror.h
@@ -0,0 +1,511 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgerror.h 1.8 2016/08/05 12:29:20 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Error codes used with Meinberg devices and drivers.
+ * The codes can be translated into an OS dependent error code.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgerror.h $
+ * 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.
+ * Updated doxygen comments.
+ * Updated function prorotypes.
+ * Revision 1.7 2014/05/27 13:32:47Z martin
+ * Defined additional common error codes which can be
+ * translated from OS specific codes.
+ * Function prototypes from new module mbgerror.c.
+ * Comments in doxygen style.
+ * Revision 1.6 2012/10/02 18:42:26Z martin
+ * New codes MBG_ERR_N_POUT_EXCEEDS_SUPP and
+ * MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP.
+ * Modified comments for doxygen.
+ * Revision 1.5 2011/03/31 10:56:17 martin
+ * Added MBG_ERR_COPY_TO_USER and MBG_ERR_COPY_FROM_USER.
+ * Revision 1.4 2008/12/05 13:28:50 martin
+ * Added new code MBG_ERR_IRQ_UNSAFE.
+ * Revision 1.3 2008/02/26 14:50:14Z daniel
+ * Added codes:
+ * MBG_ERR_NOT_SUPP_ON_OS, MBG_ERR_LIB_NOT_COMPATIBLE,
+ * MBG_ERR_N_COM_EXCEEDS_SUPP, MBG_ERR_N_STR_EXCEEDS_SUPP
+ * Added doxygen compatible comments.
+ * Revision 1.2 2007/09/27 07:26:22Z martin
+ * Define STATUS_SUCCESS for Windows if not in kernel mode.
+ * Revision 1.1 2007/09/26 08:08:54Z martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBGERROR_H
+#define _MBGERROR_H
+
+
+/* Other headers to be included */
+
+#include <mbg_tgt.h>
+#include <words.h>
+
+#ifdef _MBGERROR
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#if !defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_KERNEL )
+ //### TODO Surprisingly we need this also for Windows
+ // in kernel mode. This should be fixed.
+ #define DWORD uint32_t // just to avoid compiler errors
+#endif
+
+
+
+/**
+ * @brief Error codes used with Meinberg devices and drivers
+ *
+ * Appropriate error strings can be retrieved via the ::mbg_strerror function.
+ *
+ * Under Windows, some message strings are provided as resources appended
+ * to the mbgctrl DLL, but the codes specified here have to be translated
+ * to Windows-specific error codes before the appropriate resource string
+ * can be retrieved. Actually this is done by taking the absolute number
+ * of an error code and have it or'ed with 0xE0000000 afterwards, e.g.
+ * ::MBG_ERR_GENERIC (-19) will yield Windows code 0xE0000013.
+ * * See ::_mbg_err_to_os
+ *
+ * @see ::MBG_ERR_NAMES_ENG
+ *
+ * @anchor MBG_RETURN_CODES @{ */
+
+// NOTE: Some of these codes have to match codes which are defined in pcpsdefs.h
+// and returned by the firmware of bus-level devices, so the definitions
+// must *not* be renumbered.
+
+#define MBG_SUCCESS 0 ///< no error, has to match ::PCPS_SUCCESS
+
+ /** @anchor MBG_ERROR_CODES @{ */
+
+// Other codes which have to match codes defined in pcpsdefs.h returned by bus-level devices
+#define MBG_ERR_STIME -1 ///< tried to write invalid date/time/status to device, has to match ::PCPS_ERR_STIME
+#define MBG_ERR_CFG -2 ///< tried to write invalid configuration parameters to device, has to match ::PCPS_ERR_CFG (see also ::MBG_ERR_INV_CFG)
+
+
+// Codes returned by low level functions of the bus-level device driver
+#define MBG_ERR_GENERIC -19 ///< generic error
+#define MBG_ERR_TIMEOUT -20 ///< timeout accessing the device
+#define MBG_ERR_FW_ID -21 ///< invalid firmware ID
+#define MBG_ERR_NBYTES -22 ///< the number of parameter bytes passed to the device did not
+ ///< match the number of bytes expected by the device
+
+#define MBG_ERR_INV_TIME -23 ///< the device doesn't have valid time
+#define MBG_ERR_FIFO -24 ///< the data FIFO of a bus-level device is empty, though it shouldn't be
+#define MBG_ERR_NOT_READY -25 ///< bus-level device is temp. unable to respond e.g. during init. after RESET
+#define MBG_ERR_INV_TYPE -26 ///< bus-level device didn't recognize data type
+
+
+// Codes returned by the high level API functions
+#define MBG_ERR_NO_MEM -27 ///< failed to allocate memory
+#define MBG_ERR_CLAIM_RSRC -28 ///< failed to claim port or mem resource
+#define MBG_ERR_DEV_NOT_SUPP -29 ///< specified device type not supported by driver
+#define MBG_ERR_INV_DEV_REQUEST -30 ///< IOCTL call not supported by driver
+#define MBG_ERR_NOT_SUPP_BY_DEV -31 ///< cmd or feature not supported by device
+#define MBG_ERR_USB_ACCESS -32 ///< USB access failed
+#define MBG_ERR_CYCLIC_TIMEOUT -33 ///< cyclic event (IRQ, etc.) didn't occur
+#define MBG_ERR_NOT_SUPP_ON_OS -34 ///< function is not supported under this operating system
+#define MBG_ERR_LIB_NOT_COMPATIBLE -35 ///< installed shared lib. version not compat. with version used at build time
+#define MBG_ERR_N_COM_EXCEEDS_SUPP -36 ///< num. COM ports of the device exceeds max. supp. by driver
+#define MBG_ERR_N_STR_EXCEEDS_SUPP -37 ///< num. string formats of the device exceeds max. supp. by driver
+#define MBG_ERR_IRQ_UNSAFE -38 ///< enabled IRQ of bus-level device is unsafe with this firmware/ASIC version
+#define MBG_ERR_N_POUT_EXCEEDS_SUPP -39 ///< num. prog. outputs of the device exceeds max. supp. by driver
+
+// Legacy codes used with DOS TSRs only:
+#define MBG_ERR_INV_INTNO -40 ///< invalid interrupt number
+#define MBG_ERR_NO_DRIVER -41 ///< a driver could not be found
+#define MBG_ERR_DRV_VERSION -42 ///< the driver is too old
+
+
+#define MBG_ERR_COPY_TO_USER -43 ///< kernel driver failed to copy data from kernel to user space
+#define MBG_ERR_COPY_FROM_USER -44 ///< kernel driver failed to copy data from use to kernel space
+
+
+// More codes returned by the driver's high level functions:
+#define MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP -45 ///< num. PTP unicast masters of the device exceeds max. supp. by driver
+#define MBG_ERR_N_GNSS_EXCEEDS_SUPP -46 ///< num. of GNSS systems supp. by device exceeds max. supp. by driver
+#define MBG_ERR_N_GPIO_EXCEEDS_SUPP -47 ///< num. of GPIO ports supp. by device exceeds max. supp. by driver
+#define MBG_ERR_N_XMR_EXCEEDS_SUPP -48 ///< num. of XMR sources supp. by device exceeds max. supp. by driver
+
+#define MBG_ERR_UNSPEC -60 ///< unspecified error
+
+#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_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
+
+#define MBG_ERR_SOCK_INIT -68 ///< socket interface not initialized, or failed to initialize
+#define MBG_ERR_INV_SOCK_FD -69 ///< invalid socket when tried to open network socket
+#define MBG_ERR_NOT_A_SOCKET -70 ///< socket descriptor is not a socket
+#define MBG_ERR_NBLOCK_WAIT_SLCT -71 ///< select timed out when waiting for non-blocking network port to become ready
+#define MBG_ERR_NBLOCK_WAIT_WR_FD -72 ///< write fd not set after select when waiting for non-blocking network port to become ready
+
+#define MBG_ERR_IO -73 ///< generic I/O error
+#define MBG_ERR_INV_PARM -74 ///< invalid parameter
+#define MBG_ERR_NO_DEV -75 ///< specified device not found
+#define MBG_ERR_NOT_FOUND -76 ///< specified item not found
+
+#define MBG_ERR_OVERFLOW -77 ///< range or buffer overflow
+#define MBG_ERR_PIPE -78 ///< pipe error
+#define MBG_ERR_INTR -79 ///< interrupted system call
+#define MBG_ERR_ACCESS -80 ///< access denied, e.g. when trying to access a device
+#define MBG_ERR_PERM -81 ///< operation not permitted, e.g. when trying to set the system time
+#define MBG_ERR_BUSY -82 ///< device busy
+#define MBG_ERR_INV_HANDLE -83 ///< invalid file/device handle specified
+
+#define MBG_ERR_XBP_CASC_LVL -84 ///< too many XBP cascading levels
+#define MBG_ERR_ENCRYPT -85 ///< encryption failed
+#define MBG_ERR_DECRYPT -86 ///< decryption failed
+
+#define MBG_ERR_DISCONN -87 ///< connection closed by remote site / host
+#define MBG_ERR_INV_CFG -88 ///< invalid/inconsistent configuration parameters read from device, see also ::MBG_ERR_CFG
+#define MBG_ERR_RANGE -89 ///< input parameter was out of range
+
+#define MBG_ERR_INV_TLV_ANN_BYTES -90 ///< number of announced TLV bytes doesn't match number of transferred bytes
+#define MBG_ERR_INV_TLV_SIZE -91 ///< ### TODO
+#define MBG_ERR_INV_TLV_UID -92 ///< ### TODO
+
+#define MBG_ERR_EXIST -93 ///< file exists
+#define MBG_ERR_DATA_SIZE -94 ///< the received data size toesn't match the expected data size
+#define MBG_ERR_NO_ENTITY -95 ///< no such entity //### TODO or use MBG_ERR_NO_DEV / MBG_ERR_NOT_FOUND ?
+#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
+
+// 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
+// to the ::MBG_ERR_NAMES_ENG table initializer below, and the Windows-specific message
+// texts specified in messages.mc/.h from which the resources appended to mbgsvctl.dll
+// are generated have to be updated accordingly.
+
+/** @} anchor MBG_ERROR_CODES */
+
+/** @} anchor MBG_RETURN_CODES */
+
+
+/**
+ * @brief Strings associated with @ref MBG_RETURN_CODES
+ *
+ * @see @ref MBG_RETURN_CODES
+ */
+#define MBG_ERR_NAMES_ENG \
+{ \
+ { MBG_SUCCESS, "Success, no error" }, \
+ { MBG_ERR_STIME, "Invalid date/time for device" }, \
+ { MBG_ERR_CFG, "Invalid configuration parameters for device" }, \
+ { MBG_ERR_GENERIC, "Generic error" }, \
+ { 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_FIFO, "FIFO unexpectedly empty" }, \
+ { MBG_ERR_NOT_READY, "Device not ready" }, \
+ { MBG_ERR_INV_TYPE, "Unsupported data type" }, \
+ { MBG_ERR_NO_MEM, "Memory allocation error" }, \
+ { MBG_ERR_CLAIM_RSRC, "Faild to claim resources" }, \
+ { MBG_ERR_DEV_NOT_SUPP, "Device not supported" }, \
+ { MBG_ERR_INV_DEV_REQUEST, "Request not supported" }, \
+ { MBG_ERR_NOT_SUPP_BY_DEV, "Not supported by device" }, \
+ { MBG_ERR_USB_ACCESS, "USB access failed" }, \
+ { MBG_ERR_CYCLIC_TIMEOUT, "Cyclic message timeout" }, \
+ { MBG_ERR_NOT_SUPP_ON_OS, "Not supported by OS" }, \
+ { MBG_ERR_LIB_NOT_COMPATIBLE, "Shared lib not compatible" }, \
+ { MBG_ERR_N_COM_EXCEEDS_SUPP, "Num. COM ports exceeds supported" }, \
+ { MBG_ERR_N_STR_EXCEEDS_SUPP, "Num. string formats exceeds supported" }, \
+ { MBG_ERR_IRQ_UNSAFE, "Unsafe IRQ support" }, \
+ { MBG_ERR_N_POUT_EXCEEDS_SUPP, "Num prog. outputs exceeds supported" }, \
+ { MBG_ERR_INV_INTNO, "Invalid interrupt number" }, \
+ { MBG_ERR_NO_DRIVER, "Driver not found" }, \
+ { MBG_ERR_DRV_VERSION, "Driver too old" }, \
+ { MBG_ERR_COPY_TO_USER, "Error copying to user space" }, \
+ { MBG_ERR_COPY_FROM_USER, "Error copying from user space" }, \
+ { MBG_ERR_N_UC_MSTR_EXCEEDS_SUPP, "Num. PTP Unicast masters exceeds supported" }, \
+ { MBG_ERR_N_GNSS_EXCEEDS_SUPP, "Num. GNSS systems exceeds supported" }, \
+ { MBG_ERR_N_GPIO_EXCEEDS_SUPP, "Num. GPIO ports exceeds supported" }, \
+ { MBG_ERR_N_XMR_EXCEEDS_SUPP, "Num. XMR sources exceeds supported" }, \
+ { MBG_ERR_UNSPEC, "Unspecified error" }, \
+ { MBG_ERR_HDR_CSUM, "Header checksum error" }, \
+ { MBG_ERR_DATA_CSUM, "Data checksum error" }, \
+ { MBG_ERR_RCVD_NACK, "Received NACK message" }, \
+ { MBG_ERR_RCVD_NO_ACK, "Didn't receive ACK message" }, \
+ { MBG_ERR_CONN_TYPE, "Invalid I/O connection type" }, \
+ { MBG_ERR_BYTES_WRITTEN, "Failed to write all bytes" }, \
+ { MBG_ERR_AUTH, "Authentication failed" }, \
+ { MBG_ERR_SOCK_INIT, "Failed to initialize socket" }, \
+ { MBG_ERR_INV_SOCK_FD, "Invalid socket descriptor" }, \
+ { MBG_ERR_NOT_A_SOCKET, "Not a socket descriptor" }, \
+ { MBG_ERR_NBLOCK_WAIT_SLCT, "Select timed out waiting for port ready" }, \
+ { MBG_ERR_NBLOCK_WAIT_WR_FD, "Write file descriptor not ready after waiting for port ready" }, \
+ { MBG_ERR_IO, "Generic I/O error" }, \
+ { MBG_ERR_INV_PARM, "Invalid parameter" }, \
+ { MBG_ERR_NO_DEV, "Specified device not found" }, \
+ { MBG_ERR_NOT_FOUND, "Specified item not found" }, \
+ { MBG_ERR_OVERFLOW, "Buffer overflow" }, \
+ { MBG_ERR_PIPE, "Pipe error" }, \
+ { MBG_ERR_INTR, "Interrupted system call" }, \
+ { MBG_ERR_ACCESS, "Access denied" }, \
+ { MBG_ERR_PERM, "Operation not permitted" }, \
+ { MBG_ERR_BUSY, "Device busy" }, \
+ { MBG_ERR_INV_HANDLE, "Invalid handle" }, \
+ { MBG_ERR_XBP_CASC_LVL, "Too many XBP cascading levels" }, \
+ { MBG_ERR_ENCRYPT, "Encryption failed" }, \
+ { MBG_ERR_DECRYPT, "Decryption failed" }, \
+ { 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_SIZE, "MBG_ERR_INV_TLV_SIZE" }, /* ### TODO */ \
+ { MBG_ERR_INV_TLV_UID, "MBG_ERR_INV_TLV_UID" }, /* ### TODO */ \
+ { MBG_ERR_EXIST, "File exists" }, \
+ { MBG_ERR_DATA_SIZE, "Received data size mismatch" }, \
+ { MBG_ERR_NO_ENTITY, "No such entity" }, \
+ { MBG_ERR_ALREADY_ALLOC, "Memory already allocated" }, \
+ { MBG_ERR_HOST_NOT_FOUND, "Host not found" }, \
+ { MBG_ERR_CONN_RESET, "Connection reset by peer" }, \
+ { 0, NULL } /* end of table */ \
+}
+
+
+
+#if defined( __mbg_inline )
+
+static __mbg_inline
+/**
+ * @brief Check if the code returned by a function indicates an error
+ *
+ * @param[in] rc One of the @ref MBG_RETURN_CODES
+ *
+ * @see ::mbg_rc_is_success
+ * @see @ref MBG_RETURN_CODES
+ */
+bool mbg_rc_is_error( int rc )
+{
+ // Meinberg error codes are all < 0.
+ return rc < MBG_SUCCESS;
+
+} // mbg_rc_is_error
+
+
+static __mbg_inline
+/**
+ * @brief Check if the code returned by a function indicates success
+ *
+ * @param[in] rc One of the @ref MBG_RETURN_CODES
+ *
+ * @see ::mbg_rc_is_error
+ * @see @ref MBG_RETURN_CODES
+ */
+bool mbg_rc_is_success( int rc )
+{
+ // There are functions which don't only return MBG_SUCCESS
+ // on success but some arbitrary positive number, e.g. the
+ // number of bytes sent. So success just means "not an error".
+ return !mbg_rc_is_error( rc );
+
+} // mbg_rc_is_success
+
+#else
+
+ #define mbg_rc_is_error( _rc ) ( (_rc) < MBG_SUCCESS )
+ #define mbg_rc_is_success( _rc ) ( !mbg_rc_is_error( _rc ) )
+
+#endif
+
+
+
+#if defined( MBG_TGT_WIN32 )
+
+ // Windows-specific codes and code conversion
+
+ #if !defined( STATUS_SUCCESS ) // not in kernel mode
+ #define STATUS_SUCCESS 0
+ #endif
+
+ #define _mbg_err_to_os( _c ) \
+ ( ( (_c) == MBG_SUCCESS ) ? STATUS_SUCCESS : ( abs( _c ) | 0xE0000000 ) )
+
+#else
+
+ #define _mbg_err_to_os( _c ) (_c ) //### TODO remove this
+
+#endif
+
+
+
+/* function prototypes: */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ /**
+ * @brief Return an error string associated with the @ref MBG_ERROR_CODES
+ *
+ * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES
+ *
+ * @return A constant string describing the error, or NULL for unknown error codes
+ */
+ const char *mbg_strerror( int mbg_errno ) ;
+
+ int mbg_ioctl_err( int rc, const char *descr ) ;
+ /**
+ * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] cvi_rc An error code returned by a CVI RS-232 library function
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ *
+ * @see http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvirs232_error_conditions/
+ */
+ int mbg_cvi_rs232_error_to_mbg( int cvi_rc, const char *info ) ;
+
+ /**
+ * @brief Translate a Windows non-socket API error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] last_err A Windows non-socket API error code as returned by GetLastError()
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_win32_last_err_to_mbg( DWORD last_err, const char *info ) ;
+
+ /**
+ * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] wsa_err A Windows socket API error code as returned by WSAGetLastError()
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_win32_wsa_err_to_mbg( DWORD wsa_err, const char *info ) ;
+
+ /**
+ * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES
+ *
+ * @param[in] posix_errno A POSIX error code as usually defined in errno.h
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_posix_errno_to_mbg( int posix_errno, const char *info ) ;
+
+ /**
+ * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES
+ *
+ * This function is specific to translate error codes returned by
+ * gethostbyname() and gethostbyaddr(). In case of error these functions
+ * don't set errno but h_errno to a specific value.
+ *
+ * The functions gethostbyname() and gethostbyaddr() are obsolete,
+ * and getaddressinfo() should be used preferably.
+ *
+ * @param[in] posix_h_errno An error code as usually defined in netdb.h
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info ) ;
+
+ /**
+ * @brief Get and translate last error after non-socket function call
+ *
+ * Retrieve the "last error" code after a non-socket function has been called
+ * and translate to one of the @ref MBG_ERROR_CODES.
+ *
+ * On POSIX systems the "last error" code is always stored in errno, but
+ * e.g. under Windows the "last error" code after a socket function
+ * has to be retrieved by calling WSAGetLastError(), whereas the "last error"
+ * code from non-socket POSIX-like functions has to be retrieved
+ * by calling GetLastError().
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_get_last_error( const char *info ) ;
+
+ /**
+ * @brief Get and translate last error after socket function call
+ *
+ * Retrieve the "last error" code after a socket function has been called
+ * and translate to one of the @ref MBG_ERROR_CODES.
+ *
+ * On POSIX systems the "last error" code is always stored in errno, but
+ * e.g. under Windows the "last error" code after a socket function
+ * has to be retrieved by calling WSAGetLastError, whereas the "last error"
+ * code from non-socket POSIX-like functions is stored in errno as usual.
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_get_last_socket_error( const char *info ) ;
+
+ /**
+ * @brief Retrieve and convert last error after gethostbyname()
+ *
+ * This function is specific to retrieve and translate error codes
+ * returned by gethostbyname() and gethostbyaddr(). In case of error
+ * these functions don't set errno but h_errno on POSIX systems, but
+ * under Windows the error code can be retrieved by WSAGetLastError()
+ * as usual.
+ *
+ * The functions gethostbyname() and gethostbyaddr() are obsolete,
+ * and getaddressinfo() should be used preferably.
+ *
+ * @param[in] info An optional informational text string, or NULL
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_get_gethostbyname_error( const char *info ) ;
+
+ /**
+ * @brief Retrieve and convert last zlib internal error code
+ *
+ * @param[in] zlib_error zlib internal error code
+ * @param[in] info An optional informational text string, or NULL
+ * @param[in] msg An optional zlib specific error msg, or NULL.
+ * Struct z_stream contains member msg.
+ *
+ * @return One of the @ref MBG_ERROR_CODES
+ */
+ int mbg_zlib_error_to_mbg( int zlib_error, const char *info, const char *msg ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _MBGERROR_H */
diff --git a/mbglib/common/mbgntp.h b/mbglib/common/mbgntp.h
index c703822..d208b45 100755
--- a/mbglib/common/mbgntp.h
+++ b/mbglib/common/mbgntp.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgntp.h 1.7 2014/10/28 08:52:33 martin REL_M $
+ * $Id: mbgntp.h 1.8 2016/07/14 08:17:23 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgntp.h $
- * Revision 1.7 2014/10/28 08:52:33 martin
+ * Revision 1.8 2016/07/14 08:17:23 martin
+ * Fixed build under Windows.
+ * Revision 1.7 2014/10/28 08:52:33Z martin
* Made definition of NSECS_PER_SEC the same as in mbgtime.h to
* avoid compiler warnings in projects using both header files.
* Added/updated some comments.
@@ -53,7 +55,9 @@
#include <words.h>
#include <gpsdefs.h>
-#include <arpa/inet.h> // ntohl()
+#if defined( MBG_TGT_POSIX )
+ #include <arpa/inet.h> // ntohl()
+#endif
#ifdef _MBGNTP
diff --git a/mbglib/common/str_util.c b/mbglib/common/str_util.c
new file mode 100755
index 0000000..c5c40b5
--- /dev/null
+++ b/mbglib/common/str_util.c
@@ -0,0 +1,447 @@
+
+/**************************************************************************
+ *
+ * $Id: str_util.c 1.2 2016/08/05 12:31:04 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Meinberg Library module providing portable, safe string functions.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: str_util.c $
+ * 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.
+ * Fixed some compiler warnings.
+ * Revision 1.1 2015/08/25 15:57:21 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#define _STR_UTIL
+ #include <str_util.h>
+#undef _STR_UTIL
+
+#include <stdio.h>
+#include <string.h>
+
+
+#if defined( MBG_TGT_WIN32 ) && !defined( MBG_TGT_CVI )
+ #define mbg_vsnprintf _vsnprintf
+#else
+ #define mbg_vsnprintf vsnprintf
+#endif
+
+
+#if defined( MBG_TGT_DOS )
+
+static /*HDR*/
+// Under DOS we use the Borland C/C++ v3.1 compiler by default, which
+// doesn't provide a vsnprintf() function, so we use a simple replacement
+// here. Since we share most of the source code between several target
+// systems we assume that if it our code works properly for other targets
+// which really provide a vsnprintf() function then it also works properly
+// under DOS. ;-)
+int vsnprintf( char *s, size_t max_len, const char *fmt, va_list arg_list )
+{
+ (void) max_len; // quiet compiler warning "not used"
+
+ return vsprintf( s, fmt, arg_list );
+
+} // vsnprintf
+
+#endif
+
+
+
+/*HDR*/
+/**
+ * @brief A portable, safe implementation of vsnprintf()
+ *
+ * Unfortunately the behaviour of vsnprintf() and thus snprintf()
+ * differs in detail across various build environments and run time
+ * libraries.
+ *
+ * If the output exceeds the buffer size and thus is truncated then:<br>
+ *
+ * - Under Windows a negative value is returned and eventually *no*
+ * terminating 0 is written to the output buffer, so the output string
+ * may not be terminated properly.
+ *
+ * - Some versions of glibc return the number of bytes that *would*
+ * have been written to the buffer *if* the buffer would have been
+ * large enough, instead of the true number of characters that have
+ * been written to the buffer.
+ *
+ * So subsequent calls like
+ *
+ * n = snprintf( s, max_len, ... );
+ * n += snprintf( &s[n], max_len - n, ... );
+ *
+ * may always work properly, or fail with buffer overruns or stack
+ * corruption depending on the build environment.
+ * This wrapper function takes care that strings are always terminated
+ * properly, and that the returned value always matches the number of
+ * characters really written to the string buffer, excluding the
+ * terminating 0
+ *
+ * @note The "size_t" type parameter used to specify the buffer size
+ * can be larger (e.g. "unsigned long") than the "int" type returned
+ * by mostly all functions of the printf() family. So if a very large
+ * buffer is specified, and a large number of characters (more than
+ * MAXINT) are written to that buffer then how can an "int" type
+ * return the large number of characters written to the buffer?
+ * We also try to workaround this here.
+ *
+ * @param[out] s The string buffer to be filled
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] fmt Format string according to subsequent parameters
+ * @param[in] ap Variable argument list in va_list format
+ *
+ * @return Number of characters written to the output buffer, except the terminating 0
+ *
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+size_t __attribute__( ( format( printf, 3, 0 ) ) )
+vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list ap )
+{
+ if ( s == NULL || max_len == 0 )
+ return 0; // nothing to do anyway
+
+
+ mbg_vsnprintf( s, max_len, fmt, ap );
+
+ // Force proper worst-case termination of the output string.
+ s[max_len - 1] = 0;
+
+ // The return type of strlen() is usually size_t, so
+ // we can safely return the true length of the string
+ // written to the buffer.
+ return strlen( s );
+
+} // vsnprintf_safe
+
+
+
+/*HDR*/
+/**
+ * @brief A portable, safe implementation of snprintf()
+ *
+ * For a detailed description see ::vsnprintf_safe
+ *
+ * @param[out] s The string buffer to be filled
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] fmt Format string according to subsequent parameters
+ * @param[in] ... Variable argument list according to the format string
+ *
+ * @return Number of characters written to the output buffer, except the terminating 0
+ *
+ * @see ::vsnprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+size_t __attribute__( ( format( printf, 3, 4 ) ) )
+snprintf_safe( char *s, size_t max_len, const char * fmt, ... )
+{
+ va_list ap;
+ size_t len;
+
+ va_start( ap, fmt );
+
+ len = vsnprintf_safe( s, max_len, fmt, ap );
+
+ va_end( ap );
+
+ return len;
+
+} // snprintf_safe
+
+
+
+static __mbg_inline
+/* (explicitly excluded from doxygen)
+ * @brief A portable, safe implementation of a copy function
+ *
+ * This is the basic function used to implemment ::strncpy_safe and
+ * ::sn_cpy_safe. This function takes care that the copied string
+ * is always terminated by 0, but any remaining buffer space
+ * is *not* filled up with '0' characters.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] src Pointer to the input buffer
+ * @param[in] n Number of characters to copy at most
+ * @param[in,out] p_i Pointer to a counter variable
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+void do_str_copy_safe( char *dst, const char *src, size_t n, size_t *p_i )
+{
+ *p_i = 0;
+
+ if ( n > 0 )
+ {
+ for (;;)
+ {
+ *dst = *src;
+
+ if ( *dst == 0 )
+ break; // just copied the terminating 0, done
+
+ if ( --n == 0 ) // no more space left in buffer
+ {
+ *dst = 0; // force terminating 0
+ break;
+ }
+
+ (*p_i)++; // count normal characters
+ src++;
+ dst++;
+ }
+ }
+
+} // do_str_copy_safe
+
+
+
+/*HDR*/
+/**
+ * @brief A portable, safe implementation of strncpy()
+ *
+ * In the original implementation of strncpy(), if the length of the
+ * string to be copied into the destination buffer exceeds the specified
+ * buffer length then the string in the output buffer is not 0-terminated.
+ *
+ * Our implementation always forces a proper termination by 0, but unlike
+ * the original implementation of strncpy() it does *not* fill the whole
+ * remaining buffer space with '0' characters.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] src Pointer to the input buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ *
+ * @return Pointer to the destination buffer
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+char *strncpy_safe( char *dst, const char *src, size_t max_len )
+{
+ size_t i = 0;
+
+ do_str_copy_safe( dst, src, max_len, &i );
+
+ return dst;
+
+} // strncpy_safe
+
+
+
+/*HDR*/
+/**
+ * @brief A function to copy a string safely, returning the number of characters copied
+ *
+ * This basically works like ::strncpy_safe but instead of a pointer to
+ * the destination buffer it returns the number of characters copied
+ * to the destination buffer.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] src Pointer to the input buffer
+ *
+ * @return Number of characters copied to the destination buffer
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_char_safe
+ */
+size_t sn_cpy_str_safe( char *dst, size_t max_len, const char *src )
+{
+ size_t i = 0;
+
+ do_str_copy_safe( dst, src, max_len, &i );
+
+ return i;
+
+} // sn_cpy_str_safe
+
+
+
+/*HDR*/
+/**
+ * @brief A function to copy a character safely to a string buffer
+ *
+ * This basically works like ::sn_cpy_str_safe but expects a character
+ * to be copied to the destination buffer. Appends a terminating 0 to
+ * the string buffer and returns the number of characters copied to
+ * the destination buffer, usually 0 or 1.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] c Character to be copied to the destination buffer
+ *
+ * @return Number of characters copied to the destination buffer, without the terminating 0
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ */
+size_t sn_cpy_char_safe( char *dst, size_t max_len, char c )
+{
+ size_t i = 0;
+ char tmp_str[2];
+
+ tmp_str[0] = c;
+ tmp_str[1] = 0;
+
+ do_str_copy_safe( dst, tmp_str, max_len, &i );
+
+ return i;
+
+} // sn_cpy_char_safe
+
+
+
+/*HDR*/
+/**
+ * @brief Trim whitespace at the end of a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+void trim_trailing_whitespace( char *s )
+{
+ char *cp;
+
+ // set all trailing spaces to 0
+ for ( cp = &s[strlen( s )]; cp > s; )
+ {
+ --cp;
+
+ if ( *cp >= ' ' )
+ break;
+
+ *cp = 0;
+ }
+
+} // trim_trailing_whitespace
+
+
+
+/*HDR*/
+/**
+ * @brief Trim whitespace at the beginning of a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+void trim_leading_whitespace( char *s )
+{
+ char *srcp;
+ char *dstp;
+
+ // Search the first non-space character.
+ for ( srcp = s; *srcp; srcp++ )
+ if ( *srcp > ' ' )
+ break;
+
+ // If there are leading spaces then srcp now
+ // points behind the beginning of the string,
+ // otherwise there's nothing to do.
+ if ( srcp > s )
+ {
+ // Copy the remaining string.
+ dstp = s;
+
+ while ( *srcp )
+ *dstp++ = *srcp++;
+
+ *dstp = 0;
+ }
+
+} // trim_leading_whitespace
+
+
+
+/*HDR*/
+/**
+ * @brief Trim both leading and trailing whitespace from a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+void trim_whitespace( char *s )
+{
+ trim_trailing_whitespace( s );
+ trim_leading_whitespace( s );
+
+} // trim_whitespace
+
+
+
+/*HDR*/
+/**
+ * @brief Copy array of bytes starting at beginning of buffer
+ *
+ * Can be used if the destination address is in the same buffer
+ * in front of the source address. Even though you would expect
+ * that memcpy() would also work for this properly, we have seen
+ * cases where it didn't, and only memmove() worked correctly.
+ * Anyway, we try to avoid the overhead of memmove().
+ *
+ * @param[out] dst Destination address behind the source address
+ * @param[in] src Source address
+ * @param[in] n_bytes Number of bytes to copy
+ *
+ * @see ::mbg_memcpy_reversed
+ */
+void mbg_memcpy( void *dst, const void *src, size_t n_bytes )
+{
+ uint8_t *dstp = (uint8_t *) dst;
+ uint8_t *srcp = (uint8_t *) src;
+
+ while ( n_bytes-- )
+ *dstp++ = *srcp++;
+
+} // mbg_memcpy
+
+
+
+/*HDR*/
+/**
+ * @brief Copy an array of bytes in reversed order, starting at end of buffer
+ *
+ * Can be used if the destination address is in the same buffer
+ * behind the source address, so the source address would be
+ * overwritten by a normal memcpy().
+ *
+ * @param[out] dst Destination address behind the source address
+ * @param[in] src Source address
+ * @param[in] n_bytes Number of bytes to copy
+ *
+ * @see ::mbg_memcpy
+ */
+void mbg_memcpy_reversed( void *dst, const void *src, size_t n_bytes )
+{
+ if ( n_bytes ) // just to be sure it isn't 0
+ {
+ uint8_t *dstp = ( (uint8_t *) dst ) + n_bytes;
+ uint8_t *srcp = ( (uint8_t *) src ) + n_bytes;
+
+ while ( --n_bytes )
+ *(--dstp) = *(--srcp);
+ }
+
+} // mbg_memcpy_reversed
+
+
+
diff --git a/mbglib/common/str_util.h b/mbglib/common/str_util.h
new file mode 100755
index 0000000..2408e73
--- /dev/null
+++ b/mbglib/common/str_util.h
@@ -0,0 +1,265 @@
+
+/**************************************************************************
+ *
+ * $Id: str_util.h 1.2 2016/08/05 12:33:17 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for str_util.c
+ *
+ * -----------------------------------------------------------------------
+ * $Log: str_util.h $
+ * Revision 1.2 2016/08/05 12:33:17 martin
+ * Moved string trim functions from cfg_util module here.
+ * Added variable str_not_avail.
+ * Fixed some spelling.
+ * Updated function prototypes.
+ * Revision 1.1 2015/08/25 15:57:43 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _STR_UTIL_H
+#define _STR_UTIL_H
+
+/* Other headers to be included */
+
+#include <words.h> // implicitly includes mbg_tgt.h for non-firmware projects
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+
+#ifdef _STR_UTIL
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+_ext const char *str_not_avail
+#ifdef _DO_INIT
+ = "N/A"
+#endif
+;
+
+
+/* function prototypes: */
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ /**
+ * @brief A portable, safe implementation of vsnprintf()
+ *
+ * Unfortunately the behaviour of vsnprintf() and thus snprintf()
+ * differs in detail across various build environments and run time
+ * libraries.
+ *
+ * If the output exceeds the buffer size and thus is truncated then:<br>
+ *
+ * - Under Windows a negative value is returned and eventually *no*
+ * terminating 0 is written to the output buffer, so the output string
+ * may not be terminated properly.
+ *
+ * - Some versions of glibc return the number of bytes that *would*
+ * have been written to the buffer *if* the buffer would have been
+ * large enough, instead of the true number of characters that have
+ * been written to the buffer.
+ *
+ * So subsequent calls like
+ *
+ * n = snprintf( s, max_len, ... );
+ * n += snprintf( &s[n], max_len - n, ... );
+ *
+ * may always work properly, or fail with buffer overruns or stack
+ * corruption depending on the build environment.
+ * This wrapper function takes care that strings are always terminated
+ * properly, and that the returned value always matches the number of
+ * characters really written to the string buffer, excluding the
+ * terminating 0
+ *
+ * @note The "size_t" type parameter used to specify the buffer size
+ * can be larger (e.g. "unsigned long") than the "int" type returned
+ * by mostly all functions of the printf() family. So if a very large
+ * buffer is specified, and a large number of characters (more than
+ * MAXINT) are written to that buffer then how can an "int" type
+ * return the large number of characters written to the buffer?
+ * We also try to workaround this here.
+ *
+ * @param[out] s The string buffer to be filled
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] fmt Format string according to subsequent parameters
+ * @param[in] ap Variable argument list in va_list format
+ *
+ * @return Number of characters written to the output buffer, except the terminating 0
+ *
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+ size_t __attribute__( ( format( printf, 3, 0 ) ) ) vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list ap ) ;
+
+ /**
+ * @brief A portable, safe implementation of snprintf()
+ *
+ * For a detailed description see ::vsnprintf_safe
+ *
+ * @param[out] s The string buffer to be filled
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] fmt Format string according to subsequent parameters
+ * @param[in] ... Variable argument list according to the format string
+ *
+ * @return Number of characters written to the output buffer, except the terminating 0
+ *
+ * @see ::vsnprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+ size_t __attribute__( ( format( printf, 3, 4 ) ) ) snprintf_safe( char *s, size_t max_len, const char * fmt, ... ) ;
+
+ /**
+ * @brief A portable, safe implementation of strncpy()
+ *
+ * In the original implementation of strncpy(), if the length of the
+ * string to be copied into the destination buffer exceeds the specified
+ * buffer length then the string in the output buffer is not 0-terminated.
+ *
+ * Our implementation always forces a proper termination by 0, but unlike
+ * the original implementation of strncpy() it does *not* fill the whole
+ * remaining buffer space with '0' characters.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] src Pointer to the input buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ *
+ * @return Pointer to the destination buffer
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::sn_cpy_str_safe
+ * @see ::sn_cpy_char_safe
+ */
+ char *strncpy_safe( char *dst, const char *src, size_t max_len ) ;
+
+ /**
+ * @brief A function to copy a string safely, returning the number of characters copied
+ *
+ * This basically works like ::strncpy_safe but instead of a pointer to
+ * the destination buffer it returns the number of characters copied
+ * to the destination buffer.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] src Pointer to the input buffer
+ *
+ * @return Number of characters copied to the destination buffer
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_char_safe
+ */
+ size_t sn_cpy_str_safe( char *dst, size_t max_len, const char *src ) ;
+
+ /**
+ * @brief A function to copy a character safely to a string buffer
+ *
+ * This basically works like ::sn_cpy_str_safe but expects a character
+ * to be copied to the destination buffer. Appends a terminating 0 to
+ * the string buffer and returns the number of characters copied to
+ * the destination buffer, usually 0 or 1.
+ *
+ * @param[out] dst Pointer to the output buffer
+ * @param[in] max_len Size of the output buffer for 0-terminated string
+ * @param[in] c Character to be copied to the destination buffer
+ *
+ * @return Number of characters copied to the destination buffer, without the terminating 0
+ *
+ * @see ::vsnprintf_safe
+ * @see ::snprintf_safe
+ * @see ::strncpy_safe
+ * @see ::sn_cpy_str_safe
+ */
+ size_t sn_cpy_char_safe( char *dst, size_t max_len, char c ) ;
+
+ /**
+ * @brief Trim whitespace at the end of a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+ void trim_trailing_whitespace( char *s ) ;
+
+ /**
+ * @brief Trim whitespace at the beginning of a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+ void trim_leading_whitespace( char *s ) ;
+
+ /**
+ * @brief Trim both leading and trailing whitespace from a string
+ *
+ * @param[in,out] s The string to be trimmed
+ */
+ void trim_whitespace( char *s ) ;
+
+ /**
+ * @brief Copy array of bytes starting at beginning of buffer
+ *
+ * Can be used if the destination address is in the same buffer
+ * in front of the source address. Even though you would expect
+ * that memcpy() would also work for this properly, we have seen
+ * cases where it didn't, and only memmove() worked correctly.
+ * Anyway, we try to avoid the overhead of memmove().
+ *
+ * @param[out] dst Destination address behind the source address
+ * @param[in] src Source address
+ * @param[in] n_bytes Number of bytes to copy
+ *
+ * @see ::mbg_memcpy_reversed
+ */
+ void mbg_memcpy( void *dst, const void *src, size_t n_bytes ) ;
+
+ /**
+ * @brief Copy an array of bytes in reversed order, starting at end of buffer
+ *
+ * Can be used if the destination address is in the same buffer
+ * behind the source address, so the source address would be
+ * overwritten by a normal memcpy().
+ *
+ * @param[out] dst Destination address behind the source address
+ * @param[in] src Source address
+ * @param[in] n_bytes Number of bytes to copy
+ *
+ * @see ::mbg_memcpy
+ */
+ void mbg_memcpy_reversed( void *dst, const void *src, size_t n_bytes ) ;
+
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _STR_UTIL_H */
diff --git a/mbglib/common/timeutil.c b/mbglib/common/timeutil.c
new file mode 100755
index 0000000..83d442e
--- /dev/null
+++ b/mbglib/common/timeutil.c
@@ -0,0 +1,42 @@
+
+/**************************************************************************
+ *
+ * $Id: timeutil.c 1.1 2016/07/15 14:14:19 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Meinberg Library module for safe time conversion routines.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: timeutil.c $
+ * Revision 1.1 2016/07/15 14:14:19 martin
+ * Initial revision
+ *
+ **************************************************************************/
+
+#define _TIMEUTIL
+ #include <timeutil.h>
+#undef _TIMEUTIL
+
+#include <str_util.h>
+#include <mbgerror.h>
+
+
+
+/*HDR*/
+int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc )
+{
+ int n = snprintf_safe( s, max_len, "gmtime() call failed" );
+
+ 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 ) );
+
+ return n;
+
+} // snprint_gmtime_error
+
+
diff --git a/mbglib/common/timeutil.h b/mbglib/common/timeutil.h
new file mode 100755
index 0000000..33a744f
--- /dev/null
+++ b/mbglib/common/timeutil.h
@@ -0,0 +1,91 @@
+
+/**************************************************************************
+ *
+ * $Id: timeutil.h 1.1 2016/07/15 14:14:20 martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for timeutil.c
+ *
+ * -----------------------------------------------------------------------
+ * $Log: timeutil.h $
+ * Revision 1.1 2016/07/15 14:14:20 martin
+ * Initial revision
+ *
+ **************************************************************************/
+
+#ifndef _TIMEUTIL_H
+#define _TIMEUTIL_H
+
+/* Other headers to be included */
+
+#include <words.h> // implicitly includes mbg_tgt.h for non-firmware projects
+#include <mbgerror.h>
+
+#include <time.h>
+
+
+#ifdef _TIMEUTIL
+ #define _ext
+ #define _DO_INIT
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* function prototypes: */
+
+static __mbg_inline
+time_t cvt_to_time_t( time_t t )
+{
+ // Eventually we can do some epoch check here.
+ return (time_t) t;
+
+} // cvt_to_time_t
+
+
+
+static __mbg_inline
+int mbg_gmtime( struct tm *p_tm, const time_t *p_time )
+{
+ struct tm *p_tm_tmp = gmtime( p_time );
+
+ if ( p_tm_tmp == NULL ) // conversion failed
+ return mbg_get_last_error( NULL );
+
+ *p_tm = *p_tm_tmp;
+
+ return MBG_SUCCESS;
+
+} // mbg_gmtime
+
+
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc ) ;
+
+/* ----- function prototypes end ----- */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* End of header body */
+
+#undef _ext
+#undef _DO_INIT
+
+#endif /* _TIMEUTIL_H */
diff --git a/mbglib/common/words.h b/mbglib/common/words.h
index c298755..95042a7 100755
--- a/mbglib/common/words.h
+++ b/mbglib/common/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.34 2014/10/20 12:31:20 martin REL_M $
+ * $Id: words.h 1.35 2016/08/05 12:17:21 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
+ * Revision 1.35 2016/08/05 12:17:21 martin
+ * Moved definitions for NANO_TIME and NANO_TIME_64 here.
+ * New macro _nano_time_64_negative().
+ * Conditionally define _abs64() macro.
+ * Include <inttypes.h> for Keil ARMCC target.
+ * Added some conditional debugging code.
+ * Fixed some spelling.
* Revision 1.34 2014/10/20 12:31:20 martin
* Moved macro _isdigit() here.
* Revision 1.33 2014/05/27 10:18:35Z martin
@@ -123,6 +130,7 @@
#if defined( __ARMCC_VERSION ) // Keil RealView Compiler for ARM
#define __mbg_inline __inline
#include <stdint.h>
+ #include <inttypes.h>
#include <stdbool.h>
#define MBG_TGT_HAS_EXACT_SIZE_TYPES 1
#else
@@ -196,7 +204,7 @@
// The build environment does not support 64 bit types. However,
// 64 bit types need to be defined to avoid build errors
// if these types are formally used in function prototypes.
- // We explicitely use abnormal data types to hopefully
+ // We explicitly use abnormal data types to hopefully
// cause compiler errors in case these types are
// unexpectedly used to generate real code for a target
// platform which does not support 64 bit types.
@@ -225,6 +233,10 @@
#define MBG_TGT_HAS_64BIT_TYPES 1
+ #if !defined( MBG_TGT_HAS_ABS64 )
+ #define _abs64( _i ) ( (int64_t) ( ( (_i) < 0 ) ? -(_i) : (_i) ) )
+ #endif
+
#endif
@@ -277,34 +289,109 @@
#endif
-#if !defined( _BIT_DEFINED )
+#if defined( MBG_TGT_MISSING_BOOL_TYPE )
+ //#error MBG_TGT_MISSING_BOOL_TYPE is defined
+ // BDS/Borland C++ Builder 2006 (non-C++ mode)
+ // Borland C++ Builder 5 (non-C++ mode)
+ // BC 3.1
+ // VC6
+ // DDKbuild
+ // VS2008
+#endif
- // We need to implement a "bit" type. Preferably we use "bool"
- // to do this, but this is only supported by C++ compilers, and
- // by C compilers supporting the C99 standard.
+#if defined( __cplusplus )
+ //#error __cplusplus is defined
+#endif
- #if !defined( MBG_TGT_MISSING_BOOL_TYPE ) && \
- ( defined( __cplusplus ) || defined( __bool_true_false_are_defined ) )
+#if defined( __bool_true_false_are_defined )
+ //#error __bool_true_false_are_defined is defined
+ // Keil armcc
+ // gcc / Linux user space
+ // clang / FreeBSD user space and kernel
+#endif
- typedef bool bit;
- #define bit bit
- #else // C99 types not supported
+#if defined( MBG_TGT_MISSING_BOOL_TYPE ) /* from mbg_tgt.h */ \
+ || ( !defined( __cplusplus ) /* C++ */ \
+ && !defined( __bool_true_false_are_defined ) /* C99 */ \
+ && !defined( _LINUX_TYPES_H ) )
- // Falling back to use "int" for "bit". This prevents error
- // messages if "bit" is used in function prototypes, but may
- // yield unexpected results for code like:
- // return (bit) ( val & 0x10 );
- typedef int bit;
- #define bit bit
+ // There's no native support for a "bool" type, so we
+ // need a substitute.
+ #if defined( _BIT_DEFINED )
+ // A native "bit" type is supported, so we use it for bool.
+ //#error substituting bit for bool
+ // C166
+ typedef bit bool;
+ #else
+ // Fall back to "int". This is just a hack which
+ // may yield unexpected results with code like:
+ // return (bool) ( val & 0x10 );
+ // A safe way of coding would be:
+ // return (bool) ( ( val & 0x10 ) != 0 );
+ //#error substituting int for bool
+ // Borland C++ Builder 5
+ // BC 3.1
+ // VC6
+ // DDKbuild
+ // VS2008
+ typedef int bool;
#endif
+ // Eventually provoke a build error if the build
+ // environment unexpectedly supports "bool" natively.
+ #define bool bool
+ #define true 1
+ #define false 0
+#else
+ //#error native bool type supported
+ // Borland C++ Builder 5 and newer (C++ mode only)
+ // Keil armcc
+ // gcc / Linux user space
+ // gcc / Linux kernel
+ // clang / FreeBSD user space and kernel
+#endif
+
+
+#if !defined( _BIT_DEFINED )
+
+ // There's no native support for a "bit" type, so we
+ // need a substitute. The "bool" type would fit best
+ // and should be fine if it's supported natively.
+ //
+ // However, if "bool" has been substituted above
+ // by "int"then this is just a hack which may yield
+ // unexpected results with code like:
+ // return (bit) ( val & 0x10 );
+ // A safe way of coding would be:
+ // return (bit) ( ( val & 0x10 ) != 0 );
+
+ //#error substituting bool for bit
+ // Keil armcc
+ // Borland C++ Builder 5
+ // BC 3.1
+ // VC6
+ // DDKbuild
+ // VS2008
+ // gcc / Linux user space
+ // gcc / Linux kernel
+ // clang / FreeBSD user space and kernel
+ typedef bool bit;
+
+ // Eventually provoke a build error if the build
+ // environment unexpectedly supports "bit" natively.
+ #define bit bit
+
#define _BIT_REDEFINED 1
+#else
+ //#error native bit type supported
+ // C166
#endif
+
#define BYTE_0( _x ) ( (uint8_t ) ( (_x) & 0xFF ) )
#define BYTE_1( _x ) ( (uint8_t ) ( ( ( (uint16_t) (_x) ) >> 8 ) & 0xFF ) )
#define BYTE_2( _x ) ( (uint8_t ) ( ( ( (uint32_t) (_x) ) >> 16 ) & 0xFF ) )
@@ -372,12 +459,36 @@
#endif
+
+#define _set_array_bit( _n, _byte_array, _max_bytes ) \
+do \
+{ \
+ int byte_idx = (_n) >> 3; \
+ \
+ if ( byte_idx < _max_bytes ) \
+ _byte_array[byte_idx] |= ( 1 << ( (_n) & 0x07 ) ); \
+ \
+} while ( 0 )
+
+
+#define _clear_array_bit( _n, _byte_array, _max_bytes ) \
+do \
+{ \
+ int byte_idx = (_n) >> 3; \
+ \
+ if ( byte_idx < _max_bytes ) \
+ _byte_array[byte_idx] &= ~( 1 << ( (_n) & 0x07 ) ); \
+ \
+} while ( 0 )
+
+
+
#define _isdigit( _c ) ( (_c) >= '0' && (_c) <= '9' )
// A macro function which can safely be used without
// side effects as a macro doing nothing.
-// This is useful to define debug macros away in
+// This is useful to define debug macros away in
// release builds, etc.
#if !defined( _nop_macro_fnc )
#define _nop_macro_fnc() do {} while (0)
@@ -391,6 +502,7 @@ typedef struct
{
ulong code;
const char *name;
+
} MBG_CODE_NAME_TABLE_ENTRY;
/**
@@ -410,6 +522,67 @@ typedef struct
#define _mbg_cn_table_end() { 0, NULL }
+
+/**
+ * @brief A timestamp with nanosecond resolution
+ *
+ * @note The secs field will roll over on 2038-01-19 03:14:07
+ * if used for the number of seconds since 1970-01-01, just like
+ * 32 bit POSIX time_t.
+ *
+ * @see ::NANO_TIME_64
+ */
+typedef struct
+{
+ // ATTENTION:
+ // This structure is and has has been used in public API calls for a long time,
+ // so even though the order of member fields is different than in NANO_TIME_64
+ // this must *NOT* be changed, or API compatibility will get lost!
+ int32_t nano_secs; ///< [nanoseconds]
+ int32_t secs; ///< [seconds], usually since 1970-01-01 00:00:00
+
+} NANO_TIME;
+
+#define _mbg_swab_nano_time( _p ) \
+{ \
+ _mbg_swab32( &(_p)->nano_secs ); \
+ _mbg_swab32( &(_p)->secs ); \
+}
+
+// The macro below checks if a ::NANO_TIME value is negative.
+#define _nano_time_negative( _nt ) \
+ ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
+
+
+
+/**
+ * @brief A timestamp with nanosecond resolution, but 64 bit size
+ *
+ * @see ::NANO_TIME
+ */
+typedef struct
+{
+ // ATTENTION:
+ // This structure is and has been used in public API calls for a long time,
+ // so even though the order of member fields is different than in NANO_TIME
+ // this must *NOT* be changed, or API compatibility will get lost!
+ int64_t secs; ///< [seconds], usually since 1970-01-01 00:00:00
+ int64_t nano_secs; ///< [nanoseconds]
+
+} NANO_TIME_64;
+
+#define _mbg_swab_nano_time_64( _p ) \
+{ \
+ _mbg_swab64( &(_p)->secs ); \
+ _mbg_swab64( &(_p)->nano_secs ); \
+}
+
+// The macro below checks if a ::NANO_TIME_64 value is negative.
+#define _nano_time_64_negative( _nt ) \
+ ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
+
+
+
/* End of header body */
#undef _ext
diff --git a/ntptest.c b/ntptest.c
index 555b389..6804ce7 100755
--- a/ntptest.c
+++ b/ntptest.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: ntptest.c 1.5 2015/06/26 14:11:56 martin REL_M $
+ * $Id: ntptest.c 1.6 2016/08/05 12:42:48 martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -12,7 +12,14 @@
*
* -----------------------------------------------------------------------
* $Log: ntptest.c $
- * Revision 1.5 2015/06/26 14:11:56 martin
+ * Revision 1.6 2016/08/05 12:42:48 martin
+ * Support build build under Windows.
+ * Use precise time API under Windows, if supported.
+ * Make stdout unbuffered under POSIX, so output is shown
+ * immediately even if piped e.g. via the tee command.
+ * Use safe string functions.
+ * Use compatible Meinberg error codes.
+ * Revision 1.5 2015/06/26 14:11:56Z martin
* Don't exit on initial timeout in continuous mode.
* Revision 1.4 2015/05/11 11:12:51 martin
* Support continuous monitoring (-Z), e.g. for leap second tests.
@@ -27,40 +34,82 @@
#include <mbg_ntp_test_util.h>
-#include <unistd.h>
+#include <mbgerror.h>
+
+#if defined( MBG_TGT_WIN32 )
+ #include <wingetopt.h>
+ #include <io.h>
+#endif
+
+#if defined( MBG_TGT_POSIX )
+ #include <unistd.h>
+ #include <netdb.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <errno.h>
-#include <netdb.h>
static const char program_name[] = "ntptest";
-static const char program_version[] = "v1.2";
-static const char program_copyright[] = "(c) Meinberg 2014-2015";
+static const char program_version[] = "v1.3";
+static const char program_copyright[] = "(c) Meinberg 2014-2016";
static const char program_contact[] = "contact: <martin.burnicki@meinberg.de>";
-#define RCV_TIMEOUT 400 // [msec]
+#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;
+
+#endif
+
+#define RCV_TIMEOUT 400 // [msec]
+
+
+#if defined( MBG_TGT_WIN32 )
+ #define SLEEP_INTV_SEC_SCALE 1000 // [msec/sec]
+ #define SLEEP_INTV_USEC_SCALE 1000 // [usec/msec]
+#else
+ #define SLEEP_INTV_SEC_SCALE 1 // [sec/sec]
+ #define SLEEP_INTV_USEC_SCALE 1 // [usec/usec]
+#endif
+
+#define MIN_SLEEP_INTV ( 1 * SLEEP_INTV_SEC_SCALE )
+#define DFLT_SHORT_SLEEP_INTV ( 250000L / SLEEP_INTV_USEC_SCALE )
// parameters which can to some extent be modified via command
// line options to control the program's behaviour
-static int run_continuously; // -c, -Z
-static int sleep_intv = 1; // -s, [sec], sleep interval between requests, default 1
-static int usleep_intv; // -u, -Z [usec], sleep interval between requests
-static int prot_version; // -V, protocol version to be used
-static unsigned long rcv_timeout; // -T, [msec] receive timeout after request sent
-static int verbose; // -v print full packet details
-static int compensate_initial_offset; // -Z, compensate initial time offset to server
-
-static const char *tgt_host; // target hostname or IP address
-static struct sockaddr_in tgt_addr; // target address
+static int run_continuously; // -c, -Z
+static int sleep_intv = MIN_SLEEP_INTV; // -s, (-u, -Z also on non-POSIX), sleep interval between requests
+#if defined( MBG_TGT_POSIX )
+ static int usleep_intv; // -u, -Z (POSIX only), short sleep interval between requests
+#endif
+static int prot_version; // -V, protocol version to be used
+static unsigned long rcv_timeout; // -T, [msec] receive timeout after request sent
+static int verbose; // -v print full packet details
+static int compensate_initial_offset; // -Z, compensate initial time offset to server
+#if defined( MBG_TGT_WIN32 )
+ static bool force_legacy_gstaft;
+#endif
+static const char *tgt_host; // target hostname or IP address
+static struct sockaddr_in tgt_addr; // target address
static int must_print_usage;
static NTP_PACKET default_ntp_req_packet; // template of request packet
@@ -68,6 +117,74 @@ 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, ... )
@@ -95,20 +212,22 @@ void do_ntp_queries( void )
{
fd_set read_set;
struct timeval tv_timeout;
- NTP_PACKET_INFO req_info; // set up from template
- NTP_PACKET_INFO reply_info;
- NTP_RESULTS rslt;
- int sockfd;
+ NTP_PACKET_INFO req_info = { 0 }; // will be set up from template
+ NTP_PACKET_INFO reply_info = { 0 };
+ NTP_RESULTS rslt = { { 0 } };
+ MBG_SOCK_FD sock_fd;
int rc;
struct sockaddr_in si_src;
socklen_t slen_src;
- sockfd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); // create socket on which to send
+ sock_fd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); // create socket on which to send
- if ( sockfd < 0 )
+ if ( sock_fd == MBG_INVALID_SOCK_FD )
{
- mbglog( LOG_ERR, "Failed to open UDP socket in %s: %s", __func__, strerror( errno ) );
+ mbglog( LOG_ERR, "Failed to open UDP socket in %s: %s", __func__,
+ mbg_strerror( mbg_get_last_socket_error( NULL ) ) );
+
exit( 1 );
}
@@ -129,11 +248,12 @@ void do_ntp_queries( void )
req_info.len = NTP_BASE_PACKET_SIZE;
// send request packet
- if ( sendto( sockfd, &req_info.packet, req_info.len, 0,
+ if ( sendto( sock_fd, (void *) &req_info.packet, req_info.len, 0,
(__const__ struct sockaddr *) &tgt_addr,
- sizeof( tgt_addr ) ) < 0 )
+ sizeof( tgt_addr ) ) == MBG_SOCKET_ERR_RETVAL )
{
- mbglog( LOG_ERR, "Failed to send UDP packet in %s: %s", __func__, strerror( errno ) );
+ mbglog( LOG_ERR, "Failed to send UDP packet in %s: %s", __func__,
+ mbg_strerror( mbg_get_last_socket_error( NULL ) ) );
exit( 1 );
}
@@ -141,49 +261,55 @@ void do_ntp_queries( void )
FD_ZERO( &read_set );
- FD_SET( sockfd, &read_set );
+ FD_SET( sock_fd, &read_set );
tv_timeout.tv_sec = 0;
tv_timeout.tv_usec = rcv_timeout * 1000;
- rc = select( sockfd + 1, &read_set, NULL, NULL, &tv_timeout );
+ rc = select( sock_fd + 1, &read_set, NULL, NULL, &tv_timeout );
- if ( rc < 0 ) // select() failed
+ if ( rc == MBG_SOCKET_ERR_RETVAL ) // select() failed
{
- mbglog( LOG_ERR, "Select failed in %s: %s", __func__, strerror( errno ) );
+ mbglog( LOG_ERR, "Select failed in %s: %s", __func__,
+ mbg_strerror( mbg_get_last_socket_error( NULL ) ) );
break;
}
- if ( rc > 0 ) // no timeout
+ if ( rc == 0 ) // timeout
{
- // read response packet
- slen_src = sizeof( si_src ) ;
- reply_info.len = recvfrom( sockfd, &reply_info.packet, sizeof( reply_info.packet ), 0,
- (struct sockaddr *) &si_src, &slen_src );
+ mbglog( LOG_ERR, "Select timed out" );
+ goto cont;
+ }
- if ( reply_info.len < 0 )
- {
- mbglog( LOG_ERR, "Failed to receive from UDP socket in %s: %s", __func__, strerror( errno ) );
- continue;
- }
+ // read response packet
+ slen_src = sizeof( si_src );
+ reply_info.len = recvfrom( sock_fd, (void *) &reply_info.packet, sizeof( reply_info.packet ),
+ 0, (struct sockaddr *) &si_src, &slen_src );
- // get time stamp when response was received
- clock_gettime( CLOCK_REALTIME, &reply_info.tsr );
+ if ( reply_info.len == MBG_SOCKET_ERR_RETVAL )
+ {
+ mbglog( LOG_ERR, "Failed to receive from UDP socket: %s",
+ mbg_strerror( mbg_get_last_socket_error( NULL ) ) );
+ goto cont;
+ }
- eval_ntp_packet( &rslt, &reply_info, &glb_query_stats );
- ntoh_ntp_packet( &req_info );
+ // get time stamp when response was received
+ clock_gettime( CLOCK_REALTIME, &reply_info.tsr );
- if ( verbose )
- print_ntp_results( &rslt, &req_info, &reply_info, &glb_query_stats, 1, 1 );
- else
+ eval_ntp_packet( &rslt, &reply_info, &glb_query_stats );
+ ntoh_ntp_packet( &req_info );
+
+ if ( verbose )
+ print_ntp_results( &rslt, &req_info, &reply_info, &glb_query_stats, 1, 1 );
+ else
+ {
+ NTP_PACKET *p = &reply_info.packet;
+
+ if ( compensate_initial_offset )
{
static double initial_delta_t;
static int has_been_called;
- NTP_PACKET *p = &reply_info.packet;
-
- print_ntp_time( "", &p->base.transmit_time, NULL, 1 );
-
if ( !has_been_called )
{
// Compute and save the initial delta t.
@@ -191,30 +317,40 @@ void do_ntp_queries( void )
// available in tv_rcv and t_rcv.
initial_delta_t = delta_tstamps( &p->base.transmit_time, &rslt.t_rcv );
+ printf( "Initial time offset %.9f will be compensated\n", initial_delta_t );
has_been_called = 1;
}
- if ( compensate_initial_offset )
- rslt.ntp_offs -= initial_delta_t;
-
- printf( ", st %u, leap %u, offs[ms]: %+.3f\n",
- p->base.flags.stratum,
- p->base.flags.leap_ind,
- rslt.ntp_offs * 1000 );
- fflush( NULL );
+ rslt.ntp_offs -= initial_delta_t;
}
+
+ print_ntp_time( "", &p->base.transmit_time, NULL, 1 );
+ printf( ", st %u, leap %u, offs[ms]: %+.3f\n",
+ p->base.flags.stratum,
+ p->base.flags.leap_ind,
+ rslt.ntp_offs * 1000 );
+ fflush( NULL );
}
+cont:
if ( !run_continuously )
break;
- if ( usleep_intv )
- usleep( usleep_intv );
- else
- sleep( sleep_intv );
+ #if defined( MBG_TGT_WIN32 )
+ Sleep( sleep_intv );
+ #else
+ if ( usleep_intv )
+ usleep( usleep_intv );
+ else
+ sleep( sleep_intv );
+ #endif
}
- close( sockfd );
+ #if defined( MBG_TGT_WIN32 )
+ closesocket( sock_fd );
+ #else
+ close( sock_fd );
+ #endif
} // do_ntp_queries
@@ -237,8 +373,13 @@ void usage( void )
printf( " -V n NTP protocol version, %i..%i, default: %i\n",
MIN_REQ_NTP_VERSION, MAX_REQ_NTP_VERSION, DEFAULT_REQ_NTP_VERSION );
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( " -Z send 4 req/s to server, print time, offset changes and status summary\n" );
printf( " e.g. for leap second tests\n" );
+
+#if defined( MBG_TGT_WIN32 )
+ printf( " -L use legacy system time function even if precise time is supported\n" );
+#endif
+
printf( " -?, -h print this usage information\n"
"\n" );
@@ -251,7 +392,13 @@ void check_options( int argc, char *argv[] )
{
char c;
- while ( ( c = getopt( argc, argv, "cs:vV:T:Zh?" ) ) != -1 )
+ #if defined( MBG_TGT_WIN32 )
+ #define WIN32_OPTS "L"
+ #else
+ #define WIN32_OPTS
+ #endif
+
+ while ( ( c = getopt( argc, argv, "cs:vV:T:Zh?" WIN32_OPTS ) ) != -1 )
{
switch ( c )
{
@@ -261,10 +408,11 @@ void check_options( int argc, char *argv[] )
case 's':
- sleep_intv = strtol( optarg, NULL, 10 );
+ run_continuously = 1;
+ sleep_intv = strtol( optarg, NULL, 10 ) * SLEEP_INTV_SEC_SCALE;
- if ( sleep_intv < 1 )
- sleep_intv = 1;
+ if ( sleep_intv < MIN_SLEEP_INTV )
+ sleep_intv = MIN_SLEEP_INTV;
break;
@@ -286,12 +434,22 @@ void check_options( int argc, char *argv[] )
case 'Z': // quick settings for leap second test
run_continuously = 1;
- usleep_intv = 250000L; // 4 req/s
+ #if defined( MBG_TGT_WIN32 )
+ sleep_intv = DFLT_SHORT_SLEEP_INTV; // 4 req/s
+ #else
+ usleep_intv = DFLT_SHORT_SLEEP_INTV; // 4 req/s
+ #endif
verbose = 0;
compensate_initial_offset = 1;
break;
+ #if defined( MBG_TGT_WIN32 )
+ case 'L':
+ force_legacy_gstaft = true;
+ break;
+ #endif
+
case 'h':
case '?':
default:
@@ -333,6 +491,20 @@ int main( int argc, char *argv[] )
}
+ #if defined( MBG_TGT_WIN32 )
+ {
+ WSADATA wsaData = { 0 };
+ WSAStartup( MAKEWORD( 2, 2 ), &wsaData );
+ check_precise_time_api();
+ }
+ #endif
+
+ #if defined( MBG_TGT_POSIX )
+ // Make stdout unbuffered, so output is also shown immediately
+ // if piped via the tee command.
+ setvbuf( stdout, NULL, _IOLBF, 0 );
+ #endif
+
if ( tgt_host )
{
// Construct name, with no wildcards, of the socket to send to.
@@ -340,9 +512,10 @@ int main( int argc, char *argv[] )
// of the specified host.
p_hostent = gethostbyname( tgt_host );
- if ( p_hostent == 0 )
+ if ( p_hostent == NULL )
{
- mbglog( LOG_ERR, "Unknown host %s: (error code %i)", tgt_host, h_errno );
+ int rc = mbg_get_gethostbyname_error( NULL );
+ mbglog( LOG_ERR, "Unknown host %s: %s", tgt_host, mbg_strerror( rc ) );
exit( 2 );
}
@@ -353,7 +526,6 @@ int main( int argc, char *argv[] )
tgt_addr.sin_port = htons( NTP_PORT );
}
-
reset_query_stats( &glb_query_stats );
// setup packet templates
diff --git a/Makefile b/unix/Makefile
index d2d947f..cc0cdb2 100755
--- a/Makefile
+++ b/unix/Makefile
@@ -1,13 +1,17 @@
#########################################################################
#
-# $Id: Makefile 1.1 2014/04/01 13:02:21 martin REL_M $
+# $Id: Makefile 1.2 2016/08/05 12:40:28 martin REL_M $
#
# Description:
# Makefile for ntptest.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.2 2016/08/05 12:40:28 martin
+# Account for modified directory structure.
+# Makefile has been moved to subdirectory unix/.
+# Added some library modules.
# Revision 1.1 2014/04/01 13:02:21 martin
# Initial revision.
#
@@ -15,11 +19,14 @@
TARGET = ntptest
-MBGLIB = mbglib
+MBGLIB = ../mbglib
MBGLIB_DIRS = common
OBJS = $(TARGET).o
OBJS += mbg_ntp_test_util.o
+OBJS += timeutil.o
+OBJS += str_util.o
+OBJS += mbgerror.o
ifdef DEBUG
CPPFLAGS += -g2
@@ -33,6 +40,7 @@ CPPFLAGS += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
LDFLAGS += -lrt
+VPATH += ..
VPATH += $(foreach dir,$(MBGLIB_DIRS),$(MBGLIB)/$(dir))